:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1a1f2b;
  --muted: #5f6878;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefd;
  --ok: #17803d;   --ok-soft: #e3f4e8;
  --warn: #a15c00; --warn-soft: #fdf0dc;
  --bad: #c0262d;  --bad-soft: #fbe5e6;
  --info: #2f5bea; --info-soft: #e8eefd;
  --neutral-soft: #eceef2;
  --purple: #6b3fc4; --purple-soft: #efe8fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #171b23; --surface-2: #1e232d; --border: #2a303c;
    --text: #e6e9ef; --muted: #9aa3b2; --accent: #6b8cff; --accent-ink: #0b0e14; --accent-soft: #1d2647;
    --ok: #4cc074; --ok-soft: #15301f; --warn: #e3a447; --warn-soft: #36280f;
    --bad: #f0686e; --bad-soft: #3a1a1c; --info: #6b8cff; --info-soft: #1d2647;
    --neutral-soft: #252b36; --purple: #a98bf0; --purple-soft: #2a2140;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.brand img { width: 26px; height: 26px; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.sidebar .me { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 10px 0; font-size: 13px; }
.sidebar .me .name { font-weight: 600; }
.sidebar .me .links { display: flex; gap: 12px; margin-top: 6px; }
.main { padding: 26px 32px 60px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.menu-toggle { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .layout.nav-open .sidebar { transform: none; }
  .main { padding: 16px; }
  .btn.menu-toggle { display: inline-flex; margin-bottom: 12px; }
}

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 20px; }
.kpi { padding: 16px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.alert .value { color: var(--bad); }
.two-col { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.halves { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ref { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.domain-row td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--muted); }

/* ---------- pills & progress ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.tag { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; font-family: var(--mono); margin: 1px 2px 1px 0; }
.overdue { color: var(--bad); font-weight: 600; }
.progress { height: 8px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.progress > span.ok { background: var(--ok); }
.progress > span.bad { background: var(--bad); }
.progress > span.muted-bar { background: var(--muted); opacity: .45; }
.progress > span.info { background: var(--info); opacity: .55; }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- forms & buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; }
.checks { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; min-width: 150px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- evidence & discussion ---------- */
.dropzone { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone strong { color: var(--text); }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.files li:last-child { border-bottom: 0; }
.file-icon { width: 34px; height: 40px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--muted); flex: none; text-transform: uppercase; }
.files .meta { flex: 1; min-width: 0; }
.files .fname { font-weight: 550; word-break: break-all; }
.upload-progress { margin-top: 10px; }
.comments { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.comment { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.comment.staff { background: var(--accent-soft); }
.comment.internal { background: var(--warn-soft); border: 1px dashed var(--warn); }
.comment .who { font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.comment .who span { font-weight: 400; color: var(--muted); }
.banner { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.info { background: var(--info-soft); color: var(--info); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); white-space: nowrap; font-size: 12px; min-width: 120px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { padding: 0 0 20px; font-size: 18px; }
.auth .btn { width: 100%; }

/* ---------- modal & toasts ---------- */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; max-height: calc(100vh - 200px); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.secret { font-family: var(--mono); font-size: 16px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); user-select: all; word-break: break-all; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500; max-width: 360px; }
.toast.error { background: var(--bad); color: #fff; }
@media (max-width: 600px) { .row { grid-template-columns: 1fr; } .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }
.title-cell { min-width: 240px; }
.codeblock { position: relative; margin-bottom: 14px; }
.codeblock pre { margin: 0; padding: 10px 12px; padding-right: 70px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.codeblock .btn { position: absolute; top: 6px; right: 6px; }
.capture-preview { width: 100%; max-height: 50vh; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; background: var(--surface-2); }
.steps { margin: 0 0 12px; padding-left: 20px; }
.steps li { margin-bottom: 8px; }
