/* Lekhaa Console — Ink tokens, the same palette as the app (theme/Color.kt, Direction A). */

@font-face { font-family: Manrope; src: url("fonts/manrope_regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Manrope; src: url("fonts/manrope_semibold.ttf") format("truetype"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: Manrope; src: url("fonts/manrope_bold.ttf") format("truetype"); font-weight: 700 900; font-display: swap; }

:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --line: #E3E8EF;
  --line-soft: #EEF1F5;
  --field: #C9D3DF;
  --text: #0E1726;
  --muted: #4A5A6E;
  --primary: #001A33;
  --on-primary: #FFFFFF;
  --primary-soft: #DCE6F2;
  --brand-panel: #EEF3F8;
  --ok-bg: #DDF1E6; --ok: #0B5A39;
  --warn-bg: #FFF3DC; --warn: #5C3A00; --warn-line: #C9A25C;
  --bad-bg: #FBE3E1; --bad: #8A1C14;
  --plum-bg: #E9E1F1; --plum: #4A3560;
  --grey-bg: #ECEFF3; --grey: #3D4A5C;
  --scrim: rgba(14, 23, 38, 0.45);
  --shadow: 0 20px 60px rgba(0, 26, 51, 0.25);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1420;
    --surface: #121D2B;
    --surface-2: #162233;
    --line: #243447;
    --line-soft: #1C2A3B;
    --field: #34485F;
    --text: #E6EDF5;
    --muted: #9AA9BA;
    --primary: #A9C7EC;
    --on-primary: #001A33;
    --primary-soft: #16324F;
    --brand-panel: #101B29;
    --ok-bg: #12352A; --ok: #8FD3B4;
    --warn-bg: #3A2C10; --warn: #F2C46B; --warn-line: #6B5223;
    --bad-bg: #3D1715; --bad: #F2A39C;
    --plum-bg: #2E2440; --plum: #CDB8E6;
    --grey-bg: #222E3D; --grey: #B7C3D1;
    --scrim: rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); font-weight: 700; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; color: var(--primary); }
h2 { font-size: 16px; font-weight: 800; }
p { margin: 0; }
.boot { padding: 48px 24px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 800; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 4px; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ── Buttons & fields ─────────────────────────────────────────────────────────────────────────── */
.btn {
  height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--field);
  background: var(--surface); font-weight: 700; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text);
  white-space: nowrap;
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 800; }
.btn.danger { background: var(--bad); color: #FFFFFF; border-color: var(--bad); font-weight: 800; }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.link { border: 0; background: transparent; color: var(--primary); padding: 0 4px; text-decoration: underline; height: 40px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.warn { border-color: var(--warn-line); color: var(--warn); }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea {
  height: 48px; border: 1px solid var(--field); border-radius: 12px; padding: 0 14px;
  background: var(--surface); font-size: 16px; min-width: 0; width: 100%;
}
.field textarea { height: auto; min-height: 84px; padding: 10px 14px; resize: vertical; }
.field input.code { border: 2px solid var(--primary); font-size: 22px; font-weight: 800; letter-spacing: 6px; text-align: center; }
.field .hint { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--bad); font-weight: 700; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.money-input { display: flex; align-items: center; gap: 6px; height: 54px; border: 2px solid var(--primary); border-radius: 12px; padding: 0 14px; background: var(--surface); }
.money-input span { font-size: 20px; font-weight: 800; }
.money-input input { border: 0; outline: none; flex: 1; min-width: 0; font-size: 20px; font-weight: 800; background: transparent; height: 100%; padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--field); border-radius: 12px; overflow: hidden; }
.segmented button { height: 44px; border: 0; border-left: 1px solid var(--field); background: var(--surface); font-weight: 700; cursor: pointer; font-size: 14px; }
.segmented button:first-child { border-left: 0; }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 800; }

.form-error { background: var(--bad-bg); color: var(--bad); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 700; }
.notice { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }

/* ── Chips ─────────────────────────────────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.ACTIVE { background: var(--ok-bg); color: var(--ok); }
.chip.GRACE { background: var(--warn-bg); color: var(--warn); }
.chip.READ_ONLY { background: var(--bad-bg); color: var(--bad); }
.chip.SUSPENDED { background: var(--plum-bg); color: var(--plum); }
.chip.UNBILLED, .chip.CANCELLED, .chip.VOID { background: var(--grey-bg); color: var(--grey); }

.filters { display: flex; gap: 8px; overflow-x: auto; white-space: nowrap; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); font-size: 13px; font-weight: 700; cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

.tabs { display: flex; gap: 6px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.tabs button { flex: none; height: 38px; padding: 0 16px; border-radius: 19px; border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 800; }

/* ── Cards, tables, lists ─────────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 14px 16px; }
.card.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.card.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.card.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.tile.warn .label, .tile.warn .value, .tile.warn .sub { color: var(--warn); }
.tile .value { font-size: 24px; font-weight: 800; }
.tile .sub { font-size: 13px; color: var(--muted); }
.statusbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--line-soft); }
.statusbar span { display: block; }
.statusbar .ACTIVE { background: #0F6B45; } .statusbar .GRACE { background: #E0A526; } .statusbar .READ_ONLY { background: #B3261E; }
.statusbar .UNBILLED, .statusbar .CANCELLED { background: #9AA6B5; } .statusbar .SUSPENDED { background: #7A5E9C; }

.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line-soft); }
.list-row { display: flex; gap: 12px; padding: 12px 16px; align-items: center; justify-content: space-between; color: inherit; text-decoration: none; font-weight: inherit; }
a.list-row:hover { background: var(--surface-2); }
.list-row .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row .side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: right; }
.list-row.voided .title { text-decoration: line-through; color: var(--muted); }
.list-row.alert { background: var(--warn-bg); color: var(--warn); }
.title { font-weight: 700; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 10px 8px; background: var(--surface-2); white-space: nowrap; }
table.data td { padding: 12px 8px; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.data th:first-child, table.data td:first-child { padding-left: 16px; }
table.data th:last-child, table.data td:last-child { padding-right: 16px; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
th.sortable button { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; cursor: pointer; }

.school-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; color: inherit; text-decoration: none; font-weight: inherit; }
.school-card .name { font-size: 16px; font-weight: 800; }
.wide-only { display: none; }
@media (min-width: 840px) { .wide-only { display: block; } .narrow-only { display: none; } }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.amount-due { color: var(--warn); }
.amount-bad { color: var(--bad); }
.amount-adv { color: var(--ok); }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; font: 700 15px/1.6 ui-monospace, Menlo, monospace; }
.qr { width: 168px; height: 168px; background: #FFFFFF; border-radius: 12px; padding: 8px; border: 1px solid var(--line); flex: none; }
.keybox { font: 700 14px/1.5 ui-monospace, Menlo, monospace; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }

/* ── Shell: bottom bar < 1000px, sidebar ≥ 1000px ─────────────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.sidebar { display: none; }
.content { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
}
.bottombar a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; min-height: 52px; }
.bottombar a .pill { width: 56px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.bottombar a[aria-current="page"] { color: var(--primary); font-weight: 800; }
.bottombar a[aria-current="page"] .pill { background: var(--primary-soft); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--muted); }
.avatar { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 18px; cursor: pointer; }
.brand-badge { width: 36px; height: 36px; border-radius: 10px; background: #001A33; color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 19px; flex: none; }

@media (min-width: 1000px) {
  .shell { flex-direction: row; }
  .bottombar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; width: 240px; flex: none; background: var(--surface);
    border-right: 1px solid var(--line); padding: 24px 14px; position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 800; color: var(--primary); }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; height: 44px; border-radius: 12px; padding: 0 14px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
  .sidebar nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 800; }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar .account { margin-top: auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
  .content { padding: 28px 32px 40px; }
  .phone-only { display: none !important; }
}

/* ── Two-column detail on wide screens ────────────────────────────────────────────────────────── */
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > .main-col { flex: 2 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.cols > .side-col { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* ── Sign-in ──────────────────────────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; background: var(--surface); }
.auth .brand-panel { flex: 1 1 420px; background: var(--brand-panel); padding: 56px 32px 32px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.auth .brand-panel .big-badge { width: 60px; height: 60px; border-radius: 18px; background: #001A33; color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 800; }
.auth .brand-panel h1 { font-size: 32px; }
.auth .form-panel { flex: 1 1 420px; padding: 32px 24px 48px; display: flex; align-items: center; justify-content: center; }
.auth form, .auth .form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 860px) {
  .auth .brand-panel { flex-basis: 100%; padding: 48px 24px 8px; background: var(--surface); }
  .auth .brand-panel p { font-size: 15px; }
  .auth .form-panel { align-items: flex-start; padding-top: 16px; }
}

/* ── Modal: bottom sheet on phones, dialog from 600px ─────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
}
.sheet .grabber { align-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--field); flex: none; }
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sheet .sheet-head h2 { font-size: 20px; color: var(--primary); }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; }
.sheet .actions .btn.primary, .sheet .actions .btn.danger { flex: 1; }
@media (min-width: 600px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { max-width: 480px; border-radius: 20px; padding: 22px 24px; box-shadow: var(--shadow); }
  .sheet .grabber { display: none; }
  .sheet .actions .btn.primary, .sheet .actions .btn.danger { flex: none; }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  background: #0E1726; color: #FFFFFF; border-radius: 12px; padding: 12px 16px; display: flex; gap: 14px; align-items: center;
  max-width: calc(100% - 32px); box-shadow: var(--shadow); font-size: 14px; font-weight: 600;
}
.toast button { background: transparent; border: 0; color: #A9C7EC; font-weight: 800; cursor: pointer; height: 32px; }
@media (min-width: 1000px) { .toast { bottom: 28px; } }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu .menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 230px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column;
}
.menu .menu-items button { height: 44px; border: 0; background: transparent; text-align: left; padding: 0 12px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.menu .menu-items button:hover { background: var(--surface-2); }
.menu .menu-items button.danger { color: var(--bad); }

.searchbox { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-width: 220px; color: var(--muted); }
.searchbox input { border: 0; outline: none; background: transparent; height: 46px; font-size: 16px; flex: 1; min-width: 0; color: var(--text); }
.row select, .page-head select { height: 44px; border: 1px solid var(--field); border-radius: 12px; padding: 0 10px; background: var(--surface); font-weight: 700; }
a.card, a.tile { color: inherit; text-decoration: none; font-weight: inherit; }

/* ── School detail: tabs on phones; on wide screens every panel shows, in two columns ─────────── */
@media (max-width: 999px) { .tabbed .tab-panel:not(.active) { display: none; } }
@media (min-width: 1000px) { .tab-bar { display: none; } }
.big-money { font-size: 28px; }
.pad-x { padding: 0 16px 14px; }
.wide-label { display: none; }
@media (min-width: 600px) { .wide-label { display: inline; } }
.menu > summary.btn { width: auto; }
.list-row > input[type="checkbox"], .list-row > label > input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
label.list-row { cursor: pointer; }
.list-row .title { overflow-wrap: anywhere; }
.page-head h1 { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
@media (max-width: 519px) { .tile.span-phone { grid-column: 1 / -1; } }
table.data th.right, table.data td.right { text-align: right; }
