/* ============================================================
   TransMart board — app shell, sidebar, scheduling grid, modal.
   Reuses design tokens from style.css (data-theme="light").
   ============================================================ */

.ts-body { margin: 0; font-family: var(--font-body, system-ui, sans-serif); background: var(--bg); color: var(--text);
  font-size: 12.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }

/* thin scrollbars (Transmart) */
.ts-body ::-webkit-scrollbar { width: 9px; height: 9px; }
.ts-body ::-webkit-scrollbar-track { background: transparent; }
.ts-body ::-webkit-scrollbar-thumb { background: var(--border-hard); border-radius: 5px; }
.ts-body ::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ---- Login page ---- */
.ts-login-body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body, system-ui, sans-serif); color: var(--text);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #334155 100%); padding: 1.5rem; }
.ts-login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 2.2rem 2rem 2rem;
  box-shadow: 0 24px 70px rgba(0,0,0,.45); text-align: center; box-sizing: border-box; }
.ts-login-logo { height: 46px; margin-bottom: 1.1rem; }
.ts-login-title { margin: 0 0 .25rem; font-size: 1.3rem; font-weight: 700; }
.ts-login-sub { margin: 0 0 1.6rem; font-size: .82rem; color: var(--text-muted); }
.ts-login-form { display: flex; flex-direction: column; gap: .9rem; text-align: left; }
.ts-login-field { display: flex; flex-direction: column; gap: .3rem; font-size: .74rem; font-weight: 600;
  letter-spacing: .03em; color: var(--text-muted); text-transform: uppercase; }
.ts-login-field input, .ts-login-field select { font-size: .95rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text); background: #fff; }
.ts-login-field input:focus, .ts-login-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.ts-login-btn { margin-top: .4rem; padding: .65rem; font-size: .95rem; justify-content: center; }
.ts-login-btn:disabled { opacity: .6; cursor: progress; }
.ts-login-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 8px;
  padding: .5rem .65rem; font-size: .82rem; }
.ts-user { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600;
  color: var(--text-muted); padding: 0 .3rem 0 .5rem; border-left: 1px solid var(--border); margin-left: .2rem;
  text-transform: uppercase; }
.ts-user .ic { width: 16px; height: 16px; }

.ts-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---- Toolbar ---- */
.ts-toolbar {
  display: flex; align-items: center; gap: .35rem .5rem;
  padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 1px 0 var(--primary-light); position: sticky; top: 0; z-index: 30;
  min-height: 60px; flex-wrap: wrap;
}
/* refresh + user + logout pinned to the right edge */
.ts-toolbar-end { display: flex; align-items: center; gap: .3rem; margin-left: auto; }
.ts-logo { height: 44px; width: auto; display: block; }
.ts-ro-badge { font-size: .7rem; font-weight: 700; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 999px; padding: .15rem .55rem; white-space: nowrap; }

/* base = secondary button (used in forms/modals) */
.ts-btn {
  font-size: 11px; font-weight: 500; padding: 6px 10px; border: 1px solid var(--border-hard);
  border-radius: var(--r-sm); background: var(--surface); color: var(--text); cursor: pointer;
  white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem;
  line-height: 1.2; box-shadow: var(--shadow-xs); transition: all var(--t);
}
.ts-btn:hover { background: var(--bg-subtle); border-color: var(--text-muted); color: var(--text); }
.ts-btn-primary { background: var(--primary); border-color: transparent; color: #fff;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,.08); }
.ts-btn-primary:hover { background: var(--primary-hover); border-color: transparent; color: #fff;
  transform: translateY(-1px); box-shadow: var(--shadow); }
.ts-btn-accent { background: var(--primary); border-color: transparent; color: #fff; }
.ts-btn-accent:hover { background: var(--primary-hover); border-color: transparent; color: #fff; }
.ts-icon { padding: .35rem .5rem; font-size: 1rem; }

/* toolbar action buttons are GHOST (transparent), except primary */
.ts-toolbar .ts-btn:not(.ts-btn-primary) {
  background: transparent; border-color: transparent; color: var(--text-muted); box-shadow: none;
}
.ts-toolbar .ts-btn:not(.ts-btn-primary):hover { background: var(--bg-subtle); color: var(--text); }

/* ---- inline line icons ---- */
.ic { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; flex: none; }

/* ---- Controls (tabs + date nav + label + range picker) ---- */
.ts-controls { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
/* view tabs = pill toggle on a muted pill container */
.ts-tabs { display: flex; gap: 0; background: var(--bg-subtle); border-radius: var(--r-sm); padding: 2px; }
.ts-tab {
  font-size: 11px; font-weight: 500; padding: 4px 11px; cursor: pointer; border: none;
  background: transparent; color: var(--text-muted); text-decoration: none; line-height: 1.4;
  border-radius: 3px; transition: all var(--t);
}
.ts-tab:hover { color: var(--text); }
.ts-tab.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); font-weight: 600; }
.ts-datenav { display: flex; gap: .25rem; align-items: center; }
.ts-iconbtn {
  border: 1px solid transparent; background: transparent; border-radius: var(--r-sm);
  width: 26px; height: 26px; padding: 0; cursor: pointer; color: var(--text-muted); font-size: .95rem;
  line-height: 1; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.ts-iconbtn:hover { background: var(--bg-subtle); color: var(--text-strong); }
.ts-btn-light { background: var(--bg-subtle); border-color: transparent; box-shadow: none; color: var(--text); }
.ts-btn-light:hover { background: var(--bg-muted); color: var(--text); border-color: transparent; }
.ts-rangelabel { margin-left: 4px; font-size: 12px; color: var(--text); font-weight: 500;
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.ts-rangepick { display: flex; align-items: center; gap: .5rem; }
.ts-rangepick label { font-size: .72rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.ts-rangepick input[type=date] { font-size: .8rem; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: var(--r-sm); }

/* ---- Shell: sidebar | board ---- */
.ts-shell { display: grid; grid-template-columns: 250px 1fr; flex: 1; min-height: 0; overflow: hidden;
  transition: grid-template-columns .32s cubic-bezier(.22,.61,.36,1); }

/* ---- Sidebar ---- */
.ts-sidebar { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--border); background: var(--surface); }
.ts-sidebar-head { padding: .6rem; border-bottom: 1px solid var(--border); }
.ts-sidebar-title { font-weight: 700; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); display: flex; align-items: center; gap: .4rem; }
.ts-count { background: var(--primary); color: #fff; border-radius: var(--r-full); font-size: 10px;
  font-weight: 700; padding: 2px 7px; min-width: 1.1rem; text-align: center; font-variant-numeric: tabular-nums; }
.ts-sidebar-sub { font-size: .7rem; color: var(--text-muted); margin: .2rem 0 .5rem; }
.ts-search { width: 100%; box-sizing: border-box; font-size: .8rem; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--r-sm); }
.ts-sidebar-foot { border-top: 1px solid var(--border); padding: .5rem; }
.ts-spot { width: 100%; }

/* ---- Sidebar collapse (animated vertical rail) ---- */
/* Fixed-width inner wrapper: stays 250px and is clipped by the sidebar's
   overflow:hidden while the grid column animates, so text never reflows. */
.ts-sidebar-main { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 250px;
  opacity: 1; transition: opacity .22s ease .08s; }
.ts-collapse-btn { margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: .15rem; border-radius: 4px; cursor: pointer; color: var(--text-muted); }
.ts-collapse-btn:hover { background: rgba(0,0,0,.06); color: var(--accent); }

/* Rail overlays the sidebar; cross-fades with the main content. */
.ts-rail { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  gap: .7rem; padding: .7rem .2rem; box-sizing: border-box; background: none; border: 0; cursor: pointer;
  color: var(--text-muted); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.ts-rail:hover { background: rgba(0,0,0,.04); color: var(--accent); }
.ts-rail-label { writing-mode: vertical-rl; transform: rotate(180deg);
  font-weight: 700; font-size: .72rem; letter-spacing: .08em; white-space: nowrap; }

.ts-shell.is-sidebar-collapsed { grid-template-columns: 42px 1fr; }
.ts-shell.is-sidebar-collapsed .ts-sidebar-main { opacity: 0; pointer-events: none; transition: opacity .12s ease; }
.ts-shell.is-sidebar-collapsed .ts-rail { opacity: 1; pointer-events: auto; transition: opacity .24s ease .12s; }

@media (prefers-reduced-motion: reduce) {
  .ts-shell, .ts-sidebar-main, .ts-rail { transition: none; }
}

/* card lists (sidebar + cells) */
.ts-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
#sidebar-list { padding: .5rem; overflow-y: auto; flex: 1; min-height: 60px; }

/* ---- Service card (= Transmart .stop / .pool-card) ---- */
.svc-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-left: 4px solid var(--text-subtle);
  border-radius: var(--r-sm); padding: 3px 6px 4px 8px; cursor: grab; line-height: 1.25;
  transition: all var(--t-fast);
}
.svc-card:hover { border-color: var(--border-hard); box-shadow: var(--shadow-xs); }
.svc-card:active { cursor: grabbing; }
.svc-card.svc-c { border-left-color: var(--consegna); }
.svc-card.svc-r { border-left-color: var(--ritiro); }
.svc-head { display: flex; align-items: center; gap: .35rem; }
/* type badge = small colored square */
.svc-badge { font-family: var(--font-display); font-size: 9px; font-weight: 800; letter-spacing: .03em;
  color: #fff; border-radius: var(--r-xs); padding: 1px 5px; min-width: 16px; text-align: center; flex: none; }
.svc-c .svc-badge { background: var(--consegna); }
.svc-r .svc-badge { background: var(--ritiro); }
.svc-client { font-weight: 700; font-size: 11.5px; letter-spacing: -.005em; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-c .svc-client { color: var(--consegna); }
.svc-r .svc-client { color: var(--ritiro); }
/* pallet = pill */
.svc-pallet { font-size: 10px; font-weight: 700; color: var(--text); white-space: nowrap;
  font-variant-numeric: tabular-nums; padding: 0 6px; border: 1px solid var(--border-soft);
  border-radius: var(--r-full); background: var(--surface); line-height: 15px; }
/* numero pratica (PREFISSO.NNNNNN) sulla card */
.svc-num { font-size: 9.5px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums;
  letter-spacing: .02em; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-route { font-size: 11px; color: var(--text-strong); margin-top: 1px; display: flex; flex-direction: column; gap: 0; }
.svc-leg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.svc-leg b { color: var(--text-muted); font-size: 8.5px; font-weight: 800; letter-spacing: .06em; margin-right: .25rem; text-transform: uppercase; }
.svc-leg:last-child b { color: var(--primary); }
.svc-ghost { opacity: .4; }
/* multi-select: cards clicked (toggled) before a multi-drag */
.svc-selected { outline: 2px solid var(--primary); outline-offset: -1px; background: var(--primary-soft, rgba(37,99,235,.10)); }

/* ---- Board grid ---- */
.ts-board-region { overflow: auto; min-height: 0; background: var(--bg); }
/* tk #21.016 - era "min-width: max-content": la griglia si allargava a quanto
   chiedeva il contenuto (1601px con 7 giorni) e la board scorreva in orizzontale
   qualunque cosa facessero le colonne. Ora la griglia sta nello spazio
   disponibile, e il min-width del contenuto resta solo dove le colonne sono
   tante (mese/range), dove scorrere e' inevitabile e giusto. */
.ts-grid { display: flex; flex-direction: column; min-width: 100%; }
.has-many-cols .ts-grid { min-width: max-content; }
/* tk #21.016 - minmax(0,1fr) e non minmax(190px,...): con 7 giorni il minimo
   fisso chiedeva 150+7*190=1480px e su uno schermo da 1366 la settimana andava
   in scroll orizzontale. Ora le colonne si restringono e la settimana sta
   sempre in una pagina, compatta o no. Il minimo resta solo dove le colonne
   sono tante (mese/range), dove scorrere e' inevitabile e corretto. */
.ts-grid-row { display: grid; grid-template-columns: 150px repeat(var(--ts-cols, 7), minmax(0, 1fr)); border-bottom: 1px solid var(--border-soft); }
.ts-board-region.has-many-cols .ts-grid-row { grid-template-columns: 150px repeat(var(--ts-cols, 7), minmax(120px, 1fr)); }
.is-compatta.has-many-cols .ts-grid-row,
.is-compatta .ts-board-region.has-many-cols .ts-grid-row { grid-template-columns: 110px repeat(var(--ts-cols, 30), minmax(64px, 1fr)); }
.ts-grid-head { position: sticky; top: 0; z-index: 5; }
.ts-colhead {
  padding: 6px 8px 7px; text-align: center; border-left: 1px solid var(--border);
  color: var(--text-muted); display: block; background: var(--surface); position: relative;
}
.ts-colhead-day { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-right: 4px; }
.ts-colhead-date { font-size: 12px; font-weight: 700; color: var(--text-strong); letter-spacing: -.01em; }
.ts-colhead.is-today .ts-colhead-day,
.ts-colhead.is-today .ts-colhead-date { color: var(--primary); }
.ts-colhead.is-today::after { content: ''; display: block; height: 2px; width: 16px; margin: 3px auto 0;
  background: var(--primary); border-radius: 2px; }
.ts-colhead.is-weekend { background: var(--bg); }

/* driver column = compact sticky-left card */
.ts-rowhead {
  padding: 8px; background: var(--surface); position: sticky; left: 0; z-index: 4;
  border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 3px;
  box-shadow: 8px 0 0 0 var(--bg), 10px 0 14px -6px rgba(15,23,42,.14);
}
.ts-corner { z-index: 6; color: var(--text-muted); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; box-shadow: none; }
.dr-color-bar { width: 80%; height: 4px; border-radius: var(--r-full); margin-bottom: 4px; }
.ts-driver-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.1;
  color: var(--text-strong); letter-spacing: -.01em; }
.ts-driver-firstname { font-size: 12px; color: var(--text-muted); margin-top: -2px; }
.ts-driver-plates { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem; margin-top: .3rem; }
.ts-plate { font-family: var(--font-display); font-size: 10px; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase; border: 1px solid var(--primary-3); border-radius: var(--r-sm);
  padding: 1px 6px; color: var(--primary); background: var(--surface); }
.ts-plate.ts-cap { color: var(--text-muted); border-color: var(--border-hard); background: var(--bg-subtle);
  text-transform: none; font-family: var(--font-body); font-weight: 700; }

/* ---- Day cell (= Transmart .trip-card) ---- */
.day-cell {
  margin: 3px; padding: 3px 4px 4px; min-height: 88px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .25rem; transition: box-shadow var(--t);
}
.day-cell:hover { box-shadow: var(--shadow); }
.day-cell.is-empty { background: var(--surface); box-shadow: none; border-style: dashed; }
.cell-empty-hint { font-size: 10px; color: var(--text-subtle); text-align: center; margin: auto;
  font-style: italic; padding: .6rem 0; }
.cell-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; gap: .3rem;
  padding: 1px 3px 0; min-height: 16px; }
.cell-badges { display: flex; gap: .25rem; }
/* C/R count badges = tinted pills (tt-block style) */
.cell-badge { border-radius: var(--r-sm); padding: 1px 6px; font-weight: 700; font-size: 10px;
  font-variant-numeric: tabular-nums; }
.badge-c { background: var(--consegna-bg); color: var(--consegna); }
.badge-r { background: var(--ritiro-bg); color: var(--ritiro); }
/* Loris, 19/11/2026: la targa del viaggio quando NON e' quella predefinita
   dell'autista. Compare solo in quel caso, quindi e' fatta per farsi notare:
   se fosse sempre li' diventerebbe parte dello sfondo e non direbbe piu'
   niente. Stessi colori dell'avviso di sola lettura. */
/* Loris, 23/11/2026: con un rimorchio scelto dalla tabella la targa non si
   scrive a mano. Si vede che e' bloccata, invece di lasciar digitare in un
   campo che poi il salvataggio riscrive. */
.ts-modal input.is-bloccato { background: var(--surface-muted, #f1f3f7); color: var(--text-muted); cursor: not-allowed; }
.cell-targa { border-radius: var(--r-sm); padding: 1px 5px; font-weight: 800; font-size: 9.5px;
  letter-spacing: .03em; white-space: nowrap; color: #b45309; background: #fff7ed;
  border: 1px solid #fed7aa; }
.cell-totals { display: flex; gap: .35rem; color: var(--text-muted); white-space: nowrap;
  font-weight: 700; font-variant-numeric: tabular-nums; }
.cell-dur { font-weight: 700; color: var(--success); }
/* tk #20.661 - bancali viaggio: da consegnare / ritirati / occupazione su portata */
.cell-pal-c { color: var(--consegna); }
.cell-pal-r { color: var(--ritiro); }
.cell-cap { color: var(--text-muted); }
.cell-cap.is-over { color: var(--danger); font-weight: 800; }
.cell-cards { min-height: 24px; flex: 1; }
.cell-foot { display: flex; gap: .25rem; margin-top: auto; padding-top: 2px; }
.cell-note { flex: 1; min-width: 0; font-size: 10px; border: 1px dashed var(--border); border-radius: var(--r-sm);
  padding: .2rem .35rem; background: transparent; color: var(--text); }
.cell-note:focus { outline: none; border-color: var(--primary); border-style: solid; }
.cell-addstop { font-size: 10px; border: 1px dashed var(--border); border-radius: var(--r-sm); background: transparent;
  cursor: pointer; color: var(--text-subtle); padding: .2rem .45rem; white-space: nowrap; }
.cell-addstop:hover { color: var(--primary); border-color: var(--primary); }

/* ---- Compact (month) ---- */
.is-compatta .ts-grid-row { grid-template-columns: 110px repeat(var(--ts-cols, 30), minmax(64px, 1fr)); }
.is-compatta .day-cell { min-height: 52px; padding: .2rem; }
/* La riga in fondo alla cella (note del viaggio e "+ Tappa") e i totali si
   nascondono solo dove le colonne sono tante e strette - mese e range - non
   perche' e' acceso "Compatta".
   Prima la regola stava su .is-compatta, che pero' fino al tk #21.016 ERA la
   vista mese: da quando la compattezza e' un interruttore a se', accenderla
   sulla settimana faceva sparire la casella delle note e il "+ Tappa"
   (segnalato da Alessandro il 21/10/2026). */
.has-many-cols .cell-foot,
.has-many-cols .cell-totals { display: none; }
.is-compatta .svc-route { display: none; }
/* il percorso esiste solo nella visione compatta: nella normale c'e' gia'
   la riga DA/A per esteso */
.svc-percorso { display: none; }
.is-compatta .svc-card { padding: .2rem .3rem; }
.is-compatta .svc-client { font-size: .66rem; }
.is-compatta .ts-colhead { font-size: .62rem; }

/* ---- Modal ---- */
/* NB: niente backdrop-filter:blur — su Chromium, insieme a un'animazione sul
   figlio (.ts-modal) e a un backdrop grande (board 126 celle), ricompone in
   continuazione e ri-triggera l'animazione d'ingresso -> la modale "flashava"
   (opacity che scattava a 0) ogni pochi secondi. Il dim semi-opaco basta per la
   separazione visiva. Rimossa anche l'animazione modal-in per lo stesso motivo. */
.ts-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex;
  align-items: center; justify-content: center;
  padding: 2.5vh 1rem; z-index: 1000; overflow: auto; }
.ts-modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 760px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.ts-modal-lg { max-width: 1060px; }
.ts-modal-sm { max-width: 600px; }
/* quasi a tutto schermo: usato dal modale "Nuova/Modifica pratica" (wizard largo) */
/* Dialog della pratica. 20/10/2026, Alessandro: "troppo risicata". Misurato a
   1600x950 era 1400x443, cioe' una fascia larghissima e bassa: i campi si
   stiravano e ogni passo del wizard aveva un'altezza diversa, con il piede che
   saltava. Ora e' piu' stretta (proporzione normale) e ha un'altezza minima
   comune a tutti i passi, cosi' resta ferma e respira. */
.ts-modal-full { max-width: 1120px; width: 92vw; max-height: 94vh; }
.ts-modal-full form { min-height: 380px; padding: 1.4rem 1.6rem; }
.ts-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); flex: none; }
.ts-modal-head h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.ts-modal-x { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text-muted); }
.ts-modal-x:hover { color: #1e293b; }
.ts-modal form { padding: 1.25rem 1.4rem; overflow: auto; }
.ts-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1rem; }
.ts-form-grid label, .ts-form-full { display: flex; flex-direction: column; font-size: .68rem; font-weight: 600; color: var(--text-muted); gap: .25rem; letter-spacing: .02em; }
.ts-form-grid input, .ts-form-grid select, .ts-form-grid textarea,
.ts-form-full input, .ts-form-full textarea, .ts-modal select {
  font-size: .85rem; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; font-weight: 400; color: var(--text); background: #fff;
}
.ts-form-full { margin-top: .6rem; }
.ts-modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem; border-top: 1px solid var(--border); }

/* ---- Anagrafiche ---- */
.anag-tabs { padding: .7rem 1.4rem 0; border-bottom: 1px solid var(--border); flex: none; }
.anag-tabbody { flex: 1; min-height: 380px; overflow: auto; }
.anag-tabbody form { padding-top: .6rem; }
.anag-listhead { padding: 1.1rem 1.4rem .4rem; }
.anag-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.anag-table th { text-align: left; font-size: .68rem; color: var(--text-muted); padding: .6rem 1.4rem; border-bottom: 1px solid var(--border); letter-spacing: .03em; }
.anag-table td { padding: .6rem 1.4rem; border-bottom: 1px solid #eef1f5; }
.anag-table tbody tr:hover { background: #f8fafc; }
.color-dot { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); }
.anag-actions { display: flex; gap: .4rem; }
.ico { border: none; background: none; cursor: pointer; font-size: .95rem; color: var(--text-muted); }
.ico:hover { color: var(--accent); }
.ico-danger { color: #dc2626; }
.ico-danger:hover { color: #b91c1c; }
.anag-formhead { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem 0; }
.anag-formhead h4 { margin: 0; font-size: .95rem; }

/* vehicle type button group */
.tipo-group { border: 1px solid var(--border); border-radius: 8px; margin: 1rem; padding: .6rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.tipo-group legend { font-size: .68rem; font-weight: 700; color: var(--text-muted); padding: 0 .3rem; }
.tipo-opt { border: 1px solid var(--border); border-radius: 8px; padding: .45rem .7rem; font-size: .78rem; cursor: pointer; display: flex; align-items: center; gap: .35rem; }
.tipo-opt.is-sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tipo-hint { font-size: .7rem; color: var(--text-muted); padding: 0 1rem; line-height: 1.5; }

.ts-empty { color: var(--text-muted); font-size: .78rem; text-align: center; padding: 1rem; line-height: 1.5; }

/* Banner di errore dati (board/sidebar): rende VISIBILE un caricamento fallito
   invece di mostrare una board vuota senza spiegazione. */
.ts-err-banner {
  margin: .4rem .6rem; padding: .45rem .6rem; border-radius: 6px;
  background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
  font-size: 11.5px; font-weight: 600; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis;
}

/* Badge versione build in toolbar: discreto, non deve rubare spazio ai comandi.
   Il titolo (tooltip) porta versione completa + data/ora di compilazione. */
.ts-ver {
  font-size: 11px;
  opacity: .55;
  padding: 2px 6px;
  border: 1px solid var(--ts-border, #d0d5dd);
  border-radius: 10px;
  white-space: nowrap;
  cursor: default;
}

/* ===== tk #21.016 - opzione C: pratiche su una riga =====
   Il problema misurato: riga vuota 104px + 64px per OGNI pratica impilata ->
   con 3 pratiche per cella si vedevano 2 autisti invece di 5.
   In compatta la pratica diventa una riga sola (~20px), quindi a parita' di
   spazio si vedono molti piu' autisti.
   NB: la cella NON ha scroll interno (richiesta di Alessandro, 20/10/2026): il
   box del viaggio deve mostrare tutte le pratiche, cresce quanto serve. Un
   tetto d'altezza nascondeva lavoro assegnato e lo scroll interno confondeva
   anche il drag&drop. La compattezza la fa solo la chip su una riga. */

/* pratica su UNA riga: numero + committente, il resto si vede col doppio click */
/* Interlinea piu' stretta (Cosimo, 23/10/2026: "ridurre un poco l'interlinea"):
   la riga passa da 1,15 a 1 e il margine verticale si dimezza, cosi' a parita'
   di altezza della cella ci stanno piu' autisti. */
.is-compatta .svc-card {
  display: flex; align-items: center; gap: .3rem;
  padding: .05rem .3rem; min-height: 0; line-height: 1;
}
.is-compatta .cell-cards { gap: 1px; }
/* min-width:0 e' quello che fa funzionare i puntini di sospensione del
   percorso qui sotto. Senza, .svc-head e' un elemento flex con min-width:auto:
   non puo' stringersi sotto la larghezza del suo contenuto, e il contenuto e'
   una riga che non va a capo (il percorso). Risultato misurato: cella da 90px,
   .svc-head larga 209px -> la pratica usciva dal box del viaggio e si
   sovrapponeva alla colonna del giorno dopo (segnalato da Alessandro il
   30/10/2026). Il numero pratica resta intero (flex: 0 0 auto piu' sotto): a
   stringersi e' il percorso, che i puntini li ha gia'. */
.is-compatta .svc-head { gap: .3rem; align-items: center; flex: 1 1 auto; min-width: 0; }
/* in compatta il committente lascia il posto al percorso */
.is-compatta .svc-client { display: none; }
.is-compatta .svc-percorso {
  display: inline; flex: 1 1 auto; min-width: 0;
  font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Loris, 19/11/2026: "invece che vedere numero spedizione nel grande pannello
   meglio vedere il numero bancali su singola spedizione: cosi' si puo'
   allungare la scritta". In compatta i due si contendono la stessa riga, e
   tiene il posto quello che serve a decidere se il mezzo e' pieno. Il numero
   pratica non sparisce - e' come l'operatore la chiama al telefono - ma si
   sposta nel suggerimento del mouse (TServiceCardVM.GetTooltip) e resta nel
   doppio click. */
.is-compatta .svc-num { display: none; }
.is-compatta .svc-pallet { display: inline; flex: 0 0 auto;
  font-size: .6rem; padding: 0 4px; line-height: 14px; }
.is-compatta .svc-card > * { margin: 0; }


.is-compatta .svc-addr,
.is-compatta .svc-da,
.is-compatta .svc-a { display: none; }
.is-compatta .day-cell { min-height: 40px; }
.is-compatta .ts-driver-firstname,
.is-compatta .cell-badges { font-size: .6rem; }

/* tk #21.011/#21.012 - riga di un autista SPOT: non e' un autista fisso del
   brogliaccio, quindi si distingue a vista (bordo e badge) per non confonderlo
   con la squadra abituale. */
.ts-grid-row.is-spot { background: var(--surface, #fafbfc); }
.ts-grid-row.is-spot .ts-driver-name::after {
  content: 'SPOT';
  margin-left: .35rem; padding: 0 .25rem;
  font-size: .55rem; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--border-hard, #c3c9d4); border-radius: 3px;
  opacity: .7; vertical-align: middle;
}
.ts-tab-toggle.is-active { font-weight: 700; }

/* ===== tk #20.868 / #21.036 - merce nel form della pratica =====
   Due livelli: i TOTALI sempre in chiaro, il DETTAGLIO misure dietro una riga
   a scomparsa. Prima i totali stavano in fondo alla tabella e, senza righe, si
   vedeva una griglia vuota con dei numeri sotto: non si capiva cosa fosse. */
.merce-box {
  margin-top: .4rem; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; background: var(--surface);
}

/* --- totali: quattro caselle con la loro etichetta --- */
.merce-totali {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
  padding: .6rem .7rem; background: var(--surface-alt, #f8fafc);
  /* le caselle si appoggiano in basso: se un'etichetta fosse piu' alta delle
     altre, le caselle resterebbero comunque in linea */
  align-items: end;
}
.merce-totali label {
  display: flex; flex-direction: column; gap: .15rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--text-muted);
  /* Segnalazione di Loris (22/10/2026): "kg" e soprattutto "m3" in apice
     alzavano la riga dell'etichetta e le quattro caselle non erano piu'
     allineate. Con l'altezza della riga fissata, un apice non la fa crescere. */
  line-height: 1.2;
}
/* etichetta e unita' su una riga sola, sempre: e' lo <span> a tenerle insieme */
.merce-totali label > span { white-space: nowrap; }
.merce-totali label small {
  font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8;
  line-height: inherit; vertical-align: baseline;
}
.merce-totali input {
  width: 100%; box-sizing: border-box; padding: .35rem .5rem; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; color: inherit;
}
.merce-totali input:focus {
  outline: none; border-color: var(--primary, #32589d);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #32589d) 18%, transparent);
}
/* bloccato = calcolato dal dettaglio: deve sembrare un risultato, non un campo
   da riempire */
.merce-totali input:disabled {
  border-color: transparent; background: transparent;
  -webkit-text-fill-color: currentColor; opacity: 1; cursor: default;
}

/* --- dettaglio misure, facoltativo --- */
.merce-dettaglio { border-top: 1px solid var(--border); }
.merce-dettaglio > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: .4rem .7rem; font-size: .74rem; font-weight: 600;
  display: flex; align-items: baseline; gap: .4rem;
}
.merce-dettaglio > summary::-webkit-details-marker { display: none; }
.merce-dettaglio > summary::before {
  content: '\25B8'; font-size: .7em; color: var(--text-muted);
  transition: transform .12s ease;
}
.merce-dettaglio[open] > summary::before { transform: rotate(90deg); }
.merce-dettaglio > summary:hover { color: var(--primary, #32589d); }
.merce-dettaglio > summary small { font-weight: 500; color: var(--text-muted); }

.merce-grid { width: 100%; border-collapse: collapse; font-size: .8rem; }
.merce-grid th {
  text-align: right; font-weight: 600; font-size: .64rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
  padding: .25rem .5rem; white-space: nowrap;
  line-height: 1.2;   /* stesso motivo dei totali: l'apice di "m3" non alzi la riga */
  vertical-align: bottom;
}
.merce-grid th small {
  font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .75;
  line-height: inherit; vertical-align: baseline;
}
.merce-grid td { padding: 0; }
.merce-grid tbody tr + tr td { border-top: 1px solid var(--border); }
.merce-riga:hover td { background: var(--surface-alt, #f8fafc); }
.merce-grid input {
  width: 100%; box-sizing: border-box; padding: .35rem .5rem;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  font: inherit; font-variant-numeric: tabular-nums; text-align: right; color: inherit;
}
.merce-grid input:hover { border-color: var(--border); }
.merce-grid input:focus {
  outline: none; border-color: var(--primary, #32589d); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #32589d) 18%, transparent);
}
/* le frecce su/giu' rubano spazio e non servono con la tastiera */
.merce-grid input::-webkit-outer-spin-button,
.merce-grid input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.merce-grid input[type=number] { -moz-appearance: textfield; }

/* il volume della riga non si scrive: lo calcola il programma */
.merce-vol {
  text-align: right; padding: .35rem .5rem !important; color: var(--text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.col-az { width: 30px; text-align: center; }
.merce-del {
  border: none; background: none; cursor: pointer; padding: .25rem;
  color: var(--text-muted); border-radius: 6px; display: inline-flex; opacity: 0;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
/* il cestino compare sulla riga sotto il mouse: niente file di icone rosse */
.merce-riga:hover .merce-del, .merce-del:focus-visible { opacity: 1; }
.merce-del:hover { color: #b42318; background: color-mix(in srgb, #b42318 10%, transparent); }

.merce-azioni { padding: .35rem .7rem .6rem; }
.merce-azioni .ts-btn { padding: .2rem .6rem; font-size: .72rem; }

/* Salvataggio rifiutato: la dialog resta aperta e si segnala con una scossa
   breve, altrimenti un secondo errore uguale al primo sembra "non ha fatto
   niente". Vedi tsPraticaDopoSalvataggio in board.js. */
.ts-modal-errore { animation: ts-scossa .3s ease; }
@keyframes ts-scossa {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .ts-modal-errore { animation: none; }
}

/* tk #21.017 - menu delle azioni della cella ("+ Tappa", "Stampa distinta").
   <details> invece di un dropdown fatto a mano: si apre col click e con la
   tastiera, e si chiude da solo quando si apre un altro menu. */
.cell-menu { position: relative; flex: 0 0 auto; }
.cell-menu > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-size: 11px; line-height: 1; padding: 2px 5px;
  border: 1px dashed var(--border); border-radius: var(--r-sm);
  color: var(--text-muted);
}
.cell-menu > summary::-webkit-details-marker { display: none; }
.cell-menu > summary:hover,
.cell-menu[open] > summary { color: var(--primary); border-color: var(--primary); border-style: solid; }
.cell-menu-voci {
  position: absolute; right: 0; bottom: calc(100% + 3px); z-index: 30;
  min-width: 132px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 20px rgba(15, 23, 42, .16); overflow: hidden;
}
.cell-menu-voci > button,
.cell-menu-voci > a {
  display: block; text-align: left; text-decoration: none;
  padding: .35rem .6rem; font-size: 11px; color: inherit;
  background: none; border: none; cursor: pointer; white-space: nowrap;
}
.cell-menu-voci > button:hover,
.cell-menu-voci > a:hover { background: var(--primary-soft, #eef2fb); color: var(--primary); }

/* tk #21.036 - i totali sono caselle: scrivibili quando la pratica non ha
   dettaglio merce, bloccate (e calcolate) appena c'e' una riga. Da bloccate
   devono sembrare un risultato, non un campo vuoto da riempire. */
.merce-tot input {
  width: 100%; box-sizing: border-box; padding: .3rem .5rem; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
  font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface);
}
.merce-tot input:focus {
  outline: none; border-color: var(--primary, #32589d);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #32589d) 18%, transparent);
}
.merce-tot input:disabled {
  border-color: transparent; background: transparent; color: inherit;
  -webkit-text-fill-color: currentColor; opacity: 1; cursor: default;
}

/* Avviso in testa alla dialog della pratica: il motivo del rifiuto si legge
   dove l'utente sta guardando, non in un toast in fondo alla pagina dietro la
   finestra aperta. Sparisce appena si rimette mano al form. */
.ts-form-errore {
  margin: 0 0 .8rem; padding: .55rem .75rem; border-radius: 8px;
  border: 1px solid #f0b4ae; background: #fdf1f0; color: #8a2318;
  font-size: .82rem; line-height: 1.35;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ts-form-errore {
    border-color: #7f2a21; background: #2a1312; color: #f3c3bd;
  }
}

/* ===== Riga allargata: una sola, quella che si sta guardando =====
   La griglia parte compatta. Il tasto sulla testata dell'autista riporta
   QUELLA riga alla visione intera, senza toccare le altre: il caso vero e'
   "guardo questo autista", non "voglio tutto grande". */
.dr-espandi {
  position: absolute; top: 2px; right: 2px;
  border: none; background: none; cursor: pointer; padding: 2px;
  color: var(--text-muted); border-radius: 4px; line-height: 0; opacity: 0;
  transition: opacity .12s ease, color .12s ease;
}
.ts-rowhead { position: relative; }
.ts-rowhead:hover .dr-espandi,
.dr-espandi:focus-visible,
.ts-grid-row.is-espansa .dr-espandi { opacity: 1; }
.dr-espandi:hover { color: var(--primary, #32589d); }
.ts-grid-row.is-espansa .dr-espandi { color: var(--primary, #32589d); }

/* dentro la riga allargata la compattezza non vale piu' */
.is-compatta .ts-grid-row.is-espansa .svc-card {
  display: block; padding: .3rem .4rem; line-height: 1.25;
}
.is-compatta .ts-grid-row.is-espansa .svc-head { display: flex; }
.is-compatta .ts-grid-row.is-espansa .svc-client { display: inline; font-size: .72rem; }
.is-compatta .ts-grid-row.is-espansa .svc-percorso { display: none; }
.is-compatta .ts-grid-row.is-espansa .svc-route { display: block; }
.is-compatta .ts-grid-row.is-espansa .svc-pallet { display: inline; }
/* nella riga allargata c'e' spazio per tutti e due */
.is-compatta .ts-grid-row.is-espansa .svc-num { display: block; }
.is-compatta .ts-grid-row.is-espansa .cell-cards { gap: 3px; }
.is-compatta .ts-grid-row.is-espansa .day-cell { min-height: 104px; }
.is-compatta .ts-grid-row.is-espansa .cell-totals { display: flex; }
.is-compatta .ts-grid-row.is-espansa .cell-foot { display: flex; }

/* tk #21.018 - lista di carico dentro il viaggio: e' una fermata come le
   altre, ma non si trascina e non si apre. Il bordo tratteggiato e' stato
   tolto il 03/11/2026 (non piaceva a Loris): a dire che e' una lista basta
   "LDC - corrispondente" in testa alla riga. Resta il cursore normale, che
   e' il segnale che non si prende. */
.svc-card.svc-lista { cursor: default; }
.svc-card.svc-lista .svc-client { font-style: italic; }

/* tk #20.657 - le due scelte della duplica: righe cliccabili, non due radio
   sperse in mezzo al testo. */
.dup-scelta {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .4rem .55rem; margin-top: .3rem;
  border: 1px solid var(--border); border-radius: 8px; font-size: .85rem;
}
.dup-scelta:hover { border-color: var(--primary, #32589d); }
.dup-scelta:has(input:checked) {
  border-color: var(--primary, #32589d);
  background: var(--primary-soft, #eef2fb);
}
