/* Ideal Shule design system: brand red, ink, Space Grotesk headings, Inter body */
:root {
  --red: #C8102E; --red-dark: #8E0E24; --red-ink: #B3122E; --red-soft: #FDECEE;
  --ink: #111827; --ink-2: #1F2937; --ink-3: #374151;
  --muted: #6B7280; --body: #4B5563; --line: #E5E7EB; --line-2: #F3F4F6;
  --bg: #F3F4F6; --card: #FFFFFF;
  --blue: #2563EB; --blue-soft: #DBEAFE; --sky: #93C5FD;
  --orange: #F97316; --orange-soft: #FFF7ED; --amber-soft: #FEF3C7; --amber-ink: #92400E;
  --green: #059669; --green-soft: #DCFCE7; --green-ink: #166534;
  --radius: 16px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--red-ink); text-decoration: none; }
a:hover { color: var(--red-dark); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--red); display: grid; place-items: center; color: #fff; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font: 700 17px var(--display); letter-spacing: -0.02em; }
.brand small { display: block; font-size: 12px; color: var(--muted); }
.search { flex: 1 1 280px; max-width: 520px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.search input { flex: 1; border: 0; background: transparent; font: 14px var(--font); outline: none; min-width: 0; color: var(--ink); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.term-chip { font-size: 12px; color: var(--body); padding: 6px 10px; border-radius: 999px; background: var(--bg); }
.avatar { width: 38px; height: 38px; border-radius: 999px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: 48px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 220px; box-shadow: 0 12px 32px rgba(17,24,39,.12); }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; color: var(--ink); background: none; border: 0; font: 14px var(--font); cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--bg); }
.platform-bar { background: var(--ink); color: #fff; padding: 8px 24px; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.platform-bar a { color: #FCA5A5; }

.shell { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px; max-width: 1600px; margin: 0 auto; }
.side { flex: 1 1 220px; max-width: 240px; display: flex; flex-direction: column; gap: 2px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.lens { border-radius: 12px; }
.lens summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; cursor: pointer; font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-radius: 10px; }
.lens summary::-webkit-details-marker { display: none; }
.lens summary:hover { background: #fff; }
.lens a { display: flex; align-items: center; min-height: 38px; padding: 0 12px 0 40px; border-radius: 10px; color: var(--ink-3); font-weight: 500; }
.lens a:hover { background: #fff; color: var(--ink); }
.lens a.on { background: var(--red-soft); color: var(--red-ink); font-weight: 600; }
.side-hint { margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--ink); color: #D1D5DB; font-size: 12px; }
.side-hint b { color: #fff; display: block; margin-bottom: 4px; font-size: 13px; }

/* ---------- page parts ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head small { color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font: 700 28px var(--display); letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; color: var(--body); }
.bar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--blue); }
.bar.thick { height: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font: 600 16px var(--display); margin-bottom: 4px; }

/* AI brief */
.brief { border-radius: 20px; background: var(--ink); color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.brief-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brief-head .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--red); display: grid; place-items: center; }
.brief-head b { font: 600 15px var(--display); }
.brief-head small { margin-left: auto; color: #9CA3AF; font-size: 12px; }
.brief-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.brief-card { background: var(--ink-2); border: 1px solid var(--ink-3); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.brief-card .tag { font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: #FCA5A5; }
.brief-card p { margin: 0; color: #F3F4F6; line-height: 1.55; }
.brief-card .btn { align-self: flex-start; margin-top: auto; }

/* buttons & badges */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: 600 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #9CA3AF; color: var(--ink); }
.btn-danger { background: #fff; color: #B91C1C; border-color: #FECACA; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font: 700 11px var(--font); letter-spacing: .02em; background: var(--line-2); color: var(--ink-3); white-space: nowrap; }
.b-green { background: var(--green-soft); color: var(--green-ink); }
.b-amber { background: var(--amber-soft); color: var(--amber-ink); }
.b-red { background: #FEE2E2; color: #991B1B; }
.b-blue { background: var(--blue-soft); color: #1E3A8A; }
.b-ink { background: var(--ink); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.pill-av { width: 36px; height: 36px; border-radius: 999px; background: var(--line); color: var(--ink-3); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; overflow: hidden; }
.pill-av img { width: 100%; height: 100%; object-fit: cover; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font: 600 11px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FAFAFB; white-space: nowrap; }
.t td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #FAFAFB; }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t tr.clickable { cursor: pointer; }
.t .strong { font-weight: 600; color: var(--ink); }

/* forms */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input:not([type]), input[type=datetime-local], input[type=text], input[type=search], input[type=email], input[type=number], input[type=password], input[type=date], input[type=time], input[type=tel], input[type=url], select, textarea {
  font: 14px var(--font); color: var(--ink); background: #fff; border: 1px solid #D1D5DB; border-radius: 10px; padding: 0 12px; min-height: 40px; width: 100%; outline: none;
}
textarea { padding: 10px 12px; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,16,46,.12); }
.filters input, .filters select { width: auto; min-width: 160px; }
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid #D1D5DB; border-radius: 10px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); }
select[multiple] { min-height: 140px; padding: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font: 600 13px var(--font); color: var(--ink-3); }
.field .help { font-size: 12px; color: var(--muted); }
.field .err, .errorlist { color: #B91C1C; font-size: 12px; margin: 0; padding: 0; list-style: none; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.alert { padding: 12px 16px; border-radius: 12px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.alert-success { background: #ECFDF5; color: #065F46; }
.alert-error { background: #FEF2F2; color: #991B1B; }
.alert-info { background: #EFF6FF; color: #1E3A8A; }
.alert-warning { background: var(--amber-soft); color: var(--amber-ink); }

/* attendance register */
.register { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.reg-tile { border: 2px solid var(--line); border-radius: 16px; padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; cursor: pointer; user-select: none; transition: border-color .1s, background .1s; }
.reg-tile .pill-av { width: 44px; height: 44px; background: var(--blue); color: #fff; }
.reg-tile b { font-size: 13px; }
.reg-tile .st { font: 700 10px var(--font); letter-spacing: .05em; color: #1D4ED8; }
.reg-tile[data-s=L] { border-color: #7DD3FC; background: #F0F9FF; } .reg-tile[data-s=L] .pill-av { background: #BAE6FD; color: #075985; } .reg-tile[data-s=L] .st { color: #0369A1; }
.reg-tile[data-s=A] { border-color: #FDBA74; background: var(--orange-soft); } .reg-tile[data-s=A] .pill-av { background: #FED7AA; color: #9A3412; } .reg-tile[data-s=A] .st { color: #C2410C; }
.reg-tile[data-s=E] { border-color: #C4B5FD; background: #F5F3FF; } .reg-tile[data-s=E] .pill-av { background: #DDD6FE; color: #5B21B6; } .reg-tile[data-s=E] .st { color: #6D28D9; }
.reg-tile input[type=text] { min-height: 30px; font-size: 12px; display: none; }
.reg-tile[data-s=A] input[type=text], .reg-tile[data-s=E] input[type=text], .reg-tile[data-s=L] input[type=text] { display: block; }
.counts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.counts div { border-radius: 12px; padding: 10px 12px; }
.counts b { display: block; font: 700 22px var(--display); }

/* attendance calendar */
.cal { display: grid; grid-template-columns: 54px repeat(5, minmax(0, 1fr)); gap: 5px; align-items: center; }
.cal span.h { font-size: 11px; color: var(--muted); text-align: center; }
.cal span.w { font-size: 11px; color: var(--muted); }
.cal i { height: 18px; border-radius: 5px; background: var(--line-2); display: block; }
.cal i.P { background: var(--blue); } .cal i.L { background: var(--sky); } .cal i.A { background: var(--orange); } .cal i.E { background: #A78BFA; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--body); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* marks */
.marks-input { width: 90px !important; text-align: right; font-variant-numeric: tabular-nums; }
.grade { display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 6px; font-weight: 700; font-size: 12px; background: var(--line-2); }
.grade-A { background: var(--green-soft); color: var(--green-ink); } .grade-B { background: var(--blue-soft); color: #1E3A8A; }
.grade-C { background: #E0E7FF; color: #3730A3; } .grade-D { background: var(--amber-soft); color: var(--amber-ink); } .grade-F { background: #FEE2E2; color: #991B1B; }

/* timetable */
.tt { width: 100%; border-collapse: separate; border-spacing: 6px; }
.tt th { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px; }
.tt td { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; vertical-align: top; min-width: 120px; height: 64px; }
.tt td.clash { border-color: var(--orange); background: var(--orange-soft); }
.tt td b { display: block; font-size: 13px; }
.tt td small { color: var(--muted); font-size: 11px; }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.auth-art { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-art h1 { font-size: 40px; max-width: 480px; }
.auth-art p { color: #D1D5DB; max-width: 440px; font-size: 16px; }
.auth-form { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }

/* print: receipts, invoices, report cards */
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 40px; border: 1px solid var(--line); border-radius: 12px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--red); padding-bottom: 16px; margin-bottom: 20px; }
.doc-head h2 { font-size: 22px; }
.doc .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.doc .meta div small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.doc .total-row td { font-weight: 700; border-top: 2px solid var(--ink); }
.page-break { page-break-after: always; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12pt; }
  .topbar, .side, .no-print, .platform-bar, .messages { display: none !important; }
  .shell { padding: 0; display: block; }
  .doc { border: 0; padding: 0; max-width: none; }
}

@media (max-width: 760px) {
  .shell { padding: 14px; }
  .side { max-width: none; }
  .topbar { padding: 10px 14px; }
  h1 { font-size: 24px; }
  .counts { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- charts (dataviz reference palette, light) ---------- */
.viz { --s1: #2a78d6; --s2: #eb6834; --grid: #E5E7EB; --axis: #6B7280; }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz .gridline { stroke: var(--grid); stroke-width: 1; }
.viz .ref { stroke: #9CA3AF; stroke-width: 1.5; stroke-dasharray: 4 4; }
.viz .axis-label { fill: var(--axis); font: 500 11px var(--font); }
.viz .ref-label { fill: #4B5563; font: 600 11px var(--font); }
.viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .line.s1 { stroke: var(--s1); } .viz .line.s2 { stroke: var(--s2); }
.viz .line.dashed { stroke-dasharray: 6 5; }
.viz .dot.s1 { fill: var(--s1); } .viz .dot.s2 { fill: var(--s2); }
.viz .dot { stroke: #fff; stroke-width: 2; }
.viz .bar.s1 { fill: var(--s1); } .viz .bar.s2 { fill: var(--s2); }
.viz .hit { fill: transparent; cursor: default; }
.viz .tip { display: none; pointer-events: none; }
.viz .tip rect { fill: #111827; rx: 6; }
.viz .tip text { fill: #fff; font: 600 11px var(--font); }
.viz .pt:hover .tip, .viz .pt:focus .tip { display: block; }
.viz .pt:hover .dot { r: 6; }
.viz .end-label { fill: #111827; font: 700 11px var(--font); }
.viz-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--body); }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.viz-legend i.sq { height: 12px; width: 12px; border-radius: 3px; }
.viz-table summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 8px; }
.heat td { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; padding: 8px 6px; border: 2px solid #fff; border-radius: 6px; }

/* ---- notices from Ideal Digital + developer console ---- */
.platform-notices{display:flex;flex-direction:column}
.pnotice{padding:9px 24px;font-size:14px;border-bottom:1px solid var(--line)}
.pnotice a{font-weight:600;margin-left:8px}
.pn-info{background:#EFF6FF;color:#1E3A8A}
.pn-warning{background:#FFF7ED;color:#9A3412}
.pn-good{background:#ECFDF5;color:#065F46}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-bottom:16px}
.kpi{background:var(--card,#fff);border:1px solid var(--line);border-radius:14px;padding:14px 16px}
.kpi small{display:block;color:var(--muted);font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}
.kpi b{display:block;font:600 24px var(--display);margin-top:4px}
.kpi span{font-size:12px;color:var(--muted)}
.mbars{display:flex;align-items:flex-end;gap:10px;height:140px;padding-top:8px}
.mbars .mbar{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
.mbars .mbar i{display:block;width:100%;max-width:44px;background:#2a78d6;border-radius:4px 4px 0 0;min-height:2px}
.mbars .mbar small{font-size:11px;color:var(--muted)}
.inv-paper{max-width:820px;margin:0 auto}
@media print{.inv-actions,.sidebar,.topbar,.platform-bar,.platform-notices{display:none!important}.inv-paper{border:0!important}}
