:root {
  --navy: #1f3a5f;
  --navy-dark: #152a46;
  --gold: #d9a441;
  --gold-dark: #b8862c;
  --cream: #faf6ee;
  --paper: #ffffff;
  --ink: #22272e;
  --muted: #6b7280;
  --line: #e6e1d6;
  --green: #2e7d4f;
  --green-bg: #e6f4ec;
  --red: #b23b3b;
  --red-bg: #fbe9e9;
  --amber-bg: #fff4d6;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 58, 95, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--navy); }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 40px; }
main.wrap.narrow { max-width: 720px; }

/* top bar */
.topbar { background: var(--navy); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--gold); }
.topbar nav { display: flex; gap: 6px; align-items: center; }
.topbar nav a { color: #e8eef7; text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 0.95rem; }
.topbar nav a:hover { background: rgba(255,255,255,0.1); }
.topbar nav a.nav-cta { background: var(--gold); color: var(--navy-dark); font-weight: 600; }
.topbar nav a.nav-admin { color: var(--gold); }

/* footer */
.foot { color: var(--muted); font-size: 0.85rem; padding: 18px 0; border-top: 1px solid var(--line); }

/* cards */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card h1, .card h2 { margin-top: 0; }
h1 { font-size: 1.6rem; color: var(--navy-dark); }
h2 { font-size: 1.25rem; color: var(--navy-dark); }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

/* hero */
.hero { text-align: center; padding: 36px 20px; }
.hero h1 { font-size: 2rem; margin-bottom: 6px; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 520px; margin: 0 auto 22px; }
.hero .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* buttons */
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  background: var(--navy); color: #fff; font-weight: 600; font-size: 1rem;
  padding: 12px 22px; border-radius: 10px; transition: background .15s;
}
.btn:hover { background: var(--navy-dark); }
.btn.gold { background: var(--gold); color: var(--navy-dark); }
.btn.gold:hover { background: var(--gold-dark); }
.btn.ghost { background: transparent; color: var(--navy); border: 2px solid var(--navy); padding: 10px 20px; }
.btn.ghost:hover { background: rgba(31,58,95,0.06); }
.btn.sm { padding: 8px 14px; font-size: 0.9rem; border-radius: 8px; }
.btn.danger { background: var(--red); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.block { display: block; width: 100%; text-align: center; }

/* forms */
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 0.95rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfd6df; border-radius: 10px; font-size: 1rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
.form-actions { margin-top: 20px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

/* flashes */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-warn { background: var(--amber-bg); color: #7a5a00; }

/* week list */
.weeks { display: grid; gap: 14px; }
.week { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.week .num { flex: 0 0 56px; height: 56px; border-radius: 50%; background: var(--navy); color: var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; line-height: 1; }
.week .num small { font-size: 0.6rem; color: #cfd8e6; font-weight: 500; margin-bottom: 3px; }
.week .info { flex: 1; min-width: 0; }
.week .info strong { display: block; font-size: 1.05rem; color: var(--navy-dark); }
.week .info span { color: var(--muted); font-size: 0.9rem; }
.week.locked { opacity: 0.6; }
.week .state { text-align: right; flex: 0 0 auto; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge.done { background: var(--green-bg); color: var(--green); }
.badge.open { background: var(--amber-bg); color: #7a5a00; }
.badge.locked { background: #eceff3; color: var(--muted); }
.score-pill { font-size: 1.2rem; font-weight: 700; color: var(--navy-dark); }
@media (max-width: 560px) {
  .week { flex-wrap: wrap; }
  .week .state { flex-basis: 100%; text-align: left; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
}

/* quiz */
.progress { position: sticky; top: 0; z-index: 5; background: var(--cream); padding: 10px 0; margin-bottom: 8px; }
.progress .bar { height: 8px; background: #e3e8ef; border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-dark)); transition: width .25s; }
.progress .label { font-size: 0.85rem; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.question { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 14px; }
.question .qnum { color: var(--gold-dark); font-weight: 700; font-size: 0.85rem; letter-spacing: .04em; text-transform: uppercase; }
.question .qtext { font-size: 1.08rem; font-weight: 600; margin: 6px 0 12px; color: var(--navy-dark); }
.options { display: grid; gap: 8px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover { border-color: var(--navy); }
.option input { margin-top: 3px; accent-color: var(--navy); }
.option.selected { border-color: var(--navy); background: #eef3fa; }
.option .letter { font-weight: 700; color: var(--navy); flex: 0 0 20px; }
.question.unanswered { outline: 2px solid var(--red); }

/* results */
.result-hero { text-align: center; padding: 28px 20px; }
.result-hero .big { font-size: 3.2rem; font-weight: 800; color: var(--navy-dark); line-height: 1; }
.result-hero .big small { font-size: 1.2rem; color: var(--muted); font-weight: 500; }
.review .option { cursor: default; }
.review .option.correct { border-color: var(--green); background: var(--green-bg); }
.review .option.wrong { border-color: var(--red); background: var(--red-bg); }
.ref { margin-top: 10px; font-size: 0.9rem; color: var(--muted); }
.ref b { color: var(--navy); }
.verdict { font-weight: 700; font-size: 0.85rem; margin-left: 8px; }
.verdict.ok { color: var(--green); }
.verdict.no { color: var(--red); }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 0.95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3f0e8; color: var(--navy-dark); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
td.num, th.num { text-align: right; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .v { font-size: 1.8rem; font-weight: 800; color: var(--navy-dark); }
.stat .k { color: var(--muted); font-size: 0.85rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar form { display: inline; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.subnav a { text-decoration: none; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--navy); font-weight: 600; font-size: 0.9rem; }
.subnav a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.inline-form { display: inline; }
.link-btn { background: none; border: none; color: var(--red); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
