/* ===== Design tokens (validated categorical + status palette) ===== */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --border: #e1e0d9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --baseline: #c3c2b7;

  --accent: #2a78d6;      /* series-1 blue */
  --accent-ink: #ffffff;
  --accent-soft: #e7f0fb;

  --s1: #2a78d6; /* blue */
  --s2: #eb6834; /* orange */
  --s3: #1baf7a; /* aqua */
  --s4: #eda100; /* yellow */
  --s5: #e87ba4; /* magenta */
  --s6: #008300; /* green */
  --s7: #4a3aa7; /* violet */
  --s8: #e34948; /* red */

  --good: #0ca30c;
  --warning: #b9790a;
  --serious: #c1502c;
  --critical: #d03b3b;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(11,11,11,0.05), 0 10px 28px rgba(11,11,11,0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #202020;
    --border: #2c2c2a;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-muted: #898781;
    --baseline: #383835;

    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: #17233a;

    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;

    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 10px 28px rgba(0,0,0,0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #202020;
  --border: #2c2c2a;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --baseline: #383835;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --accent-soft: #17233a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #e66767;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 10px 28px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* ===== App shell ===== */
.app { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--s7));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 14.5px; }
.brand-text span { font-size: 11.5px; color: var(--ink-muted); }

.nav-list { list-style: none; margin: 6px 0 0; padding: 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; font-size: 13.8px; font-weight: 600;
  color: var(--ink-2); cursor: pointer;
}
.nav-item .ic { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.nav-sep { height: 1px; background: var(--border); margin: 12px 6px; }
.nav-foot { padding: 10px 8px 0; font-size: 11.5px; color: var(--ink-muted); }
.nav-foot a { color: var(--ink-muted); }

/* ===== Topbar / content ===== */
.content { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 30px; background: var(--page);
  border-bottom: 1px solid var(--border);
}
.crumbs { font-size: 13px; color: var(--ink-muted); }
.crumbs b { color: var(--ink); }
.nav-toggle { display: none; }
.overlay { display: none; }

.view { max-width: 980px; margin: 0 auto; padding: 30px 32px 70px; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(145deg, var(--accent) 0%, var(--s7) 130%);
  color: #fff; border-radius: var(--radius); padding: 34px 34px;
  margin-bottom: 22px; box-shadow: var(--shadow);
}
.hero .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.hero h1 { margin: 6px 0 10px; font-size: 25px; line-height: 1.3; }
.hero p { margin: 0; opacity: .94; max-width: 680px; font-size: 14.5px; }
.hero .hero-stats { display: flex; gap: 26px; margin-top: 20px; flex-wrap: wrap; }
.hero .hero-stats div { display: flex; flex-direction: column; }
.hero .hero-stats b { font-size: 21px; }
.hero .hero-stats span { font-size: 11.5px; opacity: .85; }

/* ===== Stat grid ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0 26px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
}
.stat-tile .v { font-size: 24px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-tile .l { font-size: 12px; color: var(--ink-2); margin-top: 4px; font-weight: 600; }
.stat-tile .n { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }

/* ===== Sections / cards ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 18px; }
.card h3 { font-size: 15px; margin: 1.3em 0 .5em; }
.section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-muted); margin: 30px 2px 10px;
}
.section-label:first-child { margin-top: 0; }

.prose p { margin: 0 0 .9em; color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose ul { padding-left: 1.3em; margin: 0 0 .9em; color: var(--ink-2); }
.prose li { margin-bottom: .35em; }

/* ===== Callouts ===== */
.callout {
  display: flex; gap: 12px; border-radius: 12px; padding: 14px 16px;
  margin: 14px 0; font-size: 13.5px; border: 1px solid var(--border);
}
.callout .ic { font-size: 17px; flex-shrink: 0; }
.callout b { display: block; margin-bottom: 2px; }
.callout.tone-info { background: var(--accent-soft); border-color: transparent; }
.callout.tone-warning { background: rgba(185,121,10,0.10); }
.callout.tone-good { background: rgba(12,163,12,0.09); }
.callout.tone-critical { background: rgba(208,59,59,0.09); }

/* ===== Cards grid ===== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.mini-card { background: var(--surface-2); border-radius: 11px; padding: 16px 18px; }
.mini-card .ic { font-size: 20px; margin-bottom: 8px; display: block; }
.mini-card h4 { margin: 0 0 6px; font-size: 14px; }
.mini-card p { margin: 0; font-size: 12.8px; color: var(--ink-2); }

/* ===== Accordion ===== */
.accordion-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.accordion-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; cursor: pointer; font-weight: 600; font-size: 13.8px;
  background: var(--surface);
}
.accordion-head:hover { background: var(--surface-2); }
.accordion-head .chev { transition: transform .15s ease; color: var(--ink-muted); font-size: 11px; }
.accordion-item.open .chev { transform: rotate(180deg); }
.accordion-body { display: none; padding: 4px 16px 16px; font-size: 13.3px; color: var(--ink-2); }
.accordion-item.open .accordion-body { display: block; }
.accordion-body .tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 2px 6px; margin-right: 6px;
}

/* ===== Timeline / roadmap ===== */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 2px; width: 17px; height: 17px; border-radius: 50%;
  border: 3px solid var(--surface); display: flex; align-items: center; justify-content: center; font-size: 9px; color: #fff;
}
.tl-item.done .tl-dot { background: var(--good); }
.tl-item.draft .tl-dot { background: var(--warning); }
.tl-item.pending .tl-dot { background: var(--baseline); }
.tl-title { font-weight: 700; font-size: 13.8px; display: flex; align-items: center; gap: 8px; }
.tl-desc { font-size: 12.8px; color: var(--ink-2); margin-top: 3px; }
.status-chip { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.status-chip.done { background: rgba(12,163,12,0.14); color: var(--good); }
.status-chip.draft { background: rgba(185,121,10,0.16); color: var(--warning); }
.status-chip.pending { background: var(--surface-2); color: var(--ink-muted); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; color: var(--ink-2); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: none; }

/* ===== Charts ===== */
.chart-block { margin: 10px 0 18px; }
.chart-title { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.chart-unit { font-size: 11.5px; color: var(--ink-muted); margin-bottom: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 150px; flex-shrink: 0; font-size: 12.5px; color: var(--ink-2); text-align: right; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 5px; height: 20px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; display: flex; align-items: center; }
.bar-value { font-size: 12px; font-weight: 700; width: 54px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.bar-fill-label { color: #fff; font-size: 11px; font-weight: 700; padding-left: 8px; white-space: nowrap; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 4px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ===== Quote grid ===== */
.quote-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; margin-top: 10px; }
.quote-card { background: var(--surface-2); border-radius: 11px; padding: 16px 18px; font-size: 13.2px; }
.quote-card .q { color: var(--ink); font-style: italic; }
.quote-card .tag { display: inline-block; margin-top: 10px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--accent); }

/* ===== Diagram / figure ===== */
figure.diagram { margin: 14px 0; }
figure.diagram svg { max-width: 100%; height: auto; display: block; }
figure.diagram figcaption { font-size: 12px; color: var(--ink-muted); margin-top: 10px; text-align: center; }

/* ===== Stage flow diagram ===== */
.stage-flow { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 6px 2px 14px; }
.stage-card {
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 11px;
  padding: 14px 14px 12px; min-width: 148px; flex-shrink: 0; position: relative;
}
.stage-card .stage-num {
  width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.stage-card h4 { margin: 0 0 4px; font-size: 12.8px; }
.stage-card p { margin: 0; font-size: 11.5px; color: var(--ink-2); }
.stage-arrow { display: flex; align-items: center; color: var(--ink-muted); font-size: 16px; flex-shrink: 0; }

/* ===== Row layout (side-by-side blocks) ===== */
.block-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin: 10px 0 18px; }
.block-row .row-item { flex: 1 1 260px; min-width: 0; }
.block-row .row-item figure.diagram { margin: 0; }

/* ===== Mapping diagram (two-column traceability) ===== */
.mapping-head {
  display: flex; justify-content: space-between; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--ink-muted); margin-bottom: 8px; padding: 0 2px;
}
.mapping-diagram { display: flex; flex-direction: column; gap: 8px; }
.mapping-row { display: flex; align-items: center; gap: 10px; }
.mapping-box {
  flex: 1; background: var(--surface-2); border-left: 3px solid; border-radius: 8px;
  padding: 10px 14px; font-size: 12.6px; color: var(--ink-2);
}
.mapping-arrow { color: var(--ink-muted); font-size: 15px; flex-shrink: 0; }

/* ===== Profile grid (Tim Peneliti) ===== */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.profile-card { background: var(--surface-2); border-radius: var(--radius); padding: 20px; }
.profile-card.placeholder { background: transparent; border: 1.5px dashed var(--border); }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--s7));
  margin-bottom: 12px;
}
.profile-card.placeholder .profile-avatar {
  background: var(--surface); color: var(--ink-muted); border: 1.5px dashed var(--border);
}
.profile-name { font-size: 14.5px; font-weight: 800; }
.profile-role { font-size: 12px; font-weight: 700; color: var(--accent); margin: 2px 0 8px; }
.profile-meta { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.profile-bio { font-size: 12.3px; color: var(--ink-2); margin-top: 8px; line-height: 1.5; }

/* ===== Source note ===== */
.source-note {
  font-size: 11.5px; color: var(--ink-muted); border-top: 1px dashed var(--border);
  margin-top: 22px; padding-top: 12px;
}
.source-note a { color: var(--ink-muted); }

/* ===== Home grid ===== */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap: 14px; }
.home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease;
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.home-card .ic { font-size: 22px; }
.home-card h3 { font-size: 14.5px; margin: 10px 0 4px; }
.home-card p { font-size: 12.5px; color: var(--ink-2); margin: 0; }

/* ===== Search ===== */
.search-wrap { position: relative; width: 280px; max-width: 44vw; }
.global-search-input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 13.3px;
}
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto; padding: 6px;
}
.sr-item { display: block; padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.sr-item:hover, .sr-item.active { background: var(--surface-2); }
.sr-item .sr-crumb { font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-muted); font-weight: 700; }
.sr-item .sr-title { font-size: 13.3px; font-weight: 700; margin: 2px 0 3px; }
.sr-item .sr-snip { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.sr-item .sr-snip mark { background: var(--accent-soft); color: var(--accent); padding: 0 2px; border-radius: 3px; }
.sr-empty { padding: 14px; text-align: center; font-size: 12.5px; color: var(--ink-muted); }

/* ===== See also ===== */
.see-also { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 18px; }
.see-also .sa-label { font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.see-also .sa-chip {
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none;
}
.see-also .sa-chip:hover { opacity: 0.8; text-decoration: none; }

/* ===== Mobile ===== */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 270px; height: 100vh; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 12px; left: 12px; z-index: 40; width: 38px; height: 38px;
    border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    font-size: 16px; cursor: pointer;
  }
  .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
  .overlay.open { display: block; }
  .topbar { padding: 14px 16px 14px 58px; flex-wrap: wrap; }
  .search-wrap { width: 100%; max-width: none; margin-top: 8px; }
  .view { padding: 20px 16px 60px; }
  .card { padding: 20px; }
  .bar-label { width: 100px; font-size: 11.5px; }
}
