/* EbbDeck — core design system (colours from the app's Theme.swift). Section files (public.css, qbank.css, test.css, account.css, admin.css) add page styles. */
:root {
  --bg: #EEF2F7;
  --surface: #F7F9FC;
  --card: #ffffff;
  --line: #E4E9F0;
  --line-strong: #CCD6E3;
  --text: #16243A;
  --text-2: #3A4A62;
  --muted: #56657C;
  --primary: #2F6BDC;
  --primary-hover: #1F4EAF;
  --on-primary: #ffffff;
  --deep: #1F4EAF;
  --on-deep: #ffffff;
  --on-deep-muted: #D6E4FB;
  --accent-soft: #EAF1FD;
  --accent-soft-text: #1F4EAF;
  --teal: #0B7E8A; --teal-bg: #E3F4F5;
  --flame: #F0792E;
  --ok: #17784F; --ok-bg: #E6F5EF;
  --bad: #B8344A; --bad-bg: #FBE8EB;
  --mark: #8A5608; --mark-bg: #FAF0D9; --mark-strong: #CF8A1C;
  --ph-bg: #fff6e0; --ph-text: #7a4b00;
  --focus: #2F6BDC;
  --brand: #2F6BDC;
  --hero-grad: linear-gradient(150deg, #2E52B4 0%, #3E68D6 55%, #4F7FE4 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(14, 26, 43, .04), 0 4px 16px rgba(14, 26, 43, .04);
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D131D; --surface: #111925; --card: #161E2B; --line: #2A3543; --line-strong: #3A4757;
    --text: #EAF0F8; --text-2: #C4D0DF; --muted: #9FB0C5;
    --primary: #4D86E6; --primary-hover: #6F9DEC; --on-primary: #0D131D;
    --deep: #18253D; --on-deep: #EAF0F8; --on-deep-muted: #A9C6F5;
    --accent-soft: #18253D; --accent-soft-text: #A9C6F5; --teal: #3FD2DC; --teal-bg: #10292C; --flame: #F58A45;
    --ok: #34C88A; --ok-bg: #10271E; --bad: #F0667A; --bad-bg: #2C1A1F; --mark: #E0A23A; --mark-bg: #2A2212; --mark-strong: #E0A23A;
    --ph-bg: #33260F; --ph-text: #E8B45C; --focus: #6F9DEC; --hero-grad: linear-gradient(150deg, #1E3A80 0%, #2B4FA8 60%, #3561C2 100%);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D131D; --surface: #111925; --card: #161E2B; --line: #2A3543; --line-strong: #3A4757;
    --text: #EAF0F8; --text-2: #C4D0DF; --muted: #9FB0C5;
    --primary: #4D86E6; --primary-hover: #6F9DEC; --on-primary: #0D131D;
    --deep: #18253D; --on-deep: #EAF0F8; --on-deep-muted: #A9C6F5;
    --accent-soft: #18253D; --accent-soft-text: #A9C6F5; --teal: #3FD2DC; --teal-bg: #10292C; --flame: #F58A45;
    --ok: #34C88A; --ok-bg: #10271E; --bad: #F0667A; --bad-bg: #2C1A1F; --mark: #E0A23A; --mark-bg: #2A2212; --mark-strong: #E0A23A;
    --ph-bg: #33260F; --ph-text: #E8B45C; --focus: #6F9DEC; --hero-grad: linear-gradient(150deg, #1E3A80 0%, #2B4FA8 60%, #3561C2 100%);
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 17px; line-height: 1.6; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 4.5vw, 46px); font-weight: 800; }
h2 { font-size: clamp(24px, 3vw, 34px); font-weight: 800; }
h3 { font-size: 19px; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.tiny { font-size: 13px; }
.center { text-align: center; }
.label { font-size: 13px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.label-blue { color: var(--primary); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: var(--radius-sm); font: inherit; font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; border: 1px solid transparent; line-height: 1.2; white-space: nowrap; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { background: var(--card); color: var(--accent-soft-text); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-light { background: #ffffff; color: #0f3a7a; }
.btn-light:hover { color: #0f3a7a; background: #eef4fd; }
.btn-outline-light { color: #ffffff; border-color: rgba(255,255,255,.45); background: transparent; }
.btn-outline-light:hover { color: #ffffff; border-color: #ffffff; }
.btn-danger { background: var(--card); color: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline; cursor: pointer; }

/* Cards, pills, tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; flex-wrap: wrap; }
.card h2 { font-size: 18px; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-mark { background: var(--mark-bg); color: var(--mark); }
.pill-blue { background: var(--accent-soft); color: var(--accent-soft-text); }
.pill-grey { background: var(--surface); color: var(--text-2); border: 1px solid var(--line); }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; padding: 10px 14px; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; background: var(--surface); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tr.is-link:hover td { background: var(--surface); }
.stat { font-family: var(--font-head); font-weight: 800; font-size: 28px; color: var(--accent-soft-text); line-height: 1.1; }
.stat-ok { color: var(--ok); } .stat-bad { color: var(--bad); } .stat-mark { color: var(--mark); }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.ph { background: none; color: inherit; padding: 0; }
.notice { border-radius: 10px; padding: 12px 16px; font-size: 15px; }
.notice-info { background: var(--accent-soft); color: var(--accent-soft-text); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-bad { background: var(--bad-bg); color: var(--bad); }
.notice-warn { background: var(--mark-bg); color: var(--mark); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .flabel { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 14px; color: var(--muted); }
.field .err { font-size: 14px; color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
  font: inherit; font-size: 16px; min-height: 46px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--text); width: 100%;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 40px; padding-top: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 10px 18px; font-weight: 700; color: var(--text-2); cursor: pointer; }
.seg input:checked + span { background: var(--primary); color: var(--on-primary); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Flash messages */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

/* Logo: mark + wordmark "Ebb" (semibold) "Deck" (regular) + teal STEP 1 pill */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-head); font-weight: 500; font-size: 21px; letter-spacing: -0.015em; }
.logo:hover { color: var(--text); }
.logo svg { flex: none; }
.logo .accent { color: var(--primary); font-weight: 800; }
.wordmark { white-space: nowrap; }
.wordmark b { font-weight: 800; }
.wordmark { font-weight: 400; }
.wordmark b { font-weight: 700; }
.wordmark-tag { font-family: var(--font-body); font-weight: 600; font-size: .5em; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; vertical-align: 4px; margin-left: 4px; color: var(--teal); background: var(--teal-bg); border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent); }

/* Theme toggle */
.theme-toggle { width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------------------------------------------------------------- Public layout */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 28px; min-height: 72px; }
.site-nav { display: flex; gap: 24px; flex: 1; }
.site-nav a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--primary); }
.site-actions { display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .site-header .wrap { gap: 12px; }
  .site-nav { display: none; position: absolute; top: 72px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--line); flex-direction: column; gap: 0; padding: 8px 16px 16px; }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .menu-btn { display: inline-flex; margin-left: auto; }
  .site-actions .btn-ghost { display: none; }
}
@media (max-width: 420px) { .site-actions .btn-primary { padding: 0 12px; } .logo { font-size: 17px; } }
.site-footer { border-top: 1px solid var(--line); margin-top: 0; }
.site-footer .wrap { padding-top: 36px; padding-bottom: 40px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; font-size: 15px; color: var(--muted); }
.site-footer h4 { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.site-footer nav { display: flex; flex-direction: column; gap: 6px; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }
@media (max-width: 760px) { .site-footer .wrap { grid-template-columns: 1fr 1fr; } }
.main-public { min-height: 60vh; }
.public-flash { padding-top: 16px; }

/* ---------------------------------------------------------------- App (members + admin) layout */
.app-shell { display: flex; min-height: 100vh; background: var(--surface); }
.side { width: 236px; flex: none; background: var(--deep); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { color: #ffffff; font-size: 17px; padding: 0 6px 18px; }
.side .logo .accent, .app-mobilebar .logo .accent { color: #9cc3f5; }
.side .wordmark-tag, .app-mobilebar .wordmark-tag { color: #ffffff; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.32); }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a, .side-btn { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: var(--radius-sm); color: #d6e4f7; text-decoration: none; font-weight: 600; background: none; border: 0; font: inherit; font-weight: 600; cursor: pointer; width: 100%; text-align: left; }
.side-nav a:hover, .side-btn:hover { background: rgba(255,255,255,.08); color: #ffffff; }
.side-nav a[aria-current] { background: #1E5BD6; color: #ffffff; }
:root[data-theme="dark"] .side-nav a[aria-current] { background: #24427E; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.side-pass { background: rgba(255,255,255,.08); border-radius: 10px; padding: 14px; font-size: 14px; color: #d6e4f7; }
.side-pass strong { color: #ffffff; display: block; }
.side-pass a { color: #9cc3f5; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 36px; border-bottom: 1px solid var(--line); background: var(--card); }
.app-top h1 { font-size: 26px; }
.app-top .sub { color: var(--muted); font-size: 15px; }
.app-top-actions { display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-soft-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; text-decoration: none; }
.app-body { padding: 28px 36px 48px; display: flex; flex-direction: column; gap: 22px; }
.app-mobilebar { display: none; }
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .app-mobilebar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--deep); color: #ffffff; position: sticky; top: 0; z-index: 30; }
  .app-mobilebar .logo { color: #ffffff; font-size: 17px; }
  .app-mobilebar button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 8px; min-height: 40px; padding: 0 12px; font: inherit; font-weight: 700; }
  .app-top { padding: 16px; }
  .app-body { padding: 16px 16px 40px; }
}

/* Auth/bare layout */
.bare { min-height: 100vh; background: var(--surface); }

/* Donut */
.donut { display: flex; align-items: center; gap: 20px; }
.donut svg { flex: none; }
.donut .big { font-family: var(--font-head); font-weight: 800; font-size: 22px; }
.donut-track { stroke: var(--line); }
.donut-text { fill: var(--text); font-family: var(--font-head); font-weight: 800; }
.tbl-wrap { position: relative; }

/* Date inputs match the other fields */
input[type="date"] { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-height: 44px; padding: 0 12px; }
input[type="date"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
