:root {
  --text: #0f172a;
  --accent: #1F4E78;
  --accent-2: #2c6bb0;
  --bg: #f4f7fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --muted: #64748b;
  --green: #2e7d32;
  --green-bg: #e6f4ea;
  --red: #c62828;
  --red-bg: #fce4ec;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--card);
  border-bottom: 3px solid var(--accent);
  box-shadow: var(--shadow);
}
.app-header .inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}
.app-header img { height: 52px; width: auto; }
.app-header .titles { flex: 1; }
.app-header h1 { font-size: 20px; margin: 0; color: var(--accent); }
.app-header .sub { font-size: 13px; color: var(--muted); }
.app-header .user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.app-header .user-box .who { color: var(--muted); }

main { flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 24px 20px; }

footer {
  background: #0f172a; color: #cbd5e1; font-size: 12px;
  padding: 16px 20px; text-align: center; margin-top: 40px;
}
footer .disclaimer { color: #94a3b8; font-size: 11px; margin-top: 6px; max-width: 800px; margin-left: auto; margin-right: auto; }

/* Buttons */
button {
  font: inherit; cursor: pointer; border: none; border-radius: 8px;
  padding: 9px 16px; background: var(--accent); color: #fff; font-weight: 600;
  transition: background .15s, opacity .15s;
}
button:hover { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: #e2e8f0; color: var(--text); }
button.secondary:hover { background: #cbd5e1; }
button.danger { background: var(--red); }
button.ghost { background: transparent; color: var(--accent); padding: 6px 10px; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.grid-modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.module-card { display: flex; flex-direction: column; }
.module-card h3 { color: var(--accent); margin: 0 0 8px; }
.module-card ul { padding-left: 18px; margin: 8px 0; color: var(--muted); font-size: 14px; }
.module-card .spacer { flex: 1; }

/* Login */
.login-wrap { max-width: 380px; margin: 6vh auto; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent-2); border-color: var(--accent-2); }

.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.msg.error { background: var(--red-bg); color: var(--red); }
.msg.ok { background: var(--green-bg); color: var(--green); }

/* Quiz */
.quiz-topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 5;
}
.timer { font-weight: 700; font-size: 18px; padding: 6px 14px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); }
.timer.warn { color: var(--red); border-color: var(--red); }
.progress { flex: 1; min-width: 200px; }
.progress .bar { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.progress .bar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.progress .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.q-meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.q-text { font-size: 17px; font-weight: 600; margin: 8px 0 16px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: 10px; cursor: pointer; background: #fff;
}
.option:hover { border-color: var(--accent-2); }
.option.selected { border-color: var(--accent); background: #eef4fb; }
.option input { margin-top: 3px; }
.nav-row { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; flex-wrap: wrap; }
.q-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.q-dot {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; font-size: 12px; color: var(--muted); padding: 0;
}
.q-dot.answered { background: var(--accent); color: #fff; border-color: var(--accent); }
.q-dot.current { outline: 2px solid var(--accent-2); }

/* Results */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; }
.stat .n { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat .l { font-size: 12px; color: var(--muted); }
.verdict { font-size: 22px; font-weight: 800; padding: 14px; border-radius: 10px; text-align: center; margin: 16px 0; }
.verdict.pass { background: var(--green-bg); color: var(--green); }
.verdict.fail { background: var(--red-bg); color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.wrong-row td { background: var(--red-bg); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.pass { background: var(--green-bg); color: var(--green); }
.badge.fail { background: var(--red-bg); color: var(--red); }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: #e2e8f0; color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; }

.hidden { display: none !important; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.muted { color: var(--muted); }
.right { text-align: right; }
@media (max-width: 640px) {
  .app-header .inner { flex-wrap: wrap; }
  .app-header h1 { font-size: 17px; }
}

/* Layer commerciale: auth tabs, prezzo, CTA */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs .auth-tab { flex: 1; background: #e2e8f0; color: var(--text); }
.auth-tabs .auth-tab.active { background: var(--accent); color: #fff; }
.price-card { align-self: start; }
.price { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.price-block { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
button.cta { background: var(--green, #16a34a); }
button.cta:hover { filter: brightness(0.95); }
