:root {
  --bg: #0a2f2d;
  --bg-2: #0d3b38;
  --panel: #0f4441;
  --panel-2: #12504c;
  --line: rgba(255, 255, 255, .08);
  --text: #eef7f5;
  --muted: #9cc3bd;
  --gold: #f2c14e;
  --green: #18a970;
  --green-2: #20c07f;
  --red: #d8433b;
  --amber: #e7a531;
  --gray: #5d7b78;
  --radius: 16px;
  --font: "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -200px, #145a55 0%, var(--bg) 60%) fixed, var(--bg);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--gold); }
h1, h2, h3 { line-height: 1.15; margin: 0; }
.muted { color: var(--muted); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }

/* ---------- Bottoni e form ---------- */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 18px;
  font: 700 15px/1 var(--font); cursor: pointer; color: var(--text);
  background: var(--panel-2); text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--green-2), var(--green)); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.wa { background: #25d366; color: #073b1f; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 14px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  font: 16px var(--font); color: var(--text); background: var(--bg);
  border: 1px solid rgba(255, 255, 255, .15); border-radius: 12px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--green-2); outline-offset: 1px; border-color: transparent; }
select { appearance: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; color: var(--muted); }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--green); }
.opt { color: var(--muted); font-weight: 400; }
.hint { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.flash { padding: 12px 14px; border-radius: 12px; margin: 0 0 16px; font-weight: 600; }
.flash.ok { background: rgba(24, 169, 112, .18); color: #9ff0c9; }
.flash.err { background: rgba(216, 67, 59, .2); color: #ffb3ae; }

/* ---------- Front ---------- */
.hero { text-align: center; padding: calc(28px + env(safe-area-inset-top)) 16px 20px; }
.hero-icon { border-radius: 18px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.eyebrow { margin: 14px 0 4px; color: var(--gold); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; }
.hero h1 { font-size: clamp(24px, 6vw, 34px); font-weight: 800; }
.hero .sub { margin: 4px 0 0; color: var(--muted); }

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px;
}
.step { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.step span {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #3a2a00; font-size: 14px;
}
.step small { color: var(--muted); font-weight: 600; font-size: 14px; }

.days { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 76px; scroll-snap-align: start; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg-2); color: var(--text); padding: 10px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--font);
}
.day .dw { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.day .dn { font-size: 26px; font-weight: 800; line-height: 1; }
.day .dm { font-size: 12px; color: var(--muted); }
.day .df { margin-top: 6px; font-size: 11px; font-weight: 700; color: var(--green-2); }
.day.full .df { color: #e98b85; }
.day[aria-pressed="true"] { background: var(--gold); color: #3a2a00; border-color: var(--gold); }
.day[aria-pressed="true"] .dw, .day[aria-pressed="true"] .dm, .day[aria-pressed="true"] .df { color: #5a4300; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.slot {
  border: 0; border-radius: 12px; padding: 12px 6px; color: #fff; cursor: pointer;
  font-family: var(--font); display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .2);
}
.slot b { font-size: 14px; letter-spacing: .01em; }
.slot span { font-size: 11px; font-weight: 800; text-transform: uppercase; opacity: .95; }
.slot.free { background: linear-gradient(180deg, var(--green-2), var(--green)); }
.slot.free:hover { transform: translateY(-1px); }
.slot.busy { background: linear-gradient(180deg, #e2554d, var(--red)); opacity: .55; cursor: not-allowed; }
.legend { margin: 14px 0 0; font-size: 12px; color: var(--muted); display: flex; gap: 14px; align-items: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -8px; }
.dot.free { background: var(--green); } .dot.busy { background: var(--red); }

.foot { text-align: center; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); font-size: 13px; }
.foot a { color: var(--muted); }

dialog {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  border: 1px solid var(--line); border-radius: 20px; padding: 22px 18px;
  background: var(--panel); color: var(--text); position: fixed;
}
dialog::backdrop { background: rgba(0, 10, 10, .65); backdrop-filter: blur(3px); }
dialog h2 { font-size: 20px; font-weight: 800; padding-right: 32px; }
dialog .x {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .08); color: var(--text); font-size: 22px; cursor: pointer;
}
.when { background: rgba(242, 193, 78, .14); color: var(--gold); font-weight: 800; padding: 10px 12px; border-radius: 10px; margin: 12px 0 16px; }
.form-error { color: #ffb3ae; font-weight: 600; min-height: 1.2em; margin: 4px 0 10px; font-size: 14px; }
.done { text-align: center; padding: 10px 0 0; }
.done-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-size: 34px; margin: 0 auto 14px; }
.done h2 { padding: 0; margin-bottom: 8px; }

.prose { padding-top: 24px; }
.prose h1 { font-size: 26px; margin: 10px 0 6px; }
.prose h2 { font-size: 17px; margin: 22px 0 6px; color: var(--gold); }
.prose p { color: #d6e9e6; }

/* ---------- Admin ---------- */
.admin { background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(10, 47, 45, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: env(safe-area-inset-top) 0 0;
}
.topbar .inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.topbar .brand { font-weight: 800; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.topbar nav a.on { background: var(--panel-2); color: var(--text); }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--amber); color: #3b2600; font-size: 12px; text-align: center; font-weight: 800; }
.admin main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 48px; }
.admin h1 { font-size: 24px; font-weight: 800; margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .title { font-weight: 800; font-size: 16px; margin: 0 6px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--bg-2); color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
.tabs a.on { background: var(--gold); color: #3a2a00; }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.req { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.req .when2 { font-weight: 800; font-size: 16px; }
.req .who { font-size: 15px; }
.req .who a { color: var(--text); }
.req .msg { background: rgba(0, 0, 0, .18); border-radius: 10px; padding: 8px 10px; font-size: 14px; color: #d6e9e6; white-space: pre-wrap; }
.req .meta { font-size: 12px; color: var(--muted); }
.req .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.req .actions form { margin: 0; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.pill.pending { background: var(--amber); color: #3b2600; }
.pill.confirmed { background: var(--green); color: #fff; }
.pill.rejected, .pill.cancelled { background: var(--gray); color: #fff; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--bg-2); border-radius: var(--radius); }

.week { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; scroll-margin-top: 80px; }
.dcard.today { outline: 2px solid var(--gold); }
.dcard.past { opacity: .55; }
.dcard h3 { font-size: 16px; font-weight: 800; color: var(--gold); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ranges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.range { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border-radius: 999px; padding: 4px 4px 4px 12px; font-weight: 700; font-size: 13px; }
.range form { margin: 0; }
.range button { border: 0; background: rgba(255, 255, 255, .1); color: var(--text); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; }
.addrange { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 12px; }
.addrange select { width: auto; margin: 0; padding: 8px 10px; font-size: 14px; }
.addrange form { margin: 0; display: contents; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.agrid form { margin: 0; }
.aslot {
  width: 100%; border: 0; border-radius: 10px; padding: 8px 4px; color: #fff; font-family: var(--font);
  font-size: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 52px;
}
.aslot b { font-size: 13px; }
.aslot small { font-size: 10px; font-weight: 700; text-transform: uppercase; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.aslot.free { background: var(--green); }
.aslot.blocked { background: repeating-linear-gradient(135deg, #4c6765 0 6px, #557370 6px 12px); }
.aslot.pending { background: var(--amber); color: #3b2600; }
.aslot.confirmed { background: var(--red); }
a.aslot { text-decoration: none; }
.legend2 { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend2 i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { width: min(380px, 100%); background: var(--panel); border-radius: 20px; padding: 26px 20px; border: 1px solid var(--line); }
.auth-box h1 { font-size: 22px; margin-bottom: 14px; }

.settings { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.settings section { background: var(--panel); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.settings h2 { font-size: 17px; margin-bottom: 10px; }
.kv { font-size: 14px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; margin-top: 8px; }
.kv dd { margin: 2px 0 0; word-break: break-all; }
ol.steps { padding-left: 20px; font-size: 14px; color: #d6e9e6; }
ol.steps li { margin-bottom: 6px; }

.planning { display: grid; gap: 20px; grid-template-columns: minmax(0, 380px) 1fr; align-items: start; }
.planning canvas { width: 100%; height: auto; border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); display: block; }
.planning .side { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .planning { grid-template-columns: 1fr; } .planning canvas { max-width: 380px; margin: 0 auto; } }

@media (max-width: 520px) {
  .topbar .brand { display: none; }
  .topbar nav { margin-left: 0; }
  .week, .cards, .settings { grid-template-columns: 1fr; }
}
