/* =========================================================
   MedicoMedal — main stylesheet (flexbox layouts throughout)
   ========================================================= */
:root {
  --navy: #1B2F5B;
  --navy-700: #142447;
  --navy-50: #EEF1F7;
  --gold: #B3842A;
  --gold-600: #96701F;
  --gold-50: #F7EFDD;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --ink: #14213A;
  --muted: #5B6578;
  --line: #DCE0E7;
  --green: #1E7F4F;
  --green-50: #E5F4EC;
  --red: #B42318;
  --red-50: #FDECEA;
  --amber: #A15C07;
  --amber-50: #FEF3E2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 33, 58, .06), 0 6px 18px rgba(20, 33, 58, .06);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans);
}
img { max-width: 100%; }
a { color: var(--navy); }
a:hover { color: var(--gold-600); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; color: var(--navy); margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--navy); color: #fff; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }

.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.site-main { flex: 1; padding: 28px 0 48px; }

/* ---------- Flex utilities ---------- */
.flex { display: flex; }
.flex-wrap { display: flex; flex-wrap: wrap; gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.flex-center { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-1 { flex: 1 1 0; min-width: 0; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; }
.cols > * { flex: 1 1 280px; min-width: 0; }
.cols-wide > :first-child { flex: 2 1 420px; }
.gap-sm { gap: 8px; }

/* ---------- Header ---------- */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark {
  display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold); color: #fff; font: 700 1.15rem var(--serif); box-shadow: inset 0 0 0 3px rgba(255,255,255,.25);
}
.brand-text { font: 700 1.25rem var(--serif); letter-spacing: .02em; }
.site-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.site-nav a, .site-nav .link-btn {
  color: #DCE3F2; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: .95rem;
}
.site-nav a:hover, .site-nav .link-btn:hover, .site-nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.site-nav .btn { color: #fff; }
.nav-spacer { flex: 1; }
.nav-user { font-weight: 600; }
.inline-form { display: inline; margin: 0; }
.link-btn { background: none; border: 0; cursor: pointer; font: inherit; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle .bars, .nav-toggle .bars::before, .nav-toggle .bars::after {
  display: block; width: 22px; height: 2px; background: #fff; position: relative; content: '';
}
.nav-toggle .bars::before { position: absolute; top: -7px; }
.nav-toggle .bars::after { position: absolute; top: 7px; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 64px; background: var(--navy-700);
    flex-direction: column; align-items: stretch; padding: 8px 16px 16px;
  }
  .site-nav.open { display: flex; }
  .site-nav .nav-spacer { display: none; }
  .site-nav .btn { text-align: center; margin-top: 6px; }
  .site-nav .link-btn { text-align: left; width: 100%; }
}

/* ---------- Footer ---------- */
.site-footer { background: #fff; border-top: 1px solid var(--line); padding: 24px 0; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px 40px; justify-content: space-between; }
.footer-note { max-width: 620px; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--navy); color: #fff; font: 600 .95rem var(--sans); text-decoration: none; line-height: 1.2;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--navy-700); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); }
.btn-gold:hover { background: var(--gold-600); }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-outline:hover { background: var(--navy-50); color: var(--navy); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #8F1C13; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #17633D; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.cols > .card + .card, .course-list > .card + .card, .test-side > .card + .card { margin-top: 0; }
.cols { margin-bottom: 20px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }
.eyebrow { color: var(--gold); font-weight: 700; letter-spacing: .14em; font-size: .75rem; text-transform: uppercase; margin-bottom: 6px; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border-left: 4px solid; }
.alert-success { background: var(--green-50); border-color: var(--green); color: #134E31; }
.alert-error { background: var(--red-50); border-color: var(--red); color: #7A1810; }
.alert-info { background: var(--navy-50); border-color: var(--navy); }
.alert-warning { background: var(--amber-50); border-color: var(--amber); color: #6B3D05; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; }
.form-row > .field { flex: 1 1 220px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
input[type=search], input[type=file], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #C7CED9; border-radius: 8px; background: #fff;
  font: inherit; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy); outline: 2px solid rgba(27,47,91,.15); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.req { color: var(--red); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Auth pages */
.auth-wrap { display: flex; justify-content: center; padding: 10px 0 20px; }
.auth-card { width: 100%; max-width: 480px; }
.auth-card.wide { max-width: 680px; }
.auth-card h1 { text-align: center; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--navy-50); color: var(--navy); white-space: nowrap; }
.badge-easy { background: var(--green-50); color: var(--green); }
.badge-medium { background: var(--amber-50); color: var(--amber); }
.badge-hard { background: var(--red-50); color: var(--red); }
.status-draft { background: #EEF0F3; color: #4A5468; }
.status-review { background: var(--amber-50); color: var(--amber); }
.status-published { background: var(--green-50); color: var(--green); }
.status-retired { background: var(--red-50); color: var(--red); }
.badge-gold { background: var(--gold-50); color: var(--gold-600); }
.chip { display: inline-flex; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; background: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #F0F2F6; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.me td { background: var(--gold-50); font-weight: 600; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- Stats ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 14px; }
.stat { flex: 1 1 150px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .num { font: 700 1.7rem var(--serif); color: var(--navy); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.good .num { color: var(--green); }
.stat.bad .num { color: var(--red); }
.stat.gold .num { color: var(--gold-600); }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pager a, .pager span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; font-size: .9rem; }
.pager .current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Home page ---------- */
.hero { display: flex; flex-wrap: wrap; gap: 28px; align-items: center; background: linear-gradient(135deg, var(--navy) 0%, #24407A 100%); color: #fff; border-radius: 16px; padding: 44px 36px; margin-bottom: 32px; }
.hero > :first-child { flex: 1.4 1 360px; }
.hero > :last-child { flex: 1 1 280px; }
.hero h1 { color: #fff; font-size: clamp(1.9rem, 4.2vw, 2.8rem); }
.hero .tagline { font-family: var(--serif); font-style: italic; color: #F0D79D; font-size: 1.1rem; }
.hero p { color: #D8E0F0; max-width: 54ch; }
.hero .card { color: var(--ink); }
.hero .card p { color: var(--muted); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.hero-actions .btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.hero-actions .btn-outline:hover { background: rgba(255,255,255,.1); color: #fff; }
.features { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 32px; }
.feature { flex: 1 1 240px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.feature .icon { width: 42px; height: 42px; border-radius: 10px; background: var(--gold-50); color: var(--gold-600); display: flex; align-items: center; justify-content: center; font: 700 1.1rem var(--serif); margin-bottom: 12px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--muted); margin: 0; font-size: .95rem; }
.steps { display: flex; flex-wrap: wrap; gap: 14px; counter-reset: step; }
.steps li { flex: 1 1 200px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 18px 58px; position: relative; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.steps { padding: 0; margin: 0 0 32px; }
.course-list { display: flex; flex-wrap: wrap; gap: 18px; }
.course-col { flex: 1 1 300px; }
.year-block { margin-bottom: 12px; }
.year-block h4 { margin: 0 0 6px; font-size: .95rem; color: var(--ink); }
.subject-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Dashboard ---------- */
.subject-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.subject-card { flex: 1 1 240px; display: flex; flex-direction: column; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s; position: relative; }
.subject-card:hover { border-color: var(--navy); }
.subject-card input { position: absolute; opacity: 0; pointer-events: none; }
.subject-card.selected, .subject-card:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(179,132,42,.2); }
.subject-card:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.subject-card.disabled { opacity: .55; cursor: not-allowed; }
.subject-card .name { font: 700 1.05rem var(--serif); color: var(--navy); }
.subject-card .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { display: flex; }
.seg input { position: absolute; opacity: 0; }
.seg span { padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 600; }
.seg input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Test page ---------- */
.test-layout { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.test-main { flex: 1 1 520px; min-width: 0; }
.test-side { flex: 0 1 280px; position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; }
.test-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.timer { display: flex; align-items: center; gap: 8px; font: 700 1.3rem ui-monospace, monospace; color: var(--navy); background: #fff; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; }
.timer.warn { color: var(--red); border-color: var(--red); background: var(--red-50); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gold); width: 0; transition: width .2s; }
.question-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.question-card[hidden] { display: none; }
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.q-text { font-size: 1.12rem; font-weight: 600; margin-bottom: 18px; white-space: pre-line; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 9px; cursor: pointer; background: #fff; transition: border-color .12s, background .12s; }
.option:hover { border-color: #9AA6BB; }
.option input { position: absolute; opacity: 0; }
.option .letter { flex: 0 0 30px; height: 30px; border-radius: 50%; border: 1.5px solid #9AA6BB; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; color: var(--muted); }
.option .text { flex: 1; padding-top: 3px; }
.option:has(input:checked) { border-color: var(--navy); background: var(--navy-50); }
.option:has(input:checked) .letter { background: var(--navy); border-color: var(--navy); color: #fff; }
.option:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.q-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.q-nav .flex-center { gap: 8px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; color: var(--ink); }
.palette button.answered { background: var(--navy); color: #fff; border-color: var(--navy); }
.palette button.marked { background: var(--amber-50); border-color: var(--amber); color: var(--amber); }
.palette button.answered.marked { box-shadow: inset 0 -4px 0 var(--amber); }
.palette button.current { outline: 2px solid var(--gold); outline-offset: 1px; }
.legend { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); background: #fff; }
.legend .l-ans::before { background: var(--navy); border-color: var(--navy); }
.legend .l-mark::before { background: var(--amber-50); border-color: var(--amber); }
@media (max-width: 860px) { .test-side { position: static; flex: 1 1 100%; } }

/* ---------- Result page ---------- */
.result-hero { display: flex; flex-wrap: wrap; gap: 28px; align-items: center; }
.score-ring { --p: 0; flex: 0 0 auto; width: 170px; height: 170px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--ring, var(--navy)) calc(var(--p) * 1%), var(--line) 0); }
.score-ring .inner { width: 136px; height: 136px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .pct { font: 700 2rem var(--serif); color: var(--navy); line-height: 1; }
.score-ring .sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.rank-box { display: flex; flex-wrap: wrap; gap: 14px; }
.rank-tile { flex: 1 1 200px; border-radius: var(--radius); padding: 18px; background: linear-gradient(135deg, var(--gold-50), #fff); border: 1px solid #E9D9B4; }
.rank-tile .big { font: 700 2rem var(--serif); color: var(--gold-600); line-height: 1.1; }
.rank-tile .lbl { color: var(--muted); font-size: .85rem; }
.review-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.review-filter button { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: .85rem; }
.review-filter button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.review-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; border-left: 5px solid var(--line); }
.review-item.is-correct { border-left-color: var(--green); }
.review-item.is-wrong { border-left-color: var(--red); }
.review-item.is-skipped { border-left-color: #9AA6BB; }
.review-item .options .option { cursor: default; }
.option.correct { border-color: var(--green); background: var(--green-50); }
.option.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-50); }
.option.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.option .tag { font-size: .75rem; font-weight: 700; margin-left: auto; padding-top: 4px; white-space: nowrap; }
.option.correct .tag { color: var(--green); }
.option.wrong .tag { color: var(--red); }
.explain { margin-top: 14px; background: #F7F8FB; border-radius: 8px; padding: 14px 16px; border: 1px solid var(--line); }
.explain h4 { margin: 0 0 4px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--navy); }
.explain p { margin: 0 0 10px; }
.explain p:last-child { margin: 0; }
.flag-form { margin-top: 10px; }
.flag-form summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.flag-form form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.flag-form input { flex: 1 1 240px; }
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-row .name { flex: 0 0 38%; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--navy); border-radius: 99px; }
.bar-row .fill.low { background: var(--red); }
.bar-row .fill.mid { background: var(--gold); }
.bar-row .fill.high { background: var(--green); }
.bar-row .val { flex: 0 0 64px; text-align: right; font-size: .85rem; font-weight: 600; }

/* ---------- Admin ---------- */
.admin-body { background: #EEF0F4; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-side { flex: 0 0 240px; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side .brand { padding: 4px 8px 18px; }
.admin-side nav { display: flex; flex-direction: column; gap: 2px; }
.admin-side .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: #8E9DBD; padding: 14px 10px 6px; }
.admin-side nav a { color: #D6DDEC; text-decoration: none; padding: 9px 12px; border-radius: 7px; font-size: .92rem; display: flex; justify-content: space-between; align-items: center; }
.admin-side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-side nav a.active { background: var(--gold); color: #fff; }
.admin-side nav a .count { background: rgba(255,255,255,.18); border-radius: 99px; padding: 0 8px; font-size: .75rem; }
.admin-side .side-foot { margin-top: auto; padding: 14px 10px 0; font-size: .82rem; color: #A9B5CF; }
.admin-side .side-foot a, .admin-side .side-foot .link-btn { color: #fff; padding: 0; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.admin-top h1 { margin: 0; font-size: 1.35rem; }
.admin-content { padding: 24px 28px 48px; }
.admin-menu-btn { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { flex: 1 1 160px; }
.filters .field.grow { flex: 2 1 240px; }
.option-editor { display: flex; flex-direction: column; gap: 10px; }
.option-row { display: flex; gap: 10px; align-items: flex-start; }
.option-row .letter { flex: 0 0 34px; height: 40px; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--navy-50); border-radius: 8px; color: var(--navy); }
.option-row textarea { min-height: 42px; flex: 1; }
.option-row .correct-pick { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; height: 40px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.tree { display: flex; flex-direction: column; gap: 6px; }
.inline-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-edit input[type=text] { flex: 1 1 200px; width: auto; }
.inline-edit input[type=number] { flex: 0 0 80px; width: 80px; }
.preview-q { white-space: pre-line; }
.audit-list { display: flex; flex-direction: column; gap: 8px; font-size: .85rem; }
.audit-list .row { display: flex; gap: 10px; flex-wrap: wrap; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
pre.code { background: #F0F2F6; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: .8rem; }

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .admin-side.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .admin-menu-btn { display: inline-flex; }
  .admin-top, .admin-content { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 560px) {
  .hero { padding: 28px 20px; }
  .card { padding: 16px; }
  .question-card { padding: 18px; }
  .bar-row .name { flex-basis: 45%; }
  .option-row { flex-wrap: wrap; }
  .option-row textarea { flex-basis: calc(100% - 44px); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .site-header, .site-footer, .no-print, .flag-form, .review-filter { display: none !important; }
  body { background: #fff; }
  .card, .review-item { box-shadow: none; break-inside: avoid; }
}

/* ---------- Searchable dropdown ---------- */
.combo { position: relative; }
.combo-input { padding-right: 34px !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235B6578' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center; }
.combo-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; }
.combo-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #C7CED9; border-radius: 8px; box-shadow: 0 10px 28px rgba(20,33,58,.16); }
.combo-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; }
.combo-list li small { color: var(--muted); font-size: .78rem; }
.combo-list li.active { background: var(--navy-50); }
.combo-list li[aria-selected="true"] { font-weight: 600; }
.combo-list li.combo-empty { color: var(--muted); }
.combo-list li.combo-none { color: var(--muted); cursor: default; }
.site-footer a { color: var(--navy); font-weight: 600; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Modal (query reply) ---------- */
dialog.modal { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 24px 60px rgba(20,33,58,.3); }
dialog.modal::backdrop { background: rgba(20,33,58,.55); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { padding: 18px 22px 22px; }
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; max-width: 92%; }
.msg.in { align-self: flex-start; background: #F7F8FB; }
.msg.out { align-self: flex-end; background: var(--navy-50); border-color: #CBD4E6; }
.msg .meta { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.msg .text { white-space: pre-line; font-size: .95rem; }
.contact-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; margin-bottom: 14px; }
.contact-meta a { word-break: break-all; }
tr.unread td:first-child { box-shadow: inset 4px 0 0 var(--gold); }

/* ---------- Toasts (replace on-page alerts) ---------- */
.js .alert { display: none; }  /* converted to toasts by ui.js; still visible without JavaScript */
.toast-stack { position: fixed; top: 76px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.admin-body .toast-stack, dialog .toast-stack { top: 16px; }
.toast { pointer-events: auto; position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px;
  background: #fff; color: var(--ink); border-radius: 10px; border: 1px solid var(--line); border-left: 5px solid var(--navy);
  box-shadow: 0 12px 32px rgba(20,33,58,.18); animation: toast-in .25s ease-out; font-size: .93rem; line-height: 1.45; }
.toast.leaving { animation: toast-out .25s ease-in forwards; }
.toast-icon { flex: 0 0 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; color: #fff; background: var(--navy); }
.toast-body { flex: 1; min-width: 0; }
.toast-body ul { margin: 6px 0 0; padding-left: 18px; }
.toast-title { display: block; margin-bottom: 2px; }
.toast-content.toast-row { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.toast-body .btn { margin-top: 4px; }
.toast-close { flex: 0 0 auto; background: none; border: 0; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
.toast-close:hover { color: var(--ink); }
.toast.timed::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .25; transform-origin: left; animation: toast-timer var(--toast-ms, 5000ms) linear forwards; }
.toast.paused::after { animation-play-state: paused; }
.toast-success { border-left-color: var(--green); } .toast-success .toast-icon { background: var(--green); } .toast-success.timed::after { color: var(--green); }
.toast-error { border-left-color: var(--red); } .toast-error .toast-icon { background: var(--red); }
.toast-warning { border-left-color: var(--amber); } .toast-warning .toast-icon { background: var(--amber); } .toast-warning.timed::after { color: var(--amber); }
.toast-info .toast-icon { background: var(--navy); } .toast-info.timed::after { color: var(--navy); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 560px) { .toast-stack { top: 72px; left: 12px; right: 12px; width: auto; } }

/* ---------- Confirm popup ---------- */
dialog.confirm-modal { width: min(440px, calc(100% - 24px)); }
.confirm-box { display: flex; gap: 14px; padding: 22px 22px 8px; }
.confirm-icon { flex: 0 0 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 800 1.2rem var(--sans); background: var(--navy-50); color: var(--navy); }
.confirm-modal.danger .confirm-icon { background: var(--red-50); color: var(--red); }
.confirm-text h2 { margin: 6px 0 6px; font-size: 1.15rem; }
.confirm-text p { margin: 0; color: var(--muted); white-space: pre-line; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex-wrap: wrap; }
dialog.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Footer columns ---------- */
.footer-right { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 8px; max-width: 620px; }
@media (max-width: 700px) { .footer-right { align-items: flex-start; text-align: left; } }
