/* Woody's CDL Trainer — brand: forest green, gold, off-white */
:root {
  --green-900: #0A3416;
  --green-800: #0F4A1F;
  --green-700: #176330;
  --green-100: #DCEADF;
  --gold-600: #C97D08;
  --gold-500: #EA960E;
  --gold-100: #FBECCF;
  --bg: #F4F6F4;
  --surface: #FFFFFF;
  --surface-2: #EBEFEB;
  --text: #16261A;
  --text-muted: #4F5F53;
  --border: #D3DBD5;
  --primary: var(--green-800);
  --on-primary: #FFFFFF;
  --accent: var(--gold-500);
  --on-accent: #1A1200;
  --ok: #1E7A3A;
  --ok-bg: #E2F3E7;
  --bad: #B42318;
  --bad-bg: #FDE8E6;
  --warn: #9A5B00;
  --warn-bg: #FFF1D6;
  --ring: #EA960E;
  --shadow: 0 1px 2px rgba(10, 52, 22, .08), 0 6px 20px rgba(10, 52, 22, .08);
  --radius: 14px;
  --radius-sm: 8px;
  --font-head: "Barlow Condensed", "Arial Narrow", Impact, system-ui, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  --bottom-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1811;
    --surface: #162419;
    --surface-2: #1E2F22;
    --text: #ECF0EC;
    --text-muted: #A9B8AD;
    --border: #2C3F31;
    --primary: #2E8B4A;
    --on-primary: #FFFFFF;
    --green-100: #1E3A26;
    --gold-100: #3A2A0A;
    --ok: #5CCB7E; --ok-bg: #163A22;
    --bad: #FF8A80; --bad-bg: #3F1B18;
    --warn: #FFC56B; --warn-bg: #3A2A0A;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0E1811; --surface: #162419; --surface-2: #1E2F22; --text: #ECF0EC; --text-muted: #A9B8AD; --border: #2C3F31;
  --primary: #2E8B4A; --on-primary: #FFFFFF; --green-100: #1E3A26; --gold-100: #3A2A0A;
  --ok: #5CCB7E; --ok-bg: #163A22; --bad: #FF8A80; --bad-bg: #3F1B18; --warn: #FFC56B; --warn-bg: #3A2A0A;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { 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.55;
  min-height: 100dvh; padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.1; margin: 0 0 .35em; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; text-transform: uppercase; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--text-muted); }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 24px; padding-bottom: 40px; outline: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: 6px; z-index: 1000; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Top bar */
.topbar { background: var(--green-800); color: #fff; position: sticky; top: 0; z-index: 40; box-shadow: 0 2px 0 var(--gold-500); }
.topbar__inner { display: flex; align-items: center; gap: 16px; min-height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { height: 40px; width: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__title { font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; text-transform: uppercase; letter-spacing: .03em; }
.brand__sub { font-size: .75rem; color: #CFE2D3; white-space: nowrap; }
.tabs { display: none; gap: 4px; margin-left: auto; }
.tabs a { color: #DDEBE0; text-decoration: none; padding: 10px 14px; border-radius: 8px; font-weight: 600; font-family: var(--font-head); font-size: 1.1rem; text-transform: uppercase; letter-spacing: .04em; transition: background .15s, color .15s; }
.tabs a:hover { background: rgba(255,255,255,.1); color: #fff; }
.tabs a[aria-current="page"] { background: var(--gold-500); color: var(--on-accent); }
.trainee-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 8px 14px 8px 10px; min-height: 44px; max-width: 46vw; }
.trainee-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.trainee-btn:hover { background: rgba(255,255,255,.18); }
@media (min-width: 900px) { .tabs { display: flex; } .trainee-btn { margin-left: 0; } .bottomnav { display: none; } body { padding-bottom: 0; } }

/* Bottom nav (mobile) */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--bottom-h); color: var(--text-muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.bottomnav a[aria-current="page"] { color: var(--primary); }
.bottomnav a[aria-current="page"] .ic { stroke-width: 2.5; }

/* Cards & buttons */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .grid--2 { grid-template-columns: 1fr 1fr; } .grid--3 { grid-template-columns: repeat(3, 1fr); } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 10px; border: 2px solid transparent; font-weight: 700; font-family: var(--font-head); font-size: 1.15rem; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; transition: transform .12s, background .15s, box-shadow .15s; user-select: none; touch-action: manipulation; }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--green-700); }
.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background: var(--gold-600); color: #fff; }
.btn--ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn--sm { min-height: 40px; padding: 6px 14px; font-size: 1rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

/* Hero */
.hero { display: grid; gap: 20px; align-items: center; background: linear-gradient(135deg, var(--green-800), var(--green-900)); color: #fff; border-radius: var(--radius); padding: 28px 24px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(234,150,14,.45), transparent 65%); pointer-events: none; }
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { color: #D8E6DB; max-width: 56ch; }
.hero__img { width: 100%; max-width: 420px; justify-self: center; border-radius: 10px; background: #fff; }
@media (min-width: 760px) { .hero { grid-template-columns: 1.3fr 1fr; } }

/* Section cards on home */
.sec-card { display: flex; flex-direction: column; gap: 10px; }
.sec-card__top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--muted { background: var(--surface-2); color: var(--text-muted); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--text-muted); }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .35s ease-out; }
.meter--gold > i { background: var(--accent); }

/* Segmented control */
.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface-2); padding: 6px; border-radius: 12px; }
.seg button, .seg a { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); font-weight: 700; font-family: var(--font-head); font-size: 1.05rem; text-transform: uppercase; letter-spacing: .03em; text-decoration: none; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* Study guide */
.guide details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 10px; }
.guide summary { cursor: pointer; padding: 14px 16px; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "+"; font-size: 1.4rem; color: var(--accent); font-weight: 800; }
.guide details[open] summary::after { content: "−"; }
.guide .body { padding: 0 16px 14px; }
.guide ul { margin: 0; padding-left: 20px; }
.guide li { margin-bottom: 6px; }
.callout { border-left: 4px solid var(--accent); background: var(--gold-100); padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 12px 0; }

/* Quiz */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.timer { font-family: var(--font-head); font-weight: 800; font-size: 1.4rem; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.timer--low { color: var(--bad); }
.q-topic { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.q-text { font-size: 1.25rem; font-weight: 600; margin: 6px 0 16px; line-height: 1.4; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 12px 14px; min-height: 52px; color: var(--text); transition: border-color .15s, background .15s; }
.choice:hover:not([disabled]) { border-color: var(--primary); background: var(--surface-2); }
.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--green-100); }
.choice__key { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 800; }
.choice[aria-pressed="true"] .choice__key { background: var(--primary); color: var(--on-primary); }
.choice--right { border-color: var(--ok) !important; background: var(--ok-bg) !important; }
.choice--right .choice__key { background: var(--ok); color: #fff; }
.choice--wrong { border-color: var(--bad) !important; background: var(--bad-bg) !important; }
.choice--wrong .choice__key { background: var(--bad); color: #fff; }
.choice[disabled] { cursor: default; }
.explain { margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.explain--ok { border-color: var(--ok); background: var(--ok-bg); }
.explain--bad { border-color: var(--bad); background: var(--bad-bg); }
.explain b { display: block; margin-bottom: 4px; }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 12px; }
.navgrid button { min-height: 44px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-variant-numeric: tabular-nums; }
.navgrid button.is-answered { background: var(--green-100); border-color: var(--primary); }
.navgrid button.is-flagged { box-shadow: inset 0 -4px 0 var(--accent); }
.navgrid button[aria-current="true"] { outline: 3px solid var(--primary); outline-offset: -3px; }

/* Results */
.score { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.score__ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--surface-2) 0); flex: none; }
.score__ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--font-head); font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.score__ring--pass { background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--surface-2) 0); }
.score__ring--fail { background: conic-gradient(var(--bad) calc(var(--pct) * 1%), var(--surface-2) 0); }
.verdict { font-family: var(--font-head); font-size: 2rem; font-weight: 800; text-transform: uppercase; }
.verdict--pass { color: var(--ok); } .verdict--fail { color: var(--bad); }
.review-item { border-top: 1px solid var(--border); padding: 14px 0; }
.review-item:first-child { border-top: 0; }
.review-item .q { font-weight: 600; margin-bottom: 6px; }
.review-item .ans { font-size: .95rem; }
.review-item .ans b { color: var(--ok); }
.review-item .ans s { color: var(--bad); }

/* Flashcards */
.flash { perspective: 1200px; }
.flash__card { position: relative; width: 100%; min-height: 240px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.8,.2,1); cursor: pointer; border: 0; padding: 0; background: none; text-align: center; color: var(--text); }
.flash__card.is-flipped { transform: rotateY(180deg); }
.flash__face { position: absolute; inset: 0; backface-visibility: hidden; display: grid; place-items: center; padding: 24px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 1.35rem; font-weight: 600; }
.flash__face--back { transform: rotateY(180deg); border-color: var(--accent); background: var(--gold-100); font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; }
.flash__hint { position: absolute; bottom: 10px; left: 0; right: 0; font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.table td.num { font-variant-numeric: tabular-nums; }

/* Forms */
label { font-weight: 600; display: block; margin-bottom: 4px; }
input[type="text"], input[type="password"], select { font: inherit; min-height: 48px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; }
input[type="text"]:focus, input[type="password"]:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(234,150,14,.35); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.trainee-form label { margin-top: 12px; }
.trainee-form .row input { flex: 1; min-width: 0; letter-spacing: .2em; }
.trainee-form .row input::placeholder { letter-spacing: 0; }
.form-error { color: var(--danger, #B3261E); font-weight: 600; margin: 8px 0 0; min-height: 1.3em; }
.small { font-size: .9rem; margin-top: 8px; }
.trainee-btn::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2E8B4A; display: none; }
html[data-sync="offline"] .trainee-btn::after { display: inline-block; background: var(--gold-600, #EA960E); }
.trainee-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.trainee-list button { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; }
.trainee-list button:hover { border-color: var(--primary); }

/* Team (managers) */
html:not([data-manager="1"]) .mgr-only { display: none; }
.team-card { display: flex; flex-direction: column; gap: 12px; }
.team-card__top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.team-card__top h3 { margin: 0 0 4px; }
.team-secs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.team-sec { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.team-sec__name { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
.team-sec b { font-family: var(--font-head); font-size: 1.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.team-sec span { font-size: .78rem; color: var(--text-muted); }
.team-card details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.team-card .table { margin-top: 8px; }

/* Modal & toast */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10, 30, 15, .55); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__card { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.modal__close { margin-top: 12px; width: 100%; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: 90vw; }
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.empty { text-align: center; padding: 32px 16px; color: var(--text-muted); }
.empty svg { width: 48px; height: 48px; margin-bottom: 8px; stroke: var(--accent); }
.kbd { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print { .topbar, .bottomnav, .btn, .toast { display: none !important; } body { padding: 0; } .card { box-shadow: none; } }

/* Desktop: top tabs replace the bottom bar (kept last so it wins the cascade) */
@media (min-width: 900px) { .bottomnav { display: none; } body { padding-bottom: 0; } }
