/* NexovClass admin panel. Colours match the apps (src/config/theme.js). Light by default, dark when the system asks
   for it or when the panel's theme button picks it (html[data-theme]). */
:root {
  --paper: #FAF7F0; --card: #FFFFFF; --ink: #101B33; --slate: #5B6478; --muted: #8A93A3; --line: #ECE7DC; --hover: #F5F1E8;
  --navy: #101B33; --navy-2: #1B2A4D; --marigold: #F2A93B; --marigold-deep: #B8740F; --tint: #FFF6E7;
  --leaf: #2F7A55; --leaf-tint: #E6F3EB; --coral: #C8402A; --coral-tint: #FDEDE6; --info: #0369A1; --info-tint: #E0F2FE;
  --shadow: 0 1px 2px rgba(16, 27, 51, .06), 0 4px 16px rgba(16, 27, 51, .06);
  --radius: 14px; --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #0E1424; --card: #182138; --ink: #F2EFE6; --slate: #AAB2C4; --muted: #808A9E; --line: #2A3652; --hover: #1F2A45;
    --tint: #3A2E18; --marigold-deep: #F2A93B; --leaf: #7FD1A6; --leaf-tint: #18342A; --coral: #FF9C86; --coral-tint: #3E221C;
    --info: #7DD3FC; --info-tint: #0C2D44; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #0E1424; --card: #182138; --ink: #F2EFE6; --slate: #AAB2C4; --muted: #808A9E; --line: #2A3652; --hover: #1F2A45;
  --tint: #3A2E18; --marigold-deep: #F2A93B; --leaf: #7FD1A6; --leaf-tint: #18342A; --coral: #FF9C86; --coral-tint: #3E221C;
  --info: #7DD3FC; --info-tint: #0C2D44; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink); line-height: 1.5; font-size: 15px;
  font-family: system-ui, -apple-system, 'Segoe UI', 'Noto Sans Tamil', 'Latha', 'Nirmala UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--marigold-deep); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
[hidden] { display: none !important; } /* buttons and fields set display; hidden must still hide them */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- sign-in ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 10% -10%, rgba(242, 169, 59, .18), transparent 60%), var(--paper); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: var(--marigold); color: var(--navy); display: grid; place-items: center; font-weight: 900; }
.auth h1 { font-size: 1.35rem; margin: 18px 0 4px; }
.auth p.lead { color: var(--slate); margin: 0 0 18px; }
.tabs { display: flex; background: var(--hover); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; cursor: pointer; color: var(--slate); font-weight: 600; }
.tabs button[aria-selected='true'] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.auth-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; color: var(--muted); font-size: .85rem; gap: 8px; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: .88rem; color: var(--slate); }
.input, .select, .textarea { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 11px; padding: 10px 12px; min-height: 44px; }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--marigold); outline: none; box-shadow: 0 0 0 3px rgba(242, 169, 59, .22); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--coral); }
.error-text { color: var(--coral); font-size: .82rem; }
.hint { color: var(--muted); font-size: .82rem; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; cursor: pointer; min-height: 38px; }
.chip[aria-pressed='true'] { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme='dark'] .chip[aria-pressed='true'] { background: var(--marigold); border-color: var(--marigold); color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chip[aria-pressed='true'] { background: var(--marigold); border-color: var(--marigold); color: var(--navy); } }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--marigold-deep); }
.banner { border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: .9rem; }
.banner.error { background: var(--coral-tint); color: var(--coral); }
.banner.info { background: var(--info-tint); color: var(--info); }
.banner.ok { background: var(--leaf-tint); color: var(--leaf); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 11px;
  padding: 9px 16px; min-height: 42px; font-weight: 700; cursor: pointer; background: var(--hover); color: var(--ink); text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.accent { background: var(--marigold); color: var(--navy); }
.btn.danger { background: var(--coral-tint); color: var(--coral); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .86rem; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
:root[data-theme='dark'] .btn.primary { background: var(--marigold); color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .btn.primary { background: var(--marigold); color: var(--navy); } }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100%; }
.side { background: var(--navy); color: #E7EAF2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; padding: 18px 18px 6px; }
.side .school { margin: 6px 14px 12px; padding: 10px 12px; background: rgba(255, 255, 255, .07); border-radius: 12px; font-size: .86rem; }
.side .school strong { display: block; color: #fff; font-size: .95rem; }
.side .school span { color: #AAB2C4; }
.nav { display: grid; gap: 2px; padding: 4px 10px 16px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #C9CFDC; text-decoration: none; font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a[aria-current='page'] { background: var(--marigold); color: var(--navy); }
.nav .group { color: #808A9E; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 12px 12px 4px; }
.side .foot { margin-top: auto; padding: 12px 14px 18px; font-size: .78rem; color: #808A9E; display: grid; gap: 10px; }
.side .foot .controls { display: none; align-items: center; gap: 8px; }
.side .foot .tabs { background: rgba(255, 255, 255, .08); }
.side .foot .tabs button { color: #C9CFDC; }
.side .foot .tabs button[aria-selected='true'] { background: var(--marigold); color: var(--navy); }
.side .foot .icon-btn { background: transparent; border-color: rgba(255, 255, 255, .2); color: #fff; }
@media (max-width: 900px) { .side .foot .controls { display: flex; } }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 20px; min-height: 64px;
  background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: var(--slate); font-size: .9rem; }
.topbar .who strong { color: var(--ink); }
.menu-btn { display: none; }
.content { padding: 20px; width: 100%; max-width: 1280px; }
.scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(5, 10, 25, .5); z-index: 20; }
  .menu-btn { display: inline-grid; }
  .topbar .lang-switch, .topbar .theme-btn { display: none; } /* in the menu instead, so the title keeps its room */
  .topbar { padding: 8px 12px; }
  .topbar .who .name { display: none; }
  .content { padding: 16px; }
}

/* ---------- blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.02rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.stat .k { color: var(--slate); font-size: .84rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat .v { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat .s { color: var(--muted); font-size: .82rem; }
.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
.two-col > .card + .card { margin-top: 0; } /* the grid gap spaces them */
@media (min-width: 1080px) { .two-col { grid-template-columns: 3fr 2fr; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .select { width: auto; min-width: 120px; }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.search .input { padding-left: 38px; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--slate); font-size: .78rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--hover); white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 700; background: var(--hover); color: var(--slate); white-space: nowrap; }
.badge.ok { background: var(--leaf-tint); color: var(--leaf); }
.badge.bad { background: var(--coral-tint); color: var(--coral); }
.badge.warn { background: var(--tint); color: var(--marigold-deep); }
.badge.info { background: var(--info-tint); color: var(--info); }
.cell-score.fail { color: var(--coral); font-weight: 800; }
.list { display: grid; }
.list-item { display: flex; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .when { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--muted); flex: none; }
.dot.ok { background: var(--leaf); } .dot.bad { background: var(--coral); } .dot.warn { background: var(--marigold); } .dot.info { background: var(--info); }

/* ---------- states ---------- */
.state { text-align: center; padding: 40px 16px; color: var(--slate); }
.state > .icon { width: 40px; height: 40px; color: var(--muted); margin: 0 auto 10px; display: block; }
.state h3 { margin: 0 0 6px; color: var(--ink); font-size: 1.05rem; }
.state p { margin: 0 auto 14px; max-width: 460px; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--hover), var(--line), var(--hover)); background-size: 200% 100%; animation: sk 1.2s infinite; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .side { transition: none; } }

/* ---------- dialogs & toasts ---------- */
dialog { border: 0; padding: 0; border-radius: 18px; background: var(--card); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(5, 10, 25, .55); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 1.08rem; flex: 1; }
.dlg-body { padding: 16px 18px; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
.creds { background: var(--tint); border-radius: 14px; padding: 14px; display: grid; gap: 10px; }
.creds .line { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.creds code { font-size: 1.15rem; font-weight: 800; letter-spacing: .04em; background: var(--card); border-radius: 8px; padding: 4px 10px; user-select: all; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--navy); color: #fff; border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); font-weight: 600; }
.toast.error { background: var(--coral); }

@media print {
  .side, .topbar, .toolbar, .btn, .no-print { display: none !important; }
  .shell { display: block; } .content { padding: 0; } .card, .table-wrap { box-shadow: none; border: 0; }
}
