/* =====================================================================
   SBT CRM styles.
   Colours are "tokens" (CSS variables) defined once at the top, with a
   second set for dark mode. Change a colour here and it changes everywhere.
   ===================================================================== */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --ink: #18212d; --muted: #5b6778; --line: #dde2ea;
  --accent: #1d3d63; --accent-soft: #e4ebf3;
  --ok: #23855a; --ok-soft: #e3f3ea; --warn: #a86400; --warn-soft: #fcf0dc; --crit: #b3261e; --crit-soft: #fbe4e2;
  --pip-empty: #e3e8ef;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d; --surface: #19202a; --ink: #e7ecf3; --muted: #9aa6b6; --line: #2a3340;
    --accent: #7ea3f2; --accent-soft: #1f2b44;
    --ok: #5cc491; --ok-soft: #173327; --warn: #e8a94a; --warn-soft: #3a2a12; --crit: #f08a82; --crit-soft: #3d1c1a;
    --pip-empty: #2c3542; color-scheme: dark;
  }
  .logo-l { display: none !important; }
  .logo-d { display: block !important; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.1rem; }
h3 a { color: inherit; text-decoration: none; }
.meta { color: var(--muted); font-size: 0.88rem; }
.small { font-size: 0.8rem; }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.logo { display: block; width: 190px; max-width: 100%; height: auto; }
.logo-d { display: none; }

/* ---- Layout: sidebar + main ---- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; max-width: 1360px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); }
.side { position: sticky; top: 20px; align-self: start; display: flex; flex-direction: column; gap: 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-weight: 700; }
.side nav a:hover { background: var(--surface); }
.side nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.who { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 10px; overflow-wrap: anywhere; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 8px 16px; font-weight: 700; font-size: 0.85rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; gap: 16px; }
  .side { position: static; }
  .side .brand .logo { width: 160px; }
  .side nav { flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .side nav a { flex: none; background: var(--surface); border: 1px solid var(--line); }
  .who { flex-direction: row; gap: 10px; align-items: center; padding: 0; }
}

/* ---- Panels, cards, grids ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel.narrow { max-width: 760px; }
.card-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.dash { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .split, .dash { grid-template-columns: 1fr; } }

.pill { font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pips { display: flex; gap: 4px; }
.pip { flex: 1; height: 10px; border-radius: 2px; background: var(--pip-empty); }
.pip.on { background: var(--accent); }
.pips.warn .pip.on { background: var(--warn); } .pips.crit .pip.on { background: var(--crit); }
.count { display: flex; justify-content: space-between; font-size: 0.88rem; margin-top: 6px; }
.last { font-size: 0.88rem; border-top: 1px dashed var(--line); padding-top: 8px; }
.last p { margin: 2px 0 0; overflow-wrap: anywhere; }
.next { font-size: 0.88rem; color: var(--accent); font-weight: 700; margin-top: 2px; }
.next.today { color: var(--ok); } .next.none { color: var(--muted); font-weight: 400; }
.warnline { margin: 0; color: var(--warn); font-weight: 700; font-size: 0.85rem; }
.empty { color: var(--muted); padding: 18px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface); }

/* ---- Buttons and forms ---- */
button, .btn { font: inherit; font-size: 0.88rem; font-weight: 700; border-radius: 7px; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; }
button:hover, .btn:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.danger { color: var(--crit); }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 700; }
.linkbtn.danger { color: var(--crit); }
.chip { font-size: 0.78rem; padding: 3px 10px; min-height: 0; border-radius: 99px; text-decoration: none; border: 1px solid var(--line); color: var(--ok); font-weight: 700; background: var(--surface); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row2, .row3 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 400; font-size: 0.92rem; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; min-width: 0; }
textarea { resize: vertical; }
label.check input { width: 18px; height: 18px; margin: 0; }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.days legend { padding: 0; margin-bottom: 6px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.days label { flex-direction: row; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink); cursor: pointer; }
.days label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.days input { margin: 0; width: 16px; height: 16px; padding: 0; }

/* ---- Dashboard ---- */
.week { display: flex; flex-direction: column; gap: 10px; }
.day .dayhead { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.day.today .dayhead b { color: var(--accent); }
.day .row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; text-decoration: none; color: var(--ink); }
.day .row:hover span:first-child { text-decoration: underline; }
.earn { color: var(--ok); font-weight: 700; font-family: var(--mono); }
.act { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.act a { color: inherit; text-decoration: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pip-empty); }
.dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.tile .num { font-size: 1.3rem; font-weight: 600; }

/* ---- Student page ---- */
.blockhead { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-top: 6px; }
.sess { border-bottom: 1px dashed var(--line); }
.sess summary { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 4px 12px; padding: 9px 0; cursor: pointer; list-style: none; }
.sess summary::-webkit-details-marker { display: none; }
.sess .notes { margin: 0 0 8px; padding: 10px 12px; background: var(--bg); border-radius: 7px; white-space: pre-wrap; font-size: 0.88rem; }
.sess .linkbtn { margin-bottom: 10px; font-size: 0.8rem; }
.emailbox { display: flex; flex-direction: column; gap: 10px; }
.emailbox textarea { font-size: 0.92rem; line-height: 1.5; }

/* ---- Tables ---- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---- Sign-in, loading, toast ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.status.err, .loading.err { color: var(--crit); }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; z-index: 10; max-width: calc(100% - 32px); }
.toast.err { background: var(--crit); }
