/* Calder XG instructor portal - shared styles (dashboard, login, teach, board). */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d5dbe3;
  --border-strong: #b8c1cc;
  --text: #121821;
  --text-2: #4a5566;
  --accent: #1f4f8f;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef9;
  --focus: #2f6fd0;
  --pass: #17703a; --pass-bg: #e3f4e9; --pass-bd: #9fd3b1;
  --warn: #8a5a00; --warn-bg: #fff4d6; --warn-bd: #f0cf7a;
  --fail: #b3261e; --fail-bg: #fde7e5; --fail-bd: #f1aaa4;
  --unknown: #4f5967; --unknown-bg: #eceff3; --unknown-bd: #c7ced8;
  --info: #1d5fae; --info-bg: #e3eefc; --info-bd: #a8c6ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1c2530;
    --border: #2c3744; --border-strong: #3c4a5a;
    --text: #e8edf3; --text-2: #a6b2c1;
    --accent: #5b9bef; --accent-ink: #0b1220; --accent-soft: #1b2b42; --focus: #7fb2ff;
    --pass: #6fd49a; --pass-bg: #123222; --pass-bd: #2b6b45;
    --warn: #f2c35b; --warn-bg: #3a2d0c; --warn-bd: #7a5c17;
    --fail: #ff8f86; --fail-bg: #3d1614; --fail-bd: #7e2f29;
    --unknown: #b3bcc8; --unknown-bg: #232c37; --unknown-bd: #3d4856;
    --info: #86b6f5; --info-bg: #14263f; --info-bd: #2f5687;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html.presenter { font-size: 20px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 0.95rem; line-height: 1.45;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .15rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.brand-title { display: block; font-weight: 700; line-height: 1.1; }
.brand-sub { display: block; font-size: .75rem; color: var(--text-2); }
.brand-lg .brand-mark { width: 2.8rem; height: 2.8rem; font-size: 1rem; }
.brand-lg .brand-title { font-size: 1.3rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
  padding: .45rem .75rem; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.session-user { color: var(--text-2); font-size: .85rem; }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .45rem .85rem; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .88rem;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--fail); filter: brightness(1.08); }
.btn-danger-outline { color: var(--fail); border-color: var(--fail-bd); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--info-bd); }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }
.input {
  font: inherit; font-size: .9rem; padding: .45rem .65rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); min-width: 14rem;
}
.toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--text-2); cursor: pointer; }
.toggle input { width: 1.05rem; height: 1.05rem; }

/* Page layout */
.page { max-width: 1680px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.status-line {
  margin: 0 0 1rem; padding: .55rem .85rem; border-radius: 8px;
  background: var(--info-bg); color: var(--info); border: 1px solid var(--info-bd); font-weight: 600;
}
.status-line.is-error { background: var(--fail-bg); color: var(--fail); border-color: var(--fail-bd); }
.status-line.is-ok { background: var(--pass-bg); color: var(--pass); border-color: var(--pass-bd); }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
}

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; border: 1px solid; white-space: nowrap; line-height: 1.5;
}
.chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.chip.lvl-pass { color: var(--pass); background: var(--pass-bg); border-color: var(--pass-bd); }
.chip.lvl-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-bd); }
.chip.lvl-fail { color: var(--fail); background: var(--fail-bg); border-color: var(--fail-bd); }
.chip.lvl-unknown { color: var(--unknown); background: var(--unknown-bg); border-color: var(--unknown-bd); }
.chip.lvl-info { color: var(--info); background: var(--info-bg); border-color: var(--info-bd); }
.chip.chip-plain::before { display: none; }
.chip-row { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

/* Integrations banner */
.integrations { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.integ {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem .9rem; box-shadow: var(--shadow);
}
.integ-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.integ-name { font-weight: 700; }
.integ-detail { font-size: .82rem; color: var(--text-2); overflow-wrap: anywhere; }
.integ-wide { grid-column: 1 / -1; }
details.perm summary { cursor: pointer; font-weight: 600; font-size: .88rem; }
.perm-table { margin-top: .5rem; }
.perm-table tr.row-limit td { background: var(--warn-bg); }

/* Cloudflare lab account */
.cf-body { padding: 1rem; }
.cf-body > .section-title:first-child { margin-top: 0; }
.radio-group { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .9rem; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.radio-group legend { font-weight: 700; font-size: .85rem; padding: 0 .3rem; }
.radio { display: flex; gap: .5rem; align-items: baseline; cursor: pointer; }

/* Student cards */
.students { display: flex; flex-direction: column; gap: 1.25rem; }
.student {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.student.is-reference { border-color: var(--info-bd); }
.student-head {
  display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.student-title { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.student-title h2 { font-size: 1.1rem; }
.student-zone { font-family: var(--mono); color: var(--text-2); font-size: .9rem; }
.student-actions { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.ref-badge {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--info); border: 1px solid var(--info-bd); background: var(--info-bg); border-radius: 4px; padding: .05rem .4rem;
}

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2);
  padding: .5rem .75rem; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap;
}
.table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.site-table td { min-width: 9rem; }
.site-table td.col-host { min-width: 12rem; }
.site-table td.col-actions { min-width: 8rem; }
.host { font-family: var(--mono); font-size: .85rem; display: block; overflow-wrap: anywhere; }
.host-primary { font-weight: 700; }
.kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 700; }
.cell-line { display: block; margin-top: .25rem; font-size: .82rem; color: var(--text-2); overflow-wrap: anywhere; }
.cell-line strong { color: var(--text); font-weight: 600; }
.drift { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--warn); font-size: .8rem; }
.rec-list { margin: .3rem 0 0; padding: 0; list-style: none; font-family: var(--mono); font-size: .76rem; color: var(--text-2); }
.rec-list li { overflow-wrap: anywhere; }
details.inline summary { cursor: pointer; font-size: .8rem; color: var(--accent); margin-top: .3rem; }
.actions-col { display: flex; flex-direction: column; gap: .35rem; align-items: stretch; }
.empty { padding: 1rem; color: var(--text-2); }

/* Checks list */
.checks { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.check {
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; background: var(--surface-2);
}
.check-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.check-label { font-weight: 600; font-size: .85rem; }
.check-id { font-family: var(--mono); font-size: .72rem; color: var(--text-2); }
.check-kv { display: grid; grid-template-columns: max-content 1fr; gap: .1rem .6rem; margin: .3rem 0 0; font-size: .8rem; }
.check-kv dt { color: var(--text-2); }
.check-kv dd { margin: 0; font-family: var(--mono); font-size: .78rem; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Audit */
.audit .table td { font-size: .82rem; }
.audit-table td.col-detail { max-width: 36rem; overflow-wrap: anywhere; font-family: var(--mono); font-size: .76rem; color: var(--text-2); }
.audit-table td.col-time { white-space: nowrap; }
.audit > .muted { padding: 1rem; margin: 0; }

/* Modals */
.modal {
  width: min(760px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal-wide { width: min(1040px, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(10, 16, 24, .55); }
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.modal-head p { margin: .2rem 0 0; }
.modal-body { padding: 1rem 1.2rem 1.4rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--text-2); font-size: .85rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 1.1rem 0 .5rem; font-weight: 700; }

/* Reset flow */
.warnings { margin: 0 0 1rem; padding: .6rem .9rem .6rem 2rem; border-radius: 8px; background: var(--warn-bg); border: 1px solid var(--warn-bd); color: var(--warn); }
.warnings li { margin: .15rem 0; }
.step-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .75rem; overflow: hidden; }
.step-group-head { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid var(--border); align-items: start; }
.step:last-child { border-bottom: 0; }
.step-order { font-family: var(--mono); color: var(--text-2); font-weight: 700; }
.step-action { font-weight: 600; }
.step-target { font-family: var(--mono); font-size: .8rem; color: var(--text-2); overflow-wrap: anywhere; }
.step-detail { font-size: .82rem; color: var(--text-2); margin-top: .15rem; overflow-wrap: anywhere; }
.step.is-failed { background: var(--fail-bg); }
.step.is-skipped { background: var(--unknown-bg); }
.destructive { color: var(--fail); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--fail-bd); border-radius: 4px; padding: .02rem .35rem; background: var(--fail-bg); }
.confirm-box { margin-top: 1rem; padding: .9rem; border: 1px solid var(--fail-bd); border-radius: 10px; background: var(--surface-2); }
.confirm-box .input { width: 100%; font-family: var(--mono); margin: .4rem 0 .7rem; }
.confirm-phrase { font-family: var(--mono); font-weight: 700; background: var(--unknown-bg); padding: .05rem .35rem; border-radius: 4px; user-select: all; }
.result-banner { padding: .8rem 1rem; border-radius: 10px; border: 1px solid; margin-bottom: 1rem; font-weight: 600; }
.result-banner.lvl-pass { color: var(--pass); background: var(--pass-bg); border-color: var(--pass-bd); }
.result-banner.lvl-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-bd); }
.result-banner.lvl-fail { color: var(--fail); background: var(--fail-bg); border-color: var(--fail-bd); }
.result-banner p { margin: .3rem 0 0; font-weight: 400; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.run { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; }
.run-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.8rem; box-shadow: var(--shadow);
}
.form { display: flex; flex-direction: column; gap: .9rem; margin: 1.4rem 0 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .88rem; }
.field input { font: inherit; font-weight: 400; padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.form-error { margin: 0; color: var(--fail); background: var(--fail-bg); border: 1px solid var(--fail-bd); padding: .5rem .7rem; border-radius: 8px; font-size: .88rem; }

@media (max-width: 720px) {
  .page { padding: 1rem; }
  .topbar { gap: .6rem; padding: .6rem 1rem; }
  .topbar-end { margin-left: 0; }
  .input { min-width: 0; width: 100%; }
  .student-actions { margin-left: 0; }
}
