:root {
  --ink: #141B24; --muted: #5C6876; --line: #DCE2E8; --bg: #F1F3F6; --card: #FFFFFF; --soft: #F6F8FA;
  --accent: #2F4FD1; --accent-soft: #E6EBFD; --good: #1D8A4E; --good-soft: #DDF3E6;
  --warn: #A86A00; --warn-soft: #FBEFD5; --bad: #B83227; --bad-soft: #FBE3E0; --head: #111A2E;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); background: var(--bg);
  box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #E5EBF2; --muted: #96A3B2; --line: #2B3644; --bg: #0E131A; --card: #161E28; --soft: #1C2531;
    --accent: #8FA6FF; --accent-soft: #232E52; --good: #5CCB8C; --good-soft: #15352A; --warn: #E8B44F; --warn-soft: #3A2D12;
    --bad: #F08A80; --bad-soft: #3E1D1A; --head: #0A0F18; }
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.tab-body h3 { margin-bottom: 8px; font-size: 1rem; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.btn { border: 0; border-radius: 8px; padding: 9px 14px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn.link { background: none; color: var(--accent); padding: 4px 6px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 38px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88em; }

/* login */
.login { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login h1 { font-size: 1.35rem; margin-bottom: 4px; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; margin-bottom: 12px; }

/* layout */
.top { background: var(--head); color: #E9EEF7; }
.top-in { max-width: 1280px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top h1 { font-size: 1.1rem; }
.top .who { margin-left: auto; font-size: .9rem; opacity: .85; }
.top .btn.ghost { color: #E9EEF7; border-color: #34405A; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 20px 60px; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile b { display: block; font-size: 1.6rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: .83rem; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--soft); }
tr.client-row { cursor: pointer; }
tr.client-row:hover td { background: var(--soft); }
tr.client-row.on td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--good); background: var(--good-soft); }
.pill.stale { color: var(--warn); background: var(--warn-soft); }
.pill.waiting { color: var(--muted); background: var(--soft); }
.pill.paused { color: var(--bad); background: var(--bad-soft); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 6px; border: 1px solid var(--line); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* detail */
.detail { margin-top: 18px; }
.detail-head { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.detail-head img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: var(--soft); }
.detail-head h2 { font-size: 1.2rem; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stats .tile b { font-size: 1.35rem; }
.list { list-style: none; padding: 0; margin: 8px 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.note { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: .9rem; margin: 12px 0; }
.note.warn { background: var(--warn-soft); border-color: transparent; }
.secret { background: var(--soft); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; word-break: break-all; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .bar { fill: var(--accent); }
.chart .grid { stroke: var(--line); }
dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .9rem; }
dl.kv dd { margin: 0; word-break: break-word; }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 20, .5); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); border-radius: 14px; padding: 20px; }
.modal h2 { margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; }

@media (max-width: 700px) {
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .toolbar input, .toolbar select { min-width: 0; width: 100%; }
}

.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 5px; vertical-align: middle; letter-spacing: .02em; }
.tag.cloud { color: var(--accent); background: var(--accent-soft); }
.tag.onprem { color: #7A4B00; background: #FBE7C2; }
@media (prefers-color-scheme: dark) { .tag.onprem { color: #F3C77A; background: #3B2B10; } }
.detail-head h2 .tag { margin-left: 6px; }
fieldset.edition-pick { border: 0; padding: 0; }
fieldset.edition-pick label { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-weight: 400; }
[hidden] { display: none !important; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }

/* new school wizard */
.modal.wiz { max-width: 640px; }
.wiz-steps { padding-left: 20px; } .wiz-steps li { margin: 0 0 12px; line-height: 1.5; }
.copy-line { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.copy-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: var(--soft); padding: 6px 8px; border-radius: 8px; font-size: 12.5px; }
.copy-line input { flex: 1; min-width: 180px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
a.btn.disabled { pointer-events: none; opacity: .5; }
.checklist { list-style: none; padding: 0; margin: 14px 0 0; }
.checklist li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.checklist .mark { font-weight: 800; width: 18px; flex: none; }
.checklist li.ok .mark { color: #1e8e3e; } .checklist li.no .mark { color: #c5221f; }
.checklist .btn { margin-top: 6px; }
.wiz-ready { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--soft); }
.okc { color: #1e8e3e; font-weight: 700; } .err { color: #c5221f; font-weight: 600; }

.checklist.progress li { padding: 5px 0; } .checklist.progress li.done .mark { color: #1e8e3e; }
.checklist.progress li.failed .mark { color: #c5221f; } .checklist.progress li.running .mark { color: #b06000; }
.checklist.progress li.waiting { color: var(--muted, #6b7280); }
#setupbox h3 { margin: 0 0 8px; }

.feat { margin: 8px 0; } .feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; margin-top: 8px; font-size: 13.5px; }
#deploybox .row { gap: 8px; flex-wrap: wrap; } #alink { margin: 6px 0; overflow-wrap: anywhere; }

.why { margin-top: 8px; } .why pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: #fff4f4; border: 1px solid #f3c4c4; border-radius: 8px; padding: 8px; max-height: 320px; overflow: auto; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; } .tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #e5e7eb); }
/* Plan & billing */
table.quote { width: 100%; max-width: 560px; border-collapse: collapse; margin-top: 8px; }
table.quote td { padding: 6px 8px; border-bottom: 1px solid var(--line, #e5e7eb); }
table.quote td.num { text-align: right; white-space: nowrap; }
table.quote tr.muted td { color: var(--muted, #6b7280); }
@media (max-width: 640px) {
  #billing .row { flex-direction: column; align-items: stretch; }
  #billing .row > label.row { margin-top: 4px !important; flex-direction: row; }
  table.quote { font-size: .85rem; }
  table.quote td.num { white-space: normal; }
}
/* schools ticked for "Update selected" */
td.pick, th.pick { width: 34px; text-align: center; padding-left: 6px; padding-right: 2px; }
td.pick input, th.pick input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent, #3b5bdb); }
/* Logins tab */
.warn-tag { display: inline-block; margin-left: 6px; font-size: .72rem; font-weight: 700; color: #92400e; background: #fef3c7; border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.note.warn-note { background: #fff7ed; border-color: #fdba74; color: #7c2d12; }
.tile .muted.small { display: block; margin-top: 2px; }
/* Plan & billing: per-module pricing */
.seg-mode { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.seg-mode label { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
.seg-mode label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.mod { display: grid; grid-template-columns: auto 1fr 78px; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: pointer; }
.mod:has(input[type=checkbox]:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mod.core { grid-column: 1 / -1; }
.mod small { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; margin-top: 2px; }
.mod .mprice { width: 78px; padding: 6px 8px; text-align: right; }
table.quote tr.mod-line td { font-size: .88rem; }

/* 💬 Messages with a school office */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0 12px; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; font-size: .92rem; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bubble.me { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--card); border-bottom-left-radius: 4px; }
.bubble .who { font-size: .75rem; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble .meta { font-size: .7rem; color: var(--muted); text-align: right; margin-top: 4px; }
.bubble .tk { margin-left: 4px; letter-spacing: -2px; }
.bubble .tk.read { color: #1d9bf0; }
.compose { display: flex; flex-direction: column; gap: 8px; }
.compose textarea, #msgwiz textarea { width: 100%; font: inherit; color: var(--ink); background: var(--card); padding: 10px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
span.ok { color: var(--good); font-weight: 600; } span.warn { color: var(--warn); font-weight: 600; }
