/* ============================================================================
   AI Tutor admin portal - "Indigo / Ink / Amber" design system.
   The same six base colours and the same type scale as the mobile app, so the
   console and the product look like one product.

     Indigo #4B3FD8  primary      Ink    #14122B  text / dark
     Amber  #F5A623  wins, CTAs   Teal   #0F9F8F  success, mastery
     Mist   #F4F3FA  background   Slate  #6B6890  secondary text

   Fonts are SELF-HOSTED (see public/fonts + OFL.txt) so the Content-Security-Policy
   needs no external origin and the console works on a locked-down network.
   ============================================================================ */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --indigo: #4B3FD8;
  --indigo-dark: #3A2FB0;
  --indigo-soft: #EDEBFC;
  --indigo-text: #2E2497;

  --ink: #14122B;
  --slate: #6B6890;
  --hint: #9B98B5;

  --amber: #F5A623;
  --amber-soft: #FEF3E0;
  --amber-text: #A96A05;

  --teal: #0F9F8F;
  --teal-soft: #E4F6F3;
  --teal-text: #0B7F72;

  --bad: #D93A4A;
  --bad-soft: #FDECEE;
  --bad-text: #B32A38;

  --mist: #F4F3FA;
  --surface: #FFFFFF;
  --border: #E7E5F2;
  --border-strong: #D9D6EA;

  --r-chip: 11px;
  --r-btn: 14px;
  --r-card: 20px;

  --shadow-sm: 0 2px 8px rgba(20, 18, 43, 0.06);
  --shadow: 0 4px 16px rgba(20, 18, 43, 0.08);
  --shadow-hero: 0 12px 28px rgba(75, 63, 216, 0.28);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 28px; font-weight: 800; line-height: 1.15; margin: 0; letter-spacing: -0.2px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--mist); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }

.muted { color: var(--slate); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--bad); }
.link { font-weight: 600; }


/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__name { font-weight: 800; letter-spacing: -0.2px; }
.brandmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--indigo);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}
.brandmark--lg { width: 56px; height: 56px; border-radius: 18px; font-size: 20px; }
.topbar__nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar__nav a { padding: 8px 14px; border-radius: var(--r-btn); color: var(--slate); font-weight: 600; }
.topbar__nav a:hover { background: var(--mist); text-decoration: none; }
.topbar__nav a.is-current { background: var(--indigo-soft); color: var(--indigo-text); }
.topbar__account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; flex-direction: column; line-height: 1.2; }
.who__meta { font-size: 12px; color: var(--slate); }
.inline { display: inline; margin: 0; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 48px; }
.authshell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }

.pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pagehead__meta { margin: 6px 0 0; color: var(--slate); font-size: 13px; }
.pagehead__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.cols--sidebar { grid-template-columns: minmax(0, 1fr) 340px; }
.col-main, .col-side { display: grid; gap: 20px; }
@media (max-width: 980px) { .cols, .cols--sidebar { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card__head h2 { margin: 0; }
.card > h2 { margin-bottom: 12px; }
.empty { color: var(--slate); margin: 0; padding: 8px 0; }

/* ---------- Stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 860px) { .statgrid, .statgrid--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat__value { font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 12px; font-weight: 600; color: var(--slate); }
.stat__meta { font-size: 12px; color: var(--hint); }
.stat--indigo .stat__value { color: var(--indigo); }
.stat--teal .stat__value { color: var(--teal); }
.stat--amber .stat__value { color: var(--amber); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #FBFBFE; }
.table--tight td { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.table--tight tr:last-child td { border-bottom: none; }
.sub { display: block; font-size: 12px; color: var(--slate); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-chip);
  font-size: 12px;
  font-weight: 600;
  background: #E9E8F0;
  color: var(--ink);
  white-space: nowrap;
}
.chip--indigo { background: var(--indigo-soft); color: var(--indigo-text); }
.chip--teal { background: var(--teal-soft); color: var(--teal-text); }
.chip--amber { background: var(--amber-soft); color: var(--amber-text); }
.chip--bad { background: var(--bad-soft); color: var(--bad-text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--indigo); }
.btn--primary:hover { background: var(--indigo-dark); }
.btn--ghost { background: var(--surface); color: var(--indigo); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--mist); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--danger:hover { background: var(--bad-text); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn--block { width: 100%; }

/* ---------- Forms ---------- */
.form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .form__grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--slate); }
.field--inline { min-width: 160px; }
.hint { font-size: 12px; color: var(--hint); }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
}
.input:focus { outline: 2px solid var(--indigo); outline-offset: 1px; border-color: var(--indigo); }
.input:disabled, .input[readonly] { background: var(--mist); color: var(--slate); }
.input[readonly]:focus { outline: none; border-color: var(--border-strong); }
.fieldset { border: 1px solid var(--border); border-radius: var(--r-btn); padding: 14px 16px; margin: 18px 0 0; }
.fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--slate); }
.checks-inline { display: flex; flex-wrap: wrap; gap: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--indigo); }
.form__actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filters__actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--r-chip);
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert--ok { background: var(--teal-soft); color: var(--teal-text); }
.alert--bad { background: var(--bad-soft); color: var(--bad-text); }
.alert--warn { background: var(--amber-soft); color: var(--amber-text); }

/* ---------- System checks (dashboard) ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checks__row { display: flex; gap: 10px; align-items: flex-start; }
.checks__mark {
  flex: 0 0 20px;
  width: 20px; height: 20px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
  background: var(--slate);
  margin-top: 1px;
}
.checks__row--ok .checks__mark { background: var(--teal); }
.checks__row--warn .checks__mark { background: var(--amber); }
.checks__row--fail .checks__mark { background: var(--bad); }
.checks__body { display: flex; flex-direction: column; }
.checks__name { font-size: 13.5px; font-weight: 600; }
.checks__detail { font-size: 12px; color: var(--slate); }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.pager__label { font-size: 13px; color: var(--slate); }

/* ---------- Auth / error ---------- */
.authcard {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 28px;
}
.authcard__brand { text-align: center; margin-bottom: 22px; display: grid; gap: 6px; justify-items: center; }
.authcard__brand h1 { font-size: 22px; }
.stack { display: grid; gap: 14px; }
.errorpage { text-align: center; max-width: 520px; padding: 48px 0; }
.errorpage__status { font-size: 14px; font-weight: 800; color: var(--bad); margin: 0; }

/* ---------- Footer ---------- */
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--slate);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer__meta { color: var(--hint); }

