/* School Management System - plain CSS, no build step required */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e3e7ef;
    --text: #1d2433;
    --muted: #6b7489;
    --primary: #1f5eff;
    --primary-dark: #1546c4;
    --sidebar: #0f1e3d;
    --sidebar-text: #b9c3dc;
    --green: #16a34a;
    --green-bg: #e7f7ed;
    --amber: #b7791f;
    --amber-bg: #fdf3e1;
    --red: #dc2626;
    --red-bg: #fde8e8;
    --gray-bg: #eef0f4;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
    position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1rem 0;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.2rem 1rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.sidebar .brand .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; font-size: 1.1rem; }
.sidebar .section { padding: .9rem 1.2rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6f7ea3; }
.sidebar a { display: flex; align-items: center; gap: .65rem; padding: .5rem 1.2rem; color: var(--sidebar-text); border-left: 3px solid transparent; }
.sidebar a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar a.active { background: rgba(31, 94, 255, .18); color: #fff; border-left-color: var(--primary); }
.sidebar .ico { width: 20px; text-align: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 5;
}
.topbar .user { display: flex; align-items: center; gap: .8rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; gap: .5rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; }
.stat .sub { font-size: .78rem; color: var(--muted); }
.stat.green .value { color: var(--green); }
.stat.red .value { color: var(--red); }
.stat.blue .value { color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f9fafc; font-weight: 600; }
tr:hover td { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding: .35rem .5rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=month], input[type=datetime-local], input[type=search], input[type=tel], input[type=file], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid #cfd5e2; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 94, 255, .25); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
select[multiple] { min-height: 140px; }
.checkbox { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
.checkbox input { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.error { color: var(--red); font-size: .8rem; margin-top: .25rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { flex: 0 1 auto; }
.filters input, .filters select { width: auto; min-width: 160px; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.25rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid transparent;
    background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-light { background: #fff; color: var(--text); border-color: #cfd5e2; }
.btn-light:hover { background: #f3f5fa; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-green { background: var(--green); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; font: inherit; cursor: pointer; }
.btn-link.danger { color: var(--red); }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--gray-bg); color: #4b5367; text-transform: capitalize; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: #e6eeff; color: var(--primary); }
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: var(--green-bg); border-color: #b6e5c6; color: #11632f; }
.alert-error { background: var(--red-bg); border-color: #f5baba; color: #8f1d1d; }

/* ---------- Misc ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: .75rem; }
.list li:last-child { border-bottom: 0; }
.profile { display: flex; gap: 1.25rem; align-items: center; }
.photo { width: 88px; height: 88px; border-radius: 12px; object-fit: cover; background: var(--gray-bg); display: grid; place-items: center; font-size: 2rem; color: var(--muted); }
dl.details { display: grid; grid-template-columns: 170px 1fr; gap: .45rem 1rem; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; font-weight: 500; }
.progress { height: 8px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.pagination { display: flex; gap: .3rem; list-style: none; padding: 0; margin: 1rem 0 0; flex-wrap: wrap; }
.pagination li > * { display: block; padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pagination li.active > * { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination li.disabled > * { color: #b3b9c6; }
.att-radio { display: flex; gap: .3rem; }
.att-radio label { margin: 0; font-weight: 600; font-size: .75rem; padding: .25rem .55rem; border-radius: 6px; border: 1px solid #cfd5e2; cursor: pointer; }
.att-radio input { display: none; }
.att-radio input:checked + span { color: #fff; }
.att-radio label:has(input:checked) { color: #fff; }
.att-radio label.p:has(input:checked) { background: var(--green); border-color: var(--green); }
.att-radio label.a:has(input:checked) { background: var(--red); border-color: var(--red); }
.att-radio label.l:has(input:checked) { background: var(--amber); border-color: var(--amber); }
.att-radio label.e:has(input:checked) { background: #6b7489; border-color: #6b7489; }
.reg td.cell { text-align: center; font-weight: 700; font-size: .75rem; padding: .3rem .2rem; }
.cell.present { color: var(--green); } .cell.absent { color: var(--red); } .cell.late { color: var(--amber); } .cell.excused { color: var(--muted); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.calendar div { background: #fff; min-height: 92px; padding: .35rem; font-size: .78rem; }
.calendar .dow { min-height: auto; font-weight: 700; text-align: center; background: #f9fafc; color: var(--muted); }
.calendar .off { background: #fafbfd; color: #c0c6d3; }
.calendar .today { outline: 2px solid var(--primary); outline-offset: -2px; }
.calendar .ev { display: block; background: #e6eeff; color: var(--primary-dark); border-radius: 4px; padding: 1px 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1e3d, #1f5eff); padding: 1rem; }
.auth .card { width: 100%; max-width: 400px; padding: 2rem; }

/* ---------- Printable documents (report card, receipt, invoice) ---------- */
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 2rem; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-head { text-align: center; border-bottom: 2px solid var(--text); padding-bottom: .8rem; margin-bottom: 1rem; }
.doc-head h1 { font-size: 1.4rem; text-transform: uppercase; margin: 0; }
.doc-head p { margin: .1rem 0; color: var(--muted); }
.doc-title { text-align: center; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: .8rem 0; }
.doc table th, .doc table td { border: 1px solid #cfd5e2; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 2.5rem; }
.signatures div { border-top: 1px solid var(--text); padding-top: .3rem; text-align: center; color: var(--muted); }

@media print {
    .sidebar, .topbar, .no-print, .page-head .actions { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; }
    .card, .doc { border: 0; box-shadow: none; padding: 0; }
}

@media (max-width: 1000px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .content { padding: 1rem; }
    dl.details { grid-template-columns: 1fr; }
}

/* ---------- Additions: language switch, ID cards, scanner, timetable ---------- */
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.lang a { padding: .2rem .5rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
.lang a.on { background: var(--primary); color: #fff; }
.lang a:hover { text-decoration: none; }
.id-cards { display: grid; grid-template-columns: repeat(auto-fill, 85.6mm); gap: 6mm; }
.id-card { width: 85.6mm; height: 54mm; border: 1px solid #c8cfdd; border-radius: 3mm; overflow: hidden; background: #fff; display: flex; flex-direction: column; page-break-inside: avoid; }
.id-card .top { background: var(--sidebar); color: #fff; padding: 1.5mm 3mm; font-size: 9pt; font-weight: 700; text-align: center; }
.id-card .top small { display: block; color: #b9c3dc; font-weight: 400; font-size: 6.5pt; }
.id-card .body { flex: 1; display: flex; gap: 2.5mm; padding: 2.5mm 3mm; align-items: center; }
.id-card .pic { width: 20mm; height: 25mm; object-fit: cover; border-radius: 1.5mm; background: var(--gray-bg); display: grid; place-items: center; font-size: 20pt; }
.id-card .info { flex: 1; font-size: 7.5pt; line-height: 1.35; }
.id-card .info strong { font-size: 9pt; display: block; margin-bottom: 1mm; }
.id-card .qr { width: 22mm; height: 22mm; }
.id-card .foot { font-size: 6pt; text-align: center; color: var(--muted); padding-bottom: 1mm; }
.scan-box { max-width: 640px; margin: 0 auto; text-align: center; }
.scan-box video { width: 100%; max-height: 320px; background: #000; border-radius: var(--radius); }
.scan-result { font-size: 1.3rem; font-weight: 700; padding: 1rem; border-radius: var(--radius); margin: 1rem 0; }
.scan-result.ok { background: var(--green-bg); color: var(--green); }
.scan-result.late { background: var(--amber-bg); color: var(--amber); }
.scan-result.err { background: var(--red-bg); color: var(--red); }
.tt td { vertical-align: top; min-width: 120px; }
.tt .slot { background: #eef3ff; border-radius: 6px; padding: .3rem .45rem; margin-bottom: .25rem; font-size: .8rem; }
.tt .slot.brk { background: var(--gray-bg); }
.inbox-row.unread td { font-weight: 700; background: #f7f9ff; }
@media print {
    .id-cards { gap: 4mm; }
    @page { margin: 10mm; }
}
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 6px; padding: .3rem .55rem; font-size: .78rem; white-space: nowrap; }
.chart-wrap .bar { cursor: default; }
