:root {
  --ink: #17202d;
  --muted: #64748b;
  --navy: #173b68;
  --navy-2: #245181;
  --paper: #f4f7fa;
  --white: #ffffff;
  --line: #dce4ec;
  --input: #e5f6ff;
  --input-focus: #d7effc;
  --green: #18794e;
  --amber: #a05b00;
  --red: #b42318;
  --shadow: 0 18px 44px rgba(19, 48, 84, .1);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(36, 81, 129, .28); outline-offset: 2px; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(440px, 1.15fr);
  background: var(--white);
}

.auth-mark {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: clamp(34px, 6vw, 76px);
  color: white;
  background: var(--navy);
}

.auth-mark::after {
  content: "";
  position: absolute;
  right: -18%;
  bottom: -13%;
  width: 68%;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  box-shadow: 0 0 0 44px rgba(255,255,255,.035), 0 0 0 88px rgba(255,255,255,.025);
}

.wordmark { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .05em; }
.wordmark-badge { display: grid; place-items: center; width: 38px; height: 38px; color: var(--navy); background: white; border-radius: 10px 2px 10px 2px; font: 900 18px/1 Georgia, serif; }
.auth-copy { position: relative; z-index: 1; max-width: 560px; }
.auth-copy h1 { margin: 0; max-width: 10ch; font: 700 clamp(42px, 6.2vw, 82px)/1.04 "FZLanTingHeiS-B-GB", "Microsoft YaHei UI", sans-serif; letter-spacing: -.055em; }
.auth-copy p { max-width: 39ch; margin: 28px 0 0; color: #cfdeee; font-size: 17px; line-height: 1.75; }
.auth-note { position: relative; z-index: 1; color: #b9cee3; font-size: 13px; }
.auth-panel { display: grid; place-items: center; min-height: 100vh; padding: 30px; }
.auth-card { width: min(440px, 100%); }
.eyebrow { margin: 0 0 9px; color: var(--navy-2); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.auth-card h2 { margin: 0; font-size: 30px; line-height: 1.25; letter-spacing: -.035em; }
.auth-card > p { margin: 12px 0 28px; color: var(--muted); line-height: 1.7; }

.field { display: grid; gap: 8px; margin: 18px 0; }
.field label, .input-label { color: #3e4d60; font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select, .data-input {
  width: 100%;
  border: 1px solid #cdd8e3;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field textarea { min-height: 94px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .data-input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(36, 81, 129, .11); outline: 0; }
.primary, .secondary, .ghost, .danger-link {
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  font-weight: 800;
}
.primary { color: white; background: var(--navy); box-shadow: 0 8px 18px rgba(23,59,104,.16); }
.primary:hover { background: var(--navy-2); }
.secondary { color: var(--navy); background: #eaf1f8; }
.ghost { color: #43546a; background: transparent; border: 1px solid var(--line); }
.danger-link { color: var(--red); background: #fff0ee; }
.full { width: 100%; margin-top: 5px; padding: 13px 18px; }
.wecom-login { display: flex; align-items: center; gap: 12px; margin-top: 13px; border: 1px solid #b9ddd0; border-radius: 10px; background: #f1faf6; padding: 11px 14px; color: #176c50; text-decoration: none; }
.wecom-login:hover { background: #e8f7f0; }
.wecom-mark { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; background: #26a269; color: white; font-weight: 900; }
.wecom-login strong, .wecom-login small { display: block; }
.wecom-login small { margin-top: 3px; color: #5c776d; font-size: 11px; }
.form-error { min-height: 22px; margin: 8px 0 0; color: var(--red); font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 0 clamp(18px, 4vw, 54px);
  color: white;
  background: rgba(23, 59, 104, .97);
  box-shadow: 0 1px 0 rgba(255,255,255,.09);
  backdrop-filter: blur(14px);
}
.topbar .wordmark-badge { width: 32px; height: 32px; font-size: 15px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-copy { text-align: right; }
.user-copy strong, .user-copy span { display: block; }
.user-copy span { color: #bed0e2; font-size: 11px; margin-top: 2px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--navy); background: #dfeaf5; font-weight: 900; }
.topbar button { color: white; border-color: rgba(255,255,255,.25); }

.page { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 54px) 52px; }
.headline-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.headline h1 { margin: 0; font-size: clamp(27px, 3vw, 40px); letter-spacing: -.04em; }
.headline p { margin: 8px 0 0; color: var(--muted); }
.date-control { display: grid; grid-template-columns: auto minmax(150px, 190px) auto; align-items: center; gap: 7px; }
.date-control input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 9px 11px; color: var(--ink); font-weight: 700; }

.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 22px; align-items: start; }
.project-rail { position: sticky; top: 86px; max-height: calc(100vh - 108px); overflow: auto; padding-right: 5px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 11px; }
.rail-head strong { font-size: 13px; }
.rail-head span { color: var(--muted); font-size: 12px; }
.project-list { display: grid; gap: 7px; }
.project-button {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 11px 10px;
  text-align: left;
  color: #334155;
}
.project-button:hover { background: white; }
.project-button.active { border-color: #c9d7e5; background: white; box-shadow: 0 8px 22px rgba(21, 49, 82, .07); color: var(--navy); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #bdc8d4; box-shadow: 0 0 0 3px rgba(189,200,212,.18); }
.status-dot.complete { background: var(--green); box-shadow: 0 0 0 3px rgba(24,121,78,.14); }
.status-dot.partial { background: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,.14); }
.project-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.project-group { color: var(--muted); font-size: 10px; }

.entry-panel { min-width: 0; }
.entry-card, .history-card, .admin-card { border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.entry-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.entry-header h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.entry-meta { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 9px; color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; background: #edf3f8; }
.save-state { min-width: 92px; color: var(--muted); font-size: 12px; text-align: right; }
.save-state.dirty { color: var(--amber); font-weight: 800; }

.form-section { padding: 22px 24px; }
.form-section + .form-section { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-head h3 { margin: 0; font-size: 15px; }
.section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.metric-field { display: grid; gap: 7px; }
.metric-field.wide { grid-column: 1 / -1; }
.metric-label { display: flex; justify-content: space-between; gap: 8px; color: #445266; font-size: 12px; font-weight: 750; }
.metric-label em { color: var(--muted); font-style: normal; font-weight: 500; }
.data-input { background: var(--input); border-color: #b9dbe9; font-variant-numeric: tabular-nums; }
.data-input:focus { background: var(--input-focus); }
textarea.data-input { min-height: 84px; resize: vertical; }
.computed-box { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fb; padding: 11px 13px; }
.computed-box span { color: var(--muted); font-size: 12px; }
.computed-box strong { font-variant-numeric: tabular-nums; }
.entry-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px 22px; border-top: 1px solid var(--line); }
.entry-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.action-buttons { display: flex; gap: 8px; }

.subnav { display: flex; gap: 7px; margin: 22px 0 14px; }
.subnav button { border: 1px solid var(--line); border-radius: 999px; background: white; padding: 7px 12px; color: #536378; font-weight: 750; font-size: 12px; }
.subnav button.active { color: white; background: var(--navy); border-color: var(--navy); }
.history-card, .admin-card { padding: 22px 24px; box-shadow: none; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.history-head h3 { margin: 0; font-size: 16px; }
.history-list { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: 118px 1fr auto; gap: 12px; align-items: center; border-bottom: 1px solid #edf1f5; padding: 10px 0; }
.history-row:last-child { border: 0; }
.history-row time { font-weight: 750; }
.history-row p { margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-status { font-size: 12px; font-weight: 800; }
.history-status.complete { color: var(--green); }
.history-status.partial { color: var(--amber); }
.history-status.empty { color: var(--muted); }

.admin-layout { display: grid; gap: 18px; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.admin-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.wecom-button { border: 0; border-radius: 9px; padding: 11px 16px; background: #e8f7f0; color: #176c50; font-weight: 800; }
.admin-toolbar h2 { margin: 0; }
.admin-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.wecom-status { display: grid; gap: 4px; margin-top: 14px; border-radius: 9px; padding: 11px 13px; font-size: 12px; }
.wecom-status strong, .wecom-status span { display: block; }
.wecom-status span { overflow-wrap: anywhere; }
.wecom-status.ready { border: 1px solid #b9ddd0; background: #f1faf6; color: #176c50; }
.wecom-status.attention { border: 1px solid #efd3a9; background: #fff8ed; color: #8a5a17; }
.user-list { display: grid; gap: 10px; margin-top: 18px; }
.user-row { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(220px, 1.6fr) auto; gap: 16px; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; }
.user-row:first-child { border-top: 0; }
.user-title strong, .user-title span { display: block; }
.user-title span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.project-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.project-tag { padding: 4px 7px; border-radius: 5px; background: #edf3f8; color: #465970; font-size: 11px; }
.project-tag.pending { background: #fff2df; color: var(--amber); }
.wecom-bound { display: inline-block; margin-right: 4px; border-radius: 4px; background: #e8f7f0; color: #176c50; padding: 2px 5px; font-size: 10px; }
.row-actions { display: flex; gap: 6px; }
.permission-dialog, .member-dialog { width: min(720px, calc(100vw - 28px)); height: min(86vh, 860px); max-height: min(86vh, 860px); border: 0; border-radius: 15px; padding: 0; box-shadow: 0 28px 90px rgba(10,31,55,.26); }
.member-dialog { width: min(560px, calc(100vw - 28px)); height: min(78vh, 720px); }
.permission-dialog::backdrop, .member-dialog::backdrop { background: rgba(17,32,50,.45); backdrop-filter: blur(3px); }
.dialog-form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; max-height: min(86vh, 860px); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 20px 22px 15px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { margin: 0; font-size: 20px; }
.dialog-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 23px; line-height: 1; }
.dialog-body { overflow: auto; padding: 18px 22px; }
.dialog-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.project-picker-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 15px 0 9px; font-size: 13px; font-weight: 800; }
.project-picker-label span { color: var(--muted); font-size: 11px; font-weight: 500; }
.project-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.project-check { display: flex; align-items: center; gap: 8px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; color: #3d4f64; font-size: 12px; }
.project-check input { accent-color: var(--navy); }
.project-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.member-search { display: grid; gap: 7px; position: sticky; top: -18px; z-index: 2; margin: -18px -22px 10px; padding: 16px 22px 11px; background: white; border-bottom: 1px solid var(--line); color: #3e4d60; font-size: 12px; font-weight: 800; }
.member-search input { border: 1px solid #cdd8e3; border-radius: 9px; padding: 10px 12px; }
.member-list { display: grid; gap: 6px; }
.member-warning { margin: 0 0 10px; border: 1px solid #efd3a9; border-radius: 9px; background: #fff8ed; padding: 10px 12px; color: #8a5a17; font-size: 12px; line-height: 1.6; }
.member-row { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; width: 100%; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 10px; text-align: left; }
.member-row:hover { border-color: #9bcdbb; background: #f5fbf8; }
.member-avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: #e8f7f0; color: #176c50; font-weight: 900; }
.member-row strong, .member-row small { display: block; }
.member-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.member-row em { color: #176c50; font-size: 11px; font-style: normal; font-weight: 800; }
.credentials { margin-top: 18px; border: 1px solid #b9d5c6; border-radius: 10px; background: #f1fbf5; padding: 14px; }
.credentials h3 { margin: 0 0 7px; font-size: 14px; color: var(--green); }
.credentials pre { max-height: 330px; overflow: auto; margin: 0; white-space: pre-wrap; font: 12px/1.7 Consolas, monospace; }
.empty-state { padding: 40px 20px; color: var(--muted); text-align: center; }
.loading { padding: 48px 20px; color: var(--muted); text-align: center; }
.no-permission { display: grid; justify-items: center; padding: clamp(54px, 10vw, 100px) 24px; text-align: center; }
.no-permission-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px 4px 16px 4px; background: #fff2df; color: var(--amber); font-size: 21px; font-weight: 900; }
.no-permission h2 { margin: 18px 0 8px; }
.no-permission p { max-width: 48ch; margin: 0; color: var(--muted); line-height: 1.7; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; transform: translateY(18px); opacity: 0; pointer-events: none; max-width: min(380px, calc(100vw - 40px)); border-radius: 10px; background: #17202d; color: white; padding: 12px 15px; box-shadow: 0 14px 40px rgba(0,0,0,.22); transition: opacity .2s, transform .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-mark { min-height: auto; padding: 32px 26px 38px; }
  .auth-copy { margin: 66px 0 44px; }
  .auth-copy h1 { font-size: 46px; }
  .auth-note { display: none; }
  .auth-panel { min-height: auto; padding: 44px 24px 58px; }
  .headline-row { align-items: start; flex-direction: column; }
  .date-control { width: 100%; grid-template-columns: auto 1fr auto; }
  .workspace { grid-template-columns: 1fr; }
  .project-rail { position: static; max-height: none; overflow: hidden; }
  .project-list { display: flex; overflow-x: auto; gap: 7px; padding: 2px 2px 9px; scroll-snap-type: x mandatory; }
  .project-button { flex: 0 0 auto; width: min(240px, 76vw); background: white; border-color: var(--line); scroll-snap-align: start; }
}

@media (max-width: 580px) {
  .topbar { padding: 0 14px; }
  .topbar .wordmark span:last-child { display: none; }
  .user-copy { display: none; }
  .page { padding: 20px 12px 40px; }
  .headline p { font-size: 13px; }
  .entry-header, .form-section, .entry-actions, .history-card, .admin-card { padding-left: 16px; padding-right: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-field.wide { grid-column: auto; }
  .section-head { align-items: start; flex-direction: column; }
  .entry-actions { align-items: stretch; flex-direction: column; }
  .action-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-toolbar { align-items: stretch; flex-direction: column; }
  .admin-toolbar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; }
  .admin-toolbar-actions button { min-width: 0; width: 100%; white-space: normal; line-height: 1.35; }
  .user-row { grid-template-columns: 1fr; }
  .dialog-fields, .project-picker { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 96px 1fr; }
  .history-row p { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
