/* ==========================================================
   PCL Learning Center — purple school UI (light + dark)
   Khmer-first typography (Kantumruy Pro) + Nunito for Latin.
   ========================================================== */
:root {
  --bg: #eeebfc;
  --surface: #ffffff;
  --surface-2: #f5f3ff;
  --surface-3: #ebe7fe;
  --border: #e4e0f7;
  --text: #241c4f;
  --muted: #7b75a0;
  --primary: #6c5dd3;
  --primary-2: #5a4bc4;
  --primary-soft: #ece9ff;
  --on-primary: #ffffff;
  --sidebar-1: #7262de;
  --sidebar-2: #5444bf;
  --green: #22c27e;   --green-soft: #ddf8eb;
  --teal: #13b5c8;    --teal-soft: #d9f6fa;
  --red: #f0616a;     --red-soft: #ffe5e7;
  --orange: #ff9a3d;  --orange-soft: #fff0df;
  --amber: #e0a100;   --amber-soft: #fff6d6;
  --blue: #3d8bfd;    --blue-soft: #e1edff;
  --violet: #8b5cf6;  --violet-soft: #efe7ff;
  --shadow: 0 2px 6px rgba(56, 40, 160, .05), 0 10px 30px rgba(56, 40, 160, .07);
  --radius: 18px;
  --font: "Kantumruy Pro", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #120f26; --surface: #1c1838; --surface-2: #231e45; --surface-3: #2c2655; --border: #322b5f;
  --text: #ebe8ff; --muted: #9c95c9; --primary: #8c7ef0; --primary-2: #a497ff; --primary-soft: #2e2763; --on-primary: #fff;
  --sidebar-1: #2b2366; --sidebar-2: #1e184c;
  --green-soft: #133b2c; --teal-soft: #0f3640; --red-soft: #45182a; --orange-soft: #46290f; --amber-soft: #3e3208; --blue-soft: #14294d; --violet-soft: #2e1f55;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #120f26; --surface: #1c1838; --surface-2: #231e45; --surface-3: #2c2655; --border: #322b5f;
    --text: #ebe8ff; --muted: #9c95c9; --primary: #8c7ef0; --primary-2: #a497ff; --primary-soft: #2e2763; --on-primary: #fff;
    --sidebar-1: #2b2366; --sidebar-2: #1e184c;
    --green-soft: #133b2c; --teal-soft: #0f3640; --red-soft: #45182a; --orange-soft: #46290f; --amber-soft: #3e3208; --blue-soft: #14294d; --violet-soft: #2e1f55;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
.lang-km { line-height: 1.8; }
h1, h2, h3 { margin: 0; line-height: 1.5; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0 0 .6rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .86em; }
.text-ok { color: var(--green); }
.text-bad { color: var(--red); }
.hide { display: none; }
.icon { flex-shrink: 0; display: block; }
em { font-style: normal; color: var(--muted); }

/* ── Colour palette for avatars / slots / series ───────── */
.c-1 { --c: #6c5dd3; --cs: #ece9ff; } .c-2 { --c: #13b5c8; --cs: #d9f6fa; }
.c-3 { --c: #ff8a3d; --cs: #fff0df; } .c-4 { --c: #22c27e; --cs: #ddf8eb; }
.c-5 { --c: #f0616a; --cs: #ffe5e7; } .c-6 { --c: #3d8bfd; --cs: #e1edff; }
.c-7 { --c: #d946ef; --cs: #fae8ff; } .c-8 { --c: #e0a100; --cs: #fff6d6; }

/* ── Brand ─────────────────────────────── */
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none !important; }
.brand__mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #fff; flex-shrink: 0; }
.brand__text { display: grid; line-height: 1.15; font-family: "Nunito", var(--font); }
.brand__text strong { font-size: 1.25rem; font-weight: 800; letter-spacing: .06em; }
.brand__text small { font-size: .72rem; opacity: .8; letter-spacing: .04em; }
.brand--dark { color: var(--text); }
.brand--dark .brand__mark { background: var(--primary); color: #fff; }

/* ── Sidebar ───────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .6rem; padding: 1.2rem 1rem 1rem;
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2)); color: #fff;
  border-radius: 0 28px 28px 0; box-shadow: 6px 0 30px rgba(84, 68, 191, .18);
}
.sidebar .brand { padding: 0 .35rem .5rem; }
.sidebar__nav { display: grid; gap: 2px; }
.sidebar__group { margin: .45rem .75rem .1rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; font-weight: 700; }
.sidebar__link {
  display: flex; align-items: center; gap: .75rem; padding: .4rem .8rem; border-radius: 12px;
  color: rgba(255,255,255,.88); font-size: .92rem; font-weight: 600; text-decoration: none !important; transition: background .15s;
}
.sidebar__link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar__link.is-active { background: #fff; color: var(--sidebar-2); box-shadow: 0 6px 16px rgba(0,0,0,.12); }
:root[data-theme="dark"] .sidebar__link.is-active { background: var(--primary); color: #fff; }
.sidebar__user {
  margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .7rem; border-radius: 16px;
  background: rgba(255,255,255,.12);
}
.sidebar__user form { margin: 0; }
.sidebar__who { display: grid; flex: 1; min-width: 0; line-height: 1.35; color: #fff; text-decoration: none !important; }
.sidebar__who strong { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__who small { font-size: .74rem; opacity: .75; }
.sidebar__logout { background: none; border: 0; color: #fff; opacity: .8; cursor: pointer; padding: .3rem; border-radius: 8px; }
.sidebar__logout:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ── Avatars ───────────────────────────── */
.avatar {
  --c: var(--primary); --cs: var(--primary-soft);
  width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--c); color: #fff; font-weight: 700; font-size: .95rem; text-decoration: none !important; border: 2px solid rgba(255,255,255,.6);
}
.avatar--sm { width: 34px; height: 34px; font-size: .85rem; border: 0; background: var(--cs); color: var(--c); }
.avatar--square { border-radius: 10px; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.5rem; }
:root[data-theme="dark"] .avatar--sm { background: var(--c); color: #fff; }
.person { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none !important; min-width: 0; }
.person > span:last-child { display: grid; line-height: 1.35; min-width: 0; }
.person strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person small { color: var(--muted); font-size: .78rem; }
a.person:hover strong { color: var(--primary); }

/* ── Main column ───────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 1.75rem 2rem; }
.topline { display: flex; align-items: center; gap: .6rem; padding: 1rem 0 .25rem; }
.topline .topline__menu { display: none; }
.topline__school { color: var(--muted); font-weight: 600; font-size: .88rem; }
.topline__spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--primary); }

.lang-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.lang-switch__item { padding: .15rem .8rem; border-radius: 999px; color: var(--muted); font-size: .84rem; font-weight: 600; text-decoration: none !important; }
.lang-switch__item.is-active { background: var(--primary); color: #fff; }

.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: .9rem 1.25rem; padding: .75rem 0 1.25rem; }
.page-head h1 { color: var(--text); }
.page-head__actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.back-link { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary); font-size: 1.1rem; text-decoration: none !important; }
.head-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .9rem; font-size: .86rem; color: var(--muted); }
.head-stat b { color: var(--text); }

/* FAB buttons like the reference (green +, soft refresh) */
.fab { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--green); color: #fff; box-shadow: 0 8px 18px rgba(34, 194, 126, .35); cursor: pointer; text-decoration: none !important; border: 0; list-style: none; }
.fab::-webkit-details-marker { display: none; }
.fab:hover { filter: brightness(1.06); }
.fab--soft { background: var(--primary); box-shadow: 0 8px 18px rgba(108, 93, 211, .3); }
.fab--sm { width: 34px; height: 34px; }

/* Pill tabs (purple capsule) */
.tabs { display: inline-flex; gap: 3px; padding: 4px; border-radius: 999px; background: linear-gradient(90deg, #8676ec, #7262de); box-shadow: 0 6px 16px rgba(108, 93, 211, .25); flex-wrap: wrap; }
.tabs__item { padding: .32rem 1rem; border-radius: 999px; color: rgba(255,255,255,.9); font-size: .86rem; font-weight: 600; text-decoration: none !important; white-space: nowrap; }
.tabs__item:hover { background: rgba(255,255,255,.14); }
.tabs__item.is-active { background: #fff; color: var(--primary-2); }

.content { display: grid; gap: 1.25rem; min-width: 0; }

/* ── Toasts & alerts ───────────────────── */
.toast { position: fixed; top: 1rem; right: 1rem; z-index: 50; display: flex; align-items: center; gap: .6rem; max-width: 420px; padding: .8rem 1.1rem; border-radius: 14px; background: var(--surface); box-shadow: 0 12px 40px rgba(36, 28, 79, .2); font-weight: 600; font-size: .92rem; transition: opacity .4s, transform .4s; }
.toast--success { border-left: 4px solid var(--green); } .toast--success .icon { color: var(--green); }
.toast--error { border-left: 4px solid var(--red); } .toast--error .icon { color: var(--red); }
.toast.is-hiding { opacity: 0; transform: translateY(-10px); }
.alert { border-radius: 12px; padding: .7rem 1rem; margin: 0 0 1rem; font-size: .9rem; }
.alert p { margin: 0; }
.alert--error   { background: var(--red-soft); color: var(--red); }
.alert--success { background: var(--green-soft); color: var(--green); }
.alert--info    { background: var(--primary-soft); color: var(--primary); }
.alert--warn    { background: var(--amber-soft); color: var(--amber); }

/* ── Cards & panels ────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid transparent; }
:root[data-theme="dark"] .card { border-color: var(--border); }
.panel { padding: 1.15rem 1.25rem; display: flex; flex-direction: column; min-width: 0; }
.panel__head { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.panel__head h2 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.panel__meta { color: var(--muted); font-size: .84rem; }
.panel__head > :last-child:not(h2) { margin-left: auto; }
.panel__link-inline { font-size: .85rem; font-weight: 600; }
.stack { display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
.span-2 { grid-column: span 2; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; display: grid; justify-items: center; gap: .5rem; margin: 0; }
.panel .empty { border: 1.5px dashed var(--border); border-radius: 14px; padding: 1.4rem 1rem; flex: 1; place-content: center; }
.empty--big { padding: 3rem 1rem; }
.empty__code { font-size: 3.5rem; font-weight: 800; color: var(--primary); margin: 0; }

/* ── Badges, chips, bars ───────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; text-decoration: none !important; line-height: 1.7; }
.badge--ok     { background: var(--green-soft);  color: var(--green); }
.badge--warn   { background: var(--orange-soft); color: var(--orange); }
.badge--info   { background: var(--teal-soft);   color: var(--teal); }
.badge--red, .badge--fail { background: var(--red-soft); color: var(--red); }
.badge--violet { background: var(--violet-soft); color: var(--violet); }
.badge--muted  { background: var(--surface-3);   color: var(--muted); }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; padding: 0 .5rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; font-weight: 800; }
.chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.chip { padding: .02rem .5rem; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #9d8cff); }
.bar__fill.is-high { background: linear-gradient(90deg, var(--orange), #ffc06e); }
.bar__fill.is-low { background: linear-gradient(90deg, var(--red), #ff9aa0); }
.fill { display: grid; gap: .25rem; min-width: 90px; font-size: .84rem; font-weight: 700; }
.rate-cell { min-width: 140px; }
.rate-cell .bar { display: inline-block; width: 80px; vertical-align: middle; margin-right: .5rem; }
.rate-cell b { font-size: .86rem; }
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}
.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}
.w-70{width:70%}.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}

/* ── Buttons ───────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .6rem 1.2rem; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none !important; line-height: 1.5; white-space: nowrap; list-style: none; }
.btn::-webkit-details-marker { display: none; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(108, 93, 211, .28); }
.btn--primary:hover { background: var(--primary-2); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn--danger { background: var(--red-soft); color: var(--red); }
.btn--sm { padding: .38rem .85rem; font-size: .85rem; border-radius: 10px; }
.btn--lg { padding: .78rem 1.2rem; font-size: 1rem; }
.btn--block { width: 100%; }
.btn.is-loading, .btn[disabled] { opacity: .6; pointer-events: none; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.inline { display: inline; margin: 0; }

/* Square action buttons (green edit, teal view, red delete) */
.acts { display: inline-flex; gap: .35rem; justify-content: flex-end; }
.act { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; color: #fff; border: 0; cursor: pointer; text-decoration: none !important; transition: transform .12s, filter .12s; }
.act:hover { transform: translateY(-1px); filter: brightness(1.07); }
.act--green { background: var(--green); } .act--teal { background: var(--teal); } .act--red { background: var(--red); } .act--violet { background: var(--primary); }

/* ── Toolbar / search ──────────────────── */
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: 1rem 1.1rem; }
.toolbar--card { padding: .9rem 1.1rem; }
.toolbar select, .toolbar input[type="date"] { padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; max-width: 100%; }
.toolbar__count { margin-left: auto; color: var(--muted); font-size: .85rem; font-weight: 600; }
.search { display: flex; align-items: center; gap: .5rem; flex: 1 1 240px; max-width: 360px; padding: .48rem .85rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; width: 100%; min-width: 0; }
.search:focus-within { border-color: var(--primary); }
.search__clear { color: var(--muted); display: grid; }

/* ── Tables (purple header like the reference) ── */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { text-align: left; padding: .7rem .75rem; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; background: var(--primary); color: #fff; }
.lang-km .table th { text-transform: none; letter-spacing: 0; font-size: .82rem; }
.table th a { color: #fff; }
.table thead th:first-child { border-top-left-radius: 14px; }
.table thead th:last-child { border-top-right-radius: 14px; }
.table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: var(--surface-2); }
.table tbody tr:hover td { background: var(--primary-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.table .narrow { width: 44px; }
.table .actions-col { width: 1%; text-align: right; }
.table-card .table-wrap { padding: 0 1rem; }
.table--plain th { background: transparent; color: var(--muted); border-bottom: 1px solid var(--border); text-transform: none; }
.table--plain tbody tr:nth-child(even) td { background: transparent; }
.table tfoot th, .table tfoot td { background: transparent; color: var(--text); text-transform: none; font-size: .92rem; border-bottom: 1px solid var(--border); }

.pager { display: flex; align-items: center; gap: .35rem; padding: 1rem 1.1rem; flex-wrap: wrap; }
.pager__btn { min-width: 34px; height: 34px; padding: 0 .55rem; border-radius: 10px; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .88rem; text-decoration: none !important; }
.pager__btn:hover { background: var(--primary-soft); color: var(--primary); }
.pager__btn.is-active { background: var(--primary); color: #fff; }
.pager__btn.is-disabled { opacity: .4; pointer-events: none; }
.pager__gap { color: var(--muted); padding: 0 .2rem; }
.pager__info { margin-left: auto; color: var(--muted); font-size: .85rem; }

/* ── Forms ─────────────────────────────── */
.form-card { padding: 1.5rem; max-width: 980px; }
.form-card--narrow { max-width: 640px; }
.form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem 1.1rem; margin-bottom: 1rem; }
.form__section { font-size: .95rem; color: var(--primary); padding: .25rem 0 .55rem; margin: .5rem 0 1rem; border-bottom: 1.5px dashed var(--border); }
.field { display: grid; gap: .3rem; font-size: .88rem; font-weight: 600; align-content: start; grid-column: span 3; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field--third { grid-column: span 2; }
.field--inline { grid-column: auto; display: flex; align-items: center; gap: .5rem; }
.field input, .field select, .field textarea, .input-group, .input-sm {
  width: 100%; padding: .6rem .85rem; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; line-height: 1.55;
}
.field textarea { resize: vertical; min-height: 84px; }
.field select[multiple] { padding: .4rem; }
.field input:focus, .field select:focus, .field textarea:focus, .input-sm:focus, .input-group:focus-within { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--red); }
.field__error { color: var(--red); font-size: .8rem; font-weight: 600; }
.req { color: var(--red); font-weight: 700; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 500; margin: 0; }
.hint--ok { color: var(--green); }
.input-sm { padding: .38rem .65rem; font-size: .88rem; border-radius: 10px; }
.input-score { width: 92px; text-align: center; font-weight: 700; }
.input-group { display: flex; padding: 0; overflow: hidden; }
.input-group input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 0; }
.input-group__btn { border: 0; background: transparent; color: var(--primary); padding: 0 .9rem; font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding-top: .5rem; }
.check { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2); font-size: .88rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .3rem; accent-color: var(--primary); flex-shrink: 0; }
.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3-1 { grid-template-columns: 3fr 1fr; }

/* Attendance segmented radios */
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg__opt { position: relative; cursor: pointer; }
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt span { display: inline-block; padding: .28rem .7rem; border-radius: 9px; border: 1.5px solid var(--border); font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface); transition: all .12s; white-space: nowrap; }
.seg__opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg__opt--ok input:checked + span   { background: var(--green); border-color: var(--green); color: #fff; }
.seg__opt--warn input:checked + span { background: var(--orange); border-color: var(--orange); color: #fff; }
.seg__opt--red input:checked + span  { background: var(--red); border-color: var(--red); color: #fff; }
.seg__opt--info input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }

/* Popover (details/summary, no JS needed) */
.popover { position: relative; }
.popover > summary { list-style: none; }
.popover__body { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px; padding: 1rem; display: grid; gap: .75rem; background: var(--surface); border-radius: 16px; box-shadow: 0 18px 50px rgba(36, 28, 79, .25); border: 1px solid var(--border); }
.popover--wide .popover__body { width: 380px; }
.popover__body .field { grid-column: auto; }

/* ── Profile pages ─────────────────────── */
.profile-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.profile-card { position: relative; padding: 1.5rem 1.25rem; display: grid; justify-items: center; text-align: center; gap: .4rem; }
.profile-card__edit { position: absolute; top: 1rem; right: 1rem; }
.profile-card__avatar { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 2.3rem; font-weight: 800; color: #fff; background: var(--c); box-shadow: 0 0 0 6px var(--cs); margin-bottom: .5rem; }
.profile-card h2 { font-size: 1.2rem; }
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.info-list { width: 100%; margin: .9rem 0 0; display: grid; gap: 0; text-align: left; }
.info-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .48rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 600; text-align: right; }
.note { background: var(--surface-2); border-radius: 12px; padding: .7rem .9rem; font-size: .88rem; width: 100%; text-align: left; margin-top: .75rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 0; font-size: .9rem; }
.rows li + li { border-top: 1px solid var(--border); }
.rows li > span:first-child { display: grid; min-width: 0; line-height: 1.45; }
.rows small { font-size: .78rem; }

/* ── Group page (reference screen 2) ───── */
.group-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.group-card { position: relative; padding: 1.6rem 1.3rem 1.3rem; display: grid; justify-items: center; text-align: center; gap: .45rem; color: #fff; background: linear-gradient(160deg, #7a6ae3, #5847c2); }
.group-card h2 { font-size: 1.15rem; }
.group-card__edit { position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #fff; }
.group-card__ring { padding: 7px; border-radius: 50%; background: conic-gradient(#b8f5d9, #8fe0ff, #c8b9ff, #b8f5d9); margin-bottom: .4rem; }
.group-card__avatar { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; background: var(--c); color: #fff; border: 5px solid #5847c2; }
.group-card .badge { background: rgba(255,255,255,.95); }
.info-list--light > div { border-bottom-color: rgba(255,255,255,.2); }
.info-list--light dt { color: rgba(255,255,255,.75); }
.group-card__stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: 100%; margin-top: .8rem; }
.group-card__stats div { background: rgba(255,255,255,.14); border-radius: 14px; padding: .6rem; display: grid; }
.group-card__stats strong { font-size: 1.25rem; }
.group-card__stats small { opacity: .8; font-size: .76rem; }

.month-nav { display: inline-flex; align-items: center; gap: .5rem; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .4rem; }
.mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-style: normal; font-weight: 800; font-size: .74rem; }
.mark--present { background: var(--green-soft); color: var(--green); }
.mark--late    { background: var(--orange-soft); color: var(--orange); }
.mark--absent  { background: var(--red-soft); color: var(--red); }
.mark--excused { background: var(--teal-soft); color: var(--teal); }
.mark--none    { color: var(--border); }
.register th, .register td { padding: .4rem .3rem; text-align: center; }
.register .register__name { text-align: left; min-width: 150px; position: sticky; left: 0; z-index: 1; background: var(--surface); white-space: nowrap; }
.register thead .register__name { background: var(--primary); }
.register tbody tr:nth-child(even) .register__name { background: var(--surface-2); }
.register__day { min-width: 34px; }
.register__day small { display: block; font-size: .65rem; opacity: .8; }
.register__day a { color: #fff; }

/* Session cards (attendance home) */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; }
.session { display: grid; gap: .2rem; padding: 1rem; border-radius: 16px; background: var(--surface-2); border: 1.5px solid var(--border); color: inherit; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.session:hover { border-color: var(--primary); transform: translateY(-2px); }
.session__time { display: inline-flex; align-items: center; gap: .35rem; color: var(--primary); font-weight: 800; font-size: .84rem; }
.session__name { font-size: 1rem; }
.session__state { margin-top: .4rem; }

/* ── Timetable (reference screen 4 style cards) ── */
.week { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.week__day { background: var(--surface); border-radius: var(--radius); padding: .9rem; box-shadow: var(--shadow); display: grid; gap: .55rem; align-content: start; }
.week__day.is-today { outline: 2.5px solid var(--primary); }
.week__head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding-bottom: .4rem; border-bottom: 1.5px dashed var(--border); }
.week__empty { color: var(--muted); text-align: center; margin: .5rem 0; }
.slot { display: grid; gap: .05rem; padding: .6rem .7rem; border-radius: 12px; background: var(--cs); border-left: 4px solid var(--c); color: var(--text); text-decoration: none !important; font-size: .85rem; transition: transform .12s; }
.slot:hover { transform: translateX(2px); }
.slot b { color: var(--c); font-size: .82rem; }
.slot span { font-weight: 700; }
.slot small { color: var(--muted); font-size: .76rem; }
:root[data-theme="dark"] .slot { background: var(--surface-2); }
.week-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.week-mini__day { display: grid; gap: .45rem; align-content: start; }
.week-mini__day h3 { font-size: .85rem; color: var(--muted); }

/* ── Ranking ───────────────────────────── */
.rank { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 800; font-size: .85rem; background: var(--surface-3); color: var(--muted); }
.rank--1 { background: linear-gradient(135deg, #ffd25e, #f5a623); color: #fff; }
.rank--2 { background: linear-gradient(135deg, #d9dde8, #a9b0c2); color: #fff; }
.rank--3 { background: linear-gradient(135deg, #f3b38a, #d97b3f); color: #fff; }
.ranking tr.is-top td { font-weight: 600; }
.points { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .6rem; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-weight: 800; white-space: nowrap; }

/* ── Invoice ───────────────────────────── */
.invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.invoice { position: relative; padding: 2rem; overflow: hidden; }
.invoice__head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: 1.25rem; border-bottom: 2px solid var(--primary-soft); }
.brand--doc { color: var(--text); align-items: flex-start; }
.brand--doc .brand__mark { background: var(--primary); }
.brand--doc > span:last-child { display: grid; line-height: 1.45; }
.brand--doc small { color: var(--muted); font-size: .8rem; }
.invoice__title { text-align: right; display: grid; justify-items: end; gap: .2rem; }
.invoice__title h2 { color: var(--primary); font-size: 1.2rem; }
.invoice__title p { margin: 0; }
.invoice__meta { display: grid; grid-template-columns: 1fr 260px; gap: 1.5rem; padding: 1.25rem 0; }
.invoice__meta h3 { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.invoice__meta p { margin: 0 0 .15rem; }
.invoice__meta .info-list { margin: 0; }
.invoice__lines tfoot th, .invoice__lines tfoot td { padding: .55rem .75rem; }
.invoice__balance th { color: var(--primary) !important; font-size: 1.05rem !important; background: var(--primary-soft) !important; }
.invoice__sub { margin: 1.5rem 0 .5rem; }
.invoice__thanks { text-align: center; color: var(--muted); margin: 1.75rem 0 0; font-size: .9rem; }
.stamp { display: block; width: fit-content; margin: 1.25rem 0 0 auto; transform: rotate(-8deg); border: 4px solid var(--green); color: var(--green); border-radius: 12px; padding: .2rem 1rem; font-size: 1.6rem; font-weight: 800; opacity: .3; pointer-events: none; text-transform: uppercase; }
.stamp--void { border-color: var(--red); color: var(--red); }

/* ── Dashboard ─────────────────────────── */
.greeting { font-size: 1.05rem; font-weight: 700; margin: -.5rem 0 0; }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis--5 .kpi__value { font-size: 1.35rem; }
.kpi { padding: 1.1rem; display: flex; gap: .9rem; align-items: flex-start; }
.kpi > div { min-width: 0; }
.kpi__icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.kpi__icon--violet { background: var(--violet-soft); color: var(--violet); }
.kpi__icon--teal   { background: var(--teal-soft);   color: var(--teal); }
.kpi__icon--green  { background: var(--green-soft);  color: var(--green); }
.kpi__icon--orange { background: var(--orange-soft); color: var(--orange); }
.kpi__icon--red    { background: var(--red-soft);    color: var(--red); }
.kpi__label { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi__value { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.35; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__sub { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 600; }
.dash-row { display: grid; gap: 1.25rem; }
.dash-row--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-row--1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dash-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tone-att { --tone: var(--primary); }
.tone-bar { --tone: var(--primary); }
.ser-1 { --tone: #6c5dd3; } .ser-2 { --tone: #13b5c8; } .ser-3 { --tone: #ff9a3d; } .ser-4 { --tone: #22c27e; } .ser-5 { --tone: #f0616a; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--tone); flex-shrink: 0; }
.donut-wrap { display: grid; justify-items: center; align-content: center; gap: 1.1rem; flex: 1; }
.donut-wrap .donut { max-width: 190px; }
.donut { width: 100%; height: auto; display: block; }
.donut__track { stroke: var(--surface-3); }
.donut__seg { stroke: var(--tone); }
.donut__value { fill: var(--text); font-size: 18px; font-weight: 800; font-family: var(--font); }
.donut__label { fill: var(--muted); font-size: 8px; font-family: var(--font); }
.legend--stack { display: grid; gap: .45rem; width: 100%; }
.legend--stack li { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; }
.legend--stack span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.legend--stack strong { color: var(--text); }
.linechart, .barchart { width: 100%; height: auto; display: block; margin: auto 0; }
.linechart__grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.linechart__axis { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.linechart__line { stroke: var(--tone); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.linechart__area { fill: var(--tone); opacity: .1; }
.linechart__dot { fill: var(--surface); stroke: var(--tone); stroke-width: 3; }
.barchart__bar { fill: var(--primary-soft); }
.barchart__bar.is-current { fill: var(--primary); }
:root[data-theme="dark"] .barchart__bar { fill: var(--surface-3); }
:root[data-theme="dark"] .barchart__bar.is-current { fill: var(--primary); }
.barchart__value { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.timeline li { display: flex; align-items: center; gap: .85rem; padding: .55rem .7rem; border-radius: 14px; background: var(--surface-2); }
.timeline__time { display: grid; text-align: center; min-width: 52px; font-weight: 800; color: var(--primary); font-size: .9rem; line-height: 1.3; }
.timeline__time small { color: var(--muted); font-weight: 600; font-size: .74rem; }
.timeline__body { display: grid; flex: 1; min-width: 0; line-height: 1.4; }
.timeline__body a { color: var(--text); }

/* ==========================================================
   Installer & login
   ========================================================== */
.page-center { min-height: 100vh; display: flex; justify-content: center; padding: 2rem 16px; }
.installer { width: 100%; max-width: 700px; }
.installer__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.installer__body { padding: 2rem; }
.installer__body .form { gap: 1rem; }
.installer__body .field { grid-column: auto; }
.installer__foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 1rem; }
.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; padding: 0; margin: 0 0 1.25rem; }
.stepper__item { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; color: var(--muted); font-size: .8rem; }
.stepper__item:not(:last-child)::after { content: ""; position: absolute; top: 17px; left: calc(50% + 24px); right: calc(-50% + 24px); height: 3px; border-radius: 3px; background: var(--border); }
.stepper__item.is-done:not(:last-child)::after { background: var(--primary); }
.stepper__dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border); font-weight: 800; }
.stepper__item.is-active { color: var(--text); font-weight: 700; }
.stepper__item.is-active .stepper__dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.stepper__item.is-done .stepper__dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.checklist { list-style: none; padding: 0; margin: 1.25rem 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.checklist__item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1rem; font-size: .9rem; }
.checklist__item + .checklist__item { border-top: 1px solid var(--border); }
.checklist__item.is-fail { background: var(--red-soft); }
.result { text-align: center; display: grid; justify-items: center; gap: .5rem; }
.result__icon { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; background: var(--green-soft); color: var(--green); }
.result__icon--warn { background: var(--amber-soft); }
.result .alert { width: 100%; text-align: left; }
.code-pill { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: .25rem .8rem; border-radius: 8px; }

.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth__hero { position: relative; overflow: hidden; color: #fff; padding: 2.5rem; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(120% 90% at 0% 0%, #8a7bf0 0%, #6c5dd3 45%, #3f2fa6 100%); }
.auth__hero::before, .auth__hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); }
.auth__hero::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth__hero::after { width: 520px; height: 520px; right: -200px; bottom: -260px; }
.auth__pitch { position: relative; z-index: 1; max-width: 470px; }
.auth__pitch h2 { font-size: 2rem; line-height: 1.45; margin-bottom: .75rem; }
.auth__pitch p { opacity: .88; }
.auth__features { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .55rem; }
.auth__features li::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: .6rem; border-radius: 50%; background: #22c27e; font-size: .75rem; font-weight: 800; }
.auth__copy { position: relative; z-index: 1; opacity: .7; }
.mock { margin-top: 1.5rem; padding: .9rem; border-radius: 18px; display: grid; gap: .55rem; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }
.mock__row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 12px; background: rgba(255,255,255,.95); color: #241c4f; font-size: .88rem; }
.mock__row em { color: #7b75a0; font-weight: 700; }
.mock__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.mock__pill { font-style: normal; padding: .05rem .55rem; border-radius: 999px; background: #ddf8eb; color: #16a066; font-weight: 800; font-size: .78rem; }
.auth__panel { display: flex; flex-direction: column; padding: 1.5rem 16px; background: var(--surface); }
.auth__top { display: flex; justify-content: flex-end; }
.auth__form-wrap { width: 100%; max-width: 400px; margin: auto; padding: 2rem 0; }
.auth__form-wrap h1 { font-size: 1.8rem; }
.auth__form-wrap .form { margin-top: 1.5rem; }
.auth .field { grid-column: auto; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 1280px) {
  .kpis--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .kpis, .kpis--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-row--2-1, .dash-row--1-1, .dash-row--3, .group-grid, .profile-grid, .invoice-layout { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__hero { display: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-105%); transition: transform .22s; }
  .sidebar.is-open { transform: none; }
  .topline .topline__menu { display: inline-grid; }
  .main { padding: 0 16px 1.5rem; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field, .field--third { grid-column: span 1; }
  .field--full { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .form-grid, .grid--2, .grid--3-1 { grid-template-columns: minmax(0, 1fr); }
  .field, .field--third { grid-column: 1 / -1; }
  .hide-sm { display: none; }
  .kpis, .kpis--5 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .7rem; }
  .kpi { padding: .85rem; flex-direction: column; gap: .5rem; }
  .kpi__icon { width: 38px; height: 38px; }
  .kpi__value { font-size: 1.2rem; }
  h1 { font-size: 1.3rem; }
  .installer__body, .form-card, .invoice { padding: 1.15rem; }
  .invoice__meta { grid-template-columns: 1fr; }
  .stepper__label { font-size: .7rem; }
  .topline__school { display: none; }
  .popover__body, .popover--wide .popover__body { position: fixed; left: 16px; right: 16px; top: 80px; width: auto; }
  .table-card .table-wrap { padding: 0 .4rem; }
  .att-table .narrow, .att-table .avatar, .att-table .person small { display: none; }
  .att-table .person strong { white-space: normal; }
  .att-table td { padding: .55rem .4rem; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .seg__opt span { display: block; text-align: center; padding: .3rem .4rem; }
  .toolbar__count { margin-left: 0; width: 100%; }
  .search { max-width: none; }
}

/* ── Print (invoices) ──────────────────── */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topline, .page-head, .no-print, .toast { display: none !important; }
  .main { padding: 0; }
  .invoice-layout { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: 0; }
  .invoice { padding: 0; }
  .table th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
