:root {
  color-scheme: dark;
  --bg: #0e0f0e;
  --rail: #121312;
  --card: #181a18;
  --card-2: #1e211e;
  --line: #2a2d2a;
  --text: #f4f6f3;
  --muted: #8e938c;
  --green: #3ddc78;
  --green-deep: #1f9a4e;
  --green-ink: #06210f;
  --warn: #e3b341;
  --bad: #f07167;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--sans); color: var(--text); background: var(--bg); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.mark { display: flex; gap: 10px; align-items: center; padding: 6px 8px 22px; }
.mark-seal {
  width: 34px; height: 34px; border-radius: 10px; background: var(--green); color: var(--green-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.mark strong { display: block; font-weight: 650; font-size: 15px; }
.mark span { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.rail nav { display: flex; flex-direction: column; gap: 4px; }
.rail a {
  text-decoration: none; padding: 10px 12px; border-radius: 10px; color: #c5cac3;
  display: flex; align-items: center; gap: 10px;
}
.rail a svg { width: 16px; height: 16px; flex: none; }
.rail a.active { background: #1c3d2a; color: #e9fff1; }
.rail a:hover { background: #222522; color: var(--text); }
.rail a.active:hover { background: #245236; }
.rail-foot { margin-top: auto; }
.rail-foot form { margin: 0; }
.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  width: 100%; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: left;
}
.ghost:hover { color: var(--text); border-color: #3a3e3a; }

.stage { padding: 28px 32px 72px; max-width: 1240px; }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 18px; }
.page-head .create { flex: 0 0 420px; background: transparent; border: 0; padding: 0; box-shadow: none; }
.kicker { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--text); }
h1 { font-weight: 650; font-size: 28px; line-height: 1.25; margin: 0; }
.lede { color: var(--muted); margin: 8px 0 0; max-width: 46em; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px;
}
.stat p { margin: 0; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 28px; font-weight: 650; letter-spacing: -0.03em; }
.stat.warn strong { color: var(--warn); }
.stat.ok strong { color: var(--green); }

.panel, .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.panel { padding: 16px 16px 14px; }
.sheet { overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input, select {
  width: 100%; background: #101210; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px;
}
input:focus, select:focus { outline: 2px solid rgba(61, 220, 120, 0.35); border-color: var(--green); }
.row-form { display: flex; gap: 8px; align-items: center; }
.row-form input, .row-form select { margin: 0; }
.btn {
  background: var(--green); color: var(--green-ink); border: 0; border-radius: 999px;
  padding: 10px 16px; cursor: pointer; white-space: nowrap; font-weight: 650;
}
.btn:hover { background: #62e892; }
.btn.secondary { background: #2a2c2a; color: var(--text); border: 1px solid #3a3d3a; font-weight: 500; }
.btn.secondary:hover { border-color: #4a4e4a; background: #343734; }
.btn.review { background: #243044; color: #d7e6ff; border: 1px solid #3a4d66; }
.btn.review:hover { background: #2d3c54; }
.btn.warn { background: #3a2422; color: #ffd4cf; border: 1px solid #5c3532; }
.btn.warn:hover { background: #4a2c2a; }
.inline { display: inline; }
.inline button { padding: 6px 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 12px 16px; }
td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #1d201d; }
.doc-link { text-decoration: none; font-weight: 600; }
.doc-link:hover { color: var(--green); }
caption { caption-side: top; text-align: left; padding: 16px 16px 4px; font-size: 16px; font-weight: 650; }

.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: #242824; color: var(--muted); }
.pill.ok { background: #163222; color: var(--green); }
.pill.bad { background: #3a2220; color: var(--bad); }
.pill.run { background: #332c18; color: var(--warn); }
.error { color: var(--bad); margin: 0 0 12px; }
.muted { color: var(--muted); }
.empty { padding: 28px 16px; color: var(--muted); }

.case-row, .list-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; text-decoration: none; padding: 16px 18px; border-top: 1px solid var(--line); }
.case-row:first-child, .list-row:first-child { border-top: 0; }
.case-row strong, .list-row strong { font-size: 15px; font-weight: 600; }
.case-row span, .list-row span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.case-row:hover, .list-row:hover { background: #1d201d; }

.board-head, .data-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.9fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
}
.board-head { color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.data-row + .data-row { border-top: 1px solid var(--line); }
.data-row:hover { background: #1d201d; }
.data-main { display: flex; align-items: center; gap: 14px; min-width: 0; text-decoration: none; }
.thumb {
  width: 64px; height: 64px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 700; color: var(--green);
  background: linear-gradient(160deg, #2c3330, #1a1e1c);
}
.data-copy { min-width: 0; }
.data-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.data-title span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.data-state { display: flex; align-items: center; gap: 12px; }
.data-when { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.meter {
  --meter: var(--green);
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--meter) calc(var(--p) * 1%), #2c302c 0);
  color: var(--meter);
}
.meter::before {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--card);
}
.meter span { position: relative; font-size: 11px; font-weight: 700; }
.meter-ok { --meter: var(--green); }
.meter-warn { --meter: var(--warn); }
.meter-bad { --meter: var(--bad); }
.meter-idle { --meter: var(--muted); }
.data-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.data-actions form { margin: 0; display: flex; align-items: center; }
.act {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green); color: var(--green-ink); border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 650; text-decoration: none; cursor: pointer;
  width: auto; margin: 0; white-space: nowrap;
}
.act svg { width: 15px; height: 15px; flex: none; }
.act:hover { background: #62e892; color: var(--green-ink); }
.act.view { background: #2a2c2a; color: #f4f6f3; border: 1px solid #3a3d3a; }
.act.view:hover { background: #343734; color: #fff; }
.act.warn { background: var(--bad); color: #2a0907; border: 0; }
.act.warn:hover { background: #ff8d84; color: #2a0907; }
.act.review { background: #243044; color: #d7e6ff; border: 1px solid #3a4d66; }
.act.review:hover { background: #2d3c54; color: #fff; }

.banner {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: #1a241c; border: 1px solid #274832; margin-bottom: 16px;
}
.work { display: grid; gap: 10px; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 0; }
.file-list li {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.file-main { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.file-list .doc-link { line-height: 1.45; }
.file-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-times { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; color: var(--muted); font-size: 12px; }
.file-actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.file-actions form { margin: 0; display: flex; align-items: center; gap: 8px; }
.file-actions select { width: auto; margin: 0; padding: 6px 10px; border-radius: 999px; }
.fill-dialog {
  width: min(1040px, calc(100vw - 48px)); max-height: min(84vh, 860px);
  margin: auto; padding: 0; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
}
.fill-dialog::backdrop { background: rgba(0, 0, 0, 0.66); }
.fill-dialog > header {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.fill-dialog > header strong { font-size: 16px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; }
.preview-dialog { width: min(1100px, calc(100vw - 48px)); }
.preview-dialog .fill-body { padding: 0; background: #111; }
.preview-frame { display: block; width: 100%; height: min(72vh, 760px); border: 0; background: #fff; }
.paper {
  margin: 16px; padding: 28px 36px; background: #f6f3ea; color: #1d1d1b;
  border-radius: 12px; line-height: 1.75;
}
.paper p { margin: 0 0 0.7em; }
.paper table { width: 100%; border-collapse: collapse; margin: 0.8em 0 1.2em; }
.paper td { border: 1px solid #d5d0c4; padding: 6px 8px; vertical-align: top; }
.preview-page .preview-frame { height: calc(100vh - 180px); }
.preview-page .paper { margin: 0; }
.fill-body { overflow: auto; max-height: calc(84vh - 64px); padding: 0 0 8px; }
.fill-summary { margin: 0; padding: 12px 16px 4px; color: var(--muted); font-size: 13px; }
.fill-dialog th { position: sticky; top: 0; background: #1c1f1c; z-index: 1; }
tr.is-empty td { color: var(--muted); }
.source-doc { display: block; color: var(--text); font-weight: 650; margin-bottom: 4px; }
.source-quote { display: block; color: var(--muted); }
.fill-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.fill-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.fill-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.fill-card header strong { font-size: 14px; line-height: 1.4; }
.fill-value { margin: 0; font-size: 18px; font-weight: 650; line-height: 1.4; }
.fill-quote { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.fill-missing { display: flex; flex-wrap: wrap; gap: 8px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.section-title h2 { margin: 0; }
.section-title .btn { flex: none; }
.form-dialog {
  width: min(480px, calc(100vw - 48px)); margin: auto; padding: 0;
  color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.form-dialog::backdrop { background: rgba(0, 0, 0, 0.66); }
.form-dialog > header {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.form-dialog > header strong { font-size: 16px; }
.form-dialog form, .form-dialog > p { padding: 16px 18px 18px; }
.form-dialog form { display: grid; }
.form-dialog .btn { justify-self: start; }
.pick-dialog { width: min(560px, calc(100vw - 48px)); }
.pick-form { gap: 14px; }
.pick-list { max-height: min(52vh, 420px); overflow: auto; }
.pick-row {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 10px 2px;
  color: var(--text); cursor: pointer; border-top: 1px solid var(--line);
}
.pick-list .pick-row:first-child { border-top: 0; }
.pick-row input {
  width: 16px; height: 16px; flex: none; margin: 0; padding: 0;
  accent-color: var(--green);
}
.pick-title { flex: 1; min-width: 0; font-weight: 600; line-height: 1.45; }
.pick-row .pill { flex: none; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; background: var(--bg); }
.login-story {
  padding: 64px; color: var(--text);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-story h1 { font-size: 48px; max-width: 9em; font-weight: 650; }
.login-story p { max-width: 28em; color: var(--muted); font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px;
}
.login-card h2 { font-size: 24px; margin: 0 0 16px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.title-form { display: flex; gap: 12px; align-items: center; }
.title-input {
  field-sizing: content; flex: 0 1 auto; width: auto; min-width: 6em; max-width: 100%;
  margin: 0; padding: 0 2px; border: 0; border-radius: 0; background: transparent;
  font-size: 28px; font-weight: 650; line-height: 1.25;
}
.title-input:hover, .title-input:focus { border-bottom: 1px solid var(--line); background: transparent; outline: none; }

@media (max-width: 960px) {
  .shell, .grid-2, .split, .login-page, .stats { grid-template-columns: 1fr; }
  .shell { align-content: start; }
  .rail {
    position: relative; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 8px 16px; padding: 14px 16px;
  }
  .mark { padding: 0; }
  .rail nav { flex-direction: row; }
  .rail-foot { margin-top: 0; }
  .ghost { width: auto; }
  .stage { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .create { flex-basis: auto; width: 100%; }
  .title-form { flex-wrap: wrap; }
  .title-input { width: 100%; }
  .board-head { display: none; }
  .board-head, .data-row { grid-template-columns: 1fr; gap: 10px; }
  .data-actions { justify-content: flex-start; }
  h1, .title-input, .login-story h1 { font-size: 26px; }
  .login-story { padding: 32px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
}
