:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #17202f;
  --muted: #667085;
  --line: #e3e7ef;
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --accent: #12b981;
  --danger: #d92d20;
  --ok-bg: #e7f8ef;
  --ok-ink: #0b6b3a;
  --err-bg: #fdecea;
  --err-ink: #a3261a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171e2d;
    --text: #e8ecf4;
    --muted: #98a2b3;
    --line: #2a3346;
    --primary: #4c8dff;
    --ok-bg: #0f3324;
    --ok-ink: #7ee2b0;
    --err-bg: #3a1714;
    --err-ink: #ffb4ab;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 1.7rem; margin: .2em 0 .5em; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .6em; }
.card h2:first-child { margin-top: 0; }
code { background: var(--line); padding: .1em .4em; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.4rem; font-weight: 700; }
.warn-text { color: var(--danger); }

/* Barra superiore */
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.logo { display: block; width: 36px; height: 36px; }
.menu { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.menu a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.menu a.on, .menu a:hover { background: var(--bg); color: var(--text); }
.menu a.btn { color: var(--primary-ink); }
.menu .logout { color: var(--danger); }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; }

/* Componenti */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 440px; margin: 32px auto; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.error { background: var(--err-bg); color: var(--err-ink); }

label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
label.inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 500; margin: 18px 0; }
label.inline input { width: 90px; margin: 0; }
input, select { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }

.btn { display: inline-block; padding: 10px 18px; font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.wide { width: 100%; }

.status { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mode, .check { display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400; }
.mode:has(input:checked), .check:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.mode input, .check input { width: auto; margin: 4px 0 0; accent-color: var(--primary); }
.mode small { display: block; color: var(--muted); margin-top: 4px; }
.checks { display: grid; gap: 10px; margin-bottom: 14px; }
.check.plain { border: 0; padding: 0; box-shadow: none; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card .table { background: transparent; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
.hours .slot { display: flex; align-items: center; gap: 6px; }
.hours input { width: auto; margin: 0; padding: 6px 8px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; background: var(--line); color: var(--muted); }
.pill.on { background: var(--ok-bg); color: var(--ok-ink); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); }
.tabs a.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
blockquote { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--bg); border-radius: 0 10px 10px 0; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 640px) {
  .table { display: block; overflow-x: auto; }
  .hours .slot { flex-direction: column; align-items: stretch; }
}

/* Homepage */
.home .topbar { position: sticky; top: 0; z-index: 2; }
.hero { max-width: 1080px; margin: 0 auto; padding: 64px 16px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 34em; }
.accent { background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.phone { justify-self: center; width: 240px; height: 460px; border-radius: 40px; padding: 12px; background: #111827; box-shadow: 0 30px 60px rgba(16, 24, 40, .25); }
.screen { height: 100%; border-radius: 30px; background: linear-gradient(160deg, #1f6feb, #12b981); color: #fff; display: flex; flex-direction: column; align-items: center; padding: 70px 16px 40px; text-align: center; }
.call-label { opacity: .8; font-size: .9rem; }
.call-number { font-size: 1.6rem; font-weight: 700; margin-top: 8px; }
.call-sub { opacity: .8; font-size: .85rem; }
.call-buttons { margin-top: auto; display: flex; gap: 60px; }
.call-buttons span { width: 56px; height: 56px; border-radius: 50%; }
.decline { background: #ef4444; }
.accept { background: #22c55e; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(34, 197, 94, .25); } }
@media (prefers-reduced-motion: reduce) { .accept { animation: none; } }
.section { max-width: 1080px; margin: 0 auto; padding: 56px 16px; }
.section h2 { font-size: 1.8rem; text-align: center; margin: 0 0 32px; }
.section.alt { max-width: none; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature .icon { font-size: 1.8rem; }
.feature h3 { margin: 10px 0 6px; }
.feature p { margin: 0; color: var(--muted); }
.steps { max-width: 1080px; margin: 0 auto; padding: 0; list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.steps li { counter-increment: s; padding: 18px; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; margin-bottom: 10px; }
.steps strong, .steps span { display: block; }
.steps span { color: var(--muted); }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
}

/* Avviso, dati legali e banner cookie (pagine pubbliche) */
.notice { max-width: 760px; margin: 0 auto; padding: 18px 20px; border-radius: var(--radius); background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--line); }
.notice p { margin: 6px 0 0; }
.foot.legal { border-top: 1px solid var(--line); line-height: 1.6; }
.foot.legal p { margin: 2px 0; }
.foot.legal a { color: var(--muted); }
.legal-text { max-width: 760px; }
.legal-text li { margin-bottom: 6px; }
.cookie-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 10; max-width: 720px; margin: 0 auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(16, 24, 40, .25); }
.cookie-banner[hidden] { display: none; }
.cookie-inner { padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; }
.cookie-inner p { margin: 0; flex: 1 1 320px; font-size: .92rem; }
.cookie-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
