/* Diario vendite — stile "accent ladder": il bordeaux pieno solo su piccoli segni e sull'azione
   principale, le sue tinte pallide sulle superfici. Telefono prima: barra 48px + menu; da 960px
   colonna di navigazione 232px a sinistra e canvas fluido con un solo gutter (24px). */
/* DM Sans (OFL, fonts/OFL.txt) servito dall'app: nessuna richiesta a servizi esterni */
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/static/fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/static/fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --ground: #faf6f5;
  --surface: #ffffff;
  --sunk: #f3eceb;
  --border: #e9e1df;
  --rule: #efe8e6;
  --control: #d5cbc9;
  --ink: #1e1a19;
  --muted: #6a605e;
  --accent: #8a1c1c;
  --accent-ink: #5f1313;
  --tint-50: #fbefee;
  --tint-100: #f5dedc;
  --tint-200: #ebbfbb;
  --warn-bg: #fdf2d8;
  --warn-ink: #6a4a05;
  --ok-bg: #e2f1e5;
  --ok-ink: #1d5a2c;
  --font: "DM Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --gap: 24px;
  --radius: 8px;
  --control-h: 44px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--ground);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; margin-top: 32px; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 12px; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
small, .muted { color: var(--muted); }
small { font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- shell ---- */
.shell { min-height: 100vh; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.menu-btn { min-height: 36px; padding: 0 14px; }
.nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav li a {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.nav li a:hover { background: var(--sunk); }
.nav li a[aria-current="page"] { background: var(--tint-100); color: var(--accent-ink); font-weight: 600; }
.nav-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding: 12px 12px 0; border-top: 1px solid var(--rule); }
.nav-foot .who { flex-basis: 100%; margin: 0; font-size: 14px; color: var(--muted); }
.nav-foot select { min-height: 36px; width: auto; }
.nav-foot button { min-height: 36px; }
.nav-foot .ghost { padding: 0 12px; }
.js-menu .nav:not(.open) { display: none; }

main { padding: 20px 16px 48px; max-width: 72rem; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .bar { grid-column: 1; height: 64px; background: transparent; border: 0; position: static; padding: 0 20px; }
  .menu-btn { display: none; }
  .nav, .js-menu .nav:not(.open) {
    display: flex; flex-direction: column; grid-column: 1; grid-row: 2;
    background: transparent; border: 0; padding: 0 12px 24px;
  }
  .nav li a { min-height: 34px; font-size: 15px; }
  .nav-foot { margin-top: auto; position: sticky; bottom: 24px; }
  main { grid-column: 2; grid-row: 1 / span 2; width: 100%; margin: 0 auto; padding: 28px var(--gap) 64px; }
}

/* ---- controlli ---- */
button, input, select, textarea { font: inherit; color: inherit; }
input[type="text"], input[type="number"], input[type="search"], input[type="email"], input:not([type]), select, textarea {
  width: 100%; min-height: var(--control-h); padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder { color: #9a8f8d; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--control); color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
button:hover, .button:hover { background: var(--sunk); }
button:active, .button:active { transform: translateY(1px); }
.primary, .button.primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.primary:hover, .button.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.ghost { background: transparent; border-color: transparent; }
.ghost:hover { background: var(--sunk); }
.danger { color: var(--accent-ink); }
.danger:hover { background: var(--tint-50); }
.small { min-height: 36px; padding: 0 12px; font-size: 14px; }

form { margin: 0; }
form.inline { display: inline; }
main form { max-width: 44rem; }
main form.inline, main .filters { max-width: none; }

/* etichetta sopra il campo; una casella resta sulla riga del suo testo */
main form p > label, main form .field {
  display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink);
}
main form p > label:has(> input[type="checkbox"]), main form p > label:has(> input[type="radio"]) {
  display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-weight: 400;
}
/* i campi non ereditano la taglia dell'etichetta: sotto 16px iOS fa zoom al tocco */
main form label > :is(input, select, textarea) { font-size: 16px; font-weight: 400; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
/* due campi brevi sulla stessa riga (arrivo/partenza, contachilometri) */
main form p:has(> label + label) { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
main form p:has(> label + label) > button { grid-column: 1 / -1; justify-self: start; }
/* campo + bottone sulla stessa riga (ricerca, data) */
main form p:has(> input[type="search"]), main form p.row { display: flex; gap: 8px; align-items: end; }
main form p.row > label { flex: 1; }
main form p:has(> input[type="search"]) > input { flex: 1; }

fieldset { margin: 0 0 20px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
legend { padding: 0 6px; font-weight: 600; font-size: 16px; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--accent-ink); font-weight: 500; }

/* luoghi come righe da toccare: nome, sotto l'indirizzo */
ul.options { list-style: none; margin: 4px 0 8px; padding: 0; }
ul.options li + li { border-top: 1px solid var(--rule); }
ul.options label { display: grid; grid-template-columns: 20px 1fr; column-gap: 12px; align-items: center; padding: 10px 4px; min-height: 52px; cursor: pointer; border-radius: var(--radius); }
ul.options label:has(input:checked) { background: var(--tint-50); }
ul.options label small { grid-column: 2; font-size: 13px; }

/* salva sempre a portata di pollice */
.savebar { position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--ground); border-top: 1px solid var(--border); }
.savebar .primary { width: 100%; }
@media (min-width: 960px) { .savebar { position: static; margin: 0; padding: 8px 0 0; border: 0; background: none; } .savebar .primary { width: auto; min-width: 12rem; } }

/* ---- messaggi ---- */
.notice, .error { padding: 12px 14px; border-radius: var(--radius); font-size: 15px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); }
.notice button { margin-left: 8px; min-height: 36px; }
.error { background: var(--tint-50); color: var(--accent-ink); font-weight: 500; }
.badge {
  display: inline-flex; align-items: center; flex: none; white-space: nowrap;
  min-height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--sunk); color: var(--muted);
}
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.start { background: var(--tint-100); color: var(--accent-ink); }
.badge.ok, .badge.s-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.s-none, .badge.s-tocheck { background: var(--warn-bg); color: var(--warn-ink); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.okline { padding: 12px 14px; border-radius: var(--radius); background: var(--ok-bg); color: var(--ok-ink); font-weight: 500; }
.error ul { margin: 6px 0 0; padding-left: 20px; }
.error p { margin: 0; }
button:disabled { opacity: 1; background: var(--sunk); border-color: var(--border); color: var(--muted); cursor: not-allowed; }

/* ---- tabelle ---- */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
thead th { font-size: 13px; font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--border); }
tfoot th, tfoot td { border-bottom: 0; font-weight: 600; }
th.num, td.num { text-align: right; } tfoot th:not(:first-child) { text-align: right; } .seller-month tfoot th:last-of-type { font-size: 18px; }
.table-wrap { overflow-x: auto; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }
td.strong, .strong { font-weight: 600; }
td.nowrap { white-space: nowrap; }
tr.selected td { background: var(--tint-50); }
.rowlinks { white-space: nowrap; text-align: right; }
.rowlinks a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 8px; font-size: 14px; font-weight: 500; text-decoration: none; border-radius: var(--radius); }
.rowlinks a:hover { background: var(--sunk); }
table.visits td { font-size: 15px; }
table.visits { min-width: 56rem; }
.count { color: var(--muted); font-size: 15px; }
.total { font-size: 18px; }
.daytotal { font-size: 18px; }

/* filtri: una griglia di campi, i bottoni in fondo */
form.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 12px; align-items: end; margin-bottom: 20px; }
form.filters > label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
form.filters > label > :is(input, select) { font-size: 16px; font-weight: 400; }
form.filters .wide { grid-column: span 2; }
form.filters .filter-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
@media (max-width: 520px) { form.filters .wide { grid-column: 1 / -1; } }
.seller-month { margin-top: 8px; }
.seller-month .titlerow h2 { margin: 0; }

/* due tabelle brevi affiancate */
.pair { display: grid; gap: var(--gap); }
.pair h2 { margin-top: 8px; }
@media (min-width: 960px) { .pair { grid-template-columns: 1fr 1fr; align-items: start; } }

/* utenti: nome a sinistra, i controlli sulla stessa riga */
ul.userlist { list-style: none; margin: 0 0 24px; padding: 0; }
ul.userlist > li { display: grid; gap: 8px 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
ul.userlist .who-col { display: grid; }
ul.userlist .who-col small { font-size: 14px; }
form.userform { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: none; }
form.userform select { width: auto; min-width: 10rem; }
form.userform input[type="text"] { flex: 1 1 14rem; width: auto; }
form.userform .check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
form.userform a { font-size: 14px; }
@media (min-width: 960px) { ul.userlist > li { grid-template-columns: 14rem 1fr; align-items: center; } }

.login { padding-top: 8vh; max-width: 26rem; }
.login .panel { padding: 24px; }
.login select { width: 100%; }

/* ---- pagine ---- */
.back { display: inline-flex; align-items: center; min-height: 36px; margin-bottom: 4px; font-size: 15px; }
.titlerow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.titlerow h1 { margin: 0; }
.monthnav { display: flex; align-items: center; gap: 4px; margin: 0; }
.monthnav strong { min-width: 6.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.monthnav a { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; border-radius: var(--radius); text-decoration: none; }
.monthnav a:hover { background: var(--sunk); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.panel > :last-child { margin-bottom: 0; } .panel > :first-child { margin-top: 0; }
.links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 15px; }

/* giorni del mese */
.days td:first-child a { font-weight: 600; }
.days .total { font-size: 18px; }

/* la giornata come percorso: le tappe sulla linea, il tratto fra una e l'altra */
ol.route { list-style: none; margin: 8px 0 20px; padding: 0; }
ol.route > li { position: relative; padding-left: 26px; }
ol.route > li::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--tint-200); }
ol.route > li:first-child::before { top: 22px; }
ol.route > li:last-child::before { bottom: auto; height: 22px; }
ol.route > li:only-child::before { display: none; }
.leg { position: relative; margin: 0; padding: 10px 0 10px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.leg .km { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.stop { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 12px 8px 16px; }
.stop::before { content: ""; position: absolute; left: -24px; top: 16px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.stop p { margin: 0 0 6px; }
.stop .time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stophead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.stophead strong { font-size: 17px; }
.stophead small { flex-basis: 100%; font-size: 14px; }
.stop .actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.stop .actions a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; border-radius: var(--radius); text-decoration: none; font-size: 14px; font-weight: 500; }
.stop .actions a:hover { background: var(--sunk); }
.stop .actions button { min-height: 40px; min-width: 40px; padding: 0 8px; font-size: 14px; background: transparent; border-color: transparent; }
.stop .actions button:hover { background: var(--sunk); }
.stop .actions form:last-child { margin-left: auto; }
.reorder { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; }
.reorder button { min-height: 40px; min-width: 40px; padding: 0; background: transparent; border-color: transparent; color: var(--muted); font-size: 18px; }
.reorder button:hover { background: var(--sunk); color: var(--ink); }
.stop:has(.reorder) .stophead { padding-right: 88px; }
.stop .actions form:last-child button { color: var(--accent-ink); }
.addstop { width: 100%; }
.narrow { max-width: 44rem; margin: 0 auto; }
@media (min-width: 960px) { .addstop { width: auto; } }

.place-map { height: 24rem; max-width: 100%; margin: 1rem 0; border-radius: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
/* bottone di invio predefinito (Invio in un campo = salva): fuori schermo ma non display:none */
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) { button:active, .button:active { transform: none; } }
@media print {
  .bar, .nav, .noprint { display: none; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  body { background: #fff; }
  table.export { font-size: 10pt; }
}
