[hidden] { display: none !important; }
:root {
  --brand: #4f46e5;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, white);
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1c1f2e;
  --muted: #6b7080;
  --line: #e6e8ef;
  --side: #141726;
  --side-text: #b9bdd0;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,23,38,.05), 0 4px 16px rgba(20,23,38,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Noto Sans Malayalam", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.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)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand .name { font-weight: 650; font-size: 15px; line-height: 1.2; word-break: break-word; }
.brand .sub { font-size: 11px; color: var(--side-text); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side .foot b { color: #fff; display: block; }
.side .foot a { color: var(--side-text); cursor: pointer; }
.main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 16px; }
}

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .v.bad { color: var(--bad); } .stat .v.warn { color: var(--warn); }
.stat.click { cursor: pointer; } .stat.click:hover { border-color: var(--brand); }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9ccd8; background: #fafbfd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
label { display: block; font-weight: 550; font-size: 12.5px; margin-bottom: 4px; color: #3b3f50; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); border: 1px solid #d6d9e3; border-radius: 8px; padding: 8px 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
input[type=color] { padding: 2px; height: 38px; width: 70px; }
.field { margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters input.search { min-width: 240px; flex: 1; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
td .sub { font-size: 12px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef0f5; color: #444a5e; white-space: nowrap; }
.pill.green { background: #dcfce7; color: #166534; } .pill.red { background: #fee2e2; color: #991b1b; }
.pill.amber { background: #fef3c7; color: #92400e; } .pill.blue { background: #dbeafe; color: #1e40af; }
.pill.purple { background: #ede9fe; color: #5b21b6; } .pill.gray { background: #eef0f5; color: #555b70; }
.due-over { color: var(--bad); font-weight: 600; } .due-today { color: var(--warn); font-weight: 600; }

/* ---------- Charts ---------- */
.bars .bar { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.bars .track { background: #eef0f5; border-radius: 6px; height: 10px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--brand); border-radius: 6px; }
.bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.cols .c .b { width: 100%; max-width: 30px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.cols .c .d { font-size: 10px; color: var(--muted); white-space: nowrap; }
.cols .c .n { font-size: 10px; color: var(--text); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; word-break: break-word; }

/* ---------- Modals & toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,17,30,.45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 820px; }
.modal .mh { padding: 18px 20px 0; display: flex; align-items: center; }
.modal .mb { padding: 16px 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { margin-left: auto; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); align-items: center; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c1f2e; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: fade .15s; }
.toast.err { background: var(--bad); }
#reminder-stack { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 40px); overflow-y: auto; }
.reminder-pop { width: 360px; max-width: calc(100vw - 40px); flex: none; background: #fff; border-radius: 14px; border: 2px solid var(--brand); box-shadow: 0 16px 50px rgba(0,0,0,.25); padding: 16px; animation: pop .2s; }
.reminder-pop .t { font-weight: 650; font-size: 15px; margin: 4px 0 6px; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(10px); opacity: 0 } }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 25%, transparent), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo-big { width: 48px; height: 48px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; font-size: 22px; display: grid; place-items: center; margin-bottom: 16px; }
.err-box { background: #fee2e2; color: #991b1b; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.ok-box { background: #dcfce7; color: #166534; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* ---------- Lead page ---------- */
.lead-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .lead-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-soft); color: var(--text); border-radius: 20px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 0 4px; }
.bulkbar { display: flex; gap: 8px; align-items: center; background: var(--brand-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.bulkbar select { width: auto; }

/* ---------- Students & documents ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #d6d9e3; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; color: #fff; }
.checklist li.got .tick { background: var(--ok); border-color: var(--ok); }
.checklist .lbl { flex: 1; }
.checklist li:not(.got) .lbl { color: var(--muted); }
.dropzone { border: 2px dashed #cfd3df; border-radius: 12px; padding: 22px; text-align: center; background: #fafbfd; transition: .15s; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.uplist { list-style: none; margin: 10px 0 0; padding: 0; }
.uplist li { display: grid; grid-template-columns: 1fr auto 120px auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.uplist .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplist .track { background: #eef0f5; border-radius: 6px; height: 6px; overflow: hidden; }
.uplist .fill { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.uplist li.good .st { color: var(--ok); } .uplist li.bad .st { color: var(--bad); }
.uplist li.bad .fill { background: var(--bad); }
code { background: #eef0f5; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- Timetable ---------- */
.tt { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tt-day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.tt-day.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.tt-h { font-weight: 650; font-size: 13px; padding: 4px 6px 8px; }
.tt-slot { background: var(--brand-soft); border-left: 3px solid var(--brand); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; }
.tt-slot.click { cursor: pointer; } .tt-slot.click:hover { filter: brightness(.97); }
.tt-time { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tt-sub { font-weight: 650; }
.tt-meta { font-size: 12px; color: var(--muted); }

/* ---------- Marks entry ---------- */
table.marks input.mk { width: 70px; text-align: right; padding: 5px 7px; }
table.marks input.mk.bad { border-color: var(--bad); background: #fee2e2; }

/* ---------- Printable pages ---------- */
.print-wrap { max-width: 820px; margin: 24px auto; padding: 0 16px; }
.paper { background: #fff; padding: 36px 40px; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.lh { display: flex; gap: 16px; align-items: center; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 16px; }
.lh img { width: 64px; height: 64px; object-fit: contain; }
.lh-name { font-size: 22px; font-weight: 700; }
.lh-sub { font-size: 12.5px; color: #444; }
.doc-title { text-align: center; font-weight: 700; letter-spacing: .08em; margin: 8px 0 16px; font-size: 16px; }
.ptable { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.ptable td, .ptable th { padding: 6px 8px; border-bottom: 0; background: none; text-transform: none; letter-spacing: 0; font-size: 13.5px; color: #111; }
.ptable.bordered td, .ptable.bordered th { border: 1px solid #999; }
.ptable.bordered th { font-weight: 700; }
.sign { display: flex; justify-content: space-between; margin-top: 56px; font-size: 13px; }
.sign div { border-top: 1px solid #888; padding-top: 6px; min-width: 160px; text-align: center; }
@media print {
  body { background: #fff; }
  .noprint, .side, .head .btn, .filters, .tabs, .pager .btn, #toast-root, #reminder-stack, .btn.menu-btn { display: none !important; }
  .shell { display: block; } .main { padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .print-wrap { margin: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .tt { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- Permissions panel ---------- */
.perm-panel { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
#permbox { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
@media (max-width: 700px) { #permbox { grid-template-columns: 1fr; } }
#permbox .ok-box { grid-column: 1 / -1; }
.perm-group { background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.perm-gh { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
label.perm { display: flex; gap: 8px; align-items: flex-start; font-weight: 450; font-size: 13.5px; padding: 4px 0; margin: 0; cursor: pointer; color: var(--text); }
label.perm input { margin-top: 3px; }
label.perm.changed span:first-of-type { font-weight: 600; }
.perm-tag { margin-left: auto; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.perm-tag.add { background: #dcfce7; color: #166534; } .perm-tag.rem { background: #fee2e2; color: #991b1b; }
.print-wrap.wide { max-width: 1400px; }
.list-print th, .list-print td { font-size: 11.5px !important; padding: 5px 6px !important; vertical-align: top; }
.list-print thead { display: table-header-group; }
.list-print tr { break-inside: avoid; }
