/* Petali di Idee – Chiusure */
:root {
  --bg: #EEE6D1;
  --ink: #2B2A28;
  --ink-soft: #6B675F;
  --red: #D10000;
  --sel-bg: #FBE1DC;
  --sel-ink: #A80000;
  --card: #FFFFFF;
  --line: #DDD3BD;
  --warn-bg: #FFF6E5;
  --warn-ink: #5C4410;
  --ok-bg: #E6F0DF;
  --ok-ink: #2F5320;
  --radius: 14px;
  --font-title: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
}
h1, h2, h3 { font-family: var(--font-title); font-weight: 700; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
a { color: var(--ink); }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mt2 { margin-top: 28px; }

/* ---------- Card, box ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.box { border-radius: var(--radius); padding: 14px 16px; }
.box-warn { background: var(--warn-bg); color: var(--warn-ink); }
.box-ok { background: var(--ok-bg); color: var(--ok-ink); }
.box-red { background: var(--red); color: #fff; }
.box-red strong { font-size: 1.15em; }
.box-sel { background: var(--sel-bg); color: var(--sel-ink); }
.box-info { background: rgba(255,255,255,.55); border: 1px dashed var(--line); }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 2px solid var(--ink);
  background: var(--ink); color: var(--bg);
  font: 600 1rem var(--font-body);
  text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-light { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 60px; font-size: 1.15rem; border-radius: 16px; width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; font: inherit; cursor: pointer; min-height: 44px; }
.link-danger { color: var(--sel-ink); }

/* Scelte grandi (chi chiude, sì/no, metodo) */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices.one { grid-template-columns: 1fr; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: 8px 10px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
  font-weight: 600;
}
.choice.big span { min-height: 76px; font-size: 1.2rem; font-family: var(--font-title); }
.choice input:checked + span { background: var(--sel-bg); color: var(--sel-ink); border-color: var(--red); }
.choice input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags .choice span { min-height: 44px; padding: 6px 16px; border-radius: 999px; font-weight: 500; }

/* ---------- Form ---------- */
label.field { display: block; }
label.field > span, .field-label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date],
input[type=month], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  font: 1.05rem var(--font-body);
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
.money { position: relative; }
.money::before { content: "€"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-weight: 600; }
.money input { padding-left: 32px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.check input { width: 26px; height: 26px; accent-color: var(--red); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.errors { background: var(--sel-bg); color: var(--sel-ink); border-radius: 12px; padding: 10px 14px; font-weight: 600; }

/* ---------- Wizard ---------- */
.wiz { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.wiz-top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 16px 8px; padding-top: max(10px, env(safe-area-inset-top)); }
.wiz-top .row { min-height: 44px; }
.back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; text-decoration: none; font-size: 1.5rem; background: var(--card); border: 1px solid var(--line); }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--red); border-radius: 99px; transition: width .3s; }
.step-n { font-weight: 600; color: var(--ink-soft); }
.wiz-form { display: flex; flex-direction: column; flex: 1; }
.wiz-links { flex: 0; padding-top: 0; }
.wiz-body { flex: 1; padding: 8px 16px 24px; }
.wiz-body h1 { font-size: 1.6rem; margin-top: 8px; }
.wiz-foot { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 75%, rgba(238,230,209,0)); padding: 18px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.wiz-home-logo { display: block; width: 62%; max-width: 260px; margin: 12px auto 4px; }
.today { text-align: center; font-family: var(--font-title); font-size: 1.15rem; color: var(--ink-soft); margin: 0; }
.wiz-title { text-align: center; font-size: 2rem; margin: 4px 0 20px; }

/* Conta contanti */
.counter { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.counter:last-of-type { border-bottom: 0; }
.bill { font-family: var(--font-title); font-weight: 700; font-size: 1.15rem; padding-left: 2px; padding-right: 2px; background: var(--bg); border-radius: 8px; text-align: center; padding: 6px 0; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1.4rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.stepper button:active { background: var(--sel-bg); border-color: var(--red); }
.stepper input { width: 58px; min-height: 44px; text-align: center; padding: 6px; font-weight: 700; font-size: 1.1rem; }
.subtot { min-width: 76px; text-align: right; font-weight: 600; }
.total-big { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; background: var(--ink); color: var(--bg); border-radius: var(--radius); }
.total-big strong { font-family: var(--font-title); font-size: 1.7rem; }

.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--bg); }
.thumb-lg { max-width: 100%; border-radius: 10px; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--ink); white-space: nowrap; }
.pill-red { background: var(--sel-bg); color: var(--sel-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill-dark { background: var(--ink); color: var(--bg); }

.photo-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; border: 2px dashed var(--ink); border-radius: 16px; background: rgba(255,255,255,.6); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.photo-btn input { display: none; }
.photo-preview { display: block; max-height: 180px; margin: 10px auto 0; border-radius: 12px; }

.sum-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; }
.sum-line + .sum-line { border-top: 1px solid var(--line); }
.sum-line strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: 32px 20px; }
.login img { display: block; width: 70%; max-width: 240px; margin: 0 auto 16px; }

/* ---------- Back office ---------- */
.admin { display: flex; min-height: 100vh; }
.side { width: 230px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side-logo { display: block; width: 150px; margin: 0 auto 18px; }
.side nav a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; text-decoration: none; font-weight: 500; }
.side nav a:hover { background: var(--bg); }
.side nav a.active { background: var(--sel-bg); color: var(--sel-ink); font-weight: 700; }
.side .foot { margin-top: auto; padding-top: 16px; font-size: .9rem; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.main-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.main-head h1 { margin: 0; }
.menu-toggle { display: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .lbl { font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
.kpi .val { font-family: var(--font-title); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .85rem; color: var(--ink-soft); }
.kpi.alert .val { color: var(--sel-ink); }
.delta-up { color: var(--ok-ink); font-weight: 600; }
.delta-down { color: var(--sel-ink); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; font-size: .95rem; }
.t th, .t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); background: #FBF8F1; white-space: nowrap; }
.t td.num, .t th.num { text-align: right; }
.t tr:last-child td { border-bottom: 0; }
.t tfoot td { font-weight: 700; background: #FBF8F1; border-top: 2px solid var(--line); }
.t tr.closed td { color: var(--ink-soft); }
.t tr.warn td { background: var(--warn-bg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters label.field { min-width: 150px; }
.filters input, .filters select { min-height: 44px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--ink-soft); }
dl.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.todo li { margin: 4px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.flash { margin-bottom: 16px; }

@media (max-width: 900px) {
  .admin { display: block; }
  .side { position: sticky; top: 0; z-index: 10; width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-logo { width: 64px; margin: 0 8px 0 0; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .side nav, .side .foot { display: none; width: 100%; }
  .side.open nav, .side.open .foot { display: block; }
  .main { padding: 16px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media print {
  .side, .menu-toggle, .btn { display: none !important; }
}

.bill.coins { font-size: .95rem; }

/* Back office: extra */
.month-nav { gap: 8px; }
.month-nav input[type=month] { min-height: 36px; width: auto; padding: 4px 10px; font-size: .95rem; }
.small-val { font-size: 1.6rem; }
.wide-left { grid-template-columns: 2fr 1fr; }
.narrow { max-width: 520px; }
.w-auto { width: auto !important; min-height: 36px !important; padding: 4px 10px !important; font-size: .9rem !important; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grid4 input { min-height: 40px; padding: 6px; font-size: .95rem; }
.shift-row + .shift-row { border-top: 1px solid var(--line); padding-top: 10px; }
.pw { font-family: ui-monospace, monospace; font-size: 1.2rem; background: #fff; padding: 2px 8px; border-radius: 6px; }
.big-diff { font-size: 1.15rem; }
code { font-family: ui-monospace, monospace; font-size: .9em; }
@media (max-width: 900px) { .wide-left { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }
.grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }
.todo a { white-space: nowrap; }
.todo { padding-left: 18px; margin: 0; }
.t td.day { white-space: nowrap; }
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .val { font-size: 1.25rem; }
  .main-head h1 { font-size: 1.4rem; }
}
.changes { margin: 4px 0 0; padding-left: 18px; }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.counts { font-size: 1.05rem; }
.match { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 16px; align-items: center; }
.match h3 { margin: 6px 0 2px; }
.match-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 1.4rem; }
.match-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 900px) { .match { grid-template-columns: 1fr; } .match-mid { flex-direction: row; } .match-actions { flex-direction: row; flex-wrap: wrap; } }
.grow-title { flex: 1; margin: 0; }
.trend h3 { display: flex; justify-content: space-between; gap: 8px; }
.kpi-inline { font-family: var(--font-title); font-size: 1.8rem; font-weight: 700; }
.m0 { margin: 0; }

/* Calendario ore */
.cal-nav { margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg a { padding: 8px 14px; text-decoration: none; min-height: 36px; display: flex; align-items: center; }
.seg a.on { background: var(--ink); color: var(--bg); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { font-size: .8rem; font-weight: 700; text-transform: uppercase; color: var(--ink-soft); padding: 0 4px; }
.cal-day { display: flex; flex-direction: column; gap: 3px; min-height: 96px; padding: 6px; border-radius: 10px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--card); overflow: hidden; }
.cal-day.st-previsto { background: rgba(255,255,255,.45); border: 1.5px dashed #BFB497; }
.cal-day.st-chiuso { background: #E4DED0; border-color: #D6CFBE; color: var(--ink-soft); }
.cal-day.out { opacity: .45; }
.cal-day.today { outline: 2px solid var(--red); outline-offset: -1px; }
.cal-day:hover { border-color: var(--ink); }
.cal-num { font-family: var(--font-title); font-weight: 700; }
.cal-z { font-size: .72rem; color: var(--ink-soft); margin-top: auto; }
.cal-day.mini { display: inline-block; min-height: 0; width: 14px; height: 12px; padding: 0; vertical-align: middle; border-radius: 3px; }
.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chip-rosa { background: var(--sel-bg); color: var(--sel-ink); }
.chip-scuro { background: var(--ink); color: #fff; }
.chip-prev { opacity: .55; }
.chip-abs { background: transparent; color: var(--ink-soft); border: 1px dashed currentColor; }
.t.week td, .t.week th { text-align: center; vertical-align: top; }
.t.week td.wk-previsto { background: rgba(238,230,209,.35); }
.t.week th.today-col { box-shadow: inset 0 -3px 0 var(--red); }
.t.tmpl td { min-width: 260px; }
.legend { margin-top: 8px; }
@media (max-width: 700px) {
  .cal { gap: 3px; }
  .cal-day { min-height: 70px; padding: 4px; }
  .cal-day .chip { font-size: .66rem; padding: 1px 4px; text-overflow: clip; }
  .cal-day .chip .cn { display: none; }
  .cal-z { display: none; }
  .cal-h { font-size: .65rem; }
}
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-slots { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px; align-items: center; }
.grid-slots .field-label { margin: 0; }
@media (max-width: 500px) { .grid-slots { grid-template-columns: 1fr 1fr; } .grid-slots .field-label { grid-column: 1 / -1; } }
