:root {
  --bg: #e8f0f2;
  --bg-accent: #d4e4e8;
  --ink: #14303a;
  --muted: #5a7380;
  --card: #f7fbfc;
  --line: #b8cdd4;
  --brand: #0d6e7a;
  --brand-dark: #0a5560;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #0f7a4c;
  --shadow: 0 18px 50px rgba(20, 48, 58, 0.1);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #c5e0e6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e6d8 0%, transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-accent));
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 18px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.brand {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.topbar-link { font-size: 0.9rem; color: var(--muted); }

.main { flex: 1; }

.footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.85rem;
}

.hero-card,
.test-card,
.result-card,
.panel {
  background: color-mix(in srgb, var(--card) 92%, white);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
}

.hero-card.narrow { max-width: 420px; margin: 40px auto; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--brand);
  font-weight: 700;
  margin: 0 0 8px;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.lead { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }

.start-form,
.edit-form { display: grid; gap: 10px; }

label { font-weight: 600; font-size: 0.92rem; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }

.btn-small {
  padding: 8px 14px;
  font-size: 0.88rem;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
}

.flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 600;
}

.flash-error { background: #fde8e6; color: var(--danger); }
.flash-success { background: #e5f6ee; color: var(--ok); }

.muted { color: var(--muted); font-size: 0.92rem; }

.test-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.timer-wrap { margin-bottom: 18px; }

.timer-bar {
  height: 8px;
  background: #d9e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--brand), #1aa0b0);
  transform-origin: left center;
  transition: background 0.2s;
}

.timer-fill.urgent { background: linear-gradient(90deg, #c2410c, #ea580c); }

.timer-text {
  margin-top: 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.question-text {
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  margin-bottom: 18px;
}

.answers { display: grid; gap: 10px; }

.answer-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}

.answer-option:has(input:checked) {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.answer-option input { margin-top: 3px; }

.score-big {
  font-family: var(--display);
  font-size: 3.4rem;
  margin: 8px 0;
  font-weight: 700;
}

.score-big span { font-size: 1.4rem; color: var(--muted); }

.score-pct { font-size: 1.15rem; font-weight: 600; }

.score-breakdown {
  list-style: none;
  margin: 18px 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.score-breakdown li {
  flex: 1 1 110px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-breakdown span { color: var(--muted); font-size: 0.85rem; }

.score-breakdown strong { font-size: 1.4rem; font-weight: 700; }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.admin-nav a.active,
.admin-nav a:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 4px;
}

.stat strong { font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }

.panel { margin-bottom: 16px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 { margin: 0; font-size: 1.2rem; }
.panel h3 { margin: 12px 0 4px; font-size: 1rem; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6eef1;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-ok { background: #d8f3e5; color: var(--ok); }
.badge-warn { background: #ffedd5; color: var(--warn); }

.actions { white-space: nowrap; }
.inline { display: inline; }

button.linkish {
  background: none;
  border: 0;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  padding: 0 4px;
}

button.linkish.danger { color: var(--danger); }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.answer-edit {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.search-form input { flex: 1 1 180px; }

.inline-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-danger {
  border-color: #d78b8b;
  color: #a33;
}

.btn-danger:hover { background: #fbeaea; }

.install-box {
  max-width: 560px;
  margin: 40px auto;
}

@media (max-width: 700px) {
  .admin-grid { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .hero-card, .test-card, .result-card, .panel { padding: 22px 18px; }
}
