/* ==========================================================
   School Manager - design system
   Brand: dark slate + lime (matches STEP SCHOOL identity)
   No external fonts or libraries: everything loads instantly.
   ========================================================== */
:root {
  --slate-950: #121a20;
  --slate-900: #1b252c;
  --slate-800: #26323a;
  --slate-700: #34424b;
  --slate-500: #6b7a85;
  --slate-300: #c3ccd3;
  --slate-200: #dde3e8;
  --slate-100: #edf1f4;
  --slate-50:  #f5f7f9;

  --lime-600: #6fa012;
  --lime-500: #8cc63f;
  --lime-400: #a4dd2f;
  --lime-100: #eef8d9;

  --red-600: #c43c3c;
  --red-100: #fde8e8;
  --amber-600: #b7791f;
  --amber-100: #fdf3dc;
  --green-600: #1f8a4c;
  --green-100: #e2f5ea;
  --blue-600: #2a78d6;
  --blue-100: #e3effc;

  --bg: var(--slate-50);
  --surface: #ffffff;
  --text: #182127;
  --text-2: #4e5c66;
  --muted: #7b8892;
  --line: var(--slate-200);
  --accent: var(--lime-400);
  --accent-ink: #132003;

  --series-1: #2a78d6;
  --series-2: #eb6834;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 1px 3px rgba(16, 24, 32, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 32, .14);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --topbar-h: 60px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- App shell ---------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; min-height: 100vh; }

.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: linear-gradient(180deg, var(--slate-800), var(--slate-900));
  color: #fff;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--sidebar-w) - 16px); min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 17px; letter-spacing: -.5px;
}
.brand-text { min-width: 0; }
.brand-text b { display: block; font-size: 14px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { display: block; font-size: 11.5px; color: var(--slate-300); white-space: nowrap; }

.modules { display: flex; gap: 4px; }
.modules a {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px;
  color: var(--slate-300); font-weight: 600; font-size: 13px;
}
.modules a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.modules a.active { background: var(--accent); color: var(--accent-ink); }

.topbar .spacer { flex: 1; }
.global-search { position: relative; width: 300px; max-width: 32vw; }
.global-search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border-radius: 8px; border: 1px solid var(--slate-700);
  background: var(--slate-950); color: #fff; outline: none;
}
.global-search input::placeholder { color: var(--slate-500); }
.global-search input:focus { border-color: var(--accent); }
.global-search svg { position: absolute; left: 10px; top: 9px; color: var(--slate-500); }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: 999px; cursor: pointer; }
.user-chip:hover { background: rgba(255, 255, 255, .08); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--slate-700); font-weight: 700; font-size: 12px; }
.user-chip small { display: block; color: var(--slate-300); font-size: 11px; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--slate-900);
  color: var(--slate-300);
  padding: 12px 10px 24px;
  overflow-y: auto;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
}
.nav-group { margin-bottom: 2px; }
.nav-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: #e8edf0; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-align: left;
}
.nav-head:hover { background: var(--slate-800); }
.nav-head .chev { margin-left: auto; width: 15px; height: 15px; transition: transform .15s; color: var(--slate-500); }
.nav-group.open .nav-head .chev { transform: rotate(180deg); }
.nav-items { display: none; padding: 2px 0 6px 18px; }
.nav-group.open .nav-items { display: block; }
.nav-items a {
  display: block; padding: 7px 10px 7px 18px; margin: 1px 0;
  color: var(--slate-300); font-size: 13px; border-radius: 6px;
  border-left: 2px solid var(--slate-700);
}
.nav-items a:hover { color: #fff; background: var(--slate-800); text-decoration: none; }
.nav-items a.active { color: var(--accent); border-left-color: var(--accent); background: rgba(164, 221, 47, .08); font-weight: 600; }
.nav-single { margin-bottom: 6px; }
.nav-single.active { background: rgba(164, 221, 47, .12); color: var(--accent); }

/* ---------------- Page ---------------- */
.main { min-width: 0; }
.page { padding: 22px 26px 40px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 700; }
.page-head p { margin: 3px 0 0; color: var(--muted); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }

/* ---------------- Stat tiles ---------------- */
.stat { padding: 16px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.stat .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.stat .value { font-size: 25px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 3px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.ico.lime { background: var(--lime-100); color: var(--lime-600); }
.ico.blue { background: var(--blue-100); color: var(--blue-600); }
.ico.red { background: var(--red-100); color: var(--red-600); }
.ico.amber { background: var(--amber-100); color: var(--amber-600); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--slate-900); background: var(--slate-900); color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--slate-700); border-color: var(--slate-700); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--lime-500); color: var(--accent-ink); }
.btn.primary:hover { background: var(--lime-500); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--slate-100); }
.btn.danger { background: var(--surface); color: var(--red-600); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--red-100); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--slate-300); border-radius: 8px;
  background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--lime-500); box-shadow: 0 0 0 3px rgba(140, 198, 63, .22);
}
.field input.big { height: 48px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }

.seg { display: inline-flex; padding: 3px; background: var(--slate-100); border-radius: 9px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--slate-50); border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { width: 170px; }
.filters .field.wide { width: 260px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-2); font-weight: 700; padding: 10px 12px;
  background: var(--slate-50); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; white-space: nowrap;
}
table.data th.num { text-align: right; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
table.data tbody tr:hover td { background: #fafcf5; }
table.data tfoot td { font-weight: 700; background: var(--slate-50); border-top: 2px solid var(--line); border-bottom: 0; }
table.data .name { font-weight: 600; white-space: nowrap; }
table.data .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.ref { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

.amt-due { color: var(--red-600); font-weight: 700; }
.amt-clear { color: var(--green-600); font-weight: 600; }
.amt-adv { color: var(--blue-600); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--green-100); color: var(--green-600); }
.badge.due { background: var(--red-100); color: var(--red-600); }
.badge.warn { background: var(--amber-100); color: var(--amber-600); }
.badge.info { background: var(--blue-100); color: var(--blue-600); }
.badge.neutral { background: var(--slate-100); color: var(--text-2); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------------- Student picker / profile ---------------- */
.picker { position: relative; }
.picker input { padding-left: 38px !important; height: 46px !important; font-size: 15px; }
.picker svg.i { position: absolute; left: 12px; top: 14px; color: var(--muted); z-index: 1; }
.picker-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  max-height: 340px; overflow-y: auto; padding: 4px;
}
.picker-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.picker-item:hover, .picker-item.active { background: var(--lime-100); }
.picker-item .who { flex: 1; min-width: 0; }
.picker-item .who b { display: block; }
.picker-item .who span { font-size: 12px; color: var(--muted); }

.profile { display: flex; gap: 14px; align-items: center; }
.profile .avatar-lg { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: var(--slate-800); color: var(--accent); font-weight: 800; font-size: 19px; flex: none; }
.profile h3 { font-size: 17px; }
.profile .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); font-size: 12.5px; margin-top: 3px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.kv > div { background: #fff; padding: 12px 16px; }
.kv span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kv b { font-size: 17px; font-variant-numeric: tabular-nums; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.summary-strip > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.summary-strip b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------------- Chart ---------------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--slate-100); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { transition: opacity .12s; }
.chart .bar-group:hover .bar { opacity: .85; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--slate-900); color: #fff; border-radius: 8px; padding: 8px 10px;
  font-size: 12px; box-shadow: var(--shadow-lg); min-width: 150px; transform: translate(-50%, -100%);
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip div { display: flex; justify-content: space-between; gap: 14px; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* ---------------- Alerts / toast ---------------- */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.ok { background: var(--green-100); color: #145c33; }
.alert.error { background: var(--red-100); color: #8f2525; }
.alert.info { background: var(--blue-100); color: #1c4f8f; }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--slate-900); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); border-left: 4px solid var(--accent); font-weight: 600; }
.toast.error { border-left-color: #ff6b6b; }

/* ---------------- Login ---------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  background: radial-gradient(circle at 20% 20%, rgba(164, 221, 47, .18), transparent 45%),
              linear-gradient(160deg, var(--slate-800), var(--slate-950));
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-art h2 { font-size: 34px; line-height: 1.15; max-width: 440px; letter-spacing: -.5px; }
.login-art h2 em { color: var(--accent); font-style: normal; }
.login-art ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; color: var(--slate-300); }
.login-art li { display: flex; gap: 10px; align-items: center; }
.login-art li svg { color: var(--accent); }
.login-form { display: grid; place-items: center; padding: 32px 16px; background: #fff; }
.login-box { width: 100%; max-width: 360px; }
.login-box h1 { font-size: 24px; margin-bottom: 4px; }
.login-box p { color: var(--muted); margin: 0 0 24px; }
.login-box .field { margin-bottom: 14px; }
.login-box .secure { margin-top: 18px; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }


/* ---------------- App extras ---------------- */
.boot { display: grid; place-items: center; height: 100vh; grid-column: 1 / -1; color: var(--muted); }
.view { min-height: 100%; }
.brand, .brand:hover { color: #fff; text-decoration: none; }
.user-menu { position: relative; }
.user-chip { border: 0; background: none; color: #fff; text-align: left; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px;
}
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: 0; background: none;
  border-radius: 7px; color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--slate-100); text-decoration: none; }
.global-search .picker input { height: 36px !important; font-size: 13.5px; border-color: var(--slate-700); background: var(--slate-950); color: #fff; }
.global-search .picker input:focus { box-shadow: none; border-color: var(--accent); }
.global-search .picker svg.i { top: 9px; left: 10px; }
.global-search .picker-list { color: var(--text); min-width: 380px; right: 0; left: auto; }
.nav-scrim { display: none; }

.hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; min-height: 38px; }
.check input { width: 16px; height: 16px; accent-color: var(--lime-600); }
.input.sm, .field .input.sm { height: 32px; padding: 0 9px; font-size: 13px; }
td .input.sm { min-width: 70px; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-grid.cols-3-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.card.narrow { max-width: 760px; }
.net-fee { height: 38px; display: flex; align-items: center; font-size: 17px; font-weight: 700; color: var(--lime-600); }
.kv-inline { text-align: right; }
.kv-inline span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.kv-inline b { font-size: 17px; }
.extra-row { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; margin: 6px 0; max-width: 560px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; cursor: pointer;
  border: 2px dashed var(--slate-300); border-radius: var(--radius); background: var(--slate-50); text-align: center;
}
.dropzone:hover { border-color: var(--lime-500); background: var(--lime-100); }
.dropzone svg.i { width: 26px; height: 26px; color: var(--lime-600); }

/* receipt: adjust against invoices */
.adjust-table tr.row-on td { background: #f6fbea; }
.adjust-table input.over { border-color: var(--red-600); background: var(--red-100); }
.adjust-table input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--lime-600); cursor: pointer; }
.adjust-table tfoot td { font-size: 13px; }

/* class promotion: fee increase bar */
.inc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; background: var(--lime-100); border-bottom: 1px solid var(--line); }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
th .check { min-height: 0; font-size: 11.5px; color: inherit; }

/* expenses */
.cat-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.cat-grid button {
  border: 1px solid var(--slate-300); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.cat-grid button:hover { border-color: var(--lime-500); }
.cat-grid button.on { background: var(--accent); border-color: var(--lime-500); color: var(--accent-ink); }
.filters .or { align-self: center; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; padding-top: 18px; }

/* monthly cash report */
.cash-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-bottom: 1px solid var(--line); }
.cash-flow .cf { padding: 14px 16px; border-right: 1px solid var(--line); position: relative; }
.cash-flow .cf:last-child { border-right: 0; }
.cash-flow .cf span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.cash-flow .cf b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; margin: 2px 0; }
.cash-flow .cf small { color: var(--muted); font-size: 11.5px; }
.cash-flow .cf.plus b::before { content: "+ "; color: var(--green-600); }
.cash-flow .cf.minus b::before { content: "− "; color: var(--red-600); }
.cash-flow .cf.total { background: var(--lime-100); }
.close-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; border-bottom: 1px solid var(--line); background: var(--slate-50); }
.close-bar > span:first-child { display: block; flex: 1; min-width: 240px; }
.close-bar > span:first-child svg.i { vertical-align: -4px; margin-right: 4px; }

/* daily & monthly detailed reports */
.report-date { padding: 12px 16px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.mode-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.mode-strip > div { padding: 10px 16px; border-right: 1px solid var(--line); }
.mode-strip > div:last-child { border-right: 0; }
.mode-strip span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.mode-strip b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.mode-strip small { color: var(--muted); font-size: 11.5px; }
.mode-strip .hand { background: var(--amber-100); }
.section-head { border-top: 1px solid var(--line); background: var(--slate-50); }
.section-head b { font-variant-numeric: tabular-nums; }
.day-block { border-top: 2px solid var(--slate-300); break-inside: avoid; page-break-inside: avoid; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 10px 16px; background: var(--lime-100); font-size: 13.5px; }
.day-head span { color: var(--text-2); }
td.moved { color: var(--text-2); font-style: italic; }
.ledger-table th .sub { text-transform: none; letter-spacing: 0; font-weight: 600; }
.ledger-table tr.day-start td { border-top: 1px solid var(--slate-300); }
.ledger-table tr.opening-row td { background: var(--lime-100); }
.ledger-table td:last-child { font-weight: 600; }
.signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 48px 24px 20px; border-top: 1px solid var(--line); }
.signatures div { border-top: 1px solid var(--text); padding-top: 6px; text-align: center; font-size: 12.5px; color: var(--text-2); }

/* users & permissions */
.perm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 4px; margin-bottom: 8px; }
.perm-group > span { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 2px; }
.perm-group.careful { border-color: #f0c4c4; background: #fff8f8; }
.perm-group.careful > span { color: var(--red-600); }
.check.perm { min-height: 30px; font-weight: 500; color: var(--text); align-items: flex-start; padding: 4px 0; }
.check.perm input { margin-top: 2px; flex: none; }
.link-btn { border: 0; background: none; color: var(--blue-600); cursor: pointer; padding: 0; font-size: 12.5px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
input[type=date][readonly] { background: var(--slate-50); color: var(--text-2); cursor: not-allowed; }

/* modal */
.modal-back { position: fixed; inset: 0; z-index: 300; background: rgba(18, 26, 32, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 440px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-body { padding: 22px 22px 18px; font-size: 14.5px; line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; background: var(--slate-50); border-top: 1px solid var(--line); }
.btn.danger-solid { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn.danger-solid:hover { background: #a83232; }

/* statements & journal */
.statement table.data td { padding: 8px 14px; }
tr.sec td { background: var(--slate-50); font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .5px; color: var(--text-2); }
tr.sub-total td { font-weight: 700; border-top: 1px solid var(--slate-300); }
tr.grand-total td { font-weight: 800; font-size: 15px; background: var(--lime-100); border-top: 2px solid var(--lime-500); }
.indent { padding-left: 18px !important; display: inline-block; }
td.indent { display: table-cell; padding-left: 28px !important; }
table.journal tr.v-first td { border-top: 1px solid var(--slate-200); }
table.journal td { border-bottom: 0; padding-top: 5px; padding-bottom: 5px; }
table.compare td, table.compare th { padding: 7px 8px; font-size: 12.5px; }
.report-grid > div { border-right: 1px solid var(--line); min-width: 0; }
.report-grid > div:last-child { border-right: 0; }
.statement-grid { gap: 0; }
.statement-grid > div:first-child { border-right: 1px solid var(--line); }

/* ---------------- Fee voucher & receipt (screen + print) ---------------- */
.voucher-stack { display: flex; flex-direction: column; gap: 18px; }
.voucher-sheet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #fff; border: 1px solid var(--line); }
.voucher {
  display: flex; flex-direction: column; padding: 10px 12px; border-right: 1px dashed #777;
  font-size: 11.5px; line-height: 1.35; color: #111; background: #fff; min-width: 0;
}
.voucher:last-child { border-right: 0; }
.voucher .v-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 6px; }
.voucher .v-head b { display: block; font-size: 14px; letter-spacing: .3px; text-transform: uppercase; }
.voucher .v-head span { display: block; font-size: 11px; font-weight: 600; }
.voucher .v-head small { display: block; font-size: 10px; color: #333; }
.voucher .v-head span.copy, .voucher .copy { display: inline-block; margin-top: 5px; padding: 1px 10px; border: 1px solid #111; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.voucher .v-bank { text-align: center; font-size: 10.5px; border-bottom: 1px solid #999; padding-bottom: 5px; margin-bottom: 6px; }
.voucher dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0 0 6px; }
.voucher dt { color: #444; }
.voucher dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.voucher table { width: 100%; border-collapse: collapse; margin: 4px 0; }
.voucher th, .voucher td { border: 1px solid #333; padding: 3px 6px; }
.voucher th { background: #e9e9e9; text-align: left; font-size: 10.5px; }
.voucher th.num { text-align: right; }
.voucher .tot td { font-weight: 700; }
.voucher .grand td { font-weight: 800; font-size: 12.5px; background: #ededed; }
.voucher .note { font-size: 10px; color: #333; margin-top: 5px; }
.voucher .v-bankuse { font-size: 10px; margin-top: 8px; padding-top: 4px; border-top: 1px solid #999; }
.voucher .sign { display: flex; justify-content: space-between; margin-top: 22px; font-size: 10px; }
.voucher .sign span { border-top: 1px solid #111; padding-top: 2px; min-width: 75px; text-align: center; }
.voucher .v-foot { display: flex; justify-content: space-between; font-size: 9px; color: #444; margin-top: 8px; padding-top: 3px; border-top: 1px solid #ccc; }
.voucher .copy-bar { margin-top: auto; background: #111; color: #fff; text-align: center; font-weight: 700; font-size: 11px; padding: 3px; letter-spacing: .4px;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.voucher .v-foot + .copy-bar { margin-top: 6px; }

/* receipt: single student copy, half an A4 page */
.receipt-sheet { max-width: 720px; }
.receipt-sheet .voucher { border: 1px solid var(--line); padding: 14px 18px; font-size: 12px; }
.receipt-sheet .r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.cut-line { display: none; }
.print-head { text-align: center; margin-bottom: 12px; }
.print-head b { font-size: 16px; }
.print-head h2 { font-size: 15px; margin-top: 4px; }

/* ---------------- Responsive ---------------- */
@media screen and (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .global-search { display: none; }
}
@media screen and (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .menu-toggle { display: block; }
  .brand { width: auto; }
  .modules { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: auto; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35; background: rgba(18, 26, 32, .4); }
  .form-grid.cols-3-form, .form-grid.cols-4-form { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .report-grid > div, .statement-grid > div:first-child { border-right: 0; }
  .receipt-sheet .r-grid { grid-template-columns: 1fr; }
  .extra-row { grid-template-columns: 1fr 110px auto; }
  .cash-flow { grid-template-columns: 1fr 1fr; }
  .cash-flow .cf { border-bottom: 1px solid var(--line); }
  .filters .or { display: none; }
  .mode-strip { grid-template-columns: 1fr 1fr; }
  .mode-strip > div { border-bottom: 1px solid var(--line); }
  .signatures { grid-template-columns: 1fr; gap: 36px; }
  .sidebar .mobile-modules { display: flex !important; }
  .page { padding: 16px; }
  .cols-3, .cols-2, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv, .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .user-chip .who { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .voucher-sheet { grid-template-columns: 1fr; }
  .voucher { border-right: 0; border-bottom: 1px dashed #9aa5ad; }
}
@media screen and (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 20px; }
  .filters .field, .filters .field.wide { width: 100%; }
}
.mobile-modules { display: none; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.mobile-modules a { padding: 6px 12px; border-radius: 999px; background: var(--slate-800); color: var(--slate-300); font-weight: 600; font-size: 12.5px; }
.mobile-modules a.active { background: var(--accent); color: var(--accent-ink); }

/* ---------------- Print ---------------- */
@media print {
  @page { margin: 10mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .sidebar, .no-print, .toast-host, .preview-bar { display: none !important; }
  .app { display: block; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #999; }
  table.data th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
  .filters, .row-actions, .seg { display: none !important; }
  .table-wrap { overflow: visible !important; max-height: none !important; }
  table.data th { position: static; }
  .card { border: 0; }
  /* Fee voucher: one A4 landscape page per student, three copies side by side. */
  .voucher-stack { gap: 0; }
  .voucher-sheet {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important; border: 0;
    height: 194mm; overflow: hidden; break-inside: avoid; page-break-inside: avoid;
    break-after: page; page-break-after: always;
  }
  .voucher-sheet:last-child { break-after: auto; page-break-after: auto; }
  .voucher-sheet .voucher { font-size: 9.5pt; padding: 0 4mm; border-right: 1px dashed #555 !important; border-bottom: 0 !important; }
  .voucher-sheet .voucher:last-child { border-right: 0 !important; }
  /* Receipt: student copy in the top half of an A4 page. */
  .receipt-sheet { max-width: none; }
  .receipt-sheet .voucher { height: 132mm; overflow: hidden; border: 1px solid #333; padding: 4mm 6mm; font-size: 10pt; }
  .cut-line { display: block; text-align: center; font-size: 9pt; color: #666; border-top: 1px dashed #666; margin-top: 3mm; padding-top: 1mm; }
  .grid.cols-3, .grid.cols-2 { display: block; }
  a { color: inherit; }
}
.print-only { display: none; }
