:root {
  /* palette Bar&Bar: verde petrolio del logo + bianco */
  --brand: #12716f;
  --brand-dark: #0b5553;
  --brand-soft: #e3f4f3;
  --bg: #f4f8f8;
  --card: #ffffff;
  --ink: #17302f;
  --muted: #5f7372;
  --line: #d9e6e5;
  --accent: #b5462b;
  --accent-soft: #f6e4dc;
  --ok: #2f7d4f;
  --ok-soft: #e1f1e6;
  --warn: #9a6a00;
  --warn-soft: #fbf0d2;
  --bad: #b3261e;
  --bad-soft: #fbe2df;
  --hl: #d8f5a2;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
nav.top {
  display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center;
  padding: 8px 20px; background: var(--brand); color: #fff;
}
nav.top .brand { font-weight: 700; margin-right: 12px; display: flex; align-items: center; gap: 8px; }
nav.top .brand img { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
nav.top form { margin: 0 0 0 auto; }
nav.top button { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); padding: 3px 10px; font-size: 14px; }
nav.top a { color: #fff; text-decoration: none; opacity: .85; }
nav.top a:hover, nav.top a.on { opacity: 1; text-decoration: underline; }
nav.top .badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 13px; }
main { max-width: 1150px; margin: 0 auto; padding: 18px 16px 60px; }
h1 { font-size: 26px; margin: 6px 0 4px; }
h2 { font-size: 19px; margin: 26px 0 8px; }
h3 { font-size: 16px; margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.btn, button {
  display: inline-block; border: 1px solid var(--brand); background: var(--card); color: var(--brand-dark);
  border-radius: 8px; padding: 7px 13px; font: inherit; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn.primary, button.primary { background: var(--brand); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--brand-dark); }
.btn.ok, button.ok { border-color: var(--ok); color: var(--ok); }
.btn.bad, button.bad { border-color: var(--bad); color: var(--bad); }
button.link { border: none; background: none; padding: 0; color: var(--brand); text-decoration: underline; }
form.inline { display: inline; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.zero td { color: #b5b3ad; }
tfoot td { font-weight: 700; border-top: 2px solid var(--brand); }
.pill { display: inline-block; border-radius: 10px; padding: 0 8px; font-size: 13px; background: var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.alert { border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.alert.warn { background: var(--warn-soft); color: #5c4000; }
.alert.bad { background: var(--bad-soft); color: #6d1712; }
.alert.ok { background: var(--ok-soft); color: #1d4d31; }
input[type=text], input[type=email], select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 100%;
}
textarea { width: 100%; min-height: 120px; }
pre.mail { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 14px/1.45 ui-monospace, Menlo, monospace; max-height: 600px; overflow: auto; }
mark.hl { background: var(--hl); padding: 0 2px; }
span.col { color: #c0392b; font-weight: 600; }
.grid-week td { font-size: 13px; }
.grid-week td.cell { min-width: 120px; }
.note { color: var(--accent); font-weight: 600; }

.pin-box { max-width: 340px; margin: 8vh auto; text-align: center; }
.pin-box img { width: 120px; height: 120px; border-radius: 50%; }
.pin-box input { font-size: 30px; letter-spacing: 12px; text-align: center; width: 100%; padding: 10px; border: 2px solid var(--brand); border-radius: 10px; }
.pin-box button { width: 100%; margin-top: 12px; font-size: 18px; padding: 10px; }
.sheet .logo { width: 64px; height: 64px; border-radius: 50%; }
.sheet h1 { color: var(--brand-dark); }

/* ---------- stampe ---------- */
.print-page { background: #fff; max-width: 210mm; margin: 0 auto; padding: 14mm 12mm; }
.print-tools { max-width: 210mm; margin: 10px auto; display: flex; gap: 10px; }
.sheet h1 { font-size: 30px; margin: 0; }
.sheet .sub { color: var(--muted); margin-bottom: 10px; }
.sheet table { font-size: 17px; }
.sheet .big td { font-size: 20px; padding: 7px 8px; }
.sheet .big td.num { font-weight: 700; }
.sheet td.firma { width: 22%; }
.sheet tr.r td { height: 34px; }
.break { break-before: page; page-break-before: always; }
.avoid { break-inside: avoid; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; font-size: 14px; }
  nav.top, .print-tools, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-page { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
}
@media (max-width: 640px) {
  main { padding: 12px; }
  th, td { padding: 5px 4px; }
  .grid-week { display: block; overflow-x: auto; }
}

/* ---------- menu settimanale ---------- */
.turni { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.items-inline { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.menu-day { padding: 12px 16px 14px; }
.menu-day-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.menu-day-head h2 { margin: 0; flex: 1; font-size: 18px; color: var(--brand-dark); }
.menu-cols { display: grid; grid-template-columns: 3fr 2fr; gap: 0 24px; }
.menu-cols h3 { margin: 10px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
ol.items { margin: 0; padding-left: 22px; }
ol.items li { margin: 0 0 6px; }
ol.items input { width: 100%; padding: 8px 10px; font-size: 15px; }
.menu-day.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--brand-soft); } to { background: var(--card); } }
.savebar-cucina { position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px; justify-content: flex-end;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 10px 0; margin-top: 10px; }
@media (max-width: 640px) { .menu-cols { grid-template-columns: 1fr; } }

/* ---------- telefono ---------- */
.daynav { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
.daynav h1 { flex: 1; text-align: center; margin: 0; }
.daynav .sm { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
nav.bottom { display: none; }
@media (max-width: 700px) {
  body { font-size: 16px; }
  nav.top { padding: 8px 12px; }
  nav.top > a { display: none; }
  nav.top .brand { margin-right: 0; }
  main { padding: 12px 12px 92px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; margin-top: 22px; }
  .daynav { gap: 6px; }
  .daynav h1 { font-size: 18px; }
  .daynav .lg { display: none; }
  .daynav .sm { display: inline; }
  .daynav .btn { padding: 8px 10px; white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 8px 12px; }
  .stat b { font-size: 24px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .actions .btn { text-align: center; padding: 11px 8px; }
  .card { padding: 12px; }
  /* tabelle "a schede": ogni riga diventa un blocco, la prima cella è il titolo */
  table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
  table.stack td { display: block; border: none; padding: 0; width: auto !important; }
  table.stack td:first-child { flex-basis: 100%; font-weight: 600; }
  table.stack td:empty { display: none; }
  table.stack td input[type=text], table.stack td input[type=email] { width: 100%; }
  .form-grid > * { flex: 1 1 100%; }
  .form-grid select, .form-grid input { width: 100%; padding: 10px; }
  .grid-week { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .savebar-cucina { bottom: 64px; padding: 10px 4px; }
  nav.bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
  nav.bottom a.on { color: var(--brand); font-weight: 600; }
  nav.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
}
@media print { nav.bottom { display: none !important; } }
@media (max-width: 700px) {
  .grid-week th:first-child, .grid-week td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 96px; }
}
