/* Code Blue — exam portal theme.
   Tokens, card treatment and type are taken from the Arena site
   (arena-edu-bd.vercel.app), read off its own :root rather than eyeballed:
     warm-white ground, white cards that are SQUARE with one soft shadow and no
     border, 36px of padding, maroon for action, gold for accent, dark plum for
     the masthead, and colour used only to carry meaning.
   Body is 16px here rather than the site's 18px: this is a dense operations
   console with wide tables, not a marketing page. */
:root {
  /* Brand — exact values from the site */
  --maroon: #7A1730;
  --maroon-d: #5F1024;
  --plum: #1C1118;          /* masthead */
  --gold: #BF872B;          /* accent, active state, the mark itself */
  --gold-ink: #8B601B;      /* gold that is legible as text */

  /* Ground and surfaces */
  --bg: #FAF7F2;            /* warm white — the page */
  --section: #EEECE8;       /* the grey band sections sit on */
  --surface: #FFFFFF;       /* cards */
  --surface-2: #F2EFEB;     /* hover rows, wells */
  --border: #DDD5CD;

  /* Ink */
  --ink: #202124;
  --secondary: #4B4648;
  --muted: #70666B;
  --on-dark: #FAF7F2;
  --on-dark-muted: #A79DA3;

  /* Status — text and rules only, never a filled card */
  --ok: #1F6F43;
  --warn: #8B601B;
  --bad: #A8322C;

  --shadow: 0 4px 16px -8px rgba(28, 17, 24, .16);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gap: 24px;
  --pad: 32px;
  --r: 2px;                 /* controls only — cards are square */
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.015em; margin: 0; line-height: 1.15; }
h1 { font-size: 38px; } h2 { font-size: 27px; } h3 { font-size: 20px; }
a { color: var(--maroon); text-underline-offset: 3px; text-decoration-color: #D7BFC6; }
a:hover { text-decoration-color: var(--maroon); }
code, .mono { font-family: var(--mono); font-size: 13.5px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Masthead: dark plum, reversed logo, gold rule ---------- */
.topbar {
  background: var(--plum); color: var(--on-dark); padding: 14px 28px;
  display: flex; align-items: center; gap: 18px; border-bottom: 3px solid var(--gold);
}
.topbar .brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar .brand img { height: 34px; width: auto; display: block; flex: none; }
/* Divider + product name sit beside the institute logo */
.topbar .brand .pname {
  font-family: var(--serif); font-size: 19px; font-weight: 500; white-space: nowrap;
  padding-left: 14px; border-left: 1px solid #3A2B33; color: var(--on-dark);
}
.topbar .brand .pname b { font-weight: 500; color: var(--gold); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--on-dark-muted); font-size: 13px; }
.topbar button { background: transparent; color: var(--on-dark); border: 1px solid #3A2B33; }
.topbar button:hover { background: #2A1B23; border-color: var(--gold); }
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .topbar .brand .pname { font-size: 16px; }
}

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: var(--gap) var(--gap) 56px; }
.wrap.narrow { max-width: 780px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: var(--gap); }

/* ---------- Card: white, square, one soft shadow, no border ---------- */
.card { background: var(--surface); border: 0; border-radius: 0; padding: var(--pad); box-shadow: var(--shadow); }
.card h2, .card h3 { margin-bottom: 14px; }
/* Status reads as a rule down the edge, not a wash across the card */
.card.ok   { box-shadow: var(--shadow), inset 3px 0 0 var(--ok); }
.card.warn { box-shadow: var(--shadow), inset 3px 0 0 var(--warn); }
.card.bad  { box-shadow: var(--shadow), inset 3px 0 0 var(--bad); }

.label { font-size: 13px; color: var(--muted); letter-spacing: 0; text-transform: none; }
.big { font-size: 21px; font-family: var(--mono); overflow-wrap: break-word; }
.muted { color: var(--muted); } .small { font-size: 14px; }

/* ---------- Controls ---------- */
button, .btn {
  font: 500 15px var(--sans); padding: 11px 20px; border-radius: var(--r);
  border: 1px solid var(--maroon); background: var(--maroon); color: #fff;
  cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.2;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
button:hover, .btn:hover { background: var(--maroon-d); border-color: var(--maroon-d); }
button.ghost, .btn.ghost { background: transparent; color: var(--maroon); border-color: #CFC4C8; }
button.ghost:hover { background: #F6EEF0; border-color: var(--maroon); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.danger:hover { background: #8E2621; border-color: #8E2621; }
button.sm, .btn.sm { padding: 6px 12px; font-size: 13.5px; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:disabled:hover { background: var(--maroon); border-color: var(--maroon); }
button.danger:disabled:hover { background: var(--bad); border-color: var(--bad); }

input, select, textarea {
  font: 15px var(--sans); padding: 11px 13px; border: 1px solid var(--border);
  border-radius: var(--r); background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 170px; }
/* A checkbox is not a text field. Without this it inherits flex:1 and min-width:170px
   from the rule above, stretches into a wide box and throws its label to the far side
   of the card. Inline width:auto cannot beat either property. */
.row > input[type="checkbox"], .row > input[type="radio"] { flex: 0 0 auto; width: auto; min-width: 0; margin: 0; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; accent-color: var(--maroon); cursor: pointer; }
/* Checkbox + wrapping label: keep the box on the first line of the text. */
label.row { align-items: flex-start; gap: 10px; cursor: pointer; }
label.row > input[type="checkbox"] { margin-top: 3px; }
form.card > * + * { margin-top: 18px; }
.field .label { display: block; margin-bottom: 6px; }

/* ---------- Pills: outlined ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
  font-weight: 500; background: transparent; color: var(--secondary); border: 1px solid var(--border);
}
.pill.ok     { color: var(--ok);      border-color: #AFCCBB; }
.pill.bad    { color: var(--bad);     border-color: #E0B6B4; }
.pill.warn   { color: var(--gold-ink);border-color: #DCC9A6; }
.pill.maroon { color: var(--maroon);  border-color: #D7BFC6; }

/* ---------- Tables ---------- */
/* No rule under the header: a timid hairline across a wide card reads as filler.
   The header is set apart by colour, size and space instead, the way the site's
   course cards separate a label from its value. */
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 13px;
  letter-spacing: 0; text-transform: none; padding: 0 14px 14px; border: 0; white-space: nowrap;
}
table.data td { padding: 14px; border-top: 1px solid #F1EEEA; vertical-align: middle; }
table.data tr:hover td { background: var(--surface-2); }
.scroll { overflow-x: auto; }

/* ---------- Bulk actions ----------
   Appears only when rows are selected, and sticks to the top of the viewport so it
   stays reachable while scrolling a cohort of twenty-five. */
.bulkbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; padding: 14px 18px; margin: 0 0 2px; background: var(--plum);
  color: var(--on-dark); box-shadow: var(--shadow);
}
.bulkbar .count { font-weight: 500; margin-right: 4px; white-space: nowrap; }
.bulkbar .sep { width: 1px; height: 22px; background: #3A2B33; }
.bulkbar button { background: transparent; color: var(--on-dark); border-color: #46343E; }
.bulkbar button:hover { background: #2A1B23; border-color: var(--gold); }
.bulkbar button.danger { border-color: #7E2B27; color: #F0B7B3; }
.bulkbar button.danger:hover { background: #3A1A1A; border-color: var(--bad); }
.bulkbar .x { margin-left: auto; }
td.pick, th.pick { width: 34px; padding-right: 0; }

/* ---------- Actions pinned to the top of a record ---------- */
.modal .head { flex-direction: column; align-items: stretch; gap: 14px; }
.head-top { display: flex; align-items: flex-start; gap: 16px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions .sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ---------- Overview row furniture ---------- */
/* Connection state as a dot, not a sentence: scannable down a column of 25. */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #CFC9C2; margin-right: 8px; vertical-align: 1px; }
.dot.on { background: var(--ok); }
.dot.off { background: #CFC9C2; }

/* Marks as a bar plus one line of figures, replacing four separate columns. */
.prog { height: 5px; background: #EDE9E4; overflow: hidden; width: 148px; max-width: 100%; }
.prog > i { display: block; height: 100%; background: var(--maroon); }
.prog.pass > i { background: var(--ok); }
.figs { font-size: 13px; margin-top: 6px; white-space: nowrap; }
.figs b { font-size: 14.5px; }
.who-id { font-weight: 500; }
.who-id:hover { text-decoration: underline; }

/* ---------- Challenge rows ---------- */
.chal { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid #F0EDE8; }
.chal:last-child { border-bottom: 0; }
.chal .t { font-weight: 500; }
.chal.done .t::before { content: "✓ "; color: var(--ok); }
.hint { margin-top: 10px; padding: 14px 16px; background: var(--surface-2); box-shadow: inset 3px 0 0 var(--gold); font-size: 14.5px; }

/* ---------- Tabs: gold underline for the active one, as on the site nav ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); flex-wrap: wrap; }
.tabs button {
  background: transparent; color: var(--secondary); border: 0; border-bottom: 3px solid transparent;
  border-radius: 0; padding: 12px 16px; font-weight: 400;
}
.tabs button.on { color: var(--maroon); border-bottom-color: var(--gold); font-weight: 500; }
.tabs button:hover { background: transparent; color: var(--maroon); }

/* ---------- Stats ---------- */
.stat { text-align: left; }
.stat .n { font-family: var(--serif); font-size: 38px; line-height: 1.1; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }

.matrix td.c { text-align: center; font-family: var(--mono); font-size: 12.5px; }
.matrix td.y { color: var(--ok); }
.log {
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all;
  max-height: 540px; overflow: auto; background: var(--plum); color: #D8D0D4; padding: 16px;
}
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--plum); color: var(--on-dark);
  padding: 14px 18px; max-width: 440px; z-index: 50; font-size: 14.5px; box-shadow: var(--shadow);
  border-left: 3px solid var(--gold);
}
.center-login { max-width: 440px; margin: 9vh auto; padding: 0 16px; }

/* ---------- Gateway: the student's first screen ----------
   Two panels. The left carries the institute's hero language — deep plum with a
   warm radial glow behind the mark, serif display, gold eyebrow. The right is the
   form, on plain warm-white so nothing competes with the one field that matters. */
.gateway { display: grid; grid-template-columns: 1.05fr .95fr; min-height: calc(100vh - 68px); }
.gw-brand {
  position: relative; overflow: hidden; display: flex; align-items: center;
  padding: 72px 64px; color: var(--on-dark);
  background:
    radial-gradient(58% 52% at 46% 44%, rgba(191,135,43,.24), transparent 68%),
    linear-gradient(158deg, #3E0F1F 0%, #27141D 46%, #1C1118 100%);
}
/* the institute mark, oversized and faint, as the site does behind its sections */
.gw-brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background: url("/static/brand/arena-mark.svg") no-repeat 78% 50% / auto 78%;
}
.gw-inner { position: relative; z-index: 1; max-width: 520px; }
.gw-eyebrow {
  margin: 0 0 18px; font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); font-weight: 500;
}
.gw-brand h1 { font-size: clamp(44px, 5.2vw, 68px); color: #fff; margin: 0; line-height: 1.02; }
.gw-lead { margin: 20px 0 0; font-size: 18px; line-height: 1.55; color: #D9CDD3; max-width: 44ch; }
.gw-facts { list-style: none; margin: 36px 0 0; padding: 0; display: grid; gap: 14px; }
.gw-facts li {
  position: relative; padding-left: 20px; font-size: 15px; color: #C9BBC2; line-height: 1.5;
}
.gw-facts li::before {
  content: ""; position: absolute; left: 0; top: .62em; width: 7px; height: 7px;
  background: var(--gold);
}
.gw-facts b { color: #F2E9EC; font-weight: 500; }

.gw-form { display: flex; align-items: center; justify-content: center; padding: 56px 40px; background: var(--bg); }
.gw-card { width: 100%; max-width: 420px; background: var(--surface); padding: 40px; box-shadow: var(--shadow); }
.gw-card > * + * { margin-top: 18px; }
.gw-card h2 { margin: 0; }
.gw-card p.muted { margin: 8px 0 0; }
/* The code is the one thing being typed: give it room and track it out. */
.gw-card #code {
  font-family: var(--mono); font-size: 19px; letter-spacing: .13em;
  text-transform: uppercase; padding: 14px; text-align: center;
}
.gw-card #code::placeholder { letter-spacing: .13em; color: #B6ADA6; text-transform: none; }
.gw-msg:empty { display: none; }
.gw-msg.is-error, .is-error { color: var(--bad); }

@media (max-width: 940px) {
  .gateway { grid-template-columns: 1fr; min-height: 0; }
  .gw-brand { padding: 48px 28px; }
  .gw-brand::before { background-position: 110% 50%; opacity: .06; }
  .gw-lead { font-size: 16.5px; }
  .gw-facts { margin-top: 26px; }
  .gw-form { padding: 36px 20px 56px; }
  .gw-card { padding: 28px; box-shadow: none; }
}
.hidden { display: none !important; }
.bar { height: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--maroon); }

/* ---------- Watermark: the institute mark, oversized and very faint ---------- */
.watermark { position: relative; overflow: hidden; }
.watermark > * { position: relative; z-index: 1; }
.watermark::before {
  content: ""; position: absolute; z-index: 0; pointer-events: none;
  top: 50%; right: -40px; transform: translateY(-50%);
  width: 320px; height: 340px; opacity: .05;
  background: url("/static/brand/arena-mark.svg") no-repeat center / contain;
}
@media (max-width: 760px) { .watermark::before { display: none; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(28,17,24,.5); display: flex; padding: var(--gap); overflow: auto; }
.modal .sheet { background: var(--surface); border-radius: 0; width: 100%; max-width: 920px; margin: auto; padding: 0; box-shadow: 0 24px 64px -24px rgba(28,17,24,.5); }
.modal .sheet.narrow { max-width: 560px; }
.modal .head {
  display: flex; align-items: flex-start; gap: 16px; padding: 26px var(--pad);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal .head .x { background: transparent; border: 1px solid #CFC4C8; color: var(--maroon); margin-left: auto; padding: 6px 14px; }
.modal .head .x:hover { background: #F6EEF0; border-color: var(--maroon); }
.modal .body { padding: var(--gap); background: var(--section); }
.modal .body > * + * { margin-top: var(--gap); }
@media (max-width: 680px) { .modal { padding: 0; } .modal .sheet { min-height: 100%; } }

/* Facts grid — small grey label over a dark value, as on the site's course cards */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 22px; }
.kv .k { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.kv .v { font-family: var(--mono); font-size: 14px; overflow-wrap: break-word; }

.section-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title .count { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

.danger-zone { box-shadow: var(--shadow), inset 3px 0 0 var(--bad); }
.danger-zone h3 { color: var(--ink); }
