/* Dark by default. The toggle in the sidebar (or portal header) switches to light and remembers the choice. */
:root, :root[data-theme="dark"] {
  --bg: #0d0f12; --surface: #14171c; --surface2: #1a1e25; --hover: #1a1e25; --line: #262b33; --line-strong: #353b46;
  --text: #dfe3e8; --heading: #f3f5f7; --muted: #8b94a1;
  --blue: #4cb2ec; --blue-dark: #3a9fd9; --on-blue: #06202f; --blue-soft: rgb(76 178 236 / .14);
  --green: #9bd04a; --green-dark: #88bb3c; --on-green: #14210a; --green-soft: rgb(155 208 74 / .15);
  --red: #f0766a; --red-soft: rgb(240 118 106 / .15); --amber: #e8b53c; --amber-soft: rgb(232 181 60 / .15);
  --grey: #1a1e25; --neutral-soft: rgb(139 148 161 / .16);
  --slate: #dfe3e8; --slate-dark: #f3f5f7; --footer: #0a0c0f;
  --radius: 10px; --radius-sm: 7px; --shadow: none; --logo: url('/images/logo-dark.png');
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --surface: #ffffff; --surface2: #f7f8fa; --hover: #f4f6f8; --line: #e4e7eb; --line-strong: #cdd3da;
  --text: #3b434b; --heading: #14181d; --muted: #6a7480;
  --blue: #0a84c6; --blue-dark: #0873ad; --on-blue: #ffffff; --blue-soft: rgb(10 132 198 / .10);
  --green: #5f8a12; --green-dark: #4f7410; --on-green: #ffffff; --green-soft: rgb(95 138 18 / .12);
  --red: #c4382b; --red-soft: rgb(196 56 43 / .10); --amber: #9a6a00; --amber-soft: rgb(154 106 0 / .12);
  --grey: #f0f2f4; --neutral-soft: rgb(106 116 128 / .13);
  --slate: #3b434b; --slate-dark: #14181d; --footer: #ffffff;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgb(16 24 40 / .04); --logo: url('/images/logo.png');
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; letter-spacing: -.01em; color: var(--heading); }
h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; color: var(--heading); }
.muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; }
strong { color: var(--heading); font-weight: 600; }

.shell { display: flex; min-height: 100vh; }
.side { width: 224px; background: var(--footer); border-right: 1px solid var(--line); flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 20px 20px 14px; }
.side .brand img { width: 100%; max-width: 160px; }
img.logo-l { display: none; } :root[data-theme="light"] img.logo-l { display: inline-block; } :root[data-theme="light"] img.logo-d { display: none; }
.logos { display: block; text-align: center; line-height: 0; } .login .logos { margin-bottom: 24px; }
.brand .logos, .plogo .logos { text-align: left; } .brand a, .plogo { display: block; }
.side nav { padding: 8px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; color: var(--muted); font-weight: 500; border-radius: var(--radius-sm); }
.side nav a:hover { background: var(--hover); text-decoration: none; color: var(--heading); }
.side nav a.on { background: var(--blue-soft); color: var(--blue); }
.side .count { background: var(--blue-soft); color: var(--blue); border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.side .user { padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side .user button, .theme { background: none; border: 0; color: var(--muted); padding: 0; cursor: pointer; font: inherit; } .side .user button:hover, .theme:hover { color: var(--heading); }
.theme { border: 1px solid var(--line-strong); border-radius: 14px; padding: 2px 10px; font-size: 12px; }
.main { flex: 1; min-width: 0; padding: 32px 36px 56px; max-width: 1320px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card.warn { background: var(--amber-soft); border-color: transparent; }
.grid { display: grid; gap: 14px; margin-bottom: 20px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; --tone: var(--blue); }
.stat.green { --tone: var(--green); } .stat.amber { --tone: var(--amber); } .stat.red { --tone: var(--red); }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; color: var(--heading); }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat .l::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); margin-right: 7px; vertical-align: 1px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
th.sort a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
th.sort a:hover { color: var(--heading); text-decoration: none; }
th.sort .arrow { font-size: 9px; opacity: .35; } th.sort.on { color: var(--heading); } th.sort.on .arrow { opacity: 1; color: var(--blue); }
th.right.sort a { flex-direction: row-reverse; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; } tbody tr:hover { background: var(--hover); }
.card table { margin: 0 -10px; width: calc(100% + 20px); }

.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 500; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.badge.paid, .badge.active, .badge.viewed { background: var(--green-soft); color: var(--green); }
.badge.overdue, .badge.suspended { background: var(--red-soft); color: var(--red); }
.badge.pending_approval, .badge.approved, .badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.sent { background: var(--neutral-soft); color: var(--text); }
.badge.void, .badge.cancelled, .badge.inactive, .badge.draft, .badge.written_off { background: var(--neutral-soft); color: var(--muted); }

.btn, button.btn { display: inline-block; background: var(--blue); color: var(--on-blue); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 7px 16px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn.green { background: var(--green); color: var(--on-green); } .btn.green:hover { background: var(--green-dark); }
.btn.outline { background: transparent; color: var(--text); border-color: var(--line-strong); } .btn.outline:hover { background: var(--hover); }
.btn.sm { padding: 3px 11px; font-size: 13px; }
.btn:disabled, button.btn:disabled { opacity: .5; cursor: not-allowed; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters a.pill { padding: 4px 13px; border-radius: 16px; background: transparent; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 500; }
.filters a.pill:hover { color: var(--heading); text-decoration: none; }
.filters a.pill.on { background: var(--heading); color: var(--bg); border-color: var(--heading); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface2); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
input[type=checkbox] { accent-color: var(--blue); }
textarea { width: 100%; min-height: 70px; }
.flash { background: var(--green-soft); color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.flash.err { background: var(--red-soft); }
.error { color: var(--red); font-size: 13px; margin-top: 4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }

.usage { min-width: 120px; } .usage__t { font-size: 12.5px; margin-top: 2px; white-space: nowrap; }
.bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.bar.mid span { background: var(--amber); } .bar.hi span { background: var(--red); } .bar.none span { background: var(--line-strong); }

.ptop { background: var(--footer); border-bottom: 1px solid var(--line); }
.pwrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.ptop .pwrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.plogo img { width: 140px; }
.pnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.pnav a { padding: 7px 14px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.pnav a:hover { background: var(--hover); color: var(--heading); text-decoration: none; }
.pnav a.on { background: var(--blue-soft); color: var(--blue); }
.pout { display: flex; align-items: center; gap: 10px; }
.pmain { padding-top: 28px; padding-bottom: 32px; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: center; }

.wizard { display: grid; grid-template-columns: 220px minmax(0, 640px); gap: 24px; align-items: start; }
.steps { list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--muted); font-weight: 500; border-radius: var(--radius-sm); }
.steps li a:hover { background: var(--hover); text-decoration: none; color: var(--heading); }
.steps li.on a { background: var(--blue-soft); color: var(--blue); }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.steps li.ok .dot { background: var(--green-soft); color: var(--green); }
.field { margin-bottom: 16px; } .field label { display: block; font-weight: 500; color: var(--heading); margin-bottom: 4px; } .field label.check { font-weight: 400; color: var(--text); }
.field input[type=text], .field input[type=email], .field input[type=number], .field input[type=password], .field input[type=search], .field select, .field textarea { width: 100%; }
.help { color: var(--muted); font-size: 13px; margin-top: 3px; }
code { background: var(--surface2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
.banner { background: var(--blue-soft); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 800px) { .wizard { grid-template-columns: 1fr; } }

/* Searchable pick-lists (replaces the browser's tiny native dropdown) */
.combo { position: relative; }
.combo input { width: 100%; padding-right: 30px; }
.combo::after { content: ''; position: absolute; right: 12px; top: 50%; margin-top: -2px; border: 5px solid transparent; border-top-color: var(--muted); pointer-events: none; }
.combo-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow-y: auto; background: var(--surface2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgb(0 0 0 / .35); padding: 4px; }
.combo-list[hidden] { display: none; }
.combo-list div { padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); }
.combo-list div.act, .combo-list div:hover { background: var(--blue-soft); color: var(--heading); }
.combo-list .none { color: var(--muted); cursor: default; } .combo-list .none:hover { background: none; }
.combo-list small { color: var(--muted); margin-left: 6px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.login img { width: 200px; }
.login label { display: block; font-weight: 500; margin: 12px 0 4px; color: var(--heading); } .login input[type=email], .login input[type=password] { width: 100%; }
@media (max-width: 800px) { .shell { flex-direction: column; } .side { width: 100%; height: auto; position: static; } .side nav { flex-direction: row; flex-wrap: wrap; padding: 4px; } .main { padding: 18px 14px; } .grid.two { grid-template-columns: 1fr; } }
.paidbox { background: var(--green-soft); border-color: transparent; }

/* Reports: charts and ranked bars */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hrow { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 92px; gap: 12px; align-items: center; font-size: 13.5px; }
.hrow .hb { background: var(--surface2); border-radius: 6px; height: 10px; overflow: hidden; }
.hrow .hb span { display: block; height: 100%; border-radius: 6px; }
.hrow .hv { text-align: right; color: var(--heading); font-variant-numeric: tabular-nums; }
.hrow .hl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs-note { font-size: 13px; }
.compare-hint { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.badge.poor { background: var(--amber-soft); color: var(--amber); }
.badge.good { background: var(--green-soft); color: var(--green); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; margin: 10px 0 14px; }
.check-grid label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }