:root {
  /* Fondo carta, blu caldo da prima serata, colori pieni dei canali (blu, carminio, verde, viola) come firma */
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #eceae4;
  --border: #dcd8cf;
  --text: #13204a;
  --muted: #5a6280;
  --accent: #2347a8;
  --accent-text: #fff;
  --link: #2347a8;
  --carmine: #c4193a;
  --green: #4fae6a;
  --violet: #7a4bc2;
  --sun: #ffcf3f;
  --ok: #256b3a;
  --warn: #94560a;
  --danger: #b3142f;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(19, 32, 74, 0.06), 0 8px 24px rgba(19, 32, 74, 0.08);
  /* striscia dei quattro colori, a tinte piene */
  --strip: linear-gradient(90deg, var(--carmine) 0 25%, var(--sun) 0 50%, var(--green) 0 75%, var(--violet) 0);
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: var(--link); }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0 0 0.4em; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ---------- header / hero */
.site-header { padding: 22px 0 26px; position: relative; background: var(--accent); color: #fff; }
.site-header::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--strip); }
.site-header .wrap { display: flex; align-items: center; gap: 14px; }
.site-header a { color: inherit; }
.site-header img.logo { width: 56px; height: 56px; object-fit: contain; border-radius: var(--radius); background: #fff; padding: 5px; }
.site-header h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0; }
.site-header p { margin: 2px 0 0; color: #d5def7; font-size: 0.95rem; }

.hero { padding: 32px 0 8px; }
.hero .wrap { display: grid; gap: 28px; grid-template-columns: 1fr; align-items: center; }
.hero img.cover { border-radius: var(--radius); box-shadow: var(--shadow); max-height: min(520px, 60vh); width: auto; margin: 0 auto; }
.hero .about { white-space: pre-line; font-size: 1.1rem; max-width: 58ch; }
@media (min-width: 760px) {
  .hero .wrap.has-cover { grid-template-columns: 340px 1fr; }
}

.section-title { margin: 40px 0 18px; font-size: 1.6rem; display: flex; align-items: center; gap: 12px; }
.section-title::before { content: ''; width: 14px; height: 14px; background: var(--carmine); flex-shrink: 0; }

/* ---------- film cards */
.films { display: grid; gap: 22px; grid-template-columns: 1fr; padding-bottom: 56px; }
@media (min-width: 700px) { .films { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .films { grid-template-columns: 1fr 1fr 1fr; } }

.film {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}
.film:hover { border-color: var(--text); }
.film .poster { aspect-ratio: 2 / 3; background: var(--surface-2); position: relative; }
.film .poster img { width: 100%; height: 100%; object-fit: cover; }
.film .poster .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 1.6rem; color: var(--muted); padding: 16px; text-align: center;
}
/* la data come un quadrato pieno, sul bordo della locandina */
.datebox {
  position: absolute; right: 0; top: 0; z-index: 1;
  width: 64px; height: 64px; background: var(--accent); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.datebox b { font-family: var(--display); font-size: 1.7rem; font-weight: 800; }
.datebox span { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 3px; }
.onair {
  position: absolute; top: 0; left: 0; z-index: 1;
  background: var(--carmine); color: #fff;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 7px 12px;
}
.film .body { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.film h3 { font-size: 1.5rem; margin: 0; }
.film .when { font-weight: 700; color: var(--accent); text-transform: capitalize; }
.film .plot { color: var(--muted); font-size: 0.95rem; white-space: pre-line; }
.film .plot.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.film .more { background: none; border: 0; color: var(--text); text-decoration: underline; padding: 0; cursor: pointer; font: inherit; font-size: 0.9rem; align-self: flex-start; }
.film .foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (min-width: 560px) and (max-width: 699px) {
  .film { flex-direction: row; }
  .film .poster { width: 42%; flex-shrink: 0; aspect-ratio: auto; min-height: 280px; }
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 700; padding: 4px 10px; border-radius: 3px;
  background: var(--surface-2); color: var(--text);
}
.badge.ok { color: var(--ok); }
.badge.warn { background: var(--sun); color: var(--text); }
.badge.danger { color: var(--danger); }

/* ---------- i miei biglietti */
.mine { padding-bottom: 8px; }
.mine .section-title { margin-top: 28px; }
.mine-list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .mine-list { grid-template-columns: 1fr 1fr; } }
.mine-item {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; color: var(--text); text-decoration: none;
}
.mine-item:hover { border-color: var(--text); border-left-color: var(--accent); }
.mine-item .datebox { position: static; flex-shrink: 0; }
.mine-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mine-text b { font-family: var(--display); font-size: 1.15rem; line-height: 1.2; }
.mine-go { font-weight: 700; color: var(--accent); white-space: nowrap; }
@media (max-width: 420px) { .mine-go { display: none; } }
.find-bar { margin: 22px 0 0; color: var(--muted); font-size: 0.95rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--link); text-decoration: underline; cursor: pointer; }
.badge.booked { background: var(--accent); color: #fff; }

/* ---------- buttons & forms */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 700; padding: 11px 20px; border-radius: var(--radius);
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: background-color 0.15s ease;
}
.btn:hover { background: #1b3888; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: rgba(179, 20, 47, 0.06); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.875rem; }
.btn.block { width: 100%; }

label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='datetime-local'], input[type='search'], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.row { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; border-left: 5px solid; }
.alert.error { color: var(--danger); background: #fbeaec; }
.alert.success { color: var(--ok); background: #e7f4ea; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 44px; height: 44px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.4rem; cursor: pointer; }
.stepper button:hover:not(:disabled) { border-color: var(--text); }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper output { font-family: var(--display); font-size: 1.5rem; font-weight: 800; min-width: 2ch; text-align: center; }

/* ---------- dialog */
dialog {
  border: 0; border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); box-shadow: var(--shadow);
  border-top: 6px solid var(--accent);
}
dialog::backdrop { background: rgba(19, 32, 74, 0.55); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
dialog .dlg-body { padding: 16px 20px 20px; }
dialog .close { background: none; border: 0; color: var(--muted); font-size: 1.8rem; line-height: 1; cursor: pointer; padding: 0 4px; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
}

dialog.confirm { width: min(440px, calc(100vw - 32px)); height: fit-content; margin: auto; border-radius: var(--radius); }
dialog.confirm .dlg-body { padding: 22px 20px 20px; }
dialog.confirm p { margin: 0 0 20px; white-space: pre-line; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- ticket */
.ticket {
  max-width: 460px; margin: 28px auto 48px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative;
}
.ticket::before { content: ''; display: block; height: 8px; background: var(--strip); }
.ticket .top { display: flex; gap: 16px; padding: 20px; }
.ticket .top img { width: 96px; border-radius: 3px; flex-shrink: 0; align-self: flex-start; }
.ticket .when { text-transform: capitalize; color: var(--accent); font-weight: 700; }
.ticket .perf { border-top: 2px dashed var(--border); margin: 0 14px; }
.ticket .bottom { padding: 20px; text-align: center; }
.ticket .qr { background: #fff; display: inline-block; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.ticket .qr img, .ticket .qr svg { width: 200px; height: 200px; }
.ticket .code { font-family: ui-monospace, Menlo, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.12em; margin: 12px 0 4px; }
.ticket .stamp { display: inline-block; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; padding: 6px 14px; border: 2px solid; border-radius: 3px; margin: 8px 0; }

footer.site { border-top: 1px solid var(--border); padding: 20px 0 32px; color: var(--muted); font-size: 0.875rem; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 48px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------- admin */
.admin-nav { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
.admin-nav::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: var(--strip); }
.admin-nav .wrap { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding-top: 10px; padding-bottom: 12px; }
.admin-nav .brand { font-family: var(--display); font-weight: 800; margin-right: 10px; white-space: nowrap; }
.admin-nav button.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 9px 12px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.admin-nav button.tab:hover { color: var(--text); }
.admin-nav button.tab.active { color: #fff; background: var(--accent); }
.admin-nav .spacer { flex: 1; }
@media (max-width: 700px) {
  .admin-nav .wrap { flex-wrap: wrap; overflow-x: visible; }
  .admin-nav .brand { flex: 1; order: -2; }
  .admin-nav .spacer { display: none; }
  .admin-nav a.btn, .admin-nav #logout { order: -1; }
  .admin-nav button.tab { flex: 1; padding: 10px 6px; font-size: 0.9rem; }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 1.3rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 22px 0; }
.toolbar .grow { flex: 1; min-width: 200px; }

.admin-film { display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--border); }
.admin-film:first-child { border-top: 0; }
.admin-film .thumb { width: 72px; aspect-ratio: 2 / 3; border-radius: 3px; background: var(--surface-2); object-fit: cover; }
.admin-film .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0 10px; }
.admin-film .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.meter { height: 8px; background: var(--surface-2); overflow: hidden; margin: 6px 0; max-width: 320px; }
.meter span { display: block; height: 100%; background: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: var(--radius); padding: 14px; }
.stat:nth-child(2) { border-top-color: var(--green); }
.stat:nth-child(3) { border-top-color: var(--violet); }
.stat:nth-child(4) { border-top-color: var(--carmine); }
.stat .n { font-size: 1.9rem; font-weight: 800; font-family: var(--display); font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 0.85rem; }

.list { display: flex; flex-direction: column; }
.booking { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.booking:first-child { border-top: 0; }
.booking.cancelled { opacity: 0.5; }
.booking .name { font-weight: 700; }
.booking .sub { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.booking .seats { font-family: var(--display); font-weight: 800; font-size: 1.2rem; text-align: right; }
.booking .ops { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.booking input[type='checkbox'] { width: 24px; height: 24px; accent-color: var(--ok); }
@media (min-width: 760px) {
  .booking { grid-template-columns: auto 1fr auto auto; }
  .booking .ops { grid-column: auto; }
}

.upload { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.upload img { width: 90px; border-radius: 3px; background: var(--surface-2); }
.upload .empty { width: 90px; aspect-ratio: 2 / 3; border-radius: 3px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 0.75rem; text-align: center; padding: 4px; }

table.log { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.log th, table.log td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: top; }
.table-scroll { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-weight: 700; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }
