:root {
  --ink: #14181d;
  --ink-2: #39414c;
  --muted: #6c7684;
  --line: #e3e4e0;
  --line-soft: #eeefea;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --nav: #171b21;
  --accent: #e0ae4a;
  --accent-strong: #c8942c;
  --ok: #2e7d50;
  --ok-bg: #e7f3ec;
  --warn: #8a6212;
  --warn-bg: #fbf1da;
  --bad: #b3392e;
  --bad-bg: #faeae8;
  --radius: 8px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 64px; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- app bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
  padding: 0 24px;
  background: var(--nav);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: #17181b;
  font-weight: 800;
  font-size: 15px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 13.5px; font-weight: 650; letter-spacing: 0; }
.brand-text em {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9aa2ad;
}

.tabs { display: flex; gap: 4px; }

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #b7bec8;
  font: inherit;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { background: #242a32; color: #fff; }
.tab.is-active { background: #2c333c; color: #fff; }

.clock {
  margin-left: auto;
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #a8b0ba;
  white-space: nowrap;
}
.clock b { color: #fff; font-weight: 650; font-variant-numeric: tabular-nums; }
.clock span.late b { color: #f0a08b; }

/* ---------- layout ---------- */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.view { display: none; }
.view.is-active { display: block; }

/* ---------- kpi strip ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.kpi { padding: 14px 18px; border-right: 1px solid var(--line-soft); }
.kpi:last-child { border-right: 0; }

.kpi-label {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi.is-ok .kpi-value { color: var(--ok); }
.kpi.is-warn .kpi-value { color: var(--warn); }
.kpi.is-bad .kpi-value { color: var(--bad); }

/* ---------- panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  min-width: 200px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfbf9;
  color: var(--muted);
}
.search:focus-within { border-color: #bfc3ba; background: #fff; }
.search svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; flex-shrink: 0; }
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  width: 100%;
  color: var(--ink);
}

.segmented {
  display: flex;
  padding: 2px;
  background: #f1f1ec;
  border-radius: 7px;
}
.seg {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.seg:hover { background: #e8e8e2; }
.seg.is-active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.07); }

.select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfbf9;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f7f7f3; border-color: #d5d6d0; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #1b1a16;
  font-weight: 620;
}
.btn.primary:hover { background: #eab954; }

.btn.ghost { border-color: transparent; background: #f4f4f0; }
.btn.ghost:hover { background: #ebebe5; }

.btn.danger { color: var(--bad); border-color: #e9cfc9; }
.btn.danger:hover { background: var(--bad-bg); }

/* ---------- editor ---------- */

.editor {
  display: grid;
  grid-template-columns: 1.2fr 2fr 130px 110px 120px auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #fafaf6;
  border-bottom: 1px solid var(--line-soft);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; color: var(--muted); }

.field input, .field select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid rgba(224,174,74,.35); outline-offset: 1px; border-color: var(--accent-strong); }

.editor-actions { display: flex; gap: 8px; }

/* ---------- table ---------- */

.table-wrap { overflow: auto; max-height: calc(100vh - 240px); }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fbfbf8;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:hover { background: #fafaf6; }
tbody tr:last-child td { border-bottom: 0; }

.col-date { width: 116px; }
.col-count { width: 168px; }
.col-status { width: 108px; }
.col-actions { width: 92px; text-align: right; }

.member-name { font-weight: 580; color: var(--ink); }
.member-date { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.link-cell a {
  color: #2c5f9e;
  text-decoration: none;
  font-size: 12.5px;
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.link-cell a:hover { text-decoration: underline; }
.link-cell svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; margin-left: 4px; vertical-align: -2px; }
.link-cell .none { color: #b3b8bf; font-size: 12.5px; }

.date-cell { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }

.count-cell { display: flex; align-items: center; gap: 10px; }
.count-num { font-variant-numeric: tabular-nums; font-weight: 600; width: 34px; text-align: right; }
.count-num small { color: var(--muted); font-weight: 400; }
.bar { position: relative; flex: 1; height: 5px; background: #eceee8; border-radius: 3px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: #b9c0b4; border-radius: 3px; }
.bar.full i { background: var(--ok); }

.chip {
  appearance: none;
  border: 1px solid transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 560;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip[data-status="待核对"] { background: var(--warn-bg); color: var(--warn); border-color: #f0dfb6; }
.chip[data-status="已通过"] { background: var(--ok-bg); color: var(--ok); border-color: #cfe6da; }
.chip[data-status="已拒绝"] { background: var(--bad-bg); color: var(--bad); border-color: #f0d3ce; }
.chip:hover { filter: brightness(.97); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: #f0f0ea; color: var(--ink); border-color: var(--line); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad); border-color: #eed3ce; }
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.empty { padding: 56px 16px; text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

.panel-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
}
.panel-foot code { background: #f2f2ec; padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}
.cards.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card h2 { font-size: 14px; font-weight: 620; margin: 0; letter-spacing: 0; }

.doc {
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-card { margin-top: 14px; }
.doc-card summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 620;
  padding: 2px 0;
  list-style: none;
}
.doc-card summary::-webkit-details-marker { display: none; }
.doc-card summary::before { content: "+"; display: inline-block; width: 16px; color: var(--muted); }
.doc-card[open] summary::before { content: "−"; }
.doc-card[open] .doc { margin-top: 14px; max-height: 60vh; overflow: auto; padding-right: 8px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.copy-float { float: right; margin-left: 12px; }

.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #1c2128;
  color: #fff;
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .editor { grid-template-columns: 1fr 1fr; }
  .editor .wide { grid-column: span 2; }
  .editor-actions { grid-column: span 2; justify-content: flex-end; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(3n) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
}

@media (max-width: 760px) {
  .appbar { height: auto; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .clock { gap: 12px; font-size: 11px; }
  main { padding: 16px 14px 40px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { border-right: 1px solid var(--line-soft); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(-n+4) { border-bottom: 1px solid var(--line-soft); }
  .toolbar { gap: 8px; }
  .search { flex-basis: 100%; }
  .editor { grid-template-columns: 1fr; }
  .editor .wide, .editor-actions { grid-column: span 1; }
  .table-wrap { max-height: none; overflow: visible; }
  thead { display: none; }
  table, tbody { display: block; }
  tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "name name status"
      "link link link"
      "date count actions";
    gap: 6px 12px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line-soft);
    align-items: center;
  }
  tbody tr:hover { background: transparent; }
  tbody td { display: block; padding: 0; border: 0; }
  tbody td:nth-child(1) { grid-area: name; }
  tbody td:nth-child(2) { grid-area: link; }
  tbody td:nth-child(3) { grid-area: date; font-size: 12px; color: var(--muted); }
  tbody td:nth-child(4) { grid-area: count; }
  tbody td:nth-child(5) { grid-area: status; justify-self: end; }
  tbody td:nth-child(6) { grid-area: actions; justify-self: end; }
  .link-cell a { max-width: 100%; font-size: 12px; }
  .bar { max-width: 90px; }
  .row-actions { gap: 2px; }
  .panel-foot { flex-direction: column; gap: 4px; }
}

.rules { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rules li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.rules li:last-child { border-bottom: 0; padding-bottom: 0; }
.rules li::before {
  counter-increment: r;
  content: counter(r);
  flex: 0 0 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: #f1f1ec;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rules .rule-text { flex: 1; font-size: 13px; line-height: 1.65; color: var(--ink-2); }
.rule-copy {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.rule-copy:hover { background: #f6f6f1; color: var(--ink); }

/* ---------- cloud login ---------- */
.login{position:fixed;inset:0;z-index:200;display:grid;place-items:center;background:#141110;padding:20px}
.login[hidden]{display:none}
.login-card{width:100%;max-width:360px;display:grid;gap:14px;padding:28px;border-radius:12px;background:#1c1917;border:1px solid #2f2a26;color:#f5efe7}
.login-card h1{font-size:19px;margin:0;letter-spacing:0}
.login-card p{margin:0;color:#a8a29e;font-size:13px;line-height:1.5}
.login-card label{display:grid;gap:6px;font-size:12px;color:#a8a29e}
.login-card input{width:100%;padding:10px 12px;border-radius:8px;border:1px solid #3a332e;background:#141110;color:#f5efe7;font:inherit}
.logout{white-space:nowrap;margin-left:8px}