/* Brand: #TEACH slate #2c3942 and reds #8a181a / #a72c23 (trainingeducators.com logo); University of Olivet crimson #b21f36. */
:root {
  --bg: #f4f5f6; --panel: #ffffff; --panel-2: #f7f8f9; --ink: #1f2a31; --ink-2: #47535c; --ink-3: #6b767e;
  --line: #dde1e4; --line-2: #eceef0;
  --brand: #2c3942; --brand-ink: #ffffff; --brand-2: #2c3942; --link: #8a181a; --accent: #a72c23; --olivet: #b21f36;
  --focus: #2f6fb0; --sel: #eef2f6;
  --ok: #1e7b4a; --ok-bg: #e5f4ec; --warn: #8a5a00; --warn-bg: #fdf3dc; --bad: #b42318; --bad-bg: #fdecea; --info: #1d4f91; --info-bg: #e8f0fb;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Montserrat", var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d; --panel: #1a1f28; --panel-2: #20262f; --ink: #e7eaf0; --ink-2: #b7bfcc; --ink-3: #8f99a8;
    --line: #2d3440; --line-2: #262c36; --brand: #1b242b; --brand-2: #4a6475; --link: #f08a84; --accent: #e0656b; --olivet: #e0656b; --focus: #6fa0db; --sel: #213249;
    --ok: #5fd197; --ok-bg: #173226; --warn: #f1c25b; --warn-bg: #362b12; --bad: #ff8a80; --bad-bg: #3a1b1a; --info: #8fb8ee; --info-bg: #1b2a40;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d; --panel: #1a1f28; --panel-2: #20262f; --ink: #e7eaf0; --ink-2: #b7bfcc; --ink-3: #8f99a8;
  --line: #2d3440; --line-2: #262c36; --brand: #1b242b; --brand-2: #4a6475; --link: #f08a84; --accent: #e0656b; --olivet: #e0656b; --focus: #6fa0db; --sel: #213249;
  --ok: #5fd197; --ok-bg: #173226; --warn: #f1c25b; --warn-bg: #362b12; --bad: #ff8a80; --bad-bg: #3a1b1a; --info: #8fb8ee; --info-bg: #1b2a40;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font: 700 22px/1.25 var(--display); margin: 0; letter-spacing: -.01em; }
h2 { font-family: var(--display); font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: var(--brand-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.12); border-top: 4px solid var(--accent); }
.brand .teach { display: block; width: 150px; height: auto; }
.brand .with { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; opacity: .6; margin: 10px 0 6px; }
.brand .olivet { display: block; width: 168px; height: auto; opacity: .95; }
.brand .app { display: block; font: 600 12px var(--display); letter-spacing: .04em; opacity: .8; margin-top: 12px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav a { color: rgba(255,255,255,.86); padding: 8px 12px; border-radius: 6px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 14px 12px 4px; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side .me { margin-top: auto; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12.5px; }
.side .me b { display: block; font-size: 13px; }
.side .me button { margin-top: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; min-height: 54px; }
.topbar .crumbs { font-size: 13px; color: var(--ink-3); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }

/* ---------- controls ---------- */
button, .btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primary, .btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.sm { padding: 3px 8px; font-size: 12.5px; }
.side button { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.side button:hover { background: rgba(255,255,255,.1); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
textarea { min-height: 70px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.field input, label.field select, label.field textarea { font-weight: 400; font-size: 14px; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.toolbar input[type=search] { min-width: 240px; }

/* ---------- panels ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-b { padding: 16px; }
.card .card-h { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.card .card-h h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat { border-top: 3px solid var(--brand); }
.stat .v { font-family: var(--display); font-size: clamp(18px, 4.6vw, 24px); overflow-wrap: anywhere; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .l { font-size: 12.5px; color: var(--ink-3); }
.stat a { color: inherit; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; background: var(--info-bg); color: var(--info); font-size: 13.5px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-width: 100%; }
.table-wrap.tall { max-height: calc(100vh - 230px); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
table.data th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 2; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover td { background: var(--panel-2); }
table.data tfoot td { position: sticky; bottom: 0; background: var(--panel-2); font-weight: 600; border-top: 1px solid var(--line); }
table.data tr.dim td { color: var(--ink-3); }
table.data tr.group td { background: var(--panel-2); font-weight: 600; }
table.data td select, table.data td input:not([type=checkbox]) { padding: 4px 6px; font-size: 13px; max-width: 100%; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* ---------- gradebook grid ---------- */
.gb-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 250px); }
table.gb { border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.gb th, table.gb td { border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 0; background: var(--panel); }
table.gb thead th { position: sticky; top: 0; z-index: 3; background: var(--panel-2); font-weight: 600; font-size: 12px; color: var(--ink-2); vertical-align: bottom; padding: 8px 8px 6px; min-width: 96px; max-width: 150px; white-space: normal; text-align: center; }
table.gb thead tr.max th { top: var(--gb-h1, 58px); font-weight: 500; color: var(--ink-3); padding: 4px 8px; }
table.gb th.stu, table.gb td.stu { position: sticky; left: 0; z-index: 2; text-align: left; min-width: 220px; max-width: 260px; padding: 6px 10px; background: var(--panel); }
table.gb thead th.stu { z-index: 4; background: var(--panel-2); }
table.gb td.stu .lvl { display: block; font-size: 11.5px; color: var(--ink-3); }
table.gb td.cell input { width: 100%; min-width: 84px; border: 0; border-radius: 0; background: transparent; text-align: center; padding: 7px 6px; font-variant-numeric: tabular-nums; }
table.gb td.cell input:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--sel); }
table.gb td.cell.saving input { color: var(--ink-3); }
table.gb td.cell.err input { background: var(--bad-bg); color: var(--bad); }
table.gb td.cell.over input { color: var(--warn); font-weight: 600; }
table.gb td.cell.flash input { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: var(--ok-bg); } 100% { background: transparent; } }
table.gb td.cell .ro { display: block; text-align: center; padding: 7px 6px; font-variant-numeric: tabular-nums; }
table.gb td.tot, table.gb th.tot { background: var(--panel-2); font-weight: 600; text-align: center; padding: 6px 10px; min-width: 70px; font-variant-numeric: tabular-nums; }
table.gb tr.dropped td { color: var(--ink-3); }
table.gb tr.dropped td.stu { text-decoration: line-through; }
table.gb th .due { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; margin-top: 2px; }
table.gb th .att { display: inline-block; font-size: 10.5px; color: var(--ink-3); }
.save-state { font-size: 12.5px; color: var(--ink-3); }
.save-state.bad { color: var(--bad); }
.save-state.ok { color: var(--ok); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 6px; vertical-align: middle; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

/* ---------- permission matrix ---------- */
table.matrix td, table.matrix th { text-align: center; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 250px; }
table.matrix td:first-child .small { max-width: none !important; }
table.matrix th:first-child { background: var(--panel-2); z-index: 3; }
table.matrix select { min-width: 86px; }
select.lvl-0 { color: var(--ink-3); }
select.lvl-1 { color: var(--info); }
select.lvl-2 { color: var(--ok); }
select.lvl-3 { color: var(--accent); font-weight: 600; }
.lvl-pill { display: inline-block; min-width: 62px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.lvl-pill.l0 { color: var(--ink-3); background: var(--panel-2); }
.lvl-pill.l1 { color: var(--info); background: var(--info-bg); }
.lvl-pill.l2 { color: var(--ok); background: var(--ok-bg); }
.lvl-pill.l3 { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---------- modal, toast, dropdown ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10,15,25,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.25); width: 100%; max-width: 560px; }
.modal.wide { max-width: 980px; }
.modal .m-h { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.modal .m-h h2 { margin: 0; flex: 1; }
.modal .m-b { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
.modal .m-f { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.bell { position: relative; }
.bell .count { position: absolute; top: -4px; right: -4px; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
.dropdown { position: absolute; right: 16px; top: 52px; width: 400px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.18); z-index: 50; max-height: 70vh; overflow-y: auto; }
.dropdown .n { padding: 10px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.dropdown .n:hover { background: var(--panel-2); }
.dropdown .n.unread { border-left: 3px solid var(--accent); }
.dropdown .n b { display: block; font-size: 13.5px; }
.dropdown .n span { font-size: 12.5px; color: var(--ink-3); white-space: pre-line; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, #3b4b57 0%, var(--brand) 55%, #1d262c 100%); }
.auth .card { width: 100%; max-width: 420px; border-top: 4px solid var(--accent); }
.auth .logos { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line-2); }
.auth .logos img { height: 44px; width: auto; }
.auth .logos .div { width: 1px; align-self: stretch; background: var(--line); }
.auth h1 { margin-bottom: 4px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }


/* ---------- walkthrough ---------- */
.tour-shade { position: fixed; inset: 0; background: rgba(15,20,26,.55); z-index: 300; }
.tour-spot { position: fixed; z-index: 301; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(15,20,26,.55), 0 0 0 3px var(--accent); pointer-events: none; transition: all .25s ease; }
.tour-card { position: fixed; z-index: 302; width: 360px; max-width: calc(100vw - 24px); background: var(--panel); border-radius: 10px; padding: 14px 16px; box-shadow: 0 18px 50px rgba(0,0,0,.3); border-top: 4px solid var(--accent); transition: top .25s ease, left .25s ease; }
.tour-card h3 { font: 700 16px/1.3 var(--display); margin: 6px 0; }
.tour-card p { font-size: 13.5px; }
.tour-top { display: flex; align-items: center; justify-content: space-between; }
.tour-dots { display: flex; gap: 5px; margin: 6px 0 10px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--accent); }
.tour-actions { display: flex; gap: 6px; align-items: center; }
.tour-tile { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; background: var(--panel-2); }
.tour-tile p { margin: 4px 0 8px; }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.flow-step { position: relative; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: 8px; padding: 12px 12px 6px; }
.flow-step .n { position: absolute; top: -12px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 12px/24px var(--display); text-align: center; }
.flow-step b { font-family: var(--display); }
.flow-step.faded { opacity: .45; }
details.faq { border-bottom: 1px solid var(--line-2); padding: 10px 0; }
details.faq:last-child { border-bottom: 0; }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { margin: 8px 0 2px; color: var(--ink-2); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 60px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
}
@media print {
  .side, .topbar, .toolbar, button { display: none !important; }
  .shell { display: block; }
  .table-wrap, .gb-wrap { max-height: none; overflow: visible; border: 0; }
}
