:root {
  --bg: #000;
  --surface: #151515;
  --text: #fff;
  --muted: #a3a3a3;
  --faint: #6f6f6f;
  --line: #2c2c2c;
  --line-strong: #4a4a4a;
  --error: #ff7a7a;
  --dev: #f5c26b;
  --radius-btn: 10px;
  --radius-field: 8px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

img { max-width: 100%; height: auto; display: block; }

[hidden] { display: none !important; }

/* ---------- Pagina di login ---------- */

.login {
  width: min(100% - 40px, 960px);
  margin: 0 auto;
  padding: 48px 0 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero {
  margin: 0;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 1358 / 784;
  background: #0e1a2a;
  animation: hero-in 900ms cubic-bezier(.2, .7, .2, 1) both;
}
.hero img { width: 100%; height: 100%; object-fit: cover; }

@keyframes hero-in {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: none; }
}

.intro { margin: 32px 0 28px; }
.intro h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 32px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.intro p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.actions { width: 100%; max-width: 520px; margin-top: 40px; display: flex; flex-direction: column; gap: 22px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.brand { width: 196px; margin: 48px 0 0; opacity: 0.92; }

.legal {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Pulsanti ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, opacity 150ms;
}
.btn-primary { background: #fff; color: #000; }
.btn-primary:hover { background: #e9e9e9; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-outline:hover { border-color: #8a8a8a; background: rgba(255, 255, 255, 0.04); }
.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

.ms-icon { width: 20px; height: 20px; flex: none; }

:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn-primary:focus-visible { outline-offset: 3px; }

.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 0;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:disabled { color: var(--faint); text-decoration: none; cursor: default; }

/* ---------- Maschera email personale ---------- */

.sheet {
  width: min(100% - 32px, 480px);
  max-height: calc(100dvh - 32px);
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.sheet[open] { animation: sheet-in 220ms cubic-bezier(.2, .7, .2, 1); }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.sheet-close:hover { background: rgba(255, 255, 255, 0.08); }
.sheet-close svg { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; fill: none; }

.step h2 { margin: 0 40px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.step-lead { margin: 8px 0 24px; color: var(--muted); font-size: 15px; }
.step-lead strong { color: var(--text); font-weight: 500; display: inline-block; max-width: 100%; overflow-wrap: anywhere; }

form { display: flex; flex-direction: column; gap: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }

.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-field);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color 150ms;
}
.field input:hover, .field select:hover { border-color: #6a6a6a; }
.field input:focus, .field select:focus { outline: none; border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.16); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--error); }

.field select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
.field select:invalid { color: var(--faint); }
.field select option { color: var(--text); background: var(--surface); }

.code-input {
  font-size: 28px !important;
  letter-spacing: 0.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-left: calc(14px + 0.5em) !important;
}

.form-error { margin: 0; color: var(--error); font-size: 14px; text-align: left; }

.dev-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--dev);
  border-radius: var(--radius-field);
  color: var(--dev);
  font-size: 13px;
  text-align: left;
}

.fineprint { margin: 0; color: var(--faint); font-size: 12px; line-height: 1.55; text-align: left; }

.step-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; }


/* ---------- Homepage ---------- */

.topbar {
  width: min(100% - 40px, 1280px);
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-logo { width: 150px; }

.btn-ghost {
  width: auto;
  min-height: 40px;
  padding: 0 18px;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: #8a8a8a; background: rgba(255, 255, 255, 0.04); }

.home { width: min(100% - 40px, 1280px); margin: 0 auto; padding-bottom: 56px; }

.banner {
  position: relative;
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #0d1117;
}
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner-top { aspect-ratio: 4 / 1; }
.banner-side { align-self: stretch; }   /* alto quanto benvenuto + tabella slot */
.banner-side img { position: absolute; inset: 0; object-position: center top; }

.banner-missing { display: none; }
.banner.is-missing { background: transparent; border: 1px dashed var(--line-strong); }
.banner.is-missing img { display: none; }
.banner.is-missing .banner-missing {
  display: grid;
  place-content: center;
  height: 100%;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--faint);
  font-size: 15px;
  line-height: 1.6;
}
.banner-missing small { font-size: 12px; }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
  margin-top: 32px;
}

.welcome { margin-bottom: 24px; }
.welcome p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.welcome h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b0b0b;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.panel-head h2 svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.panel-meta { margin: 0; color: var(--muted); font-size: 14px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 16px 0 20px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}
.legend li { display: flex; align-items: center; gap: 8px; }

[data-status="ok"] { --led: #22c55e; }
[data-status="low"] { --led: #facc15; }
[data-status="full"] { --led: #ef4444; }

.led {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--led);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--led) 22%, transparent), 0 0 10px var(--led);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color 150ms;
}
.slot:hover { border-color: var(--line-strong); }
.slot-time { margin: 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot-avail { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.slot[data-status="full"] .slot-time { color: var(--faint); }

.btn-slot {
  min-height: 40px;
  margin-top: auto;
  font-size: 14px;
  border-radius: 8px;
  background: #fff;
  color: #000;
}
.btn-slot:hover { background: #e9e9e9; }
.btn-slot:disabled { background: #1c1c1c; color: var(--faint); cursor: not-allowed; }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .banner-side { width: min(100%, 420px); margin: 0 auto; aspect-ratio: 800 / 2120; }
  .banner-side.is-missing { aspect-ratio: 2 / 3; }
}

@media (max-width: 480px) {
  .topbar-logo { width: 110px; }
  .topbar-nav .btn { padding: 0 12px; }
  .panel { padding: 18px 14px; }
  .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .slot { padding: 12px; }
  .slot-time { font-size: 16px; }
}


/* ---------- Prenotazione ---------- */

.field input::placeholder { color: var(--faint); }

.readonly {
  margin: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 500;
}

.move-note {
  margin: -8px 0 20px;
  padding: 10px 12px;
  border-left: 3px solid var(--dev);
  border-radius: 4px;
  background: rgba(245, 194, 107, 0.08);
  color: #f3dcb0;
  font-size: 14px;
}

.booking-summary {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
}
.booking-summary p { display: flex; justify-content: space-between; gap: 12px; margin: 0; font-size: 14px; color: var(--muted); }
.booking-summary strong { color: var(--text); font-variant-numeric: tabular-nums; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-slot:disabled { opacity: 1; }

.done { text-align: center; }
.done h2 { margin: 0; }
.done-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 4px auto 16px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.14);
}
.done-icon svg { width: 26px; height: 26px; fill: none; stroke: #22c55e; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.done .people { margin: 0 0 24px; text-align: left; }

.people {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
}
.people li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-size: 15px;
}
.people li + li { border-top: 1px solid var(--line); }
.people-role { color: var(--faint); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

.sheet-small { width: min(100% - 32px, 420px); }
.sheet-small h2 { margin: 0; font-size: 20px; font-weight: 600; }
.dialog-actions { display: flex; gap: 12px; }
.dialog-actions .btn { flex: 1; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost-danger { background: transparent; color: #fca5a5; border-color: transparent; }
.btn-ghost-danger:hover { background: rgba(239, 68, 68, 0.1); }

.my-booking { margin-bottom: 24px; border-color: rgba(34, 197, 94, 0.45); }
.my-booking-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.my-booking-head h2 { margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.my-booking-time { margin: 4px 0 0; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.my-booking-count { margin: 4px 0 0; color: var(--muted); font-size: 14px; white-space: nowrap; }
.my-booking-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.my-booking-actions .btn { width: auto; min-height: 44px; font-size: 15px; }

.slot.is-mine { border-color: rgba(34, 197, 94, 0.6); background: rgba(34, 197, 94, 0.06); }
.slot-mine { margin: -4px 0 0; color: #86efac; font-size: 12px; font-weight: 500; }
.slot.is-mine .btn-slot { background: transparent; color: var(--text); border-color: var(--line-strong); }
.slot.is-mine .btn-slot:hover { border-color: #8a8a8a; }


/* ---------- Pannello admin ---------- */

.topbar-nav { display: flex; align-items: center; gap: 10px; }
.topbar-nav form { margin: 0; display: block; }

.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 24px; }
.admin-head .welcome { margin: 0; }
.btn-export { width: auto; min-height: 48px; padding: 0 22px; }
.btn-export svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: #0b0b0b; }
.stat p { margin: 0; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 4px; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--faint); font-size: 13px; }

.admin .panel + .panel { margin-top: 24px; }
.admin .panel-head { margin-bottom: 16px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .led { display: inline-block; margin-top: 4px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.muted { color: var(--faint); }
.small { font-size: 12px; }
.guests { min-width: 200px; color: var(--muted); }
.actions { text-align: right; }

.fill-col { width: 28%; min-width: 120px; }
.bar { display: block; height: 6px; margin-top: 7px; border-radius: 3px; background: #1d1d1d; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--led); }

.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.btn-small { width: auto; min-height: 34px; padding: 0 12px; font-size: 13px; }
.empty { margin: 20px 0 8px; text-align: center; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .stat { padding: 14px 16px; }
  .stat strong { font-size: 24px; }
  .btn-export { width: 100%; }
  .admin .panel { padding: 18px 14px; }
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
  .login { padding-top: 20px; }
  .hero { border-radius: 14px; }
  .actions { margin-top: 28px; }
  .legal br { display: none; }
  .row { grid-template-columns: 1fr; }
  .my-booking-actions .btn { flex: 1; }
  .dialog-actions { flex-direction: column-reverse; }
  .sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.login-error {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 122, 122, 0.4);
  border-radius: var(--radius-field);
  background: rgba(255, 122, 122, 0.08);
  color: var(--error);
  font-size: 14px;
  text-align: center;
}

.step-hint { margin: -12px 0 20px; color: var(--faint); font-size: 13px; line-height: 1.5; }
