/* Nimdi staff dashboard — Material 3 surfaces and Wallet-style pass cards, in the Nimdi brand
   colours of the original app: red #FB281B (primary) and yellow #FFCF2E (accent). */

@font-face {
  font-family: "Google Sans Flex";
  src: url("fonts/GoogleSansFlex.c5d647c0d815.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f6f3f3;
  --surface-3: #efeaea;
  --text: #201a1a;
  --text-2: #534341;
  --text-3: #857371;
  --outline: #d8c2bf;
  --outline-soft: #ede0de;
  --primary: #fb281b;
  /* Brand red is too light for small text on white; links use this deeper shade of it. */
  --primary-ink: #c0160b;
  --on-primary: #ffffff;
  --primary-soft: #ffdad4;
  --on-primary-soft: #410000;
  --accent: #ffcf2e;
  --on-accent: #3a2f00;
  --accent-soft: #fff0bf;
  --on-accent-soft: #3a2f00;
  --positive: #146c2e;
  --positive-soft: #c4eed0;
  --warning: #7a5900;
  --warning-soft: #ffdf99;
  --danger: #b3261e;
  --danger-soft: #f9dedc;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 1px 3px 1px rgb(0 0 0 / 4%);
  --radius-xl: 28px;
  --radius-l: 20px;
  --radius-m: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161212;
    --surface: #201a1a;
    --surface-2: #2a2322;
    --surface-3: #352c2b;
    --text: #ede0de;
    --text-2: #d8c2bf;
    --text-3: #a08c89;
    --outline: #534341;
    --outline-soft: #3b2f2e;
    --primary: #ffb4a8;
    --primary-ink: #ffb4a8;
    --on-primary: #690100;
    --primary-soft: #930a00;
    --on-primary-soft: #ffdad4;
    --accent: #ffcf2e;
    --on-accent: #3a2f00;
    --accent-soft: #544600;
    --on-accent-soft: #ffe08a;
    --positive: #6dd58c;
    --positive-soft: #0f5223;
    --warning: #f5c542;
    --warning-soft: #5c4300;
    --danger: #f2b8b5;
    --danger-soft: #8c1d18;
    --shadow: 0 1px 3px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 "Google Sans Flex", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-ink); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 20px; }
.icon { fill: currentColor; flex: none; }
.muted { color: var(--text-3); }

/* ---- Shell ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 16px 20px; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-name { font-size: 20px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-3); margin-top: -2px; }
.rail-group { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 18px 16px 6px; letter-spacing: .04em; }
.rail a {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px;
  border-radius: 999px; color: var(--text-2); font-weight: 500;
}
.rail a:hover { background: var(--surface-3); }
.rail a.active { background: var(--primary-soft); color: var(--on-primary-soft); }
.rail-foot { margin-top: auto; padding-top: 16px; }
.me { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 600; flex: none;
}
.main { padding: 28px 40px 64px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; margin-bottom: 8px; }

/* ---- Buttons & chips --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px;
  padding: 0 22px; border-radius: 999px; border: 0; cursor: pointer; font: inherit; font-weight: 500;
  background: var(--primary); color: var(--on-primary);
}
.btn:hover { filter: brightness(1.06); box-shadow: var(--shadow); }
.btn.tonal { background: var(--primary-soft); color: var(--on-primary-soft); }
.btn.text { background: transparent; color: var(--primary-ink); padding: 0 14px; }
.btn.text:hover { background: var(--surface-3); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; }
.fab { height: 56px; border-radius: 18px; padding: 0 22px 0 18px; box-shadow: var(--shadow); }
.badge {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-positive { background: var(--positive-soft); color: var(--positive); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-accent { background: var(--accent-soft); color: var(--on-accent-soft); }

/* ---- Pass cards (Wallet) ---------------------------------------------- */
.passes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pass {
  --pass: #1a73e8;
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 168px; padding: 20px 22px; border-radius: var(--radius-xl); overflow: hidden;
  background: var(--pass); color: #fff; box-shadow: var(--shadow); transition: transform .15s ease;
}
.pass::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px;
  border-radius: 50%; background: rgb(255 255 255 / 12%);
}
.pass:hover { transform: translateY(-2px); }
.pass-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pass-chip { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.pass-title { font-size: 22px; font-weight: 600; line-height: 1.2; margin-top: 18px; }
.pass-sub { font-size: 14px; opacity: .9; margin-top: 4px; }
.pass .badge { background: rgb(255 255 255 / 22%); color: #fff; }
/* The subject's icon on a white disc, over the pass's corner circle. */
.pass-icon {
  position: absolute; right: 18px; bottom: 18px; z-index: 1; width: 64px; height: 64px;
  border-radius: 50%; background: #fff; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgb(0 0 0 / 18%);
}
.pass-icon img { width: 44px; height: 44px; object-fit: contain; }
.pass:has(.pass-icon) .pass-sub, .pass:has(.pass-icon) .pass-title { padding-right: 76px; }
.pass.add {
  background: transparent; color: var(--primary-ink); border: 2px dashed var(--outline);
  box-shadow: none; align-items: center; justify-content: center; gap: 8px; font-weight: 500;
}
.pass.add::after { display: none; }

/* ---- Surfaces ---------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.card { background: var(--surface); border-radius: var(--radius-l); padding: 20px 22px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 12px; }
.stat-value { font-size: 32px; font-weight: 500; line-height: 1.1; }
.stat-label { color: var(--text-2); font-weight: 500; }
.stat-note { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 14px; }
.hero { padding: 28px; border-radius: var(--radius-xl); background: var(--surface-2); margin-bottom: 24px; }
.hero h1 { margin-bottom: 6px; }
.empty { padding: 48px 24px; text-align: center; color: var(--text-3); }

/* ---- Toolbar & table -------------------------------------------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px; flex: 1 1 260px;
  max-width: 460px; border-radius: 999px; background: var(--surface-3); color: var(--text-2);
}
.search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--text); outline: none; }
.toolbar select {
  height: 40px; padding: 0 34px 0 14px; border-radius: 10px; border: 1px solid var(--outline);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.table-wrap { background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--text-3); padding: 14px 16px; border-bottom: 1px solid var(--outline-soft); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--outline-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
td.math-cell { max-width: 520px; }
.q-cell { display: flex; gap: 12px; align-items: center; }
.thumb {
  width: 56px; height: 56px; flex: none; object-fit: contain; border-radius: 10px;
  background: #fff; border: 1px solid var(--outline-soft);
}
.pager { display: flex; justify-content: space-between; align-items: center; padding: 16px 4px; color: var(--text-2); }

/* ---- Forms ------------------------------------------------------------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); gap: 24px; align-items: start; }
.form-layout.single { grid-template-columns: minmax(0, 720px); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field legend { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-m); border: 1px solid var(--outline);
  background: var(--surface); color: var(--text); font: inherit;
}
.field textarea { resize: vertical; min-height: 48px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.field input[type=color] { width: 64px; height: 44px; border: 0; background: none; padding: 0; }
.field.wide-text { grid-column: 1 / -1; }
.field .help { font-size: 12px; color: var(--text-3); }
.field .errors { color: var(--danger); font-size: 13px; margin: 0; padding: 0; list-style: none; }
.check { flex-direction: row; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.options-radio { display: flex; gap: 8px; flex-wrap: wrap; }
.options-radio label {
  display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 44px;
  border-radius: 12px; border: 1px solid var(--outline); cursor: pointer; font-weight: 600;
}
.options-radio input { position: absolute; opacity: 0; pointer-events: none; }
.options-radio label:has(input:checked) { background: var(--positive-soft); color: var(--positive); border-color: transparent; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }
.form-errors { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-m); margin-bottom: 16px; }
.mathbar {
  display: flex; gap: 4px; flex-wrap: wrap; position: sticky; top: 0; z-index: 2;
  padding: 10px 0 14px; margin-top: -6px; background: var(--surface);
}
.mathbar button {
  height: 30px; min-width: 34px; padding: 0 8px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--surface-3); color: var(--text-2); font: 13px ui-monospace, Menlo, monospace;
}
.mathbar button:hover { background: var(--primary-soft); color: var(--on-primary-soft); }
.math-error { color: var(--danger); font-size: 12px; }

/* Live preview, styled like a question card in the app. */
.preview { position: sticky; top: 24px; }
.preview-card { background: var(--surface); border-radius: var(--radius-xl); padding: 22px; box-shadow: var(--shadow); }
.preview-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--text-3); text-transform: uppercase; margin-bottom: 12px; }
.preview-question { font-size: 17px; line-height: 1.55; margin-bottom: 16px; overflow-wrap: anywhere; }
.preview-image {
  display: block; max-width: 100%; max-height: 320px; margin: -4px auto 16px; border-radius: 14px;
  background: #fff; border: 1px solid var(--outline-soft);
}
.preview-image[hidden] { display: none; }
.preview-option {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px;
  background: var(--surface-2); margin-bottom: 8px; overflow-wrap: anywhere;
}
.preview-option b {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-3); font-size: 14px;
}
.preview-option.correct { background: var(--positive-soft); }
.preview-option.correct b { background: var(--positive); color: #fff; }
.preview-explanation { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--outline-soft); color: var(--text-2); }
.katex { font-size: 1.08em; }

/* ---- Messages & login ----------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: #303030; color: #f2f2f2; padding: 14px 20px; border-radius: 12px; box-shadow: var(--shadow);
  animation: toast 4s forwards;
}
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: var(--radius-xl); padding: 36px 32px; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 24px; }
.login-card .fields { grid-template-columns: 1fr; }
.login-card .btn { width: 100%; margin-top: 8px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 12px 16px; gap: 4px; }
  .rail .brand, .rail-group, .rail-foot .me { display: none; }
  .rail a { flex: none; height: 40px; }
  .rail-foot { margin: 0; padding: 0; }
  .main { padding: 20px 16px 48px; }
  .grid.two, .form-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .fields { grid-template-columns: 1fr; }
}
