/* Portale clienti — tema scuro. Il colore del cliente (--cliente) si usa solo per le scritte. */
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url('/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url('/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  color-scheme: dark;
  --bg: #0a0b0d; --panel: #111317; --panel-2: #16191e; --hover: #1b1f25;
  --border: #22262d; --border-strong: #30353e;
  --text: #e8eaed; --muted: #8b929d; --faint: #5c636e;
  --accent: #7aa2ff; --ok: #3ecf8e; --warn: #f5b83d; --late: #ff5d5d; --info: #6ea8ff; --purple: #b197fc;
  --ok-bg: rgba(62, 207, 142, .10); --warn-bg: rgba(245, 184, 61, .10); --late-bg: rgba(255, 93, 93, .09);
  --info-bg: rgba(110, 168, 255, .10); --purple-bg: rgba(177, 151, 252, .10); --grey-bg: rgba(139, 146, 157, .12);
  --cliente: #e8eaed;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: var(--accent); text-decoration: none; }
.mt { margin-top: 16px; }
.card .value, .right, .stat strong, .totale, .count { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- Accesso ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #171a20 0%, var(--bg) 60%); }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 30px 26px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.login-card p { margin: 0 0 6px; font-size: 13px; }
.login-logo { width: 44px; height: 44px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select { font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); background: var(--bg); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 162, 255, .18); }
.errore { background: var(--late-bg); color: var(--late); border: 1px solid rgba(255, 93, 93, .3); padding: 9px 12px; border-radius: 8px; font-size: 14px; }

/* ---- Pulsanti ---- */
.btn { font: inherit; font-weight: 500; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel-2); cursor: pointer; color: var(--text); display: inline-block; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.ghost-light { background: transparent; color: var(--muted); }

/* ---- Intestazione ---- */
.top { position: sticky; top: 0; z-index: 10; background: rgba(10, 11, 13, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.top-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px 6px; max-width: 1100px; margin: 0 auto; }
.top-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-title strong { font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--cliente); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-ro { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.logo { width: 38px; height: 38px; border-radius: 9px; background: #fff; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; font-weight: 600; font-family: var(--mono); font-size: 13px; }
.logo.iniziali { background: transparent; border: 1px solid var(--border-strong); color: var(--cliente); }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 10px; max-width: 1100px; margin: 0 auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; background: none; border: none; color: var(--muted); padding: 11px 12px; font: inherit; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--cliente); font-weight: 500; border-bottom-color: currentColor; }
.count { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: var(--late); color: var(--bg); font-size: 11px; font-weight: 600; text-align: center; margin-left: 4px; }

/* ---- Contenuto ---- */
.content { max-width: 1100px; margin: 0 auto; padding: 18px 16px calc(36px + env(safe-area-inset-bottom)); }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 14px; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 7px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; }
.card .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.card .value { font-size: 22px; font-weight: 500; margin-top: 4px; }
.card .sub { font-size: 12px; color: var(--muted); }
.card.alert { border-color: rgba(255, 93, 93, .45); background: linear-gradient(180deg, var(--late-bg), transparent 70%), var(--panel); }
.card.alert .value { color: var(--late); }
.card.warn { border-color: rgba(245, 184, 61, .4); background: linear-gradient(180deg, var(--warn-bg), transparent 70%), var(--panel); }
.card.warn .value { color: var(--warn); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 15px 16px; margin-bottom: 14px; }
.panel.alert { border-color: rgba(255, 93, 93, .35); }
.panel.alert h3 { color: var(--late); }

.list { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: none; }
.row .grow { flex: 1; min-width: 0; }
.row.click, .click { cursor: pointer; }
.row.late { background: var(--late-bg); margin: 0 -16px; padding: 11px 16px; box-shadow: inset 2px 0 0 var(--late); }
.row.arrivo { background: var(--warn-bg); margin: 0 -16px; padding: 11px 16px; box-shadow: inset 2px 0 0 var(--warn); }
.percorso .row.late { margin: 0 -12px; padding: 10px 12px; }
.right { text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input { flex: 1; min-width: 180px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex-shrink: 0; border: 1px solid var(--border-strong); background: var(--panel); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }
.chip.alert { color: var(--late); }
.chip.alert.active { background: var(--late); color: var(--bg); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; font-family: var(--font); }
.b-ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(62, 207, 142, .25); }
.b-warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(245, 184, 61, .25); }
.b-yellow { background: rgba(245, 184, 61, .14); color: var(--warn); border-color: rgba(245, 184, 61, .4); font-weight: 600; }
.b-late { background: rgba(255, 93, 93, .14); color: var(--late); border-color: rgba(255, 93, 93, .4); font-weight: 600; }
.b-grey { background: var(--grey-bg); color: var(--muted); border-color: var(--border); }
.b-blue { background: var(--info-bg); color: var(--info); border-color: rgba(110, 168, 255, .25); }
.b-purple { background: var(--purple-bg); color: var(--purple); border-color: rgba(177, 151, 252, .25); }
.late-text { color: var(--late); font-weight: 500; }

.back { display: inline-block; margin-bottom: 8px; cursor: pointer; font-size: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 9px 11px; }
.stat span { display: block; font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.stat strong { font-size: 15px; font-weight: 500; }
.percorso { border: 1px solid var(--border); background: var(--bg); border-radius: 10px; padding: 11px 12px; margin-bottom: 10px; }
.percorso.late { border-color: rgba(255, 93, 93, .4); box-shadow: inset 2px 0 0 var(--late); }
.percorso > strong { margin-right: 4px; }
.empty { color: var(--faint); padding: 20px; text-align: center; border: 1px dashed var(--border-strong); border-radius: 10px; }
.totale { font-weight: 600; text-align: right; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border-strong); }
.loading { color: var(--faint); padding: 30px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw; }
.toast.err { border-color: rgba(255, 93, 93, .5); color: #ffb3b3; }

@media (min-width: 800px) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}

/* ---- Icone (a linea, colore del testo) ------------------------------------ */
.ic { display: inline-block; width: 15px; height: 15px; flex-shrink: 0; vertical-align: -3px; background: currentColor;
  -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
h3 .ic { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.prom-icon .ic { width: 18px; height: 18px; color: var(--muted); }
.b-late::before {
  content: ''; width: 11px; height: 11px; background: currentColor;
  -webkit-mask: var(--ic-alert) center / contain no-repeat; mask: var(--ic-alert) center / contain no-repeat; }
.b-ok-check::before { content: ''; width: 11px; height: 11px; background: currentColor;
  -webkit-mask: var(--ic-check) center / contain no-repeat; mask: var(--ic-check) center / contain no-repeat; }
.stato-db { display: inline-flex; align-items: center; gap: 6px; }
.stato-db::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--late); }
.stato-db.ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(62, 207, 142, .18); }
:root {
  --ic-home: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%2010.5%2012%203l9%207.5V21h-6v-6H9v6H3z%22/%3E%3C/svg%3E");
  --ic-settings: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h9M17%206h3M4%2012h3M11%2012h9M4%2018h11M19%2018h1%22/%3E%3Ccircle%20cx%3D%2215%22%20cy%3D%226%22%20r%3D%222%22/%3E%3Ccircle%20cx%3D%229%22%20cy%3D%2212%22%20r%3D%222%22/%3E%3Ccircle%20cx%3D%2217%22%20cy%3D%2218%22%20r%3D%222%22/%3E%3C/svg%3E");
  --ic-alert: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203.5%202.5%2020h19L12%203.5z%22/%3E%3Cpath%20d%3D%22M12%2010v4.5M12%2017.2v.3%22/%3E%3C/svg%3E");
  --ic-bell: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%2016v-5a6%206%200%201%201%2012%200v5l1.5%202h-15z%22/%3E%3Cpath%20d%3D%22M10%2020.5a2%202%200%200%200%204%200%22/%3E%3C/svg%3E");
  --ic-box: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207.5%2012%203l9%204.5v9L12%2021l-9-4.5z%22/%3E%3Cpath%20d%3D%22M3%207.5%2012%2012l9-4.5M12%2012v9%22/%3E%3C/svg%3E");
  --ic-file: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%203H6v18h12V7z%22/%3E%3Cpath%20d%3D%22M14%203v4h4M9%2013h6M9%2017h6%22/%3E%3C/svg%3E");
  --ic-chat: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%205h16v11H9l-5%204z%22/%3E%3C/svg%3E");
  --ic-mail: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%225%22%20width%3D%2218%22%20height%3D%2214%22%20rx%3D%221.5%22/%3E%3Cpath%20d%3D%22m3.5%207%208.5%206%208.5-6%22/%3E%3C/svg%3E");
  --ic-check: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m5%2012.5%204.5%204.5L19.5%207%22/%3E%3C/svg%3E");
  --ic-sliders: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h9M17%206h3M4%2012h3M11%2012h9M4%2018h11M19%2018h1%22/%3E%3Ccircle%20cx%3D%2215%22%20cy%3D%226%22%20r%3D%222%22/%3E%3Ccircle%20cx%3D%229%22%20cy%3D%2212%22%20r%3D%222%22/%3E%3Ccircle%20cx%3D%2217%22%20cy%3D%2218%22%20r%3D%222%22/%3E%3C/svg%3E");
}
.ic-home { --ic: var(--ic-home); }
.ic-settings { --ic: var(--ic-settings); }
.ic-alert { --ic: var(--ic-alert); }
.ic-bell { --ic: var(--ic-bell); }
.ic-box { --ic: var(--ic-box); }
.ic-file { --ic: var(--ic-file); }
.ic-chat { --ic: var(--ic-chat); }
.ic-mail { --ic: var(--ic-mail); }
.ic-check { --ic: var(--ic-check); }
.ic-sliders { --ic: var(--ic-sliders); }
