/* =========================================================
   App Pianali - Design system interno (mobile-first)
   ---------------------------------------------------------
   Sezioni:
     0. Token             5. Pulsanti           10. Wizard
     1. Reset             6. Campi              11. Login
     2. Tipografia        7. Card e badge       12. Guida
     3. Boot screen       8. Toolbar e filtri   13. Utenti (admin)
     4. App shell         9. Liste, stati       14. Legacy (in rimozione)
                                                 15. Movimento ridotto
   Regole: nessun input sotto 16px (zoom iOS), nessun controllo
   sotto 44px, un solo colore per l'azione primaria (verde).
   ========================================================= */

/* ---------------------------------------------------------
   0. Token
   --------------------------------------------------------- */
:root {
    /* superfici e testo */
    --c-bg: #eef1f5;
    --c-surface: #ffffff;
    --c-ink: #0f1f33;
    --c-muted: #536273;
    --c-line: #d5dce6;
    --c-line-soft: #e6ebf1;

    /* brand */
    --c-navy: #0e2a4a;
    --c-navy-700: #163a63;
    --c-navy-tint: #e6edf5;
    --c-green: #7fb539;
    --c-green-600: #6aa02c;
    --c-green-text: #3f6d12;
    --c-green-tint: #e6f2d5;

    /* semantici (fondo / testo) */
    --c-blue: #1a56b8;
    --c-blue-text: #123e86;
    --c-blue-tint: #e3ecfb;
    --c-amber: #e0a400;
    --c-amber-text: #7a4e00;
    --c-amber-tint: #fff0c9;
    --c-red: #c4291f;
    --c-red-text: #9b1c14;
    --c-red-tint: #fbe7e5;

    /* forme */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 14px;
    --r-pill: 999px;

    /* spaziatura */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;

    /* tipografia */
    --t-12: 12px;
    --t-14: 14px;
    --t-16: 16px;
    --t-18: 18px;
    --t-22: 22px;
    --t-28: 28px;
    --t-num: 56px;

    /* touch */
    --touch-icon: 44px;
    --touch: 48px;
    --touch-lg: 56px;

    /* safe area (iPhone con notch / Dynamic Island) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --shadow-up: 0 -4px 16px rgba(14, 34, 56, .08);
    --shadow-modal: 0 18px 40px rgba(14, 34, 56, .22);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --focus-ring: 0 0 0 3px rgba(127, 181, 57, .55);
}

/* ---------------------------------------------------------
   1. Reset (sostituisce Bootstrap)
   --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    min-height: 100%;
    margin: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--t-16);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
h1, h2, h3, h4 { font-weight: 800; letter-spacing: -.01em; color: var(--c-navy); line-height: 1.2; }
ol, ul { margin: 0; padding-left: 1.25rem; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: not-allowed; }
textarea { resize: vertical; }
[hidden] { display: none !important; }
b, strong { font-weight: 700; }
small { font-size: var(--t-14); }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: var(--focus-ring); }

/* ---------------------------------------------------------
   2. Tipografia
   --------------------------------------------------------- */
.muted { color: var(--c-muted); }
.eyebrow {
    color: var(--c-green-text);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: var(--t-12);
    font-weight: 800;
}
.tnum { font-variant-numeric: tabular-nums; }
.page-title { font-size: var(--t-22); }
.page-subtitle { color: var(--c-muted); font-size: var(--t-14); margin-top: 2px; }

/* ---------------------------------------------------------
   3. Boot screen (index.html)
   --------------------------------------------------------- */
.boot-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s-5);
    background: var(--c-navy);
}
.boot-card {
    width: min(380px, 92vw);
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: 38px 32px;
    text-align: center;
    box-shadow: var(--shadow-modal);
    border-top: 4px solid var(--c-green);
}
.logistics-loader { width: 100%; height: 142px; display: grid; place-items: center; overflow: hidden; }
.logistics-loader img {
    width: 100%;
    max-width: 330px;
    height: auto;
    backface-visibility: hidden;
    will-change: transform;
    animation: travel 2.8s ease-in-out infinite;
}
.boot-card h1 { font-size: 21px; margin: 8px 0 4px; }
.boot-card p { color: var(--c-muted); margin: 0 0 22px; font-size: var(--t-14); }
.loading-bar { height: 6px; border-radius: var(--r-pill); background: var(--c-navy-tint); overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--c-green); animation: loading-slide 1.1s ease-in-out infinite; }

@keyframes loading-slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(260%); } }
@keyframes travel {
    0%, 100% { transform: translate3d(-12px, 0, 0); }
    50% { transform: translate3d(12px, 0, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------------------------------------------------------
   4. App shell: barra superiore sticky, tab, fasce di stato
   --------------------------------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; background: var(--c-bg); }

.app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--c-navy);
    color: #fff;
    padding: var(--safe-top) calc(var(--s-3) + var(--safe-right)) 0 calc(var(--s-3) + var(--safe-left));
}
.app-bar__row {
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.app-bar__brand {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
    flex: 1;
}
.app-bar__icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: var(--r-sm);
    background: #fff;
    overflow: hidden;
}
.app-bar__icon img { width: 100%; height: 100%; }
.app-bar__title {
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -.01em;
    color: #fff;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-bar__title small { display: block; font-size: var(--t-12); font-weight: 600; color: rgba(255, 255, 255, .72); }
.app-bar__title .tnum { font-variant-numeric: tabular-nums; }
.app-bar .btn-icon { color: #fff; background: rgba(255, 255, 255, .10); }
.app-bar .btn-icon:active { background: rgba(255, 255, 255, .2); }
.app-bar .btn-icon svg { width: 22px; height: 22px; }
.app-bar__text-btn {
    min-height: var(--touch-icon);
    padding: 0 var(--s-3);
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .10);
    color: #fff;
    font-weight: 700;
    font-size: var(--t-14);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.app-bar__text-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-bar__text-btn:active { background: rgba(255, 255, 255, .2); }

/* chip stato rete */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(255, 255, 255, .12);
    color: #fff;
}
.status-chip__dot { width: 9px; height: 9px; border-radius: 50%; background: #9fd35a; flex: 0 0 9px; }
.status-chip--offline { background: var(--c-amber-tint); color: var(--c-amber-text); }
.status-chip--offline .status-chip__dot { background: var(--c-amber); }
.status-chip--syncing .status-chip__dot { background: #8db4f5; animation: pulse 1s ease-in-out infinite; }

/* tab di navigazione */
.app-tabs { display: flex; gap: var(--s-1); }
.app-tab {
    flex: 1;
    min-height: var(--touch-icon);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, .72);
    border-bottom: 3px solid transparent;
    padding: 0 var(--s-2);
    white-space: nowrap;
    transition: color .15s var(--ease), border-color .15s var(--ease);
}
.app-tab:active { color: #fff; }
.app-tab.active { color: #fff; border-bottom-color: var(--c-green); }

/* progresso a segmenti (wizard) nella barra */
.app-bar__steps { display: flex; gap: var(--s-1); padding: var(--s-2) 0 var(--s-3); }
.app-bar__steps span { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .22); transition: background .2s var(--ease); }
.app-bar__steps span.done { background: var(--c-green); }
.app-bar__steps span.current { background: #fff; }

.app-content { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.app-main {
    flex: 1;
    padding: var(--s-3) calc(var(--s-3) + var(--safe-right)) calc(var(--s-5) + var(--safe-bottom)) calc(var(--s-3) + var(--safe-left));
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}

/* fasce informative sotto la barra */
.strip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px calc(var(--s-4) + var(--safe-right)) 8px calc(var(--s-4) + var(--safe-left));
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    border-bottom: 1px solid transparent;
}
.strip svg { width: 22px; height: 22px; flex: 0 0 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.strip__text { flex: 1; min-width: 0; }
.strip__text small { display: block; font-weight: 400; font-size: 13px; opacity: .9; }
.strip--offline { background: var(--c-amber-tint); color: var(--c-amber-text); border-color: #ecd9a1; }
.strip--pending { background: var(--c-amber-tint); color: var(--c-amber-text); border-color: #ecd9a1; }
.strip--syncing { background: var(--c-blue-tint); color: var(--c-blue-text); border-color: #c5d6f2; }
.strip--syncing svg { animation: spin 1.2s linear infinite; }
.strip--ok { background: var(--c-green-tint); color: var(--c-green-text); border-color: #cfe4b4; }
.strip--update { background: #fff7d6; color: #654b00; border-color: #e8cf73; }
.strip .btn { min-height: 36px; height: 36px; font-size: var(--t-14); padding: 0 var(--s-3); border-radius: var(--r-sm); }
.strip .btn-link { color: inherit; text-decoration: underline; font-weight: 700; font-size: var(--t-14); min-height: var(--touch-icon); padding: 0 var(--s-2); }

/* desktop: la barra diventa sidebar (regole complete nella sezione 13c) */
@media (min-width: 901px) {
    .app { display: grid; }
    .app-bar { height: 100vh; display: flex; flex-direction: column; }
    .app-bar__title { white-space: normal; }
    .app-bar__steps { display: none; }
    .app-bar__version { color: rgba(255, 255, 255, .55); font-size: var(--t-12); font-weight: 700; letter-spacing: .04em; padding: 0 var(--s-2); }
    .app-main { gap: var(--s-4); width: 100%; }
    .strip { padding-left: var(--s-5); padding-right: var(--s-5); }
}
@media (max-width: 900px) { .app-bar__version { display: none; } }

/* ---------------------------------------------------------
   5. Pulsanti
   --------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--touch);
    padding: 0 var(--s-4);
    border: 1.5px solid transparent;
    border-radius: var(--r-md);
    font-weight: 700;
    font-size: var(--t-16);
    line-height: 1.2;
    white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
    -webkit-user-select: none;
    user-select: none;
}
.btn svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled { opacity: .45; }

.btn-primary { background: var(--c-green); color: var(--c-navy); }
.btn-primary:active:not(:disabled) { background: var(--c-green-600); }
@media (hover: hover) { .btn-primary:hover:not(:disabled) { background: var(--c-green-600); } }

.btn-secondary { background: var(--c-surface); color: var(--c-navy); border-color: var(--c-line); }
.btn-secondary:active:not(:disabled) { background: var(--c-navy-tint); }
@media (hover: hover) { .btn-secondary:hover:not(:disabled) { background: var(--c-navy-tint); } }

.btn-dark { background: var(--c-navy); color: #fff; }
.btn-dark:active:not(:disabled) { background: var(--c-navy-700); }

.btn-danger { background: var(--c-red-tint); color: var(--c-red-text); }

.btn-text { background: transparent; color: var(--c-blue-text); padding: 0 var(--s-2); }
.btn-text:active:not(:disabled) { background: var(--c-navy-tint); }

.btn-lg { min-height: var(--touch-lg); font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon {
    width: var(--touch-icon);
    height: var(--touch-icon);
    min-height: var(--touch-icon);
    padding: 0;
    border-radius: var(--r-sm);
    background: var(--c-surface);
    color: var(--c-navy);
    border-color: var(--c-line);
    flex: 0 0 var(--touch-icon);
}
.btn-icon svg { width: 22px; height: 22px; }
.btn-icon:active:not(:disabled) { background: var(--c-navy-tint); }
.btn-icon.is-active { background: var(--c-navy-tint); border-color: var(--c-navy); }

.btn-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(14, 42, 74, .28);
    border-top-color: var(--c-navy);
    animation: spin .75s linear infinite;
    flex: 0 0 18px;
}

/* gruppi */
.btn-row { display: flex; gap: var(--s-2); }
.btn-row > .btn { flex: 1; }
.btn-row--split { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s-2); }

/* ---------------------------------------------------------
   6. Campi
   --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
    display: block;
    font-weight: 700;
    font-size: var(--t-14);
    color: var(--c-navy);
}
.field-hint { font-size: 13px; color: var(--c-muted); }

.input {
    width: 100%;
    min-height: var(--touch);
    padding: 0 14px;
    border-radius: var(--r-md);
    border: 1.5px solid var(--c-line);
    background: var(--c-surface);
    color: var(--c-ink);
    font-size: var(--t-16); /* mai sotto 16px: Safari iOS zooma */
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: #8a96a6; }
.input:focus, .input:focus-visible { border-color: var(--c-green); box-shadow: 0 0 0 3px var(--c-green-tint); }
.input:disabled { background: var(--c-bg); color: var(--c-muted); }
textarea.input { min-height: 150px; padding: 12px 14px; line-height: 1.45; }
select.input {
    padding-right: 40px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%230e2a4a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
input.input[type="date"] { line-height: 1.2; }
input.input[type="date"]::-webkit-calendar-picker-indicator { padding: 8px; cursor: pointer; }
input.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
input.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input.input[type="number"]::-webkit-outer-spin-button,
input.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* campo ricerca con icona e pulsante cancella */
.input-search { position: relative; display: flex; align-items: center; }
.input-search > svg {
    position: absolute;
    left: 14px;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: var(--c-muted);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}
.input-search .input { min-height: var(--touch); padding-left: 46px; padding-right: 52px; font-size: var(--t-16); }
.input-search__clear {
    position: absolute;
    right: 4px;
    width: var(--touch-icon);
    height: var(--touch-icon);
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--c-muted);
}
.input-search__clear svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.input-search__clear:active { background: var(--c-navy-tint); }

/* campo con icona a sinistra (login) */
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; fill: none; stroke: var(--c-muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.input-icon .input { padding-left: 46px; }

/* password con toggle */
.password-input { position: relative; width: 100%; }
.password-input .input { width: 100%; padding-right: 56px; }
.password-input input[type="password"] { appearance: none; -webkit-appearance: none; }
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; }
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-contacts-auto-fill-button { visibility: hidden; display: none !important; pointer-events: none; }
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: var(--touch-icon);
    height: var(--touch-icon);
    border-radius: var(--r-sm);
    color: var(--c-muted);
    display: grid;
    place-items: center;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.password-toggle:active { background: var(--c-navy-tint); color: var(--c-navy); }
.password-toggle:disabled { opacity: .55; }
.password-toggle-icon { width: 22px; height: 22px; }

/* checkbox e interruttore */
.check {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--touch);
    font-size: var(--t-16);
    font-weight: 600;
    color: var(--c-ink);
    cursor: pointer;
}
.check input[type="checkbox"] {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    margin: 0;
    accent-color: var(--c-green-600);
    cursor: pointer;
}
.toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: var(--touch); font-weight: 600; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
    position: relative;
    width: 52px;
    height: 32px;
    flex: 0 0 52px;
    border-radius: var(--r-pill);
    background: #b9c3d0;
    transition: background .15s var(--ease);
}
.toggle__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .15s var(--ease);
}
.toggle input:checked + .toggle__track { background: var(--c-green-600); }
.toggle input:checked + .toggle__track::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle__track { box-shadow: var(--focus-ring); }

/* ---------------------------------------------------------
   7. Card e badge
   --------------------------------------------------------- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    padding: var(--s-4) var(--s-4) var(--s-3);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.card__top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); margin-bottom: -4px; }
.card__top .card__meta { margin: 0; }
.card__head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card__title {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--c-navy);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.card__meta { font-size: var(--t-14); color: var(--c-muted); margin-top: 4px; }
.card__sub { font-size: 15px; color: var(--c-ink); margin-top: 4px; }
.card__top .badge { height: 28px; }
.card__counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card__counts span { font-size: 13px; color: var(--c-ink); background: #f1f4f8; border-radius: var(--r-sm); padding: 4px 8px; }
.card__counts b { font-variant-numeric: tabular-nums; }
.card__note {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--c-navy-tint);
    color: var(--c-navy);
    font-size: var(--t-14);
    line-height: 1.4;
}
.card__actions { display: grid; grid-template-columns: minmax(96px, 1fr) 2fr; gap: var(--s-2); }
.card__actions .btn { min-height: 52px; }
.card__actions .btn-secondary { font-size: 15px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    flex: 0 0 auto;
}
.badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.badge--open { background: var(--c-blue-tint); color: var(--c-blue-text); }
.badge--done { background: var(--c-green-tint); color: var(--c-green-text); }
.badge--pending { background: var(--c-amber-tint); color: var(--c-amber-text); }
.badge--muted { background: var(--c-navy-tint); color: var(--c-navy); }
.badge--danger { background: var(--c-red-tint); color: var(--c-red-text); }

/* ---------------------------------------------------------
   8. Toolbar e filtri
   --------------------------------------------------------- */
.toolbar { display: flex; flex-direction: column; gap: var(--s-2); }
.toolbar__row { display: flex; align-items: center; gap: var(--s-2); }
.toolbar__row .input-search { flex: 1; }
.toolbar__row .btn-icon { width: var(--touch); height: var(--touch); min-height: var(--touch); flex-basis: var(--touch); border-radius: var(--r-md); }
.toolbar__summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--t-14);
    color: var(--c-muted);
    min-height: 32px;
}
.toolbar__summary b { color: var(--c-ink); font-weight: 700; font-variant-numeric: tabular-nums; }

.filters {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    display: grid;
    gap: var(--s-3);
}
.filters__grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
.filters__actions { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-2); }
@media (min-width: 601px) {
    .filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters__grid .field--wide { grid-column: 1 / -1; }
    .filters__actions { grid-template-columns: 180px 140px; justify-content: end; }
}
@media (min-width: 901px) {
    .filters__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .filters__grid .field--wide { grid-column: span 2; }
}

/* ---------------------------------------------------------
   9. Liste, paginazione, stati vuoti, notifiche
   --------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: var(--s-3); }

.pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) 0;
    color: var(--c-muted);
    font-weight: 700;
    font-size: var(--t-14);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.empty {
    text-align: center;
    padding: 48px var(--s-4);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
}
.empty svg { width: 56px; height: 56px; fill: none; stroke: var(--c-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: var(--s-1); }
.empty h2 { font-size: var(--t-18); }
.empty p { color: var(--c-muted); max-width: 32ch; }
.empty .btn { margin-top: var(--s-2); }

.skeleton { position: relative; overflow: hidden; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-4); display: grid; gap: var(--s-3); min-height: 168px; }
.skeleton i { display: block; height: 14px; border-radius: 6px; background: var(--c-navy-tint); animation: pulse 1.4s ease-in-out infinite; }
.skeleton i.t { height: 22px; width: 60%; }
.skeleton i.m { width: 80%; }
.skeleton i.b { height: 52px; border-radius: var(--r-md); margin-top: var(--s-2); }

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}
.notice svg { width: 22px; height: 22px; flex: 0 0 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.notice--error { background: var(--c-red-tint); color: var(--c-red-text); }
.notice--warning { background: var(--c-amber-tint); color: var(--c-amber-text); }
.notice--info { background: var(--c-blue-tint); color: var(--c-blue-text); }
.notice--ok { background: var(--c-green-tint); color: var(--c-green-text); }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.section-head h2 { font-size: var(--t-18); }

/* finestra di conferma */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(8, 26, 48, .55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: var(--s-3);
    padding-bottom: calc(var(--s-3) + var(--safe-bottom));
}
.dialog {
    width: min(480px, 100%);
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--s-5) var(--s-4) var(--s-4);
    box-shadow: var(--shadow-modal);
    display: grid;
    gap: var(--s-3);
}
.dialog h2 { font-size: var(--t-22); }
.dialog p { color: var(--c-muted); }
.dialog .btn-row { margin-top: var(--s-2); }
@media (min-width: 601px) { .dialog-backdrop { align-items: center; } }

/* ---------------------------------------------------------
   10. Wizard
   --------------------------------------------------------- */
/* Le azioni del passo stanno in flusso, subito sotto il contenuto: niente barra
   fissa, così la tastiera non le copre. Budget verticale a 390x844 con tastiera
   iOS (~508 px visibili): barra 101 + padding 12 + etichetta 20 + domanda 56 +
   hint 18 + campo 96 + azioni 56 + spazi 40 ≈ 400 px. */
.wizard { display: flex; flex-direction: column; gap: var(--s-3); padding-bottom: var(--s-4); }
.wizard__step { font-size: var(--t-14); font-weight: 600; color: var(--c-muted); }
.wizard__step b { color: var(--c-ink); font-variant-numeric: tabular-nums; }
.wizard__question { font-size: 24px; font-weight: 800; color: var(--c-navy); letter-spacing: -.01em; line-height: 1.15; text-wrap: balance; }
.wizard__hint { font-size: var(--t-14); color: var(--c-muted); line-height: 1.35; }
.wizard__hint--empty { color: var(--c-amber-text); font-weight: 600; }
.wizard__step { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.wizard__step-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: var(--r-sm);
    background: var(--c-blue-tint);
    color: var(--c-blue-text);
    font-size: 13px;
    font-weight: 700;
}
.wizard__step-tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.step-panel { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.step-panel__head { display: flex; flex-direction: column; gap: var(--s-2); }
.step-panel__body { display: flex; flex-direction: column; gap: var(--s-3); }
.step-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.step-actions--single { grid-template-columns: 1fr; }
.step-actions .btn { min-height: var(--touch-lg); }

.numrow { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 10px; align-items: stretch; }
.numrow .stepper {
    border-radius: var(--r-lg);
    background: var(--c-surface);
    border: 1.5px solid var(--c-line);
    display: grid;
    place-items: center;
    color: var(--c-navy);
    min-height: 96px;
}
.numrow .stepper svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.numrow .stepper:active:not(:disabled) { background: var(--c-navy-tint); }
.numrow .stepper:disabled { opacity: .35; }
.input-number-xl {
    width: 100%;
    height: 96px;
    border-radius: var(--r-lg);
    border: 2px solid var(--c-line);
    background: var(--c-surface);
    color: var(--c-navy);
    font-size: 48px;
    font-weight: 800;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding: 0 var(--s-2);
    outline: none;
    scroll-margin: 16px 0 140px;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* schermi bassi (iPhone SE, Android compatti): con la tastiera aperta restano ~400 px */
@media (max-width: 900px) and (max-height: 700px) {
    .wizard { gap: var(--s-2); }
    .step-panel { gap: var(--s-2); }
    .step-panel__head { gap: 4px; }
    .wizard__question { font-size: 20px; }
    .wizard__hint:not(.wizard__hint--empty) { display: none; }
    .numrow .stepper, .input-number-xl { min-height: 84px; height: 84px; }
    .input-number-xl { font-size: 42px; }
    .step-actions .btn { min-height: 52px; }
    .app-bar__steps { padding: 6px 0 8px; }
}
.input-number-xl::-webkit-outer-spin-button, .input-number-xl::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-number-xl:focus { border-color: var(--c-green); box-shadow: 0 0 0 4px var(--c-green-tint); }
.input-number-xl::selection { background: #cfe4b4; }

.summary-table { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); overflow: hidden; }
.summary-table__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--s-3);
    padding: 4px var(--s-4);
    border-bottom: 1px solid var(--c-line-soft);
    font-size: var(--t-16);
    min-height: 52px;
}
.summary-table__label { padding: 6px 0; }
.summary-table__row:last-child { border-bottom: 0; }
.summary-table__label { color: var(--c-ink); font-weight: 600; }
.summary-table__label small { display: block; color: var(--c-muted); font-weight: 400; font-size: var(--t-14); overflow-wrap: anywhere; }
.summary-table__num { font-size: 26px; font-variant-numeric: tabular-nums; color: var(--c-navy); font-weight: 800; min-width: 34px; text-align: right; }
.summary-table__val { color: var(--c-muted); font-size: 15px; text-align: right; max-width: 40vw; overflow-wrap: anywhere; }
.summary-table .btn-text { min-height: var(--touch-icon); font-size: 15px; }

/* foto */
.photo-tools { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.photo-tools .photo-pick { position: relative; }
.photo-tools .photo-pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-tools .photo-pick.disabled { opacity: .45; }
.photo-tools .photo-pick.disabled input[type="file"] { cursor: not-allowed; }
.photo-tools .btn { min-height: var(--touch-lg); width: 100%; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.photo-tile { position: relative; overflow: hidden; border-radius: var(--r-md); border: 1px solid var(--c-line); background: var(--c-navy-tint); }
.photo-tile__open { display: block; width: 100%; padding: 0; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-tile small { display: block; padding: 6px 8px; color: var(--c-muted); font-weight: 600; font-size: var(--t-12); }
.photo-tile__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: var(--touch-icon);
    height: var(--touch-icon);
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: rgba(14, 42, 74, .85);
    color: #fff;
}
.photo-tile__remove svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.photo-tile__remove:disabled { opacity: .45; }
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: var(--s-5);
    background: rgba(8, 26, 48, .94);
}
.lightbox img { max-width: min(1100px, 96vw); max-height: 86vh; object-fit: contain; border-radius: var(--r-sm); background: #fff; }
.lightbox__close {
    position: fixed;
    top: calc(var(--s-3) + var(--safe-top));
    right: var(--s-3);
    z-index: 201;
    min-height: var(--touch);
    padding: 0 var(--s-4);
    border-radius: var(--r-md);
    background: #fff;
    color: var(--c-navy);
    font-weight: 800;
}

/* esito salvataggio */
.result {
    flex: 1;
    min-height: calc(100vh - 150px);
    min-height: calc(100dvh - 150px);
    display: grid;
    place-items: center;
    padding: var(--s-5);
    border-radius: var(--r-lg);
    background: var(--c-green-tint);
    text-align: center;
}
.result--offline { background: var(--c-amber-tint); }
.result__inner { max-width: 320px; display: grid; gap: var(--s-2); justify-items: center; }
.result__icon { width: 96px; height: 96px; border-radius: 50%; background: var(--c-green); display: grid; place-items: center; margin-bottom: var(--s-2); }
.result--offline .result__icon { background: var(--c-amber); }
.result__icon svg { width: 52px; height: 52px; fill: none; stroke: var(--c-navy); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.result h2 { font-size: var(--t-28); }
.result p { color: var(--c-muted); font-size: var(--t-16); }
.result .btn { margin-top: var(--s-3); width: 100%; }

/* ---------------------------------------------------------
   11. Login
   --------------------------------------------------------- */
.login-shell {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--c-navy);
    padding-top: var(--safe-top);
}
/* Foto di sfondo ottimizzata (≈100 KB): il navy è dipinto subito, l'immagine arriva
   sopra senza spostare nulla; su navy pieno resta leggibile anche se manca. */
.login-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--c-navy) url("../images/login-bg.jpg") center / cover no-repeat;
    background-image: image-set(url("../images/login-bg.webp") type("image/webp"), url("../images/login-bg.jpg") type("image/jpeg"));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
}
.login-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(14, 42, 74, .30) 0%, rgba(14, 42, 74, .62) 55%, rgba(14, 42, 74, .92) 85%, var(--c-navy) 100%);
    pointer-events: none;
}
.login-hero h1, .login-hero p { text-shadow: 0 1px 8px rgba(0, 0, 0, .35); }
.login-shell > * { position: relative; z-index: 1; }
.login-claim { display: none; }
.login-card { flex: 1; display: grid; grid-template-rows: 1fr auto; }
.login-hero { display: grid; place-items: center; padding: 48px var(--s-5) 28px; color: #fff; text-align: center; }
.login-hero__icon { width: 72px; height: 72px; border-radius: 18px; background: #fff; display: grid; place-items: center; margin: 0 auto 14px; overflow: hidden; }
.login-hero__icon img { width: 100%; height: 100%; }
.login-hero h1 { font-size: var(--t-28); color: #fff; }
.login-hero p { color: rgba(255, 255, 255, .72); font-size: 15px; margin-top: 4px; }
.login-sheet {
    background: var(--c-surface);
    border-radius: 24px 24px 0 0;
    padding: 28px var(--s-5) calc(32px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}
.login-sheet .field { gap: 6px; }
.login-sheet .field + .field { margin-top: var(--s-2); }
.login-sheet .input { min-height: var(--touch-lg); font-size: 17px; }
.login-sheet .btn-primary { margin-top: var(--s-4); }
.login-sheet .notice { margin-top: var(--s-2); }
.login-footer { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-top: var(--s-4); color: var(--c-muted); font-size: var(--t-12); font-weight: 700; letter-spacing: .04em; }
.login-footer img { height: 28px; width: auto; }
@media (min-width: 601px) {
    .login-shell { align-items: center; justify-content: center; padding: var(--s-5); }
    .login-shell::after { background: linear-gradient(160deg, rgba(14, 42, 74, .45), rgba(8, 26, 48, .72)); }
    .login-claim h2, .login-claim p { text-shadow: 0 1px 10px rgba(0, 0, 0, .4); }
    .login-card { flex: 0 0 auto; grid-template-rows: auto auto; width: min(440px, 100%); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-modal); }
    .login-hero { padding: 36px var(--s-5) 24px; }
    .login-sheet { border-radius: 0; padding-bottom: 28px; }
}
@media (min-width: 901px) {
    .login-shell { flex-direction: row; gap: 64px; padding: var(--s-6); }
    .login-claim { display: block; color: #fff; max-width: 440px; }
    .login-claim h2 { color: #fff; font-size: 36px; line-height: 1.1; text-wrap: balance; }
    .login-claim p { color: rgba(255, 255, 255, .8); font-size: 17px; margin-top: var(--s-3); line-height: 1.5; }
}

.app-version { color: var(--c-muted); font-size: var(--t-12); font-weight: 700; letter-spacing: .04em; }

/* ---------------------------------------------------------
   12. Guida utente
   --------------------------------------------------------- */
.guide-index-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-4);
    padding-bottom: var(--s-4);
    border-bottom: 1px solid var(--c-line-soft);
}
.guide-index-header h2 { margin: 4px 0 6px; font-size: var(--t-22); }
.guide-index-header p { color: var(--c-muted); }

.guide-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
@media (min-width: 720px) { .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.guide-card {
    min-height: 82px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--s-3);
    padding: 13px var(--s-3);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    background: var(--c-surface);
    color: var(--c-navy);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.guide-card:active { background: var(--c-navy-tint); }
.guide-number, .guide-detail-number {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--c-navy);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.guide-card-copy { min-width: 0; }
.guide-card-copy strong { display: block; margin-bottom: 3px; font-size: 15px; }
.guide-card-copy small { display: block; color: var(--c-muted); font-size: 13px; line-height: 1.4; }
.guide-admin-tag { padding: 4px 7px; border-radius: 6px; background: var(--c-navy-tint); color: var(--c-navy); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.guide-card-arrow { color: var(--c-green-text); width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.guide-detail { width: min(820px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-4); }
.guide-detail-header { display: flex; flex-direction: column; gap: var(--s-2); padding-bottom: var(--s-4); border-bottom: 1px solid var(--c-line-soft); }
.guide-back-link { display: inline-flex; align-items: center; gap: 4px; min-height: var(--touch-icon); color: var(--c-green-text); font-size: var(--t-14); font-weight: 800; }
.guide-back-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.guide-detail-header h2 { font-size: var(--t-22); }
.guide-detail-header p { color: var(--c-muted); }

.guide-screenshot { margin: 0; }
.guide-screenshot img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    background: var(--c-navy-tint);
}
.guide-screenshot.has-real-screen { width: min(390px, 100%); margin-inline: auto; }
.guide-screenshot.has-real-screen img { aspect-ratio: 390 / 844; object-fit: contain; background: #fff; }
.guide-screenshot figcaption { margin-top: 7px; color: var(--c-muted); font-size: var(--t-12); text-align: center; }

.guide-steps { list-style: none; counter-reset: guide-step; display: grid; gap: var(--s-2); padding: 0; }
.guide-steps li {
    counter-increment: guide-step;
    min-height: 54px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-2);
    border-bottom: 1px solid var(--c-line-soft);
    line-height: 1.45;
}
.guide-steps li::before {
    content: counter(guide-step);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--c-green);
    color: var(--c-navy);
    font-size: 13px;
    font-weight: 900;
}
.guide-tip { padding: 14px 16px; border-left: 4px solid var(--c-green); background: var(--c-green-tint); color: var(--c-navy); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.guide-tip strong { display: block; margin-bottom: 4px; font-size: var(--t-12); text-transform: uppercase; letter-spacing: .06em; }
.guide-tip p { line-height: 1.45; }

.guide-faq-list { display: grid; gap: var(--s-2); }
.guide-faq { border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); overflow: hidden; }
.guide-faq summary { min-height: 52px; display: flex; align-items: center; padding: 12px 44px 12px 14px; color: var(--c-navy); font-weight: 800; cursor: pointer; position: relative; list-style: none; }
.guide-faq summary::-webkit-details-marker { display: none; }
.guide-faq summary::after { content: "+"; position: absolute; right: 16px; color: var(--c-green-text); font-size: 22px; }
.guide-faq[open] summary::after { content: "−"; }
.guide-faq p { padding: 0 14px 15px; color: var(--c-muted); line-height: 1.5; }
.guide-detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
    padding-top: var(--s-4);
    border-top: 1px solid var(--c-line-soft);
}
@media (max-width: 720px) {
    .guide-index-header { align-items: stretch; flex-direction: column; }
    .guide-detail-actions { position: sticky; bottom: var(--s-2); z-index: 5; padding: 10px; border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface); box-shadow: var(--shadow-up); }
}

/* ---------------------------------------------------------
   13. Utenti (admin)
   --------------------------------------------------------- */
.user-form { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-4); display: grid; gap: var(--s-3); }
.user-form__grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
@media (min-width: 601px) { .user-form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 901px) { .user-form__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.user-row .card__actions { grid-template-columns: 1fr 1fr; }
.user-row .badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------
   13b. Mobile v2: barra senza tab per il corriere, card a tre
        righe, correzione dal riepilogo, tablet
   --------------------------------------------------------- */
.app-bar__spacer { height: var(--s-2); }
.app-bar__help { color: #fff; background: rgba(255, 255, 255, .10); border-color: transparent; }
.app-bar__help.active { background: rgba(127, 181, 57, .25); }
.app-bar__text-btn { position: relative; }
.app-bar__dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c-amber);
    border: 2px solid var(--c-navy);
}
.status-chip { min-width: 84px; justify-content: center; }

.card__counts-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    padding: 0 8px;
    margin-left: auto;
    border-radius: var(--r-sm);
    background: var(--c-blue-tint);
    color: var(--c-blue-text);
    font-weight: 700;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.card__counts-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card__single { min-height: var(--touch); width: 100%; font-size: var(--t-16); }

.summary-table__row.is-changed { animation: row-flash 1.6s var(--ease) 1; }
@keyframes row-flash { 0%, 40% { background: var(--c-green-tint); } 100% { background: transparent; } }

/* tablet: card a due colonne, contenuti centrati */
@media (min-width: 601px) and (max-width: 900px) {
    .app-main { padding: var(--s-4); }
    .list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .toolbar { max-width: none; }
    .wizard, .result, .empty { max-width: 640px; margin-left: auto; margin-right: auto; width: 100%; }
    .dialog-backdrop { align-items: center; }
}

/* ---------------------------------------------------------
   13c. Desktop (> 900 px): sidebar, page-head, filtri,
        griglia a densità, drawer, wizard a tre colonne.
        Il touch si distingue con (pointer), non con la larghezza.
   --------------------------------------------------------- */
:root {
    --sidebar-w: 240px;
    --row-h: 56px;      /* densità Comoda */
    --content-max: none;
}
.density-compact { --row-h: 44px; }

/* elementi solo desktop / solo mobile */
.only-desktop { display: none !important; }
@media (min-width: 901px) {
    .only-desktop { display: revert !important; }
    .only-mobile { display: none !important; }
}

@media (min-width: 901px) and (max-width: 1200px) {
    :root { --sidebar-w: 72px; }
}
@media (min-width: 1801px) {
    :root { --content-max: 1720px; }
}

@media (min-width: 901px) {
    .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .app-main { max-width: var(--content-max); margin: 0 auto; padding: var(--s-5); }

    /* sidebar: la riga della barra si "apre" (display: contents) così brand, utente,
       stato, menu, Esci e versione sono ordinabili in colonna */
    .app-bar { padding: var(--s-4) var(--s-3); gap: var(--s-3); overflow: hidden; }
    .app-bar__row { display: contents; }
    .app-bar__brand { flex: 0 0 auto; order: 1; }
    .app-bar__user { order: 2; }
    .app-bar .status-chip { align-self: flex-start; order: 3; }
    .app-tabs { order: 4; }
    .app-bar__text-btn { order: 5; margin-top: auto; justify-content: center; min-height: var(--touch-icon); }
    .app-bar__version { order: 6; }
    .app-bar__help { display: none; }
    .app-bar__spacer { display: none; }
    .app-bar__user {
        display: block;
        background: rgba(255, 255, 255, .08);
        border-radius: var(--r-sm);
        padding: 10px 12px;
        font-size: 13px;
        line-height: 1.3;
        color: rgba(255, 255, 255, .8);
    }
    .app-bar__user b { display: block; color: #fff; font-size: var(--t-14); }
    .app-tabs { flex-direction: column; gap: 2px; }
    .app-tab { justify-content: flex-start; gap: 10px; border-bottom: 0; border-left: 3px solid transparent; border-radius: var(--r-sm); padding: 0 var(--s-3); min-height: var(--touch-icon); }
    .app-tab svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .app-tab.active { border-left-color: var(--c-green); background: rgba(127, 181, 57, .16); }
    .app-bar__version { margin-top: 0; }
}
@media (max-width: 900px) { .app-bar__user, .app-tab svg { display: none; } }

/* sidebar ridotta a icone */
@media (min-width: 901px) and (max-width: 1200px) {
    .app-bar { padding: var(--s-4) 10px; align-items: center; }
    .app-bar__brand .app-bar__title, .app-bar__user, .app-bar__version { display: none; }
    .app-bar__icon { width: 40px; height: 40px; flex-basis: 40px; }
    .app-bar .status-chip { min-width: 0; width: 44px; padding: 0; justify-content: center; align-self: center; }
    .status-chip__text { display: none; }
    .app-bar__text-btn { width: var(--touch); padding: 0; }
    .app-bar__text-btn > span { display: none; }
    .app-tabs { width: 100%; }
    .app-tab { justify-content: center; padding: 0; border-left: 0; }
    .app-tab.active { box-shadow: inset 3px 0 0 var(--c-green); }
    .app-tab__label { display: none; }
}

/* intestazione pagina e contatori */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.01em; }
.page-head .page-title { font-size: 24px; }
.page-head .kpis { align-self: center; }
.kpi { min-height: 56px; display: flex; flex-direction: column; justify-content: center; }
.page-head p { color: var(--c-muted); font-size: var(--t-14); margin-top: 2px; }
.kpis { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); padding: 8px 14px; min-width: 128px; }
.kpi small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.kpi b { display: block; font-size: 22px; font-weight: 800; color: var(--c-navy); font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi--open b { color: var(--c-blue-text); }
.kpi--done b { color: var(--c-green-text); }
.kpi--pending b { color: var(--c-amber-text); }

/* barra filtri */
.filter-bar {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 10px;
    align-items: end;
}
.filter-bar .field { gap: 4px; }
.filter-bar .field-label { font-size: var(--t-12); }
.filter-bar .input, .filter-bar .btn { min-height: 40px; }
.filter-bar .toggle { min-height: 40px; }
.filter-bar .input-search .input { min-height: 40px; font-size: 15px; padding-left: 40px; padding-right: 44px; }
.filter-bar .input-search > svg { width: 18px; height: 18px; left: 12px; }
.filter-bar .input-search__clear { width: 36px; height: 36px; }
.filter-bar--search-only { grid-template-columns: minmax(280px, 480px); }
.filter-bar__actions { display: flex; gap: var(--s-2); justify-content: flex-end; grid-column: 3 / -1; }
.filter-bar__toggle { grid-column: 1 / 3; }
.filter-bar--search-only { grid-template-columns: minmax(280px, 480px) auto; align-items: end; }
.filter-bar--search-only .filter-bar__actions { grid-column: auto; }
@media (min-width: 1201px) {
    .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr auto auto; }
    .filter-bar__toggle { grid-column: auto; }
    .filter-bar__actions { grid-column: auto; }
}

/* barra sopra la griglia */
.grid-toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); font-size: 13px; color: var(--c-muted); flex-wrap: wrap; }
.grid-toolbar__right { display: flex; align-items: center; gap: var(--s-2); }
.density-toggle { display: inline-flex; border: 1.5px solid var(--c-line); border-radius: var(--r-sm); overflow: hidden; background: var(--c-surface); }
.density-toggle button { padding: 0 12px; min-height: 34px; font-weight: 600; font-size: 13px; color: var(--c-muted); }
.density-toggle button.is-on { background: var(--c-navy); color: #fff; }
.density-toggle button:focus-visible { box-shadow: inset var(--focus-ring); }

/* griglia */
.grid-wrap { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); overflow: auto; }
.grid-table { width: 100%; border-collapse: collapse; font-size: var(--t-14); }
.grid-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--c-surface);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #7b8898;
    padding: 12px 12px 8px;
    border-bottom: 1px solid var(--c-line-soft);
    white-space: nowrap;
}
.grid-table th.num, .grid-table td.num { text-align: right; }
.grid-table th { padding-left: 10px; padding-right: 10px; }
.grid-table th:first-child, .grid-table td:first-child { padding-left: 16px; }
.grid-table th:last-child, .grid-table td:last-child { padding-right: 16px; }
.grid-table td {
    padding: 0 10px;
    height: var(--row-h);
    border-bottom: 1px solid #eef1f5;
    vertical-align: middle;
    white-space: nowrap;
}
.grid-table tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) { .grid-table tbody tr.grid-row:hover td { background: #f6f8fb; } }
.grid-table td.doc { font-weight: 800; color: var(--c-navy); font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: -.01em; }
.grid-table td.muted { color: var(--c-muted); }
.grid-table td.num { font-variant-numeric: tabular-nums; font-weight: 600; width: 64px; }
.grid-table td.num.zero { color: #a5afbd; font-weight: 400; }
.grid-table td.actions { text-align: right; }
.grid-table td.actions .btn + .btn { margin-left: 6px; }
.grid-table .badge { height: 28px; font-size: 11px; padding: 0 8px; }
.grid-table td.num { width: 56px; }
.grid-table .note-cell { max-width: 150px; }
.grid-table .btn-sm { padding: 0 10px; }
.grid-table .exp {
    width: 28px;
    height: 28px;
    min-height: 28px;
    border-radius: 7px;
    border: 1.5px solid var(--c-line);
    color: var(--c-muted);
    display: inline-grid;
    place-items: center;
    background: var(--c-surface);
}
.grid-table .exp svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s var(--ease); }
.grid-table .exp.is-open { background: var(--c-navy); border-color: var(--c-navy); color: #fff; }
.grid-table .exp.is-open svg { transform: rotate(90deg); }
.grid-table .note-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--c-ink); }
.grid-table .note-cell svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: var(--c-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.grid-table .note-cell span { overflow: hidden; text-overflow: ellipsis; }
.grid-table .foto-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 7px;
    background: var(--c-blue-tint);
    color: var(--c-blue-text);
    font-weight: 700;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.grid-table .foto-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.grid-table .foto-chip--none { background: transparent; color: #a5afbd; font-weight: 400; }
.grid-table .foto-chip:active { background: #c5d6f2; }
.grid-table tr.grid-sub td { height: auto; padding: 10px 16px 14px 50px; background: #f6f8fb; white-space: normal; border-bottom: 1px solid var(--c-line-soft); }
.grid-table .grid-sub__inner { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-4); font-size: 13.5px; line-height: 1.45; }
.grid-table .grid-sub__inner b { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #7b8898; margin-bottom: 2px; font-weight: 700; }

/* colonne secondarie: sotto i 1200 px passano nella riga espandibile */
@media (max-width: 1200px) { .grid-table .col-wide { display: none; } }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grid-table tr.is-selected td { background: var(--c-navy-tint); }
.wizard__body { min-width: 0; }

/* densità compatta */
.density-compact .grid-table td { font-size: 13.5px; }
.density-compact .grid-table td.doc { font-size: 14px; }
.density-compact .grid-table .badge { height: 24px; font-size: 11px; padding: 0 7px; }
.density-compact .grid-table .foto-chip { height: 26px; font-size: 12.5px; }
.density-compact .grid-table .exp { width: 24px; height: 24px; min-height: 24px; }
.density-compact .grid-table .btn-sm { min-height: 30px; font-size: 12.5px; padding: 0 10px; }

/* pulsanti piccoli (solo dove c'è il mouse) */
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 7px; gap: 6px; }
.btn-sm svg { width: 16px; height: 16px; }
@media (pointer: coarse) {
    .btn-sm { min-height: var(--touch-icon); }
    .grid-table td { height: max(var(--row-h), var(--touch-icon)); }
    .grid-table .exp { width: var(--touch-icon); height: var(--touch-icon); min-height: var(--touch-icon); }
}

/* pannello laterale (drawer) */
.drawer-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(8, 26, 48, .35); }
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    width: min(420px, 100%);
    background: var(--c-surface);
    border-left: 1px solid var(--c-line);
    box-shadow: var(--shadow-modal);
    padding: var(--s-5) var(--s-5) calc(var(--s-5) + var(--safe-bottom));
    overflow-y: auto;
    display: grid;
    gap: var(--s-3);
    align-content: start;
}
.drawer__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.drawer__head h2 { font-size: var(--t-22); }
.drawer__actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-2); }

/* wizard desktop: pannello con intestazione, corpo e piè di pagina */
@media (min-width: 901px) {
    .wizard--desktop .step-panel { gap: 0; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); overflow: hidden; }
    .wizard--desktop .step-panel__head { padding: 18px var(--s-5) 0; gap: 6px; }
    .wizard--desktop .step-panel__body { padding: var(--s-4) var(--s-5) 20px; }
    .wizard--desktop .step-panel__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px var(--s-5); border-top: 1px solid var(--c-line-soft); background: #f9fafc; }
    .wizard--desktop .step-panel__foot .btn { min-height: 40px; min-width: 120px; padding: 0 var(--s-4); font-size: 15px; border-radius: var(--r-sm); }
    .wizard--desktop .wizard__question { font-size: 22px; }
    .wizard--desktop .wizard__step { font-size: 13px; }
    .wizard--desktop .numrow { grid-template-columns: 56px minmax(0, 1fr) 56px; }
    .wizard--desktop .step-panel__body .notice { font-size: var(--t-14); }
}
@media (min-width: 1201px) {
    .wizard--desktop { display: grid; grid-template-columns: 220px minmax(0, 560px) 300px; gap: var(--s-5); justify-content: center; align-items: start; padding-bottom: var(--s-5); }
}
@media (min-width: 901px) and (max-width: 1200px) {
    .wizard--desktop { width: 100%; max-width: 640px; margin: 0 auto; }
    .wizard-rail, .wizard-aside { display: none; }
}
.wizard-rail { display: flex; flex-direction: column; gap: 6px; }
.wizard-rail span { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-sm); background: var(--c-surface); border: 1px solid var(--c-line); color: var(--c-muted); font-weight: 600; font-size: var(--t-14); }
.wizard-rail span i { width: 24px; height: 24px; border-radius: 50%; background: var(--c-navy-tint); color: var(--c-navy); display: grid; place-items: center; font-size: 12px; font-weight: 800; font-style: normal; flex: 0 0 24px; }
.wizard-rail span.done i { background: var(--c-navy); color: #fff; }
.wizard-rail span.current { border-color: var(--c-green); background: var(--c-green-tint); color: var(--c-ink); }
.wizard-rail span.current i { background: var(--c-green); }
.wizard-aside { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 6px; font-size: 13.5px; }
.wizard-aside h4 { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); font-weight: 700; margin-top: 6px; }
.wizard-aside h4:first-child { margin-top: 0; }
.wizard-aside .r { display: flex; justify-content: space-between; gap: var(--s-2); }
.wizard-aside .r b { font-variant-numeric: tabular-nums; text-align: right; }
.wizard-aside .thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wizard-aside .thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--c-navy-tint); }
@media (max-width: 1200px) { .wizard-rail, .wizard-aside { display: none; } }

/* ---------------------------------------------------------
   14. Errore Blazor non gestito e varie
   --------------------------------------------------------- */
.guide-version { text-align: center; margin-top: var(--s-4); }

#blazor-error-ui { background: #fff7d6; color: #654b00; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .18); display: none; left: 0; padding: .8rem 3rem .8rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .reload { text-decoration: underline; font-weight: 700; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------------------------------------------------------
   15. Movimento ridotto
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    .logistics-loader img, .loading-bar span { animation: none; transform: none; }
}
