:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f8f9fc; --text: #1c2233; --muted: #6b7489; --line: #e3e7f0;
  --brand: #3b5bdb; --brand-d: #2f49b3; --brand-l: #edf1ff; --ok: #12875a; --ok-l: #e3f6ee; --warn: #b7791f; --warn-l: #fdf3dc;
  --bad: #c62f3e; --bad-l: #fdebed; --info: #0b7fab; --info-l: #e1f4fb; --radius: 10px; --shadow: 0 1px 2px rgba(20,30,60,.06), 0 4px 14px rgba(20,30,60,.05);
  --side: #172042; --side-text: #b9c2e2; --side-active: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1424; --surface: #171d33; --surface-2: #1c2340; --text: #e6e9f5; --muted: #8f99b8; --line: #2a3354; --brand: #7b93ff; --brand-d: #96a8ff; --brand-l: #222c57;
    --ok: #4cc79a; --ok-l: #123a2d; --warn: #e5b04d; --warn-l: #3b2f12; --bad: #ff7b87; --bad-l: #3d1a20; --info: #5cc3e8; --info-l: #12323d; --side: #0b1020; --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .gap-lg { gap: 18px; }
.hidden { display: none !important; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 20% -10%, #5b7cff33, transparent), radial-gradient(900px 500px at 100% 110%, #12875a22, transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login-card .logo { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.login-card h1 { margin-bottom: 4px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 30px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; color: #fff; font-weight: 650; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; flex: none; }
.brand small { display: block; color: var(--side-text); font-weight: 400; font-size: 11.5px; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7482b3; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; margin: 1px 0; }
.nav a:hover { background: #ffffff14; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .badge { margin-left: auto; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .search { position: relative; flex: 1; max-width: 420px; }
.top .search input { width: 100%; padding: 8px 12px 8px 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); }
.top .search svg { position: absolute; left: 10px; top: 9px; opacity: .5; }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 30; max-height: 360px; overflow: auto; }
.search-results a { display: block; padding: 8px 12px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--brand-l); }
.content { padding: 22px; max-width: 1400px; width: 100%; }
.icon-btn.menu-btn { display: none; }
.grid > .card, .grid > .stat { margin-top: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 9px; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-l); color: var(--brand); display: grid; place-items: center; font-weight: 650; flex: none; }
.dropdown { position: fixed; right: 22px; top: 54px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 210px; z-index: 40; padding: 6px; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: 7px; color: var(--text); cursor: pointer; text-decoration: none; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-h h1 { margin: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat.ok .v { color: var(--ok); } .stat.bad .v { color: var(--bad); } .stat.warn .v { color: var(--warn); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--bad); border-color: var(--bad-l); } .btn.danger:hover { background: var(--bad-l); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { padding: 6px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--muted); display: grid; place-items: center; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-l); color: var(--ok); border-color: transparent; } .badge.bad { background: var(--bad-l); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-l); color: var(--warn); border-color: transparent; } .badge.info { background: var(--info-l); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand-l); color: var(--brand); border-color: transparent; }
.nav .badge { background: #ef4444; color: #fff; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.actions { white-space: nowrap; text-align: right; } .actions .btn { margin-left: 4px; }

label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=month], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
textarea { min-height: 76px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.req::after { content: " *"; color: var(--bad); }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.check input { width: auto; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar > div { min-width: 150px; } .toolbar .btn { align-self: end; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

.modal-bg { position: fixed; inset: 0; background: #0a0f2088; z-index: 100; display: grid; place-items: start center; padding: 40px 14px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px #0006; border: 1px solid var(--line); }
.modal.wide { max-width: 900px; } .modal.xl { max-width: 1150px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; }
.modal-b { padding: 18px; } .modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { background: #1c2233; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s; }
.toast.err { background: var(--bad); } .toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.alert { padding: 10px 14px; border-radius: 9px; background: var(--info-l); color: var(--info); margin-bottom: 12px; }
.alert.warn { background: var(--warn-l); color: var(--warn); } .alert.bad { background: var(--bad-l); color: var(--bad); } .alert.ok { background: var(--ok-l); color: var(--ok); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.list li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* attendance */
.att-btns { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.att-btns button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-weight: 650; border-right: 1px solid var(--line); color: var(--muted); }
.att-btns button:last-child { border-right: 0; }
.att-btns button.on.P { background: var(--ok); color: #fff; } .att-btns button.on.A { background: var(--bad); color: #fff; }
.att-btns button.on.L { background: var(--warn); color: #fff; } .att-btns button.on.E { background: var(--info); color: #fff; }
.cell { display: inline-block; min-width: 22px; text-align: center; font-size: 11.5px; font-weight: 650; border-radius: 4px; padding: 1px 3px; }
.cell.P { background: var(--ok-l); color: var(--ok); } .cell.A { background: var(--bad-l); color: var(--bad); } .cell.L { background: var(--warn-l); color: var(--warn); } .cell.E { background: var(--info-l); color: var(--info); }
.matrix th, .matrix td { padding: 4px 5px; text-align: center; font-size: 12px; } .matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.matrix .we { background: var(--surface-2); }

/* timetable */
.tt th, .tt td { text-align: center; min-width: 118px; vertical-align: top; }
.tt td.slot { cursor: pointer; height: 62px; }
.tt td.slot:hover { background: var(--brand-l); }
.tt .lesson { background: var(--brand-l); border-radius: 8px; padding: 5px 7px; text-align: left; font-size: 12.5px; }
.tt .lesson b { display: block; } .tt .lesson span { color: var(--muted); font-size: 11.5px; }
.tt .brk { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px); color: var(--muted); }

/* charts */
.bars { display: flex; align-items: end; gap: 10px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: end; height: 100%; gap: 4px; min-width: 0; }
.bars .col { width: 100%; max-width: 38px; display: flex; gap: 3px; align-items: end; height: 120px; justify-content: center; }
.bars .col i { display: block; width: 45%; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .col .inc { background: var(--ok); } .bars .col .exp { background: #e8706b; } .bars .col .one { background: var(--brand); width: 70%; }
.bars .lab { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.progress { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--brand); }
.progress.ok > i { background: var(--ok); } .progress.bad > i { background: var(--bad); }

/* test taking */
.q-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface); }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin-top: 8px; cursor: pointer; }
.opt:hover { background: var(--surface-2); } .opt.sel { border-color: var(--brand); background: var(--brand-l); }
.opt.right { border-color: var(--ok); background: var(--ok-l); } .opt.wrongc { border-color: var(--bad); background: var(--bad-l); }
.opt .k { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font-weight: 650; font-size: 12px; }
.opt.sel .k { background: var(--brand); border-color: var(--brand); color: #fff; }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.qnav button.ans { background: var(--brand-l); border-color: var(--brand); color: var(--brand); } .qnav button.cur { outline: 2px solid var(--brand); }
.timer { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; padding: 6px 14px; border-radius: 9px; background: var(--brand-l); color: var(--brand); }
.timer.low { background: var(--bad-l); color: var(--bad); }

.omr-stage { position: relative; display: inline-block; max-width: 100%; }
.omr-stage canvas { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 30px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--brand); background: var(--brand-l); }
.ans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ans-cell { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.ans-cell select { width: auto; padding: 2px 4px; } .ans-cell.ok { background: var(--ok-l); } .ans-cell.no { background: var(--bad-l); } .ans-cell.blank { background: var(--warn-l); }

/* wizard, plan + template cards, website editor */
.steps { display: flex; gap: 6px; margin-bottom: 18px; } .steps div { flex: 1; text-align: center; padding: 8px 4px; border-bottom: 3px solid var(--line); color: var(--muted); font-weight: 600; font-size: 13px; }
.steps div.on { border-color: var(--brand); color: var(--brand); } .steps div.done { border-color: var(--ok); color: var(--ok); }
.pick-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; } .pick { position: relative; cursor: pointer; border: 2px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface); transition: border-color .15s, box-shadow .15s; display: block; }
.pick:hover { border-color: var(--brand); } .pick input { position: absolute; opacity: 0; } .pick:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); background: var(--brand-l); }
.pick h4 { margin: 8px 0 2px; font-size: 14.5px; } .pick p { margin: 0; font-size: 12.5px; color: var(--muted); } .pick .tagline { position: absolute; top: 8px; right: 8px; }
.pick-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-l); color: var(--brand); display: grid; place-items: center; } .pick:has(input:checked) .pick-ico { background: var(--brand); color: #fff; }
.tpl-thumb { height: 74px; border-radius: 8px; border: 1px solid var(--line); background: #fff; overflow: hidden; position: relative; } .tpl-thumb i { position: absolute; display: block; border-radius: 3px; }
.tpl-thumb .bar { left: 0; right: 0; top: 0; height: 12px; background: #e5e7eb; border-radius: 0; } .tpl-thumb .b1 { background: var(--tc, var(--brand)); } .tpl-thumb .b2 { background: #d1d5db; }
.device { display: flex; gap: 6px; } .device button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.frame-wrap { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; justify-items: center; } .frame-wrap iframe { width: 100%; height: 440px; border: 1px solid var(--line); border-radius: 8px; background: #fff; transition: width .2s; }
.progress-ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex: none; } .progress-ring b { width: 64px; height: 64px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 19px; }
.check-list { list-style: none; margin: 0; padding: 0; } .check-list li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); } .check-list .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 12px; } .check-list .done .dot { background: var(--ok); border-color: var(--ok); color: #fff; } .check-list .done span { color: var(--muted); text-decoration: line-through; }
.rep-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 8px; margin-bottom: 8px; align-items: start; } .rep-row.two { grid-template-columns: 1fr 1fr auto; }
.img-slot { border: 1px dashed var(--line); border-radius: 12px; padding: 8px; text-align: center; background: var(--surface-2); } .img-slot .thumb { height: 92px; border-radius: 8px; background: var(--surface) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.url-row { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; margin-bottom: 6px; overflow: hidden; } .url-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .pick-cards { grid-template-columns: 1fr; } .rep-row, .rep-row.two { grid-template-columns: 1fr; } }

/* classroom chat + card scanning */
.chat { padding: 0; display: flex; flex-direction: column; height: min(68vh, 640px); overflow: hidden; }
.chat-feed { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { max-width: min(560px, 88%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--brand-l); border-color: transparent; }
.msg .who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; } .msg .who .icon-btn { margin-left: auto; padding: 2px; }
.msg .body { margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.linkcard { display: block; margin-top: 6px; padding: 7px 10px; border: 1px dashed var(--brand); border-radius: 9px; color: var(--brand); overflow-wrap: anywhere; font-weight: 600; text-decoration: none; }
.chat-form { padding: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; background: var(--surface); } .chat-form textarea { min-height: 54px; }
.scan-frame { position: absolute; inset: 14% 22%; border: 3px solid #fff9; border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 999px #0003; }
.scan-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line); } .scan-row > div { flex: 1; min-width: 0; }
.scan-row.ok { background: var(--ok-l); } .scan-row.bad { background: var(--bad-l); } .scan-row.dup { background: var(--warn-l); }

/* per-school look: light sidebar, square corners, theme picker */
body.side-light .side { background: var(--surface); color: var(--muted); border-right: 1px solid var(--line); }
body.side-light .brand { color: var(--text); } body.side-light .nav-group { color: var(--muted); }
body.side-light .nav a { color: var(--muted); } body.side-light .nav a:hover { background: var(--surface-2); color: var(--text); } body.side-light .nav a.active { background: var(--brand-l); color: var(--brand); font-weight: 600; }
body.sq { --radius: 3px; } body.sq .btn, body.sq .badge, body.sq input, body.sq select, body.sq textarea, body.sq .modal, body.sq .login-card, body.sq .dropdown, body.sq .user-chip, body.sq .opt, body.sq .q-card, body.sq .alert, body.sq .toast, body.sq .lesson, body.sq .stat, body.sq .table-wrap, body.sq .search-results, body.sq .dropzone { border-radius: 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; } .swatch { cursor: pointer; text-align: center; font-size: 11.5px; color: var(--muted); }
.swatch input { position: absolute; opacity: 0; } .swatch span { display: block; width: 62px; height: 40px; border-radius: 9px; border: 3px solid transparent; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.swatch span i { position: absolute; left: 0; top: 0; bottom: 0; width: 18px; } .swatch input:checked + span { border-color: var(--text); } .swatch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* print */
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block !important; }
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
  @page { margin: 12mm; }
}
.doc { color: #111; background: #fff; font-family: "Segoe UI", system-ui, sans-serif; }
.doc h1 { font-size: 20px; text-align: center; margin: 0; } .doc .sub { text-align: center; color: #444; font-size: 12px; margin-bottom: 8px; }
.doc table { border: 1px solid #999; } .doc th, .doc td { border: 1px solid #999; padding: 4px 8px; font-size: 12.5px; color: #111; background: #fff; position: static; }
.doc th { background: #eee; }
.page-break { page-break-after: always; break-after: page; }
.id-grid { display: grid; grid-template-columns: repeat(2, 86mm); gap: 6mm; }
.id-card { width: 86mm; height: 54mm; border: 1px solid #333; border-radius: 3mm; padding: 3mm; display: flex; flex-direction: column; background: #fff; color: #111; break-inside: avoid; }
.id-card .hd { background: var(--brand-print, #3b5bdb); color: #fff; margin: -3mm -3mm 2mm; padding: 2mm 3mm; font-weight: 700; font-size: 11px; border-radius: 3mm 3mm 0 0; }
.id-card .nm { font-size: 14px; font-weight: 700; } .id-card div { font-size: 10.5px; }

@media (max-width: 600px) {
  body { font-size: 15px; }
  input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=month], input[type=datetime-local], select, textarea { font-size: 16px; padding: 10px; } /* no iOS zoom */
  .btn { padding: 9px 14px; min-height: 40px; } .btn.sm { min-height: 34px; padding: 5px 10px; }
  .toolbar { gap: 8px; } .toolbar > div { min-width: 0; flex: 1 1 130px; } .toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .page-h h1 { font-size: 19px; } .page-h > .row { width: 100%; } .page-h > .row .btn { flex: 1 1 auto; justify-content: center; }
  .g4 .stat .v { font-size: 19px; } .stat .l { font-size: 11.5px; }
  .modal-bg { padding: 0; place-items: stretch; } .modal, .modal.wide, .modal.xl { max-width: none; min-height: 100%; border-radius: 0; }
  .card { padding: 12px; } .stat .v { font-size: 22px; } .hidden-sm { display: none; }
  th, td { padding: 8px; } .actions { white-space: normal; } .actions .btn { margin: 2px; }
  .dropdown { right: 8px; } .toasts { left: 12px; right: 12px; } .id-grid, .id-card { max-width: 100%; }
  .att-btns button { padding: 8px 13px; } .tt td, .tt th { min-width: 96px; } .login-card { padding: 20px; }
}
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: -270px; width: 252px; z-index: 60; transition: left .2s; } .side.open { left: 0; }
  .icon-btn.menu-btn { display: grid; } .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat { padding: 11px 12px; } .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; } .top { padding: 8px 12px; } .kv { grid-template-columns: 110px 1fr; }
}

/* institution type cards (super admin) */
.inst-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.inst-card { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.inst-card input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.inst-card:has(input:checked) { border-color: var(--brand); background: var(--brand-l); }
.inst-card.disabled { opacity: .55; cursor: not-allowed; } .inst-card.disabled input { cursor: not-allowed; }
body.sq .inst-card { border-radius: 3px; }

/* files attached to homework, diary and materials */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: .88rem; text-decoration: none; color: var(--text); max-width: 100%; overflow-wrap: anywhere; }
a.file-chip:hover { border-color: var(--brand); color: var(--brand); }
.file-chip button { border: 0; background: none; cursor: pointer; color: var(--bad); font-size: 1.05rem; line-height: 1; padding: 0 2px; }

/* ---------- analytics charts (palette validated for light and dark; see public/js/charts.js) ---------- */
.viz { --v-1: #2a78d6; --v-2: #eb6834; --v-warn: #ec835a; --v-grid: #e1e0d9; --v-axis: #c3c2b7; --v-muted: #898781; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .viz { --v-1: #3987e5; --v-2: #d95926; --v-grid: #2c2c2a; --v-axis: #383835; } }
:root[data-theme="dark"] .viz { --v-1: #3987e5; --v-2: #d95926; --v-grid: #2c2c2a; --v-axis: #383835; }
.viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; } .viz-grid .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .viz-grid { grid-template-columns: 1fr; } }
.viz-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; } .viz-h h3 { margin: 0 0 2px; }
.seg-sw { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-sw button { border: 0; background: none; padding: 4px 10px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--muted); } .seg-sw button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.viz-host { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; } .viz-svg:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.viz-svg text { font-family: inherit; }
.viz-svg .g { stroke: var(--v-grid); stroke-width: 1; } .viz-svg .base, .viz-svg .goal, .viz-svg .cross { stroke: var(--v-axis); stroke-width: 1; }
.viz-svg .ax { fill: var(--v-muted); font-size: 12px; } .viz-svg .val { fill: var(--text); font-size: 12px; font-weight: 700; } .viz-svg .cap { fill: var(--muted); font-size: 12px; font-weight: 600; }
.viz-svg .ln { fill: none; stroke: var(--v-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } .viz-svg .area { fill: var(--v-1); opacity: .1; stroke: none; }
.viz-svg .dot { fill: var(--v-1); stroke: var(--surface); stroke-width: 2; } .viz-svg .seg.hot { filter: brightness(1.1); }
.viz-svg .col:focus { outline: none; } .viz-svg .col:focus-visible .seg { stroke: var(--text); stroke-width: 1.5; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; margin-bottom: 8px; } .viz-legend span { display: inline-flex; align-items: center; gap: 6px; } .viz-legend i { width: 10px; height: 10px; border-radius: 2px; }
.viz-rows { display: flex; flex-direction: column; gap: 6px; }
.viz-row { display: grid; grid-template-columns: minmax(70px, 30%) 1fr minmax(54px, auto); gap: 10px; align-items: center; padding: 2px 4px; border-radius: 6px; }
.viz-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; } .viz-row:hover { background: var(--surface-2); }
.viz-row .lab { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .viz-row .v { font-size: .88rem; font-weight: 700; text-align: right; white-space: nowrap; }
.viz-row .trk { position: relative; height: 18px; border-left: 1px solid var(--v-axis); } .viz-row .bar { height: 18px; background: var(--v-1); border-radius: 0 4px 4px 0; } .viz-row .bar.flag { background: var(--v-warn); }
.viz-row .gl { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.viz-key { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); margin-top: 8px; } .viz-key .goal-sw { width: 1px; height: 12px; background: var(--muted); } .viz-key .flag-sw { width: 10px; height: 10px; border-radius: 2px; background: var(--v-warn); }
.viz-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: .82rem; z-index: 5; min-width: 120px; }
.viz-tip .t { font-weight: 600; margin-bottom: 4px; } .viz-tip .r { display: flex; align-items: center; gap: 6px; } .viz-tip .r i { width: 12px; height: 3px; border-radius: 2px; } .viz-tip .r b { font-size: .95rem; } .viz-tip .r span { color: var(--muted); }
.kpi .delta { font-size: .8rem; margin-top: 4px; color: var(--muted); } .kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--bad); }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 6px; }
.filters-row button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .88rem; cursor: pointer; } .filters-row button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.viz-body { transition: opacity .15s; } .viz-body.busy { opacity: .55; }
.table-wrap td.num { white-space: nowrap; }

/* coaching: meters, enquiry funnel, test-series leaderboard */
.mbar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 4px; min-width: 70px; overflow: hidden; }
.mbar i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.mbar.ok i { background: var(--ok); } .mbar.bad i, .mbar.full i { background: var(--bad); }
.funnel .fr { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: .92rem; }
.funnel .fr .mbar { margin: 0; height: 10px; } .funnel .fr b { text-align: right; }
table.board td, table.board th { white-space: nowrap; } table.board tr.mine td { background: var(--brand-l); }
table.board tr.avg td { color: var(--muted); border-top: 2px solid var(--line); }
.up { color: var(--ok); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }
@media (max-width: 560px) { .funnel .fr { grid-template-columns: 100px 1fr 30px; } }