:root {
  --ink: #10262B; --ink-2: #1B383D; --paper: #F5F6F3; --card: #ffffff; --line: #D9DFDC;
  --text: #14201F; --muted: #5B6B69; --accent: #0F766E; --accent-soft: #E0F1EC;
  --good: #16845D; --bad: #B42318; --warn: #966000; --gold: #E8A317;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--paper); font-variant-numeric: tabular-nums; }
h1, h2, p { margin: 0; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 12.5px; background: #EDF3F1; padding: 1px 5px; border-radius: 4px; }
.url { display: inline-block; max-width: 420px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: #D2E0DC; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; padding: 4px 10px 18px; letter-spacing: -0.01em; }
.brand.dark { color: var(--ink); padding: 0 0 20px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 210deg, var(--accent), var(--gold), #31A99D, var(--accent)); }
.nav-title { font-size: 12px; color: #8FA9A4; padding: 16px 10px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 11px; color: #D2E0DC; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; width: 100%; }
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.is-active { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-link .icon { flex: none; opacity: .9; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid #294348; }
.who { display: flex; flex-direction: column; padding: 4px 10px 10px; color: #fff; }
.who span { color: #9DB1AD; font-size: 12.5px; }

.main { padding: 26px 32px 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; letter-spacing: -0.02em; line-height: 1.2; }
.subtitle { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.controls, .filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters { margin-bottom: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; letter-spacing: -0.01em; }
.kpi-row { display: grid; gap: 14px; margin-bottom: 14px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.15; overflow-wrap: anywhere; }
.kpi-value.good { color: var(--good); } .kpi-value.bad { color: var(--bad); }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.note { color: var(--muted); font-size: 13px; margin: 4px 0 18px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.approvals { display: flex; flex-direction: column; gap: 10px; }
.approval-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.approval-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.count { min-width: 28px; text-align: center; padding: 2px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }

.chart-fig { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sw-total { background: #0F766E; } .sw-invalid { background: #B42318; } .sw-valid { background: #16845D; } .sw-unique { background: #C07A0A; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #EEF2F0; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.right { text-align: right; }
.clip { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.empty { color: var(--muted); padding: 18px 4px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #EDF3F1; color: var(--muted); }
.badge.good { background: #DDF2E9; color: var(--good); } .badge.bad { background: #FCE8E6; color: var(--bad); } .badge.warn { background: #FCF2D7; color: var(--warn); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; min-width: 0; }
.field small { font-weight: 400; color: var(--muted); }
input, select { font: inherit; padding: 8px 10px; border: 1px solid #C5D2CE; border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-actions { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid #C5D2CE; background: #fff; color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0B5F59; color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.amount { width: 90px; } .reference { width: 120px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 5px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); text-decoration: none; font-weight: 600; text-transform: capitalize; }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: #DDF2E9; border-color: #B7E3CF; color: #116449; }
.flash.bad { background: #FCE8E6; border-color: #F1C3BF; color: #9B2C23; }
.flash.warn { background: #FCF2D7; border-color: #EED99B; color: #694800; }
.docs dt { font-weight: 700; margin-top: 12px; } .docs dd { margin: 4px 0 0; }

body.public { background: var(--paper); }
.public-main { max-width: 760px; margin: 0 auto; padding: 56px 20px; }
.public-title { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 18px; }
.public-note { color: var(--muted); margin-top: 16px; }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.role-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--text); text-decoration: none; }
.role-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.role-card h2 { font-size: 16px; margin-bottom: 6px; } .role-card p { color: var(--muted); font-size: 13.5px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.demo-box { margin-top: 16px; padding: 10px 14px; border: 1px dashed #B7CBC5; border-radius: 10px; background: #fff; max-width: 380px; }

@media (max-width: 1180px) { .cols-5, .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px 16px 40px; }
  .cols-4, .cols-5, .cols-6, .role-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .cols-4, .cols-5, .cols-6, .role-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
