:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --ink: #1b2420;
  --ink-2: #4a5550;
  --muted: #7d8783;
  --line: #e2e5df;
  --line-2: #eef0eb;
  --side: #17211d;
  --side-ink: #c9d2cd;
  --side-dim: #7f8c86;
  --accent: #1f7a5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --bad: #b4382f;
  --bad-soft: #f9e5e2;
  --ok: #1f7a5c;
  --ok-soft: #e3f1ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 1px 1px rgba(20, 30, 25, .03);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --surface: #161d1a; --surface-2: #1b2320; --ink: #e4ebe7; --ink-2: #b4bfba; --muted: #808c86;
    --line: #26302c; --line-2: #1f2825; --side: #0b100e; --accent: #3fae86; --accent-soft: #17312a;
    --warn-soft: #33281a; --bad-soft: #3a1f1c; --ok-soft: #17312a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -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; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; font-weight: 620; }
h3 { font-size: 13px; font-weight: 620; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 8px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
small { font-size: 12px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side) 236px, transparent 236px); }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; padding: 4px 8px 18px; font-size: 14.5px; }
.brand:hover { text-decoration: none; }
.logo-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #3fae86, #1f7a5c 60%, #0f4d39); position: relative; flex: none; }
.logo-mark::after { content: ""; position: absolute; inset: 6px 5px 7px; border: 2px solid rgba(255,255,255,.9); border-top-width: 0; border-radius: 0 0 3px 3px; }
.side nav { flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-dim); padding: 14px 10px 6px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 7px; color: var(--side-ink); font-size: 13.5px; }
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-item.active { background: rgba(63,174,134,.18); color: #fff; }
.nav-item.upcoming span:first-child { opacity: .62; }
.nav-item .tag { font-size: 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 4px; padding: 0 5px; color: var(--side-dim); }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 12px 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-foot .me { color: var(--side-ink); display: flex; flex-direction: column; min-width: 0; }
.side-foot .me strong { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .me small { color: var(--side-dim); }
.side-foot .linkbtn { color: var(--side-dim); }
.main { padding: 26px 32px 40px; min-width: 0; max-width: 1280px; }
.foot { color: var(--muted); font-size: 12px; margin-top: 32px; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--ink-2); margin: 4px 0 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--ink-2); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card.narrow, .narrow { max-width: 760px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.pad { padding: 16px 18px; }
.pad-x { padding: 0 18px; }
.cols { display: flex; gap: 18px; align-items: flex-start; }
.cols > .grow { flex: 1; min-width: 0; }
.cols > .side-card, .side-card { width: 320px; flex: none; }
.card .cols { gap: 0; }
.card .cols > * + * { border-left: 1px solid var(--line-2); }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-value.small { font-size: 19px; margin: 8px 0 6px; }
.kpi-foot { font-size: 12.5px; color: var(--ink-2); }
.kpi .bar { margin-top: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mini-stats > div { padding: 12px 16px; display: flex; flex-direction: column; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.mini-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 12px; color: var(--ink-2); }

/* Bars */
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }
.bar.sm { height: 6px; }
.bar.xs { height: 3px; margin-top: 4px; background: transparent; }
.bar.xs > span { opacity: .55; }
.qcell { min-width: 150px; }
.qcell small { color: var(--ink-2); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 9px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 9px 18px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .right { text-align: right; }
.tbl .share { width: 22%; }
.tbl td.share .bar { margin-top: 7px; }
.tbl.compact td { padding: 6px 0; }
.tbl tr.muted td { color: var(--muted); }
.tbl tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tbl tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tbl td small { display: block; }
.tbl.audit td.details { color: var(--ink-2); font-size: 12.5px; max-width: 420px; word-break: break-word; }
.nowrap { white-space: nowrap; }
.trunc { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag { color: var(--bad); }

/* Pills & roles */
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); vertical-align: middle; letter-spacing: 0; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.muted { background: var(--line-2); color: var(--muted); }
h1 .pill { font-size: 12px; }
.role { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; margin-left: 6px; background: var(--line-2); color: var(--ink-2); }
.role-trash { background: var(--bad-soft); color: var(--bad); }
.role-inbox { background: var(--accent-soft); color: var(--accent); }
.role-junk { background: var(--warn-soft); color: var(--warn); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 18px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; }
.list li:last-child { border-bottom: 0; }
.list small { color: var(--muted); }
.bullets { margin: 0; padding-left: 36px; }
.bullets li { margin: 6px 0; }
.steps li { margin: 8px 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.small { font-size: 12.5px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.alert.error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.banner { padding: 8px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 36px 20px; color: var(--ink-2); }
.empty h2 { margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2); margin-bottom: 12px; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input.short { width: 110px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
fieldset { border: 0; border-top: 1px solid var(--line-2); margin: 10px 0 6px; padding: 14px 0 0; }
legend { font-weight: 650; color: var(--ink); padding-right: 8px; font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; align-items: end; }
.span2 { grid-column: span 2; }
.filters { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.filters label { width: 170px; }
.filters .actions { margin-bottom: 12px; }
.row-form { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line-2); }
.row-form input { margin: 0; max-width: 280px; }
form.inline { display: inline; }
.settings .setting { display: flex; justify-content: space-between; gap: 24px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); align-items: center; }
.settings .setting:last-child { border-bottom: 0; }
.settings .control { flex: none; }
.switch { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.switch input { width: 36px; height: 20px; margin: 0; accent-color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; 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.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkbtn.danger { color: var(--bad); }
.pager { display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line-2); }

/* Job */
.job { padding: 14px 18px; }
.job-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 12px; }
.job .bar { height: 10px; margin-bottom: 6px; }

/* Auth */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 640px; }
.auth-card h1 { margin: 6px 0 16px; }
.brand-lg { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink-2); }
.checks { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.checks td { padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.checks .ok { color: var(--ok); font-weight: 600; text-align: right; }
.checks .bad { color: var(--bad); font-weight: 600; text-align: right; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { flex-direction: column; }
  .cols > .side-card, .side-card { width: 100%; }
  .card .cols > * + * { border-left: 0; border-top: 1px solid var(--line-2); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-section { width: 100%; padding: 8px 10px 2px; }
  .main { padding: 18px 16px; }
  .kpis { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .tbl th, .tbl td { padding: 8px 10px; }
  .trunc { max-width: 200px; }
}
fieldset .hint { margin: -4px 0 12px; }

/* Module 3 */
.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { padding: 8px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-size: 11.5px; background: var(--line-2); color: var(--ink-2); border-radius: 99px; padding: 0 7px; margin-left: 4px; }
.ptype { display: inline-block; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 2px; }
.tbl.patterns td .pill { margin: 1px 2px 1px 0; }
.tbl tr.focus td { background: var(--accent-soft); }
.tbl .tags { margin-top: 4px; }
.tbl .tags .pill { margin-right: 4px; }
.tbl.compact-pad th.lbl { width: 110px; background: none; border-bottom: 1px solid var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.iconbtn { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; cursor: pointer; font-size: 13px; line-height: 1.4; }
.iconbtn:hover { background: var(--surface-2); }
.row-actions form { margin-left: 2px; }
.checks-list li { flex-direction: column; }
.checks-list li.pass span { color: var(--ok); }
.checks-list li.hit span { color: var(--bad); font-weight: 600; }
.stack .actions { margin-top: 4px; }
fieldset.ack { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); border-radius: 8px; padding: 12px 14px 4px; margin: 8px 0 14px; }
fieldset.ack legend { color: var(--bad); padding: 0 6px; }
.list li.row { flex-direction: row; justify-content: space-between; align-items: center; }
input.search { width: 200px; margin: 0; padding: 6px 10px; }
textarea.wide { width: 360px; max-width: 100%; }
.settings .setting:has(textarea) { flex-direction: column; align-items: stretch; }
.settings .setting:has(textarea) textarea.wide { width: 100%; }
.linkbtn.muted { color: var(--muted); }
.tbl tr.grouprow td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

@media print {
  .side, .foot, .actions, form.inline, .btn, .iconbtn, .row-actions, .tabs, .crumbs { display: none !important; }
  .shell { display: block; background: none; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .tbl tr { break-inside: avoid; }
  a { color: inherit; }
}

/* Module 4 */
.nav-item .tag.hot { background: var(--warn); color: #fff; border-color: var(--warn); }
.lifecycle { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 0; flex-wrap: wrap; }
.lifecycle li { flex: 1; min-width: 120px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); margin-left: -1px; font-size: 12.5px; color: var(--muted); font-weight: 600; position: relative; }
.lifecycle li:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.lifecycle li:last-child { border-radius: 0 8px 8px 0; }
.lifecycle li::before { content: "○ "; }
.lifecycle li.done { color: var(--ok); background: var(--ok-soft); }
.lifecycle li.done::before { content: "● "; }
.mini-stats.two { grid-template-columns: 1fr 1fr; }
.approve-box { border-top: 1px solid var(--line-2); background: var(--accent-soft); }
.danger-box { border-top: 1px solid var(--line-2); background: var(--bad-soft); }
.authorize { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
ul.plain { margin: 6px 0 0; padding-left: 18px; }
details summary { cursor: pointer; color: var(--accent); }
