/* SchoolMS stylesheet — "calm precision".
   Mobile first. Wide-screen container rules live in one place (section "Layout").
   Campuses may override --primary / --accent / --font from the layout; every tint below is derived from them with color-mix(). */

/* ---------- Font (self-hosted Inter, served from /vendor/fonts; falls back to system fonts) ---------- */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/vendor/fonts/inter-latin-wght-normal.woff2) format("woff2-variations"), url(/vendor/fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/vendor/fonts/inter-latin-ext-wght-normal.woff2) format("woff2-variations"), url(/vendor/fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  --primary: #5b5bd6;
  --accent: #8e4ec6;
  --font: "Inter Variable", "Inter", "Noto Naskh Arabic", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ebebee;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #6b6b74;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --link: var(--primary);
  --on-primary: #ffffff;

  --ok: #15803d;
  --warn: #975a00;
  --bad: #dc2626;
  --info: #0369a1;
  --ok-bg: color-mix(in srgb, var(--ok) 10%, var(--surface));
  --warn-bg: color-mix(in srgb, var(--warn) 11%, var(--surface));
  --bad-bg: color-mix(in srgb, var(--bad) 9%, var(--surface));
  --info-bg: color-mix(in srgb, var(--info) 10%, var(--surface));

  --tint: color-mix(in srgb, var(--primary) 9%, transparent);
  --tint-strong: color-mix(in srgb, var(--primary) 15%, transparent);
  --ring: color-mix(in srgb, var(--primary) 30%, transparent);

  --shadow-xs: 0 1px 2px rgb(16 16 24 / .05);
  --shadow-sm: 0 1px 2px rgb(16 16 24 / .04), 0 1px 3px rgb(16 16 24 / .04);
  --shadow-md: 0 2px 4px rgb(16 16 24 / .04), 0 8px 24px -6px rgb(16 16 24 / .10);
  --shadow-lg: 0 4px 8px rgb(16 16 24 / .04), 0 16px 48px -8px rgb(16 16 24 / .18);

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --topbar: 56px;
  --sidebar: 252px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b; --surface: #111113; --surface-2: #18181b; --surface-3: #232327;
    --text: #fafafa; --text-2: #d4d4d8; --muted: #a1a1aa; --border: #26262b; --border-strong: #34343a;
    --link: color-mix(in srgb, var(--primary) 55%, #ffffff);
    --ok: #4ade80; --warn: #facc15; --bad: #f87171; --info: #38bdf8;
    --ok-bg: color-mix(in srgb, var(--ok) 12%, var(--surface)); --warn-bg: color-mix(in srgb, var(--warn) 11%, var(--surface));
    --bad-bg: color-mix(in srgb, var(--bad) 12%, var(--surface)); --info-bg: color-mix(in srgb, var(--info) 12%, var(--surface));
    --tint: color-mix(in srgb, var(--primary) 18%, transparent); --tint-strong: color-mix(in srgb, var(--primary) 26%, transparent);
    --ring: color-mix(in srgb, var(--primary) 45%, transparent);
    --shadow-xs: 0 1px 2px rgb(0 0 0 / .4); --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-md: 0 0 0 1px rgb(255 255 255 / .04), 0 10px 30px -8px rgb(0 0 0 / .7);
    --shadow-lg: 0 0 0 1px rgb(255 255 255 / .05), 0 20px 50px -10px rgb(0 0 0 / .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b; --surface: #111113; --surface-2: #18181b; --surface-3: #232327;
  --text: #fafafa; --text-2: #d4d4d8; --muted: #a1a1aa; --border: #26262b; --border-strong: #34343a;
  --link: color-mix(in srgb, var(--primary) 55%, #ffffff);
  --ok: #4ade80; --warn: #facc15; --bad: #f87171; --info: #38bdf8;
  --ok-bg: color-mix(in srgb, var(--ok) 12%, var(--surface)); --warn-bg: color-mix(in srgb, var(--warn) 11%, var(--surface));
  --bad-bg: color-mix(in srgb, var(--bad) 12%, var(--surface)); --info-bg: color-mix(in srgb, var(--info) 12%, var(--surface));
  --tint: color-mix(in srgb, var(--primary) 18%, transparent); --tint-strong: color-mix(in srgb, var(--primary) 26%, transparent);
  --ring: color-mix(in srgb, var(--primary) 45%, transparent);
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .4); --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 0 0 1px rgb(255 255 255 / .04), 0 10px 30px -8px rgb(0 0 0 / .7);
  --shadow-lg: 0 0 0 1px rgb(255 255 255 / .05), 0 20px 50px -10px rgb(0 0 0 / .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg);
  font-feature-settings: "cv11", "ss03"; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--tint-strong); }
a { color: var(--link); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; letter-spacing: -.022em; margin: 0 0 .9rem; }
h2 { font-size: 1.0625rem; letter-spacing: -.012em; margin: 1.75rem 0 .75rem; }
h3 { font-size: .9375rem; letter-spacing: -.006em; margin: 1.25rem 0 .5rem; }
h4 { font-size: .875rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
ul, ol { padding-inline-start: 1.25rem; }
li { margin: .15rem 0; }
b, strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.right { text-align: end; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
code, .mono, kbd, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .05em .35em; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
img { max-width: 100%; }
.i { flex: none; display: inline-block; vertical-align: middle; }
[dir="rtl"] .i.flip, [dir="rtl"] .crumbs .sep { transform: scaleX(-1); }
.skiplink { position: absolute; inset-inline-start: 8px; top: 8px; transform: translateY(-200%); z-index: 100; background: var(--surface); color: var(--text); padding: .5rem .8rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.skiplink:focus { transform: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .5rem;
  height: var(--topbar); padding: 0 12px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border); color: var(--text);
}
.brand {
  display: inline-flex; align-items: center; gap: .6rem; min-width: 0; color: var(--text);
  font-weight: 600; font-size: .9375rem; letter-spacing: -.01em; padding: .25rem .35rem; border-radius: var(--radius-sm);
}
.brand:hover { text-decoration: none; background: var(--surface-2); }
.brandname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand { flex: 0 1 auto; }
.brandmark {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 85%, #fff) 0%, var(--primary) 45%, var(--accent) 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), inset 0 -1px 0 rgb(0 0 0 / .12), 0 1px 2px color-mix(in srgb, var(--primary) 40%, transparent), 0 4px 12px -2px color-mix(in srgb, var(--primary) 45%, transparent);
}
.brand .logo { height: 30px; width: auto; max-width: 88px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; border: 1px solid var(--border); }
.spacer { flex: 1; }
.navtoggle { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

.iconbtn {
  position: relative; flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.iconbtn:active { background: var(--surface-3); }
.burger { margin-inline-end: -.15rem; }

.themetoggle .i-sun { display: none; }
:root[data-theme="dark"] .themetoggle .i-sun { display: inline-block; }
:root[data-theme="dark"] .themetoggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .themetoggle .i-sun { display: inline-block; }
  :root:not([data-theme="light"]) .themetoggle .i-moon { display: none; }
}

.campus-switch { display: none; min-width: 0; }
.campus-switch select {
  height: 32px; min-height: 32px; width: auto; max-width: 220px; border-radius: 999px; font-size: .8125rem; font-weight: 500;
  background-color: var(--surface-2); border-color: var(--border); padding-inline: .85rem 1.9rem; box-shadow: none;
}
.campus-switch select:hover { background-color: var(--surface-3); }

.cmdk {
  display: none; align-items: center; gap: .5rem; height: 34px; width: min(340px, 30vw); margin-inline-start: .75rem;
  padding: 0 .4rem 0 .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.cmdk:hover { border-color: var(--border-strong); }
.cmdk:focus-within { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.cmdk input { border: 0; background: transparent; min-height: 0; height: 100%; padding: 0; box-shadow: none; font-size: .8125rem; flex: 1; min-width: 0; }
.cmdk input:focus { box-shadow: none; outline: none; }
.cmdk input::-webkit-search-cancel-button { display: none; }
kbd {
  display: inline-flex; align-items: center; height: 20px; padding: 0 .4rem; border-radius: 5px; font-size: .6875rem; font-weight: 500;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border); white-space: nowrap; font-family: var(--font);
}

.topicon .countslot { position: absolute; top: 3px; inset-inline-end: 3px; line-height: 1; }
.topicon .count {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: #e5484d; color: #fff; font-size: .625rem; font-weight: 600; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}

.usermenu { position: relative; flex: none; }
.usermenu summary {
  display: flex; align-items: center; gap: .5rem; height: 36px; padding: 0 .35rem; border-radius: 999px; cursor: pointer; list-style: none;
  color: var(--text-2); font-weight: 500; font-size: .8125rem; transition: background-color .15s;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--surface-2); }
.usermenu .uname { display: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu .chev { display: none; width: 14px; height: 14px; color: var(--muted); }
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tint-strong), color-mix(in srgb, var(--accent) 20%, transparent));
  color: var(--link); font-size: .6875rem; font-weight: 650; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}
.avatar.lg { width: 36px; height: 36px; font-size: .8125rem; }
.usermenu .menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 40; min-width: 232px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop .16s var(--ease);
}
.usermenu .menuhead { display: flex; align-items: center; gap: .65rem; padding: .5rem .55rem .65rem; }
.usermenu .menuhead > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.usermenu .menuhead b { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu .menu hr { margin: .3rem -.35rem; }
.usermenu .menu a, .usermenu .menu .linklike {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: start; padding: .45rem .55rem; border-radius: 6px;
  color: var(--text-2); font-size: .8125rem; font-weight: 500;
}
.usermenu .menu .i { width: 16px; height: 16px; color: var(--muted); }
.usermenu .menu a:hover, .usermenu .menu .linklike:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; color: var(--link); padding: 0; }
.linklike:hover { text-decoration: underline; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Sidebar ---------- */
.shell { display: block; }
.sidebar {
  position: fixed; top: var(--topbar); bottom: 0; inset-inline-start: 0; z-index: 25; width: min(var(--sidebar), 86vw);
  overflow-y: auto; overscroll-behavior: contain; padding: .6rem .6rem 2.5rem;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .22s var(--ease), box-shadow .22s;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
[dir="rtl"] .sidebar { transform: translateX(100%); }
.navtoggle:checked ~ .shell .sidebar { transform: none; box-shadow: var(--shadow-lg); }
.navbackdrop { display: none; }
.navtoggle:checked ~ .navbackdrop {
  display: block; position: fixed; inset: var(--topbar) 0 0 0; z-index: 24; background: rgb(9 9 11 / .38);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.navgroup { margin: 0 0 .35rem; }
.navgroup + .navgroup { padding-top: .2rem; }
.navhead {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; list-style: none; user-select: none;
  padding: .7rem .65rem .35rem; border-radius: 6px;
  font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.navhead::-webkit-details-marker { display: none; }
.navhead .chev { width: 13px; height: 13px; opacity: 0; transition: transform .2s var(--ease), opacity .15s; }
.navhead:hover { color: var(--text-2); }
.navhead:hover .chev, .navhead:focus-visible .chev { opacity: 1; }
.navgroup:not([open]) .navhead .chev { transform: rotate(-90deg); opacity: 1; }
[dir="rtl"] .navgroup:not([open]) .navhead .chev { transform: rotate(90deg); }
.sidebar a {
  position: relative; display: flex; align-items: center; gap: .65rem; margin: 1px 0; padding: .38rem .65rem; border-radius: 7px;
  color: var(--text-2); font-size: .8125rem; font-weight: 500; line-height: 1.35; transition: background-color .12s, color .12s;
}
.sidebar a .i { width: 17px; height: 17px; color: var(--muted); transition: color .12s; }
.sidebar a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar a:hover .i { color: var(--text-2); }
.sidebar a.active { background: var(--tint); color: var(--link); font-weight: 600; }
.sidebar a.active .i { color: var(--link); }
.sidebar a.active::before {
  content: ""; position: absolute; inset-inline-start: -.6rem; top: 50%; width: 3px; height: 18px; margin-top: -9px;
  border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--primary);
}

/* ---------- Layout (wide screens use the space: see project rules) ---------- */
.main { padding: 1.25rem 0 3.5rem; min-width: 0; }
.container { width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 640px) {
  .topbar { padding: 0 16px; gap: .6rem; }
  .campus-switch { display: block; }
  .usermenu .uname, .usermenu .chev { display: inline-block; }
  .usermenu summary { padding: 0 .6rem 0 .3rem; }
  [dir="rtl"] .usermenu summary { padding: 0 .3rem 0 .6rem; }
}
@media (min-width: 900px) {
  .cmdk { display: flex; }
  .searchlink { display: none; }
}
@media (min-width: 1024px) {
  .burger { display: none; }
  .sidebar { transform: none !important; box-shadow: none !important; width: var(--sidebar); background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }
  .navbackdrop { display: none !important; }
  .main { margin-inline-start: var(--sidebar); padding-top: 1.75rem; }
  .topbar { padding-inline-start: 14px; }
  .brand { width: calc(var(--sidebar) - 22px); }
  .cmdk { margin-inline-start: 0; }
}
@media (min-width: 1280px) {
  .container { max-width: min(100%, 1680px); padding: 0 clamp(1.5rem, 2.5vw, 3rem); }
}
@media (min-width: 1920px) {
  .container { max-width: 1840px; }
}
/* Deliberately narrow reading/form widths. */
.narrow { max-width: 720px; }
.reading { max-width: 860px; }
.narrow.center, .reading.center { margin-inline: auto; }

/* ---------- Page header, breadcrumbs ---------- */
.pagehead { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.pagehead h1, .pagehead h2, .pagehead h3 { margin: 0; min-width: 0; }
.pagehead h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.card > .pagehead:first-child { margin-bottom: 1rem; }
/* Pages without breadcrumbs: keep the h1 at the same height as pages with them. */
.container > .pagehead:first-child, .container > .flash:first-child + .pagehead { margin-top: calc(.78rem * 1.55 + .6rem); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .78rem; color: var(--muted); margin-bottom: .6rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.crumbs .sep { width: 13px; height: 13px; opacity: .6; }
.crumbs > span:last-child { color: var(--text-2); font-weight: 500; }
@media (min-width: 768px) { h1 { font-size: 1.5rem; } }

/* ---------- Cards, grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
  margin-bottom: 1rem; box-shadow: var(--shadow-xs); min-width: 0;
}
@media (min-width: 640px) { .card { padding: 1.25rem; } }
.card > h2:first-child, .card > h3:first-child, .card > legend + h2 { margin-top: 0; }
.card > h2:first-child { font-size: .9375rem; margin-bottom: .9rem; }
.card > input[type=hidden] + h2, .card > input[type=hidden] + h3, .card > input[type=hidden] + input[type=hidden] + h2, .card > input[type=hidden] + input[type=hidden] + h3 { margin-top: 0; }
.form > h2, .form > h3, .form > h4 { margin: 0; }
.card > :last-child { margin-bottom: 0; }
.card .tablewrap { box-shadow: none; border-radius: var(--radius-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .tablewrap { border: 0; border-top: 1px solid var(--border); border-radius: 0; margin: 0; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.25rem; }
.cardhead h2 { margin: 0; font-size: .9375rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin: 0 0 1rem; min-width: 0; }
fieldset.card { padding-top: .75rem; }
legend { padding: 0 .4rem; margin-inline-start: -.4rem; font-weight: 600; font-size: .875rem; color: var(--text); }
.grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 700px) { .grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.g3, .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid > .card, .grid > section, .grid > form { margin-bottom: 0; align-self: start; }
.grid + .grid, .grid + .card, .grid + .tablewrap { margin-top: 1rem; }

/* KPI tiles: label on top, big tabular number, tone as a small dot. */
.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.25rem; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
@media (min-width: 1280px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; } }
.tile {
  position: relative; display: flex; flex-direction: column; gap: .35rem; min-width: 0; padding: .9rem 1rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .2s var(--ease), transform .2s var(--ease);
}
@media (min-width: 640px) { .tile { padding: 1rem 1.1rem 1.1rem; } }
.tile > br { display: none; }
.tile .l, .tile > span.muted.small:first-child { order: -1; color: var(--muted); font-size: .78rem; font-weight: 500; line-height: 1.35; padding-inline-end: 1.1rem; }
.tile .v, .tile > strong {
  font-size: 1.5rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
@media (min-width: 1280px) { .tile .v, .tile > strong { font-size: 1.625rem; } }
.tile > .small:not(:first-child) { font-size: .75rem; }
a.tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
a.tile::after {
  content: ""; position: absolute; inset-block-end: .9rem; inset-inline-end: .9rem; width: 14px; height: 14px; opacity: 0;
  background: var(--muted); transition: opacity .15s, transform .2s var(--ease); transform: translate(-3px, 3px);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
}
[dir="rtl"] a.tile::after { transform: scaleX(-1) translate(-3px, 3px); }
a.tile:hover::after { opacity: 1; transform: none; }
[dir="rtl"] a.tile:hover::after { transform: scaleX(-1); }
.tile.warn::before, .tile.bad::before {
  content: ""; position: absolute; inset-block-start: 1.05rem; inset-inline-end: 1rem; width: 7px; height: 7px; border-radius: 50%;
  background: var(--tone); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent);
}
.tile.ok { --tone: var(--ok); } .tile.warn { --tone: var(--warn); } .tile.bad { --tone: var(--bad); } .tile.info { --tone: var(--info); }
.tile.bad .v, .tile.bad > strong { color: var(--bad); }

.chartbox { position: relative; height: 280px; }
dl.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: .45rem 1.25rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .8125rem; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.tablewrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 1rem; box-shadow: var(--shadow-xs); -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
table { border-collapse: collapse; width: 100%; font-size: .8125rem; }
th, td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
td { color: var(--text); }
th {
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface)); color: var(--muted);
  font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  padding-top: .55rem; padding-bottom: .55rem;
}
tbody th { text-transform: none; letter-spacing: 0; font-size: .8125rem; color: var(--text-2); background: transparent; }
th:first-child, td:first-child { padding-inline-start: 1rem; }
th:last-child, td:last-child { padding-inline-end: 1rem; }
tbody tr:last-child > td, tbody tr:last-child > th { border-bottom: 0; }
tbody tr { transition: background-color .1s; }
.tablewrap tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td a { font-weight: 500; }
td .btn, td form.inline { vertical-align: middle; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td, tfoot th { font-weight: 600; background: color-mix(in srgb, var(--surface-2) 65%, var(--surface)); border-top: 1px solid var(--border); border-bottom: 0; }
td.empty, .empty { padding: 2.25rem 1rem; text-align: center; color: var(--muted); }
td.empty { background: transparent !important; }
.emptystate { text-align: center; padding: 2.5rem 1rem; }
.emptystate > .i { width: 28px; height: 28px; color: var(--muted); margin-bottom: .5rem; }
.emptystate p { margin: .2rem 0; }

/* ---------- Forms ---------- */
form.inline { display: inline; }
.form { display: grid; gap: .9rem 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .form.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .form.cols3 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.form .full { grid-column: 1 / -1; }
.form > .btn { justify-self: start; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field .label { font-weight: 500; font-size: .8125rem; color: var(--text-2); }
.req { color: var(--bad); font-weight: 600; }
.hint { color: var(--muted); font-size: .75rem; line-height: 1.4; }
input, select, textarea {
  font: inherit; font-size: .875rem; color: var(--text); background-color: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs);
  padding: 0 .7rem; width: 100%; min-height: 36px; height: 36px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea { height: auto; padding: .5rem .7rem; line-height: 1.5; resize: vertical; }
select[multiple], select[size] { height: auto; padding: .3rem; }
select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none; padding-inline-end: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: right .55rem center;
}
[dir="rtl"] select:not([multiple]):not([size]) { background-position: left .55rem center; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:hover:not(:focus):not([readonly]):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not([readonly]) { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input[readonly], input:disabled, select:disabled, textarea:disabled, textarea[readonly] { background-color: var(--surface-2); color: var(--muted); box-shadow: none; cursor: not-allowed; }
input[readonly] { cursor: default; }
input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; box-shadow: none; accent-color: var(--primary); cursor: pointer; flex: none;
}
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: none; }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type=color] { width: 52px; padding: 3px; cursor: pointer; }
input[type=range] { padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }
input[type=file] { height: auto; padding: .3rem; font-size: .8125rem; color: var(--muted); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: .3rem .7rem; margin-inline-end: .7rem; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-3); }
input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
input[type=search]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-inline-start: .4rem; cursor: pointer; opacity: .55; background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type=search]::-webkit-search-cancel-button:hover { opacity: 1; }
input[type=date], input[type=time], input[type=datetime-local], input[type=month] { font-variant-numeric: tabular-nums; }
input[type=number] { font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .875rem; cursor: pointer; }
.check .hint { flex-basis: 100%; }
.formfoot { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.card .formfoot:last-child { margin-bottom: 0; }
.search { display: flex; gap: .5rem; flex-wrap: wrap; }
.search input, .search select { width: auto; flex: 1 1 200px; }
.filters {
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.card .filters, .filters .filters { padding: 0; background: none; border: 0; box-shadow: none; }
.filters .field { min-width: 150px; flex: 0 1 220px; }
.filters .field:has(input[type=search]) { flex: 1 1 260px; max-width: 420px; }
.filters .check { min-height: 36px; }
.radios { display: inline-flex; gap: .25rem; flex-wrap: wrap; }
.radios label {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; min-height: 28px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); font-size: .78rem; font-weight: 500; color: var(--text-2);
  transition: background-color .12s, border-color .12s, color .12s;
}
.radios label:hover { background: var(--surface-2); }
.radios input { width: 14px; height: 14px; }
.radios label:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: var(--tint); color: var(--link); }
.radios input:checked + span { font-weight: 600; }

/* ---------- Buttons ---------- */
.btn, button:not([class]), input[type=submit], input[type=button] {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; width: auto;
  font: inherit; font-size: .8125rem; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  height: 36px; min-height: 36px; padding: 0 .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s, transform .05s;
}
.btn:hover, button:not([class]):hover { text-decoration: none; background: var(--surface-2); border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }
.btn:active, button:not([class]):active { transform: translateY(.5px); background: var(--surface-3); }
.btn:focus-visible, button:not([class]):focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.btn .i { width: 16px; height: 16px; }
.btn.primary, .btn.accent {
  --b: var(--primary);
  background: var(--b); color: var(--on-primary); border-color: color-mix(in srgb, var(--b) 82%, #000);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .16), 0 1px 2px color-mix(in srgb, var(--b) 35%, transparent), 0 2px 6px -2px color-mix(in srgb, var(--b) 45%, transparent);
}
.btn.accent { --b: var(--accent); }
.btn.primary:hover, .btn.accent:hover { background: color-mix(in srgb, var(--b) 88%, #000); border-color: color-mix(in srgb, var(--b) 75%, #000); }
.btn.primary:active, .btn.accent:active { background: color-mix(in srgb, var(--b) 80%, #000); }
.btn.primary:focus-visible, .btn.accent:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border-strong)); }
.btn.danger:hover { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.btn.primary.danger, .btn.danger.solid { background: var(--bad); color: #fff; border-color: color-mix(in srgb, var(--bad) 80%, #000); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.secondary { background: var(--surface-2); border-color: var(--border); box-shadow: none; }
.btn.sm { height: 28px; min-height: 28px; padding: 0 .6rem; font-size: .75rem; border-radius: 6px; }
.btn.lg { height: 42px; padding: 0 1.25rem; font-size: .875rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"], button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Badges, flashes ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; height: 20px; padding: 0 .5rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 550; text-transform: capitalize; white-space: nowrap; line-height: 1; vertical-align: middle;
  background: var(--surface-2); color: var(--text-2); border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: var(--surface-2); color: var(--muted); }


.flash {
  --tone: var(--info);
  position: relative; display: flex; align-items: flex-start; gap: .65rem; margin-bottom: 1rem; padding: .7rem .9rem .7rem 2.35rem;
  border-radius: 10px; border: 1px solid color-mix(in srgb, var(--tone) 26%, var(--border));
  background: color-mix(in srgb, var(--tone) 7%, var(--surface)); color: var(--text); font-size: .8125rem;
  box-shadow: var(--shadow-xs); animation: slidein .25s var(--ease);
}
[dir="rtl"] .flash { padding: .7rem 2.35rem .7rem .9rem; }
.flash::before {
  content: ""; position: absolute; inset-inline-start: .8rem; top: .78rem; width: 16px; height: 16px; background: var(--tone);
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
}
.flash.ok { --tone: var(--ok); }
.flash.ok::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.flash.warn { --tone: var(--warn); }
.flash.error, .flash.bad { --tone: var(--bad); }
.flash.warn::before, .flash.error::before, .flash.bad::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.flash a { font-weight: 500; }
@keyframes slidein { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.pager { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .25rem 0 1rem; }
.pager > .muted { margin-inline-end: auto; }
.tabs {
  display: flex; gap: .15rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; padding: .55rem .75rem; margin-bottom: -1px; border-bottom: 2px solid transparent; white-space: nowrap;
  color: var(--muted); font-size: .8125rem; font-weight: 500; border-radius: 6px 6px 0 0; transition: color .12s, background-color .12s;
}
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.steps { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 1.25rem; padding: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step; display: inline-flex; align-items: center; gap: .45rem; margin: 0; padding: .25rem .7rem .25rem .3rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .75rem; font-weight: 500;
}
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: .6875rem; font-weight: 600;
}
.steps li.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, var(--border)); }
.steps li.done::before { content: "\2713"; background: var(--ok-bg); color: var(--ok); }
.steps li.current { color: var(--link); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--tint); font-weight: 600; }
.steps li.current::before { background: var(--primary); color: #fff; }

/* details / summary in page content */
.main details:not(.usermenu):not(.navgroup) > summary { cursor: pointer; color: var(--text-2); font-weight: 500; padding: .2rem 0; }
.main details:not(.usermenu):not(.navgroup) > summary:hover { color: var(--text); }
.main details:not(.usermenu):not(.navgroup)[open] > summary { margin-bottom: .5rem; }

/* ---------- Dashboard ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden; display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1.75rem; padding: 1.4rem 1.25rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  background: var(--surface); box-shadow: var(--shadow-xs);
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 120% at 0% 0%, color-mix(in srgb, var(--primary) 34%, transparent), transparent 72%),
    radial-gradient(45% 110% at 100% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 72%),
    radial-gradient(40% 90% at 70% 120%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 70%);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 10%, transparent) 1px, transparent 1px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 100%); mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
}
[dir="rtl"] .hero::after { -webkit-mask-image: linear-gradient(-90deg, transparent 30%, #000 100%); mask-image: linear-gradient(-90deg, transparent 30%, #000 100%); }
.hero h1 { margin: 0 0 .25rem; font-size: 1.5rem; letter-spacing: -.028em; }
.hero p { margin: 0; }
.hero .eyebrow { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--link); margin-bottom: .35rem; }
@media (min-width: 768px) { .hero { padding: 1.9rem 2rem; } .hero h1 { font-size: 1.875rem; } }
.hero-pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .8rem .5rem .7rem; border-radius: 999px; font-size: .8125rem;
  background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  color: var(--text-2); box-shadow: var(--shadow-sm); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hero-pill:hover { text-decoration: none; border-color: var(--warn); color: var(--text); }
.hero-pill .i { width: 15px; height: 15px; color: var(--muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 50%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.dashsection > h2 { margin: 0 0 .7rem; font-size: .8125rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dashsection { animation: rise .4s var(--ease) both; }
.dashsection:nth-of-type(2) { animation-delay: .04s; } .dashsection:nth-of-type(3) { animation-delay: .08s; }
.dashsection:nth-of-type(4) { animation-delay: .12s; } .dashsection:nth-of-type(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bare pages (login, public forms) ---------- */
body.bare { display: flex; min-height: 100vh; min-height: 100dvh; align-items: flex-start; justify-content: center; }
.bare-main { width: 100%; max-width: 440px; padding: 8vh var(--gutter) 2rem; }
.bare-main.wide { max-width: 900px; }
body.bare:has(.loginbox) {
  align-items: center;
  background:
    radial-gradient(42rem 28rem at 50% -8%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 70%),
    radial-gradient(30rem 22rem at 85% 8%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
}
body.bare:has(.loginbox)::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 0%, #000 20%, transparent 75%); mask-image: radial-gradient(ellipse 60% 50% at 50% 0%, #000 20%, transparent 75%);
}
body.bare:has(.loginbox) .bare-main { padding-top: 2rem; padding-bottom: 4rem; }
.loginbox { padding: 2rem 1.5rem 1.5rem; border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .45s var(--ease) both; }
@media (min-width: 480px) { .loginbox { padding: 2.25rem 2.25rem 1.75rem; } }
.loginbox h1 { text-align: center; font-size: 1.375rem; margin: .9rem 0 .25rem; }
.loginbox > p.muted { margin: 0 0 1.5rem; font-size: .875rem; }
.loginbox .form { gap: 1rem; }
.loginbox .btn.primary { height: 40px; margin-top: .25rem; font-size: .875rem; }
.loginmark {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 80%, #fff) 0%, var(--primary) 45%, var(--accent) 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), 0 8px 24px -6px color-mix(in srgb, var(--primary) 60%, transparent);
}
.loginfoot { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); text-align: center; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Printable documents (receipts, report cards, ID cards) ---------- */
.printonly { display: none; }
.doc { background: #fff; color: #000; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.5rem; max-width: 820px; margin: 0 auto 1rem; box-shadow: var(--shadow-sm); color-scheme: light; }
.doc h1, .doc h2, .doc h3, .doc td, .doc th { color: #000; }
.doc .muted { color: #555; }
.doc a { color: #000; }
.doc table th { background: #f1f1f1; color: #000; text-transform: none; letter-spacing: 0; font-size: .8125rem; }
.doc th, .doc td { border-bottom-color: #ddd; }
.doc tbody tr:hover > td { background: transparent; }
.doc .dochead { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #000; padding-bottom: .6rem; margin-bottom: 1rem; }
.doc .tablewrap { background: #fff; border-color: #ddd; box-shadow: none; }
.idcards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, 86mm); justify-content: start; }
.idcard {
  position: relative; display: flex; flex-direction: column; width: 86mm; height: 54mm; padding: 0 10px 12px; overflow: hidden;
  border: 1px solid #d4d4d8; border-radius: 10px; background: #fff; color: #18181b; font-size: 10.5px; line-height: 1.45;
  box-shadow: 0 1px 2px rgb(16 16 24 / .05), 0 6px 18px -8px rgb(16 16 24 / .18);
  -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid;
}
.idcard .top {
  display: flex; align-items: center; gap: 7px; margin: 0 -10px 8px; padding: 6px 10px; font-weight: 600; font-size: 11px; letter-spacing: -.005em; color: #fff;
  background: linear-gradient(110deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--accent)) 70%, var(--accent));
}
.idcard .top::before {
  content: ""; flex: none; width: 15px; height: 15px; border-radius: 4px; background-color: rgb(255 255 255 / .22);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 3 8.5l9 4.5 9-4.5L12 4Z'/%3E%3Cpath d='M7 11v4.5c0 1.2 2.2 2.5 5 2.5s5-1.3 5-2.5V11'/%3E%3C/svg%3E");
  background-size: 11px; background-position: center; background-repeat: no-repeat;
}
.idcard > div:nth-child(2) { flex: 1; align-items: center; gap: 10px !important; }
.idcard > div:nth-child(2) > div:first-child { border-radius: 6px; border-color: #e4e4e7 !important; background: #f4f4f5; font-size: 9px; letter-spacing: .08em; }
.idcard > div:nth-child(2) > div:last-child > div:first-child { font-size: 13px !important; font-weight: 650 !important; letter-spacing: -.01em; margin-bottom: 2px; }
.idcard::after { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.idcard .mono { font-size: 9.5px; color: #52525b; }

@media print {
  .topbar, .sidebar, .navbackdrop, .skiplink, .noprint, .flash, .crumbs, .pagehead .actions { display: none !important; }
  :root { color-scheme: light; }
  .main { margin: 0 !important; padding: 0; }
  .container { max-width: none !important; padding: 0 !important; }
  body, body.bare:has(.loginbox) { background: #fff !important; color: #000; font-size: 12px; }
  body.bare:has(.loginbox)::before, .hero::before, .hero::after { display: none; }
  h1, h2, h3, h4, td, th, .muted, a { color: #000 !important; }
  .card, .tablewrap, .tile, .hero, .doc, .filters { border: 0; padding: 0; box-shadow: none !important; background: #fff !important; border-radius: 0; }
  th { background: #f1f1f1 !important; color: #000 !important; }
  td, th { border-bottom-color: #ccc !important; }
  .badge { background: none !important; color: #000 !important; border: 1px solid #999; }
  .badge::before { display: none; }
  .printonly { display: block; }
  .pagebreak { page-break-after: always; }
  * { animation: none !important; transition: none !important; }
}

/* ---------- Dashboard: headline KPIs + per-module cards ---------- */
.hero-side { display: flex; align-items: center; }
.hero-pill.calm { border-color: var(--border); box-shadow: var(--shadow-xs); color: var(--muted); }
.okdot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.5rem; }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; } }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: .5rem; min-width: 0; padding: 1rem 1rem .85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .2s var(--ease), transform .2s var(--ease);
  animation: rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms);
}
@media (min-width: 640px) { .kpi { padding: 1.15rem 1.25rem 1rem; } }
.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; font-weight: 500; line-height: 1.3; }
.kpi-label .i { width: 15px; height: 15px; color: var(--link); flex: none; }
.kpi-value { font-size: 1.5rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 640px) { .kpi-value { font-size: 1.875rem; } }
@media (min-width: 1280px) { .kpi-value { font-size: 2.125rem; } }
.kpi.zero .kpi-value { color: var(--muted); }
.kpi.warn .kpi-value { color: var(--warn); } .kpi.bad .kpi-value { color: var(--bad); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .6rem; margin-top: .15rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .72rem; font-weight: 500; }
.kpi-foot .i { width: 14px; height: 14px; transition: transform .2s var(--ease); }
.kpi:hover .kpi-foot { color: var(--link); }
.kpi:hover .kpi-foot .i { transform: translateX(2px); }
[dir="rtl"] .kpi:hover .kpi-foot .i { transform: scaleX(-1) translateX(2px); }

.modcards { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); margin-bottom: 1.5rem; align-items: start; }
@media (min-width: 700px) { .modcards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; } }
@media (min-width: 1280px) { .modcards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1700px) { .modcards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.modcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; animation: rise .4s var(--ease) both; animation-delay: .12s; }
.modcard header { display: flex; align-items: center; gap: .55rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.modcard header .i { width: 16px; height: 16px; color: var(--muted); }
.modcard h2 { margin: 0; font-size: .8125rem; font-weight: 600; letter-spacing: 0; }
.modcard ul { list-style: none; margin: 0; padding: .3rem; }
.modcard li { margin: 0; }
.modcard li a { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .5rem .7rem; border-radius: 7px; color: var(--text-2); font-size: .8125rem; }
.modcard li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.modcard .ml { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.modcard .mv { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.modcard a.zero .mv { color: var(--muted); font-weight: 500; }
.modcard a.warn .mv { color: var(--warn); } .modcard a.bad .mv { color: var(--bad); }
.tonedot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.bad .tonedot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }

/* ---------- Phones ---------- */
@media (max-width: 639.98px) {
  /* Tables scroll sideways inside .tablewrap instead of wrapping every cell; soft shadows hint at more content. */
  .tablewrap th, .tablewrap td { white-space: nowrap; }
  .tablewrap td.wrap, .tablewrap td.empty { white-space: normal; }
  .tablewrap {
    background:
      linear-gradient(90deg, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
      linear-gradient(-90deg, var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / .12), transparent) left / 10px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / .12), transparent) right / 10px 100% no-repeat scroll,
      var(--surface);
  }
  .tablewrap tbody tr:hover > td { background: transparent; }
  /* Filter bars: every control full width. */
  .filters .field, .filters .field:has(input[type=search]) { flex: 1 1 100%; max-width: none; min-width: 0; }
  .filters > .btn { flex: 1 1 auto; }
  .search input, .search select { flex-basis: 100%; }
}
.menu .themeitem { display: none !important; }
@media (max-width: 479.98px) {
  .topbar .themetoggle { display: none; }
  .topbar { gap: .25rem; }
  .brand { gap: .5rem; padding-inline: .2rem; }
  .menu .themeitem { display: flex !important; }
}

/* ---------- Public pages (apply, status, verify) ---------- */
.bare-brand { display: flex; align-items: center; justify-content: center; gap: .65rem; margin: 0 0 1.25rem; color: var(--text); font-weight: 600; font-size: 1rem; letter-spacing: -.01em; }
.bare-brand .brandmark { width: 32px; height: 32px; border-radius: 9px; }
body.bare:has(.loginbox) .bare-brand { display: none; }
body.bare:not(:has(.loginbox)) {
  background:
    radial-gradient(48rem 22rem at 50% -6%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%),
    radial-gradient(28rem 18rem at 90% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg);
}
body.bare:not(:has(.loginbox)) .bare-main { padding-top: 2.5rem; }
.bare-main > .card { box-shadow: var(--shadow-md); border-radius: 16px; }
@media (min-width: 640px) { .bare-main > .card { padding: 2rem 2.25rem; } }
.bare-main > .card > h1 { margin-bottom: .25rem; }
.bare-main form { counter-reset: sec; }
.bare-main form > h2 {
  counter-increment: sec; display: flex; align-items: center; gap: .6rem; margin: 2rem 0 1rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border); font-size: 1rem;
}
.bare-main form > h2::before {
  content: counter(sec); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--tint); color: var(--link); font-size: .75rem; font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}
@media print {
  .bare-brand, .kpi-foot { display: none; }
  .kpi, .modcard { border: 1px solid #ccc !important; box-shadow: none !important; }
  .idcard { box-shadow: none; }
}
.bare-brand:hover { text-decoration: none; }
.okdot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.kpi-value { margin-top: auto; }

/* ---- Admissions CRM board + timelines (admissions / feedback modules) ---- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .6rem; min-height: 220px; display: flex; flex-direction: column; gap: .5rem; }
.kanban-col.drop { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-col > h3 { font-size: .8125rem; margin: 0 0 .15rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .65rem; font-size: .8125rem; }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .45; }
.kcard .l { color: var(--muted); font-size: .75rem; margin-top: .15rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; border-left: 2px solid var(--border); padding: 0 0 .9rem 1rem; margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li.sys::before { border-color: var(--border-strong); }
.timeline .meta { color: var(--muted); font-size: .75rem; }
.bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; margin: .4rem 0; }
.bubble.mine { background: var(--tint, var(--surface-2)); }
.bubble.internal { border-style: dashed; }

/* ---------- Installable app / push / offline attendance (pwa module) ---------- */
.cardhead.pushhead { padding: 0 0 .75rem; }
.cardhead.pushhead h2 { display: flex; align-items: center; gap: .5rem; }
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.subhead { margin-top: 1.25rem; }
.pushcats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: .4rem 1rem; margin: .6rem 0 .9rem; }
.synclist { margin: 0; padding-left: 1.1rem; }
.synclist li { margin: .3rem 0; }

/* ---- sign-in security (2FA, SSO) ---- */
.ssodivider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 1rem; color: var(--muted); font-size: .8125rem; }
.ssodivider::before, .ssodivider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.ssobuttons { display: grid; gap: .5rem; }
.ssobtn { height: 40px; justify-content: center; gap: .6rem; }
.ssobtn .i { width: 18px; height: 18px; }
.loginmark .i { width: 22px; height: 22px; }
.otpinput { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .2em; text-align: center; max-width: 16rem; }
.loginbox .otpinput { max-width: none; }
.otphelp { margin-top: 1rem; }
.otphelp summary { cursor: pointer; }
.setupsteps { padding-inline-start: 1.25rem; margin: 0 0 1rem; }
.setupsteps li { margin-bottom: .75rem; }
.qrbox { display: block; width: fit-content; margin: .6rem 0 .25rem; padding: .5rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.qrbox img { display: block; width: 200px; height: 200px; }
.secretkey code { font-size: .95rem; letter-spacing: .06em; overflow-wrap: anywhere; }
.recoverycodes { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.recoverycodes code { display: block; text-align: center; font-size: 1rem; padding: .35rem .5rem; }
.card:not(.flush) > .cardhead.tight { padding: 0 0 .9rem; }
#offline-att [hidden], [data-push-card] [hidden], .menu [data-install-app][hidden] { display: none !important; }
