:root {
  --ink: #14253d; --ink-2: #203b5d; --paper: #f2f6fb; --card: #ffffff; --line: #dbe4ef;
  --text: #172a43; --muted: #64758d; --accent: #08a6c7; --accent-soft: #e2f7fb;
  --good: #19845b; --bad: #cc4355; --warn: #a66b18; --violet: #7462df;
  --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: #edf3ef; 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: #c8d8eb; 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), #8bdd74, var(--violet), var(--accent)); }
.nav-title { font-size: 12px; color: #91a8c5; padding: 16px 10px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 11px; color: #c8d8eb; 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 #2d4566; }
.who { display: flex; flex-direction: column; padding: 4px 10px 10px; color: #fff; }
.who span { color: #9bb0c9; 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: #08a6c7; } .sw-invalid { background: #cc4355; } .sw-valid { background: #19845b; } .sw-unique { background: #7462df; }

.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 #eef1f7; 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: #edf3ef; color: var(--muted); }
.badge.good { background: #e1f4ed; color: var(--good); } .badge.bad { background: #fde8ec; color: var(--bad); } .badge.warn { background: #fdf1da; 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 #cbdad1; 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 #cbdad1; 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: #0786a2; 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: #e1f4ed; border-color: #b5dfcf; color: #12634f; }
.flash.bad { background: #fde8ec; border-color: #f5c0ca; color: #a3233a; }
.flash.warn { background: #fdf1da; border-color: #f0d9a4; color: #7b4f08; }
.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 #b6cbc1; 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; } }
