/* EduERP — plain CSS, no external dependencies (CSP: style-src 'self') */
:root {
    --bg: #f4f6f9; --panel: #fff; --ink: #1d2430; --muted: #687385; --line: #dde2ea;
    --brand: #1f4e8c; --brand-ink: #fff; --brand-soft: #e7eef8;
    --ok: #1d7a46; --ok-soft: #e3f4ea; --err: #b42318; --err-soft: #fdecea; --info: #175cd3; --info-soft: #e8f0fd;
    --warn-soft: #fff6e0; --radius: 8px;
    font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code { background: var(--brand-soft); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small, small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.inline { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }

/* Top bar & shell */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 10; }
.topbar a, .topbar .link { color: var(--brand-ink); }
.brand { font-weight: 700; font-size: 1.15rem; display: flex; flex-direction: column; line-height: 1.1; }
.brand small { font-weight: 400; opacity: .8; font-size: .75rem; }
.who { font-size: .9rem; }
.menu-toggle { display: none; background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; }
.shell { display: flex; min-height: calc(100vh - 100px); align-items: flex-start; }
/* the menu stays in view under the top bar and scrolls on its own */
.sidebar { width: 230px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); padding: .75rem 0; overflow-y: auto;
           position: sticky; top: var(--topbar-h, 49px); height: calc(100vh - var(--topbar-h, 49px)); overscroll-behavior: contain; }
.nav-group { margin-bottom: .25rem; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .5rem 1.25rem .3rem; }
summary.nav-title { cursor: pointer; list-style: none; display: flex; align-items: center; user-select: none; }
summary.nav-title::-webkit-details-marker { display: none; }
summary.nav-title::after { content: "\25B8"; margin-left: auto; font-size: .85rem; transition: transform .15s; }
details[open] > summary.nav-title::after { transform: rotate(90deg); }
summary.nav-title:hover { color: var(--ink); background: var(--brand-soft); }
.sidebar a { display: block; padding: .35rem 1.25rem; color: var(--ink); border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--brand-soft); text-decoration: none; }
.sidebar a.active { background: var(--brand-soft); border-left-color: var(--brand); color: var(--brand); font-weight: 600; }
.content { flex: 1; padding: 1.25rem 1.5rem 2rem; min-width: 0; }
.ay-pick label { font-size: .85rem; display: inline-flex; gap: .35rem; align-items: center; }
.ay-pick select { padding: .2rem .4rem; font-size: .85rem; }
.ay-tag { font-size: .8rem; font-weight: 600; vertical-align: middle; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .1rem .6rem; }
.alert.warn { background: var(--warn-soft); border-color: #f0c36d; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* Panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.25rem; }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: .75rem; }
.narrow { max-width: 460px; }
.alert { padding: .65rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: #b7e1c7; }
.alert.err { background: var(--err-soft); color: var(--err); border-color: #f5c2bd; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: #c3d6f8; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; background: #e9ecf1; color: var(--ink); }
.topbar .badge { background: rgba(255,255,255,.2); color: #fff; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* KPI cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; color: var(--ink); }
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; margin: .15rem 0; }
.kpi-value.small { font-size: 1.05rem; }
.kpi-sub { font-size: .82rem; color: var(--muted); }

/* Buttons & inputs */
.btn { display: inline-block; padding: .42rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
       font: inherit; cursor: pointer; line-height: 1.3; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: .2rem .6rem; font-size: .85rem; }
.btn.block { display: block; width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }
.link.danger { color: var(--err); }
input, select, textarea { font: inherit; padding: .4rem .55rem; border: 1px solid #c8cfda; border-radius: 6px; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[disabled], select[disabled], textarea[disabled] { background: #f1f3f6; color: var(--muted); }
input.num { text-align: right; width: 8rem; }
input.short { width: 7rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.form .field, .form-grid .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1rem; }
.form-grid .field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9rem; }
.req { color: var(--err); }
.check { display: inline-flex; gap: .35rem; align-items: center; font-weight: 400 !important; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.card .table-wrap { border: 0; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: .45rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid thead th { background: #f7f9fc; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.grid tfoot th { background: #f7f9fc; }
.grid tbody tr:hover { background: #fafbfd; }
.grid .num { text-align: right; }
.grid td.actions, .grid th.actions { white-space: nowrap; text-align: right; }
.grid td.actions a, .grid td.actions form { margin-left: .5rem; }
.grid tr.warn td { background: var(--warn-soft); }
.grid td.fail { color: var(--err); font-weight: 600; }
.grid tr.cancelled td { color: var(--muted); text-decoration: line-through; }
.grid tr.cancelled td .badge { text-decoration: none; }
.grid td.details { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; max-width: 420px; word-break: break-all; }
.grid.att td:nth-child(n+4), .grid.att th:nth-child(n+4) { text-align: center; }
progress { width: 90px; height: .7rem; vertical-align: middle; accent-color: var(--brand); }

.timetable td { min-width: 120px; }
.timetable tr.today th, .timetable tr.today td { background: var(--brand-soft); }
.tt-cell { background: var(--brand-soft); border-left: 3px solid var(--brand); border-radius: 4px; padding: .25rem .4rem; margin-bottom: .25rem; }
.tt-cell.lab { background: var(--ok-soft); border-left-color: var(--ok); }
.occupant { padding: .1rem 0; }

.pager { display: flex; gap: .75rem; align-items: center; justify-content: flex-end; margin: .5rem 0 1rem; }
.pager .disabled { color: #b5bcc8; }
.tabs { display: flex; gap: .25rem; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; border-bottom: 2px solid transparent; color: var(--ink); }
.tabs a.active { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }

/* Login / install */
body.plain { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; width: 100%; max-width: 440px; box-shadow: 0 10px 30px rgba(20,40,80,.08); }
.box h1 { color: var(--brand); margin-bottom: .2rem; }

/* Print pages (receipt, report card) */
body.print-page { background: #fff; padding: 1.5rem; }
.print-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.receipt { max-width: 760px; margin: 0 auto 1.5rem; border: 1px solid #999; padding: 1.5rem 2rem; position: relative; }
.receipt header { text-align: center; border-bottom: 2px solid var(--ink); margin-bottom: 1rem; }
.receipt header h1 { margin: 0; font-size: 1.35rem; }
.receipt header p { margin: .25rem 0 .75rem; }
.receipt table.meta { width: 100%; margin-bottom: 1rem; border-collapse: collapse; }
.receipt table.meta th { text-align: left; width: 18%; font-weight: 600; padding: .2rem .4rem .2rem 0; }
.receipt table.meta td { padding: .2rem .4rem; }
.receipt footer { display: flex; justify-content: space-between; margin-top: 2.5rem; font-size: .85rem; color: var(--muted); gap: 1rem; }
.receipt.cancelled { border-color: var(--err); }
.stamp { color: var(--err); font-weight: 700; border: 2px solid var(--err); display: inline-block; padding: .3rem .8rem; transform: rotate(-2deg); }

@media (max-width: 860px) {
    .menu-toggle { display: block; }
    .sidebar { position: fixed; top: var(--topbar-h, 52px); left: 0; bottom: 0; height: auto; z-index: 9; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 12px rgba(0,0,0,.1); }
    .sidebar.open { transform: none; }
    .content { padding: 1rem; }
    .who { display: none; }
}
@media print {
    .no-print, .topbar, .sidebar, .footer, .print-bar { display: none !important; }
    body, body.print-page { background: #fff; padding: 0; }
    .receipt { border: 0; padding: 0; }
    a { color: inherit; }
}
