:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-2: #1d4ed8;
  --primary-soft: #e0e7ff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --orange: #c2410c;
  --orange-soft: #ffedd5;
  --indigo: #4338ca;
  --indigo-soft: #e0e7ff;
  --slate: #475569;
  --slate-soft: #e2e8f0;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #0b1b3f; color: #c7d2fe; padding: 18px 14px; position: fixed; inset: 0 auto 0 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 4px 8px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #60a5fa, #a78bfa); display: grid; place-items: center; font-size: 15px; color: #0b1b3f; font-weight: 800; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #c7d2fe; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(96,165,250,.18); color: #fff; }
.nav .section { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6b7fb3; padding: 14px 10px 6px; }
.nav .badge { margin-left: auto; }
.sidebar .user { margin-top: 18px; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: #94a3b8; }
.sidebar .user b { color: #e2e8f0; display: block; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .crumbs { color: var(--muted); font-size: .85rem; }
.topbar .crumbs b { color: var(--text); }
.content { padding: 22px 28px 48px; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 2px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card .card-h h2, .card .card-h h3 { margin: 0; }
.card .card-b { padding: 16px 18px; }
.card .card-b.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* kpi */
.kpi { padding: 14px 16px; }
.kpi .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.kpi .value.good { color: var(--green); }
.kpi .value.bad { color: var(--red); }
.kpi .value.warn { color: var(--amber); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; background: var(--surface-2); }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-indigo { background: var(--indigo-soft); color: var(--indigo); }
.badge-slate { background: var(--slate-soft); color: var(--slate); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; line-height: 1.2; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 9px; font-size: .78rem; }
.btn.link { border: 0; background: transparent; color: var(--primary); padding: 2px 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--slate); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; font-size: .875rem; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29,78,216,.35); outline-offset: 1px; border-color: var(--primary-2); }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 12px; }
.field .help { font-size: .75rem; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.filters input, .filters select { padding: 6px 9px; font-size: .82rem; }

/* misc */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; border: 1px solid; }
.flash.success { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.flash.warning { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.flash.info { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 14px; font-size: .82rem; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .78rem; }
.timeline .what b { display: block; }
.bar { height: 8px; background: var(--slate-soft); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.bar.red span { background: var(--red); }
.bar.amber span { background: var(--amber); }
.bar.green span { background: var(--green); }
.risk-meter { display: inline-flex; align-items: center; gap: 6px; }
.risk-meter .bar { width: 60px; }
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .85rem; }
.stat-row:last-child { border-bottom: 0; }
.stat-row b { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .85rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.pre { white-space: pre-wrap; font-family: var(--font); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: .85rem; }
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.step { display: grid; grid-template-columns: 76px 90px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: 0; }
.step .day { font-weight: 700; font-variant-numeric: tabular-nums; }
.step .day.pre { color: var(--green); }
.callout { padding: 12px 14px; border-radius: 8px; background: var(--primary-soft); color: #1e3a8a; font-size: .85rem; border: 1px solid #c7d2fe; }
.callout.warn { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.copy { cursor: pointer; }
.progress-ring { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #dbeafe, transparent), radial-gradient(900px 500px at 110% 110%, #ede9fe, transparent), var(--bg); padding: 24px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0 0 12px; justify-content: center; }
.auth .brand .logo { background: linear-gradient(135deg, #1d4ed8, #7c3aed); color: #fff; }

/* portal */
.portal { max-width: 900px; margin: 0 auto; padding: 32px 20px 60px; }
.portal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

/* print */
@media print {
  .sidebar, .topbar, .actions, .filters, .btn, .pager, .no-print { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* responsive */
@media (max-width: 1100px) {
  .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-3 { grid-column: span 2; }
}
@media (max-width: 820px) {
  .sidebar { position: static; width: 100%; inset: auto; padding: 10px; }
  .sidebar .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .sidebar .nav .section { display: none; }
  .sidebar .user { display: none; }
  .shell { flex-direction: column; }
  .main { margin-left: 0; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; }
  .step { grid-template-columns: 60px 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}

.checklist .check-row { padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: .85rem; }
.checklist .check-row:last-child { border-bottom: 0; }
.checklist h1 { font-size: 1.2rem; }
.checklist table { margin: 10px 0 18px; max-width: 560px; }
