/* ITeLearn Analytics — tokens first, then layout, then components */
:root {
  color-scheme: light;
  --bg: #eef1f6;
  --raised: #f8fafc;
  --ink: #0b1220;
  --ink-2: #414d63;
  --muted: #5b677d;
  --line: #d3dae6;
  --line-soft: #e2e7f0;
  --signal: #1c62dd;
  --signal-wash: rgba(28, 98, 221, .10);
  --live: #d6303a;
  --live-wash: rgba(214, 48, 58, .10);
  --good: #0c7a52;
  --warn: #9a5b00;
  --shadow: 0 18px 50px rgba(11, 18, 32, .16);
  --display: "Bricolage Grotesque", "Segoe UI Variable Display", system-ui, sans-serif;
  --text: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0a101c;
    --raised: #111a2b;
    --ink: #eaf0fa;
    --ink-2: #b3bdd0;
    --muted: #8b98b0;
    --line: #253150;
    --line-soft: #1a2540;
    --signal: #5aa2ff;
    --signal-wash: rgba(90, 162, 255, .14);
    --live: #ff7078;
    --live-wash: rgba(255, 112, 120, .13);
    --good: #3fd693;
    --warn: #f0b04a;
    --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a101c;
  --raised: #111a2b;
  --ink: #eaf0fa;
  --ink-2: #b3bdd0;
  --muted: #8b98b0;
  --line: #253150;
  --line-soft: #1a2540;
  --signal: #5aa2ff;
  --signal-wash: rgba(90, 162, 255, .14);
  --live: #ff7078;
  --live-wash: rgba(255, 112, 120, .13);
  --good: #3fd693;
  --warn: #f0b04a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, h2, h3, p, dl, dd, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
.num, .fig { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 12px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { font: 700 18px/1 var(--display); letter-spacing: -.01em; margin-right: auto; }
.brand span { font-weight: 400; color: var(--muted); margin-left: 8px; }
.sync { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sync[data-stale="true"] { color: var(--warn); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }
.sync[data-stale="true"] .dot { background: var(--warn); }
.btn {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--signal-wash); border-color: var(--signal); }
.btn-primary { background: var(--signal); border-color: var(--signal); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--signal); filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.bar .btn { white-space: nowrap; }
.account { display: flex; align-items: center; gap: 8px; }
.account form { margin: 0; }
.account .btn { display: inline-flex; align-items: center; text-decoration: none; }
.account .who { font-size: 13.5px; color: var(--ink-2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .account .who { display: none; } }
@media (max-width: 560px) {
  .bar { flex-wrap: wrap; row-gap: 4px; }
  .brand span { display: none; }
  .sync { order: 3; flex-basis: 100%; }
}
kbd { font: 500 12px var(--text); padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); }

/* page grid */
.shell {
  max-width: 1240px; margin: 0 auto;
  padding: 36px max(20px, env(safe-area-inset-right)) 120px max(20px, env(safe-area-inset-left));
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px;
}
@media (min-width: 1040px) { .shell { grid-template-columns: minmax(0, 1fr) 340px; gap: 64px; } }
main > section + section { margin-top: 64px; }
.rail { min-width: 0; }
@media (min-width: 1040px) { .rail-inner { position: sticky; top: 84px; } }

h2 { font: 650 22px/1.2 var(--display); letter-spacing: -.01em; text-wrap: balance; }
.lede { color: var(--ink-2); max-width: 62ch; margin-top: 6px; text-wrap: pretty; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }

/* briefing */
.brief-range { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
h1 {
  font: 620 clamp(30px, 4.6vw, 52px)/1.06 var(--display);
  letter-spacing: -.025em; max-width: 24ch; text-wrap: balance;
}
.changes { margin-top: 32px; border-top: 1px solid var(--line); }
.change {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 4px 20px;
  padding: 16px 0; border-bottom: 1px solid var(--line-soft); align-items: baseline;
}
.change .fig { font: 620 30px/1 var(--display); letter-spacing: -.02em; }
.change h3 { font: 600 15px/1.3 var(--text); }
.change p { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; text-wrap: pretty; }
.quiet { margin-top: 28px; color: var(--ink-2); }

/* ledger */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-block: 1px solid var(--line); }
.ledger > div { padding: 18px 20px 18px 0; }
@media (min-width: 720px) { .ledger > div + div { padding-left: 20px; border-left: 1px solid var(--line-soft); } }
.ledger > div { display: flex; flex-direction: column; }
.ledger dd { font: 620 30px/1.1 var(--display); letter-spacing: -.02em; }
.ledger dt { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.ledger .sub { color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }

/* registrants next */
.next-rows { display: grid; gap: 14px; }
.next-row { display: grid; grid-template-columns: minmax(130px, 200px) minmax(0, 1fr) 138px; gap: 8px 16px; align-items: center; }
.next-row .label { font-size: 14.5px; }
.track { height: 30px; background: var(--line-soft); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: var(--w); background: var(--signal); border-radius: 0 6px 6px 0; transform-origin: left center; animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 90ms); }
.next-row:first-child .fill { background: var(--ink-2); opacity: .55; border-radius: 0; }
.next-row .val { text-align: right; font-size: 14px; }
.next-row .val b { font: 620 17px var(--display); }
@keyframes grow { from { transform: scaleX(0); } }
@media (max-width: 640px) {
  .next-row { grid-template-columns: 1fr auto; }
  .next-row .track { grid-column: 1 / -1; grid-row: 2; }
}

/* two column area */
.two { display: grid; grid-template-columns: minmax(0, 1fr); gap: 56px; }
@media (min-width: 900px) { .two { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; } }
.scroll { overflow-x: auto; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 0 12px 8px 0; }
th.r, td.r { text-align: right; padding-right: 0; }
td { padding: 11px 12px 11px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.rate { display: inline-flex; align-items: center; gap: 8px; }
.rate i { display: block; width: 44px; height: 6px; border-radius: 3px; background: var(--line-soft); position: relative; overflow: hidden; }
.rate i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--signal); border-radius: 3px; }

.offer { display: grid; gap: 4px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.offer:first-child { border-top: 0; padding-top: 0; }
.offer-top { display: flex; justify-content: space-between; gap: 12px; }
.offer-top span:first-child { overflow-wrap: anywhere; }
.offer i { display: block; height: 5px; border-radius: 3px; background: var(--signal); width: var(--w); min-width: 3px; opacity: .85; }
.offer small { color: var(--muted); font-size: 12.5px; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .hit:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; border-radius: 4px; }
.chart .hit:hover { fill: var(--signal-wash); }
.tip {
  position: absolute; pointer-events: none; z-index: 3; display: none;
  background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.35; white-space: nowrap;
}
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; color: var(--ink-2); font-size: 13px; min-height: 32px; display: flex; align-items: center; }
.charts-2 { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .charts-2 { grid-template-columns: 1fr 1fr; gap: 48px; } }
.charts-2 h3 { font: 600 15px var(--text); margin-bottom: 14px; }

/* rail: upcoming webinars */
.rail h2 { display: flex; align-items: center; gap: 10px; }
.live-tag { font: 600 12px var(--text); color: var(--live); background: var(--live-wash); padding: 2px 9px; border-radius: 99px; }
.rooms { margin-top: 16px; border-top: 1px solid var(--line); }
.room { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.room h3 { font: 600 15.5px/1.3 var(--text); overflow-wrap: anywhere; text-wrap: balance; }
.room .when { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.room .row { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-top: 10px; }
.room .count { font: 620 28px/1 var(--display); letter-spacing: -.02em; }
.room .count small { display: block; font: 400 12.5px var(--text); color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.room .gain { color: var(--good); font-weight: 600; }
.room a { color: var(--signal); font-size: 13.5px; display: inline-block; margin-top: 8px; text-underline-offset: 3px; min-height: 24px; transition: text-decoration-thickness .15s; }
.room a:hover { text-decoration-thickness: 2px; }
.spark { width: 132px; height: 34px; flex: none; }

/* ask sheet */
.fab {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 30;
  min-height: 48px; padding: 0 20px; border-radius: 99px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
}
.fab kbd { color: inherit; border-color: rgba(255, 255, 255, .5); }
@media (max-width: 640px) { .fab kbd { display: none; } }
.sheet {
  position: fixed; inset: 0 0 0 auto; z-index: 40; width: min(460px, 100%);
  background: var(--raised); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transform: translateX(105%); visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s .28s;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet[data-open="true"] { transform: none; visibility: visible; transition-delay: 0s; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.sheet-head h2 { font-size: 18px; }
.log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.empty h3 { font: 620 20px/1.2 var(--display); margin-bottom: 6px; }
.empty p { color: var(--ink-2); margin-bottom: 14px; }
.chips { display: grid; gap: 8px; }
.chip { text-align: left; padding: 11px 14px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; transition: background-color .15s, border-color .15s; }
.chip:hover { background: var(--signal-wash); border-color: var(--signal); }
.msg { overflow-wrap: anywhere; }
.msg .by { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.user .by { color: rgba(255, 255, 255, .8); }
.msg.user.other { align-self: flex-start; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; }
.msg.user.other .by { color: var(--muted); }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--signal); color: #fff; padding: 9px 14px; border-radius: 14px 14px 4px 14px; }
.msg.bot { border-left: 2px solid var(--line); padding-left: 14px; }
.msg.bot > div + div, .msg.bot ul + div { margin-top: 8px; }
.live-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.live-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; transform: translateY(-1px); }
.live-note.warn { color: var(--warn); }
.live-note.warn::before { background: var(--warn); }
.msg.bot ul { list-style: disc; padding-left: 20px; margin: 6px 0; }
.ask { display: flex; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line-soft); }
.ask input { flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.ask input:focus-visible { outline-offset: 0; border-color: var(--signal); }

@media (prefers-reduced-motion: reduce) {
  .fill { animation: none; }
  .sheet { transition: none; }
  * { scroll-behavior: auto !important; }
}
