/* admin.css — stile backoffice Fashion Hair Gestionale.
   Niente librerie esterne. Variabili CSS per palette consistente. */

/* F-025: tema light (default) + dark via [data-theme="dark"] sull'html.
   Toggle persistente in localStorage('theme'), rispetto prefers-color-scheme
   come default per nuovi utenti. */
:root, html[data-theme="light"] {
    --c-bg:        #f5f6f8;
    --c-bg-alt:    #fafafa;
    --c-surface:   #ffffff;
    --c-card:      #ffffff;
    --c-border:    #e5e7eb;
    --c-text:      #1f2937;
    --c-text-muted:#6b7280;
    --c-muted:     #6b7280;
    --c-primary:   #6d28d9;
    --c-primary-d: #5b21b6;
    --c-accent:    #ec4899;
    --c-success:   #059669;
    --c-success-bg: #d1fae5;
    --c-warning:   #d97706;
    --c-error:     #dc2626;
    --c-error-bg:  #fee2e2;
    --c-info:      #3b82f6;
    --c-info-bg:   #dbeafe;
    --radius:      8px;
    --shadow-sm:   0 1px 2px rgba(0,0,0,.05);
    --shadow:      0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
}

html[data-theme="dark"] {
    --c-bg:        #0f1419;
    --c-bg-alt:    #1a1f2a;
    --c-surface:   #1a202c;
    --c-card:      #1a202c;
    --c-border:    #2d3748;
    --c-text:      #e2e8f0;
    --c-text-muted:#a0aec0;
    --c-muted:     #a0aec0;
    --c-primary:   #a78bfa;
    --c-primary-d: #8b5cf6;
    --c-accent:    #f472b6;
    --c-success:   #34d399;
    --c-success-bg: #064e3b;
    --c-warning:   #fbbf24;
    --c-error:     #f87171;
    --c-error-bg:  #7f1d1d;
    --c-info:      #60a5fa;
    --c-info-bg:   #1e3a8a;
    --shadow-sm:   0 1px 2px rgba(0,0,0,.3);
    --shadow:      0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
}

/* Auto-dark se l'utente NON ha mai scelto manualmente */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --c-bg:        #0f1419;
        --c-surface:   #1a202c;
        --c-border:    #2d3748;
        --c-text:      #e2e8f0;
        --c-muted:     #a0aec0;
        --c-primary:   #a78bfa;
        --c-primary-d: #8b5cf6;
        --c-accent:    #f472b6;
        --c-success:   #34d399;
        --c-success-bg: #064e3b;
        --c-warning:   #fbbf24;
        --c-error:     #f87171;
        --c-error-bg:  #7f1d1d;
        --c-info-bg:   #1e3a8a;
        --shadow-sm:   0 1px 2px rgba(0,0,0,.3);
        --shadow:      0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
    }
}

/* Bottone toggle theme (anche per pwa) */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-muted);
    cursor: pointer;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-left: 0.5rem;
    transition: background 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--c-bg); color: var(--c-text); }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
}

body.logged-out {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(135deg, #faf5ff 0%, #fdf2f8 100%);
}
html[data-theme="dark"] body.logged-out,
html:not([data-theme]) body.logged-out {
    /* fallback nel dark mode: nessun gradient lavanda chiaro */
}
html[data-theme="dark"] body.logged-out {
    background: linear-gradient(135deg, #1a1625 0%, #2d1b2e 100%);
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) body.logged-out {
        background: linear-gradient(135deg, #1a1625 0%, #2d1b2e 100%);
    }
}

h1, h2, h3 { margin: 0 0 0.5em; color: var(--c-text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
.muted { color: var(--c-muted); margin: 0; }

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout container ─────────────────────────────────────── */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
body.logged-out .container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Navigazione ──────────────────────────────────────────── */
/* Luca, 2026-09-17: "Accedi come" (lib/auth.php::authImpersonaInizia()) —
   banner sempre visibile finché la sessione impersona un altro utente. */
.impersona-banner {
    background: var(--c-warning, #d97706);
    color: #fff;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.impersona-banner .btn { background: #fff; color: var(--c-warning, #d97706); border: none; }

.app-nav {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-sm);
    position: relative;
}
.app-nav-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.app-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--c-text);
}
.app-brand:hover { text-decoration: none; }
.brand-mark {
    background: var(--c-primary);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}
.brand-mark.big {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}
.brand-text { font-weight: 600; }
/* Logo Fashion Hair: barra di navigazione (ogni pagina) e login. */
.brand-logo { height: 36px; width: auto; display: block; }
.auth-logo { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto 1rem; }
.app-menu {
    flex: 1;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.menu-item {
    color: var(--c-muted);
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.menu-item:hover {
    background: #f3e8ff;
    color: var(--c-primary);
    text-decoration: none;
}
.menu-item.is-active {
    background: var(--c-primary);
    color: #fff;
}
.menu-item.is-active:hover { background: var(--c-primary-d); }
.menu-item.is-soon { opacity: 0.55; cursor: help; }
.menu-item .badge {
    font-size: 0.65rem;
    background: var(--c-border);
    color: var(--c-muted);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.app-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-info {
    font-size: 0.85rem;
    text-align: right;
    line-height: 1.2;
}
.user-role {
    display: block;
    color: var(--c-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    color: var(--c-muted);
    padding: 2rem 1rem;
    font-size: 0.8rem;
}

/* ── Bottoni ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--c-primary-d); color: #fff; }
.btn-ghost {
    background: transparent;
    color: var(--c-muted);
    border-color: var(--c-border);
}
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.btn-block { width: 100%; }

/* ── Form ─────────────────────────────────────────────────── */
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--c-surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
}
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-header h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; }
.auth-form label span { font-size: 0.85rem; color: var(--c-muted); }
.auth-form input {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.15);
}

/* ── Alert ────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error {
    background: var(--c-error-bg);
    color: var(--c-error);
    border: 1px solid #fecaca;
}

/* ── Dashboard ────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.kpi-card.kpi-placeholder { opacity: 0.6; }
.kpi-label {
    color: var(--c-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--c-text);
}
.kpi-note {
    font-size: 0.75rem;
    color: var(--c-muted);
    margin-top: 0.25rem;
}

.roadmap-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.roadmap-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}
.roadmap-list li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-muted);
}
.roadmap-list li:last-child { border-bottom: none; }
.roadmap-list li.done {
    color: var(--c-success);
    font-weight: 500;
}
.roadmap-list li.done::before { content: "✓ "; }
.roadmap-list li:not(.done)::before { content: "○ "; color: var(--c-border); }

/* ── Pagina errore ────────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}
.error-page h1 {
    font-size: 5rem;
    color: var(--c-primary);
    margin-bottom: 0.5rem;
}

/* ── Page header con azioni a destra ──────────────────────── */
.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.back-link {
    display: inline-block;
    color: var(--c-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.back-link:hover { color: var(--c-primary); }

/* ── Filtri lista ─────────────────────────────────────────── */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filters input[type="search"],
.filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--c-surface);
}
.filters input[type="search"] {
    flex: 1;
    min-width: 220px;
}

/* ── Tabelle dati ─────────────────────────────────────────── */
.table-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #fafafa;
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
    color: var(--c-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #faf5ff; }
.data-table tbody tr.row-clickable { cursor: pointer; }
.data-table .row-inactive { opacity: 0.55; }
.data-table .row-inactive:hover { background: #f5f5f5; }
/* R-fix (a11y R377, sez.11 v4): .row-warn aveva una sola regola, qualificata
   [data-theme="dark"] — nel tema chiaro (default, nessun data-theme finché
   l'utente non sceglie dark) l'evidenziazione di riga per stock sotto-soglia/
   rischio era completamente assente, non solo "solo colore" ma invisibile.
   Stessa palette di .alert-warning/.badge-warning già usata nel tema chiaro. */
.data-table .row-warn { background: #fef3c7; }
.data-table .row-warn:hover { background: #fde68a; }
.data-table .empty {
    text-align: center;
    color: var(--c-muted);
    padding: 2rem !important;
}
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table code {
    background: #f3f4f6;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
}
.row-actions { text-align: right; white-space: nowrap; }
.cell-thumb { width: 56px; }
.cell-thumb img {
    width: 48px; height: 48px; object-fit: cover;
    border-radius: 4px; border: 1px solid var(--c-border);
}
.thumb-placeholder {
    display: inline-block; width: 48px; height: 48px;
    background: #f3f4f6; border-radius: 4px;
    text-align: center; line-height: 48px; color: var(--c-muted);
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-muted   { background: var(--c-border); color: var(--c-muted); }

/* ── Form entità ──────────────────────────────────────────── */
.entity-form fieldset {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 0 0 1rem;
    box-shadow: var(--shadow-sm);
}
.entity-form legend {
    padding: 0 0.5rem;
    font-weight: 600;
    color: var(--c-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.form-grid label > span,
.form-grid .field-label {
    font-size: 0.8rem;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--c-surface);
    font-family: inherit;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.12);
}
.form-grid input[readonly] { background: #f9fafb; color: var(--c-muted); }
.form-grid .span-1 { grid-column: span 1; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-4 { grid-column: span 4; }
.form-grid .span-6 { grid-column: span 6; }
.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
}
.checkbox-row input[type="checkbox"] { width: auto; }
.form-hint { color: var(--c-muted); font-size: 0.85rem; align-self: end; }
.article-preview {
    max-width: 140px; max-height: 140px;
    border: 1px solid var(--c-border); border-radius: var(--radius);
    object-fit: cover;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: var(--c-error); color: #fff; margin-left: auto; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

/* ── Alert (success / warning / info) ─────────────────────── */
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Paginazione ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--c-muted);
}
.pagination .pg-info { flex: 1; text-align: center; }
.pagination a {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
}
.pagination a:hover {
    background: var(--c-primary);
    color: #fff;
    text-decoration: none;
}

/* ── Editor listino ──────────────────────────────────────── */
.editor-actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin: 1rem 0 2rem;
}
.add-row-form, .bulk-action {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.add-row-form h2,
.bulk-action h2 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bulk-action {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.75rem;
}

.inline-row-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.inline-row-form input[type="number"],
.inline-row-form input[type="text"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 0.85rem;
    width: 100px;
}
.inline-row-form input[name="prezzo"]            { width: 110px; }
.inline-row-form input[name="sconto_percentuale"] { width: 75px; }
.inline-row-form input[name="pezzi_omaggio"]      { width: 80px; }
.inline-row-form .checkbox-inline                 { display: inline-flex; align-items: center; gap: 0.2rem; white-space: nowrap; }
.inline-row-form input[name="note"]              { flex: 1; min-width: 120px; width: auto; }
.btn-danger-soft {
    color: var(--c-error);
    border-color: var(--c-border);
    background: transparent;
    padding: 0.25rem 0.5rem;
    font-weight: 700;
}
.btn-danger-soft:hover { background: var(--c-error-bg); }

@media (max-width: 1100px) {
    .editor-actions { grid-template-columns: 1fr; }
}

/* ── Stato ordini: badge addizionali ────────────────────── */
.badge-warning      { background: #fef3c7; color: #92400e; }
.badge-info         { background: #dbeafe; color: #1e40af; }
.badge-success-dark { background: #065f46; color: #fff; }
.badge-error        { background: var(--c-error-bg); color: var(--c-error); }

/* ── Card riassunto ordine ─────────────────────────────── */
.ordine-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.ordine-summary-main {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    grid-column: 1 / -1;
}
.ordine-summary h2 { margin: 0.25rem 0; font-size: 1.3rem; }
.ordine-summary .muted small { font-size: 0.85rem; }
.ordine-stato { text-align: right; display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-end; }

.ordine-totali {
    grid-column: 1 / -1;
    display: flex;
    gap: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
}
.ordine-totali > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.ordine-totali strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ordine-totale-lordo { margin-left: auto; text-align: right; }
.ordine-totale-lordo strong { font-size: 1.5rem; color: var(--c-primary); }

/* ── Pannello firma OTP ────────────────────────────────── */
.firma-panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-primary);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.firma-panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.firma-form {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    margin: 1rem 0;
    flex-wrap: wrap;
}
.firma-form label { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 200px; }
.firma-form label > span { font-size: 0.8rem; color: var(--c-muted); }
.firma-form input {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: ui-monospace, monospace;
    letter-spacing: 0.15em;
}
.firma-form input[name="codice"] {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.4em;
}
.canale-otp {
    display: flex; gap: 1.25rem; border: none; padding: 0; margin: 0 0 0.75rem;
    flex-basis: 100%;
}
.canale-otp label {
    display: flex; flex-direction: row; align-items: center; gap: 0.35rem;
    flex: none; min-width: 0; font-weight: 500; font-family: inherit; letter-spacing: normal;
}

/* ── Hash firma card ──────────────────────────────────── */
.hash-card {
    background: #f9fafb;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1.5rem 0;
}
.hash-card h2 { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--c-muted); text-transform: uppercase; }
.hash-mono {
    display: block;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.8rem;
    word-break: break-all;
    background: var(--c-surface);
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
}
.hash-meta {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--c-muted);
}
.hash-meta li { padding: 0.15rem 0; }

/* ── Riga ordine: valori calcolati read-only ────────── */
.num-readonly {
    display: inline-block;
    min-width: 65px;
    padding: 0.35rem 0.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--c-text);
}

@media (max-width: 900px) {
    .ordine-summary, .ordine-summary-main { grid-template-columns: 1fr; }
    .ordine-stato { text-align: left; align-items: flex-start; }
    .ordine-totali { flex-direction: column; gap: 0.75rem; }
    .ordine-totale-lordo { margin-left: 0; text-align: left; }
}

/* ── Import / Export ──────────────────────────────────────── */
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.import-grid .card { margin: 0; }
.import-grid .card h2 { font-size: 1.05rem; }
.import-grid input[type="file"] {
    margin: 0.5rem 0;
    width: 100%;
}
.errors-list {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 0.75rem 1rem 0.75rem 2rem;
    margin: 0.5rem 0;
    max-height: 240px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: #92400e;
}
.csv-sample {
    background: #f9fafb;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.card { margin-bottom: 1rem; }
.card h3 { margin-top: 0; }

/* ── Dashboard direzionale (Fase 2.4) ────────────────────── */
.period-switch {
    display: flex; gap: 0.25rem; flex-wrap: wrap;
}
.period-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-muted);
    font-size: 0.85rem;
    text-decoration: none;
}
.period-btn:hover { background: var(--c-bg); text-decoration: none; }
.period-btn.is-active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

.dash-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}
.dash-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
/* R-fix (QA live 2026-09-10, B.4): alcune dash-card sono ora <a>, non <div> —
   resettano lo stile link di default e aggiungono un affordance hover
   perché altrimenti sembrerebbero identiche a quelle non cliccabili. */
a.dash-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
a.dash-card-link:hover {
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
    transform: translateY(-1px);
}
.dash-card h2 {
    margin: 0 0 1rem; font-size: 0.95rem;
    color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.dash-card-primary {
    border-color: var(--c-primary);
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 60%);
}
.dash-card-warn {
    border-left: 4px solid var(--c-warning);
}
.dash-label {
    font-size: 0.8rem; color: var(--c-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}
.dash-value {
    font-size: 1.7rem; font-weight: 700; color: var(--c-text);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.25rem;
}
.dash-card-primary .dash-value { color: var(--c-primary); }
.dash-meta {
    font-size: 0.8rem; color: var(--c-muted);
    margin-bottom: 0.5rem;
}

.trend-up   { color: var(--c-success); font-weight: 600; }
.trend-down { color: var(--c-error); font-weight: 600; }
.trend-flat { color: var(--c-muted); }

.sparkline { display: block; width: 100%; height: 40px; }

.dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dash-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ── Bar list (distribuzione) ─────────────── */
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-list li {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}
.bar-label { color: var(--c-muted); }
.bar-track {
    background: #f3f4f6; border-radius: 999px;
    height: 8px; overflow: hidden;
}
.bar-fill { height: 100%; transition: width 0.4s; }
.bar-value { font-variant-numeric: tabular-nums; min-width: 90px; text-align: right; }

/* ── Top list (clienti / articoli / agenti) ──── */
.top-list { list-style: none; padding: 0; margin: 0; counter-reset: top; }
.top-list li {
    counter-increment: top;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name val" "meta val";
    padding: 0.5rem 0 0.5rem 2rem;
    border-bottom: 1px solid var(--c-border);
    position: relative;
    font-size: 0.9rem;
}
.top-list li:last-child { border-bottom: none; }
.top-list li::before {
    content: counter(top);
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    background: var(--c-primary); color: #fff;
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.top-list li a, .top-list li strong { grid-area: name; font-weight: 600; }
.top-list li small { grid-area: meta; color: var(--c-muted); font-size: 0.75rem; }
.top-val { grid-area: val; align-self: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Event list (ultimi ordini) ──────────────── */
.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name meta" "info meta";
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.85rem;
}
.event-list li:last-child { border-bottom: none; }
.event-list li a { grid-area: name; font-weight: 600; }
.event-list li small { grid-area: info; color: var(--c-muted); }
.event-meta { grid-area: meta; align-self: center; display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }

@media (max-width: 1000px) {
    .dash-grid-2, .dash-grid-3 { grid-template-columns: 1fr; }
}

/* ── Score predittivo ────────────────────────────────────── */
.score-bar {
    position: relative;
    background: #f3f4f6;
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    min-width: 100px;
}
.score-bar .score-fill {
    height: 100%;
    transition: width 0.3s;
}
.score-bar span {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    color: var(--c-text);
}
.alert-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}
.alert-list .alert {
    margin: 0.25rem 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid [class*="span-"] { grid-column: span 2; }
}
@media (max-width: 768px) {
    .app-nav-inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .app-menu { width: 100%; }
    .app-user { width: 100%; justify-content: space-between; }
    .container { padding: 1rem; }
}

/* ── F-025: overrides specifici per dark mode ─────────────── */
/* Tabelle, badge, alert: invertiamo le palette pastello chiare in versione dark. */
html[data-theme="dark"] .data-table thead,
html[data-theme="dark"] .data-table tbody tr:nth-child(even) { background: #232733; }
html[data-theme="dark"] .data-table tbody tr:hover { background: #2d3748; }
html[data-theme="dark"] .data-table .row-inactive { color: var(--c-muted); background: #1a1f2a; }
html[data-theme="dark"] .data-table .row-warn { background: #3a2a14; }
html[data-theme="dark"] code,
html[data-theme="dark"] pre { background: #232733; color: var(--c-text); }
html[data-theme="dark"] .menu-item:not(.is-active):hover { background: #2d2640; color: var(--c-text); }

html[data-theme="dark"] .alert-success { background: #064e3b; color: #d1fae5; border-color: #047857; }
html[data-theme="dark"] .alert-warning { background: #78350f; color: #fef3c7; border-color: #b45309; }
html[data-theme="dark"] .alert-info    { background: #1e3a8a; color: #dbeafe; border-color: #2563eb; }
html[data-theme="dark"] .alert-error   { background: #7f1d1d; color: #fee2e2; border-color: #b91c1c; }

html[data-theme="dark"] .badge-success      { background: #064e3b; color: #d1fae5; }
html[data-theme="dark"] .badge-warning      { background: #78350f; color: #fef3c7; }
html[data-theme="dark"] .badge-info         { background: #1e3a8a; color: #dbeafe; }
html[data-theme="dark"] .badge-success-dark { background: #d1fae5; color: #065f46; }
html[data-theme="dark"] .badge-warn         { background: #78350f; color: #fef3c7; border-color: #b45309; }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border);
}
html[data-theme="dark"] input::placeholder { color: var(--c-muted); }

/* Stessa logica anche con prefers-color-scheme: dark se utente non ha scelto */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) .data-table thead,
    html:not([data-theme]) .data-table tbody tr:nth-child(even) { background: #232733; }
    html:not([data-theme]) .data-table tbody tr:hover { background: #2d3748; }
    html:not([data-theme]) code,
    html:not([data-theme]) pre { background: #232733; color: var(--c-text); }
    html:not([data-theme]) input,
    html:not([data-theme]) select,
    html:not([data-theme]) textarea {
        background: var(--c-surface); color: var(--c-text); border-color: var(--c-border);
    }
    html:not([data-theme]) .alert-success { background: #064e3b; color: #d1fae5; border-color: #047857; }
    html:not([data-theme]) .alert-warning { background: #78350f; color: #fef3c7; border-color: #b45309; }
    html:not([data-theme]) .alert-info    { background: #1e3a8a; color: #dbeafe; border-color: #2563eb; }
    html:not([data-theme]) .alert-error   { background: #7f1d1d; color: #fee2e2; border-color: #b91c1c; }
    html:not([data-theme]) .badge-success { background: #064e3b; color: #d1fae5; }
    html:not([data-theme]) .badge-warning { background: #78350f; color: #fef3c7; }
    html:not([data-theme]) .badge-info    { background: #1e3a8a; color: #dbeafe; }
}

/* ── F-023: stile stampa / PDF (browser print → save as PDF) ───── */
@media print {
    /* Reset colori per stampa (no dark mode in print) */
    html, body { background: white !important; color: #000 !important; font-size: 11pt; }

    /* Nasconde elementi UI non utili per la stampa */
    .app-nav, .app-footer, .no-print,
    .filters, .form-actions, .back-link,
    .theme-toggle, .app-user, .btn,
    nav, .breadcrumb {
        display: none !important;
    }

    .print-only { display: block !important; }
    body:not(.has-print-block) .print-only { display: none; }

    /* Header titolo: visibile in print con prefisso azienda */
    h1.print-only::before { content: "Fashion Hair — "; color: #666; font-weight: normal; }

    /* Container occupa tutta la pagina */
    .container { max-width: none !important; padding: 0 !important; margin: 0 !important; }
    main.container { padding: 1cm !important; }

    /* Card: niente shadow, bordo sottile per separazione */
    .card, .hash-card, section.card {
        box-shadow: none !important;
        background: white !important;
        border: 1px solid #ccc !important;
        padding: 0.5cm !important;
        margin-bottom: 0.5cm !important;
        page-break-inside: avoid;
    }

    /* Tabelle: ottimizzate per A4, evita break a metà riga */
    .data-table {
        width: 100% !important;
        font-size: 9.5pt !important;
        border-collapse: collapse !important;
    }
    .data-table th, .data-table td {
        padding: 4px 6px !important;
        border: 1px solid #ddd !important;
        color: #000 !important;
    }
    .data-table thead { background: #f0f0f0 !important; }
    .data-table tbody tr { page-break-inside: avoid; }
    .data-table tr:nth-child(even) { background: #fafafa !important; }

    /* Badge & alert in B/N */
    .badge { background: white !important; color: #333 !important; border: 1px solid #999 !important; }
    .alert { background: #f5f5f5 !important; color: #000 !important; border: 1px solid #999 !important; }

    /* Link: mostra URL accanto al testo (utile per documenti firmati) */
    a[href]:not(.btn)::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
    a[href^="#"]::after, a[href^="javascript:"]::after { content: ""; }

    /* Hash + codice fissati monospace per leggibilità */
    code, pre { background: #f5f5f5 !important; color: #000 !important; border: 1px solid #ddd !important; }

    /* Pagina A4, margini ridotti */
    @page { size: A4; margin: 1.5cm 1.2cm; }

    /* Page break in punti naturali */
    h1, h2, h3 { page-break-after: avoid; }
    section { page-break-inside: avoid; }
}

/* .print-only nascosto a video, mostrato solo in print */
.print-only { display: none; }

/* ── F-085: fix grafica/responsività audit Round 8 ──────── */

/* Disabled state per tutti i bottoni (era mancante) */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(20%);
}

/* Focus visibile per navigazione tastiera (WCAG 2.1 SC 2.4.7) */
.menu-item:focus-visible,
.btn:focus-visible,
.data-table a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Touch target min 44px (WCAG 2.5.5) anche per btn-sm */
.btn-sm {
    min-height: 36px;
}
@media (hover: none) and (pointer: coarse) {
    /* device touch-only: alza touch target a 44px */
    .btn, .btn-sm, .menu-item, .pagination a {
        min-height: 44px;
    }
}

/* Zebra stripe tabelle anche light (era solo dark) */
.data-table tbody tr:nth-child(even) {
    background: var(--c-bg-alt);
}
.data-table tbody tr:hover {
    background: rgba(109, 40, 217, 0.05);
}

/* Reduce motion preference (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode coverage per componenti mancanti (B-118) */
html[data-theme="dark"] .data-table thead {
    background: var(--c-surface);
    color: var(--c-text);
}
html[data-theme="dark"] .data-table code,
html[data-theme="dark"] code {
    background: var(--c-bg-alt);
    color: var(--c-text);
}
html[data-theme="dark"] .hash-card,
html[data-theme="dark"] .hash-mono {
    background: var(--c-bg-alt);
    color: var(--c-text);
}
html[data-theme="dark"] .form-grid input[readonly],
html[data-theme="dark"] input[readonly] {
    background: var(--c-bg-alt);
    color: var(--c-muted);
}
html[data-theme="dark"] .help-tip {
    background: var(--c-bg-alt);
    color: var(--c-text-muted);
}

/* Mobile menu hamburger visibility (era nascosto sempre) */
#mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-text);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    min-height: 44px;
}
@media (max-width: 768px) {
    #mobile-menu-toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
    .app-menu { display: none; }
    .app-menu.is-mobile-open {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%; left: 0; right: 0;
        background: var(--c-surface);
        border-top: 1px solid var(--c-border);
        padding: 0.5rem;
        z-index: 50;
    }
}

/* AI card priority borders via CSS vars (no hardcoded) */
.ai-card[data-priority="1"] { border-left-color: var(--c-error); }
.ai-card[data-priority="2"] { border-left-color: var(--c-warning); }
.ai-card[data-priority="3"] { border-left-color: var(--c-info); }

/* Pagination touch-friendly mobile */
@media (max-width: 640px) {
    .pagination a {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: 44px;
        text-align: center;
    }
    .pagination .muted.small { display: none; } /* nascondi "Pagina X di Y" su mobile */
}

/* Print stylesheet: standardizza margin a 1cm uniforme */
@media print {
    @page { size: A4; margin: 1cm; }
    /* fix per skip-link printing */
    .skip-link { display: none !important; }
}

/* F-106: form grid responsive uniforme (era inconsistente span-N mobile) */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .form-grid [class*="span-"] {
        grid-column: 1 / -1 !important;
    }
}

/* F-107: focus trap visivo modali (#fh-search-overlay, #fh-ai-overlay) */
#fh-search-overlay:focus-within .fh-search-box,
#fh-ai-overlay:focus-within .fh-ai-panel {
    outline: 3px solid var(--c-primary);
    outline-offset: -3px;
}

/* F-108: stato loading universale via aria-busy */
[aria-busy="true"] {
    opacity: 0.7;
    cursor: progress;
    position: relative;
}
[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent, transparent 10px,
        rgba(109, 40, 217, 0.05) 10px, rgba(109, 40, 217, 0.05) 20px
    );
    animation: ariaBusyStripe 1s linear infinite;
    pointer-events: none;
}
@keyframes ariaBusyStripe {
    from { background-position: 0 0; }
    to   { background-position: 40px 0; }
}
@media (prefers-reduced-motion: reduce) {
    [aria-busy="true"]::after { animation: none; }
}

/* F-109: better contrast su badge in dark mode */
html[data-theme="dark"] .badge-info    { background: #1e3a8a; color: #dbeafe; }
html[data-theme="dark"] .badge-success { background: #064e3b; color: #d1fae5; }
html[data-theme="dark"] .badge-warning { background: #78350f; color: #fef3c7; }
html[data-theme="dark"] .badge-error   { background: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .badge-muted   { background: #374151; color: #d1d5db; }

/* F-110: input/select consistency height (era 32-40px misti) */
.form-grid input:not([type="checkbox"]):not([type="radio"]),
.form-grid select,
.form-grid textarea,
.filters input, .filters select {
    min-height: 40px;
    box-sizing: border-box;
}

/* Skip to main content link (WCAG 2.4.1) */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--c-primary);
    color: #fff;
    padding: 0.7rem 1rem;
    z-index: 9999;
    text-decoration: none;
    border-radius: 0 0 6px 0;
    transition: top 0.15s;
}
.skip-link:focus {
    top: 0;
    outline: 2px solid #fff;
    outline-offset: -4px;
}

/* ── F-082: tooltip help inline ─────────────────────────── */
.help-tip {
    display: inline-block;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--c-bg-alt, #e5e7eb);
    color: var(--c-text-muted, #666);
    font-size: 12px; font-weight: 600;
    text-align: center; line-height: 18px;
    cursor: help;
    position: relative;
    margin-left: 0.3rem;
}
.help-tip:hover { background: var(--c-primary); color: #fff; }
.help-tip::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: #1f2937; color: #f9fafb;
    padding: 0.5rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem; font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    min-width: 180px; max-width: 280px;
    text-align: left;
    z-index: 100;
    opacity: 0; pointer-events: none;
    transition: opacity 0.15s;
}
.help-tip:hover::after { opacity: 1; }

/* ── F-083: empty states più ricchi ─────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--c-bg-alt, #fafafa);
    border: 2px dashed var(--c-border);
    border-radius: 8px;
    margin: 1rem 0;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.3rem; }
.empty-state-text { color: var(--c-text-muted, #666); margin-bottom: 1rem; }

/* ── F-084: mobile responsive data-table accordion ──────── */
@media (max-width: 640px) {
    .data-table.mobile-cards { display: block; }
    .data-table.mobile-cards thead { display: none; }
    .data-table.mobile-cards tbody { display: block; }
    .data-table.mobile-cards tr {
        display: block;
        border: 1px solid var(--c-border);
        border-radius: 6px;
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        background: var(--c-card, #fff);
    }
    .data-table.mobile-cards td {
        display: flex; justify-content: space-between; align-items: baseline;
        border: 0;
        padding: 0.25rem 0;
        font-size: 0.9rem;
    }
    .data-table.mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--c-text-muted, #666);
        margin-right: 0.5rem;
        flex-shrink: 0;
    }
}

/* ── F-053: dashboard agente AI suggestions ─────────────── */
.ai-suggestions .ai-cards {
    display: flex; flex-direction: column; gap: 0.6rem;
}
.ai-card {
    display: flex; align-items: center; gap: 1rem;
    background: var(--c-card, #fff);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-primary);
    border-radius: 8px;
    padding: 0.8rem 1rem;
}
.ai-card[data-priority="1"] { border-left-color: #ef4444; }
.ai-card[data-priority="2"] { border-left-color: #f97316; }
.ai-card[data-priority="3"] { border-left-color: #3b82f6; }
.ai-card[data-priority="4"] { border-left-color: #eab308; }
.ai-card[data-priority="5"] { border-left-color: #8b5cf6; }
.ai-card[data-priority="6"] { border-left-color: #64748b; }
.ai-card-icon { font-size: 1.6rem; flex: 0 0 auto; }
.ai-card-body { flex: 1; min-width: 0; }
.ai-card-title { font-weight: 600; }
.ai-card-detail { font-size: 0.9rem; margin-top: 0.15rem; }
@media (max-width: 640px) {
    .ai-card { flex-wrap: wrap; }
    .ai-card-body { flex-basis: 100%; }
}

/* ── F-064: AI assistant overlay (Cmd+J/Ctrl+J) ──────── */
#fh-ai-overlay {
    position: fixed; inset: 0; z-index: 9998;
    background: rgba(0,0,0,0.3);
    display: none;
}
#fh-ai-overlay.is-open { display: block; }
.fh-ai-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 420px; max-width: 100vw;
    background: var(--c-bg); color: var(--c-text);
    box-shadow: -8px 0 30px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
}
.fh-ai-header {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--c-border);
    display: flex; flex-direction: column; gap: 0.2rem;
    position: relative;
}
.fh-ai-header small { color: var(--c-text-muted, #666); font-size: 0.75rem; }
.fh-ai-close {
    position: absolute; top: 0.6rem; right: 0.7rem;
    background: transparent; border: 0; cursor: pointer;
    font-size: 1.2rem; padding: 0.2rem 0.5rem;
    color: var(--c-text);
}
.fh-ai-history {
    flex: 1; overflow-y: auto;
    padding: 0.8rem 1rem;
}
.fh-ai-hint {
    color: var(--c-text-muted, #888);
    font-size: 0.85rem;
    padding: 0.5rem 0;
}
.fh-ai-msg {
    margin: 0.5rem 0; padding: 0.5rem 0.7rem;
    border-radius: 6px;
    font-size: 0.9rem; line-height: 1.4;
    white-space: pre-wrap; word-wrap: break-word;
}
.fh-ai-msg-user { background: var(--c-primary); color: #fff; }
.fh-ai-msg-assistant { background: var(--c-bg-alt, #f5f5f5); }
.fh-ai-msg-thinking { color: var(--c-text-muted, #888); font-style: italic; }
.fh-ai-msg-error { background: #fee; color: #c00; }
.fh-ai-form {
    border-top: 1px solid var(--c-border);
    padding: 0.6rem;
    display: flex; gap: 0.5rem; align-items: end;
}
.fh-ai-form textarea {
    flex: 1; resize: vertical; min-height: 50px;
    padding: 0.4rem 0.6rem; font: inherit;
    background: var(--c-bg); color: var(--c-text);
    border: 1px solid var(--c-border); border-radius: 4px;
}
.fh-ai-form button {
    padding: 0.5rem 0.9rem;
    background: var(--c-primary); color: #fff;
    border: 0; border-radius: 4px; cursor: pointer;
    font: inherit;
}
.fh-ai-form button:hover { opacity: 0.9; }
@media (max-width: 480px) {
    .fh-ai-panel { width: 100vw; }
}

/* ── F-051: search globale ⌘K overlay ──────────────────── */
#fh-search-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.5);
    display: none; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
}
#fh-search-overlay.is-open { display: flex; }
.fh-search-box {
    width: 100%; max-width: 600px;
    background: var(--c-bg); color: var(--c-text);
    border-radius: 12px; box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    overflow: hidden;
}
#fh-search-input {
    width: 100%; padding: 1.2rem 1.4rem;
    font-size: 1.1rem; border: 0; outline: 0;
    background: transparent; color: inherit;
    border-bottom: 1px solid var(--c-border);
}
#fh-search-results { max-height: 60vh; overflow-y: auto; }
.fh-search-group {
    padding: 0.5rem 1.4rem; font-size: 0.8rem;
    color: var(--c-text-muted, #666); background: var(--c-bg-alt, #fafafa);
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.fh-search-item {
    display: block; padding: 0.7rem 1.4rem;
    text-decoration: none; color: var(--c-text);
    border-bottom: 1px solid var(--c-border);
}
.fh-search-item:hover, .fh-search-item.is-selected {
    background: var(--c-primary); color: #fff;
}
.fh-search-item:hover .fh-search-meta, .fh-search-item.is-selected .fh-search-meta {
    color: rgba(255,255,255,0.85);
}
.fh-search-item strong { display: block; }
.fh-search-meta { font-size: 0.85rem; color: var(--c-text-muted, #666); }
.fh-search-hint, .fh-search-err {
    padding: 1.5rem; text-align: center; color: var(--c-text-muted, #888);
}
.fh-search-err { color: #ef4444; }
.fh-search-footer {
    display: flex; gap: 1rem; justify-content: center;
    padding: 0.6rem 1.4rem; font-size: 0.8rem;
    color: var(--c-text-muted, #888);
    background: var(--c-bg-alt, #fafafa);
    border-top: 1px solid var(--c-border);
}
.fh-search-footer kbd {
    background: var(--c-bg, #fff); border: 1px solid var(--c-border);
    border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.75rem;
    color: var(--c-text);
}

/* Ricerca globale (Luca 2026-10-21): annuncio per screen reader, «vedi tutti», tema scuro, icona nella barra */
.fh-search-sr, .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.fh-search-item.fh-search-more {
    font-size: 0.85rem; color: var(--c-primary); font-weight: 600; text-align: right;
}
.fh-search-item.fh-search-more:hover, .fh-search-item.fh-search-more.is-selected { color: #fff; }
#fh-search-input:focus-visible { box-shadow: inset 0 -2px 0 var(--c-primary); }
.fh-search-item:focus-visible { outline: 2px solid var(--c-primary); outline-offset: -2px; }
#global-search-btn { font-size: 1rem; }
/* Contrasto (WCAG AA 4.5:1) di meta/suggerimenti nel tema chiaro (il grigio condiviso --c-text-muted e' a 4.47:1 su --c-bg)
   e della voce selezionata nel tema scuro (--c-primary e' un viola chiaro: il testo bianco non basta). */
.fh-search-meta, .fh-search-hint, .fh-search-footer, .fh-search-group { color: #4b5563; }
html[data-theme="dark"] .fh-search-meta, html[data-theme="dark"] .fh-search-hint,
html[data-theme="dark"] .fh-search-footer, html[data-theme="dark"] .fh-search-group { color: var(--c-text-muted); }
.fh-search-err { color: #b91c1c; }
html[data-theme="dark"] .fh-search-err { color: #f87171; }
html[data-theme="dark"] .fh-search-item:hover, html[data-theme="dark"] .fh-search-item.is-selected,
html[data-theme="dark"] .fh-search-item.fh-search-more:hover, html[data-theme="dark"] .fh-search-item.fh-search-more.is-selected { color: #0f1419; }
html[data-theme="dark"] .fh-search-item:hover .fh-search-meta, html[data-theme="dark"] .fh-search-item.is-selected .fh-search-meta { color: #1f2937; }

/* ── Autocomplete ricerca clienti (lista /clienti, dopo 3 lettere) ── */
.clienti-ac-wrap { position: relative; flex: 1; min-width: 240px; }
.clienti-ac-wrap input[type="search"] { width: 100%; }
.clienti-ac-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    margin-top: 0.25rem; max-height: 320px; overflow-y: auto;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

/* ── F-050: mobile responsive (≤768px) backoffice ─────── */
@media (max-width: 768px) {
    /* Tabelle dati: scroll orizzontale invece di overflow page */
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .data-table th, .data-table td {
        white-space: nowrap;
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Container più stretto */
    .container { padding: 0.75rem !important; }

    /* Page header in colonna */
    .page-header-actions {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }
    .page-header-actions > div { width: 100%; }
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.1rem; }

    /* Filtri in colonna */
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    .filters > * { width: 100%; }

    /* Form grid: tutto in singola colonna su mobile */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .form-grid [class*="span-"] {
        grid-column: span 1 !important;
    }

    /* KPI cards mobile: 1 colonna piena */
    .dash-kpi, .portale-kpi {
        grid-template-columns: 1fr !important;
    }

    /* Nav top con menu hamburger collassabile */
    .app-nav-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .app-menu {
        display: none;
        flex-direction: column;
        gap: 0.25rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--c-border);
    }
    .app-menu.is-mobile-open {
        display: flex !important;
        position: static;
    }
    .app-menu .menu-item {
        padding: 0.6rem 0.75rem;
        border-radius: 4px;
    }
    .app-user {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    /* Hamburger button injection */
    #mobile-menu-toggle {
        display: inline-flex !important;
        background: transparent;
        border: 1px solid var(--c-border);
        color: var(--c-text);
        font-size: 1.2rem;
        padding: 0.4rem 0.7rem;
        border-radius: 6px;
        cursor: pointer;
        align-items: center;
        gap: 0.3rem;
    }
}
#mobile-menu-toggle { display: none; }

/* ── Menu raggruppato con dropdown (Lotto 42) ─────────── */
.menu-group {
    position: relative;
    display: inline-block;
}
.menu-group-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.menu-group .caret { font-size: 0.7rem; opacity: 0.7; }
.menu-group.is-active > .menu-group-btn { color: var(--c-primary); font-weight: 600; }
.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    min-width: 180px;
    padding: 0.3rem 0;
    box-shadow: var(--shadow);
    margin-top: 2px;
}
.menu-group.is-open .menu-dropdown,
.menu-group:hover .menu-dropdown {
    display: block;
}
.menu-dropdown .menu-item {
    display: block;
    padding: 0.5rem 0.9rem;
    border-radius: 0;
    color: var(--c-text);
    text-decoration: none;
    white-space: nowrap;
}
.menu-dropdown .menu-item:hover { background: var(--c-bg); }
.menu-dropdown .menu-item.is-active { background: var(--c-primary); color: #fff; }

/* Mobile: i dropdown diventano sub-list inline (no positioning) */
@media (max-width: 768px) {
    .menu-group { display: block; width: 100%; }
    .menu-group-btn { width: 100%; text-align: left; padding: 0.6rem 0.75rem; }
    .menu-dropdown { position: static; box-shadow: none; border-left: 3px solid var(--c-border); margin-left: 1rem; }
}

/* R-fix (report QA 2026-09-10/11, C.1): filtro testo iniettato da
   enhanceSearchableSelect() (assets/js/admin.js) sopra i <select> enormi. */
.searchable-select-wrapper { display: flex; flex-direction: column; gap: .25rem; }
.searchable-select-filter { font-size: .85em; }

/* R-fix (report QA Fase 5, punto 1): enhanceArticoloPicker() (assets/js/
   admin.js) — dropdown di risultati sotto l'input di ricerca articoli. */
.articolo-picker { position: relative; display: flex; flex-direction: column; gap: .25rem; }
.articolo-picker-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: var(--c-surface, #fff); border: 1px solid var(--c-border);
    border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.12);
    max-height: 320px; overflow-y: auto; margin-top: 2px;
}
.articolo-picker-item {
    display: block; width: 100%; text-align: left; padding: .5rem .75rem;
    border: none; background: none; cursor: pointer; font: inherit; color: inherit;
    border-bottom: 1px solid var(--c-border);
}
.articolo-picker-item:last-child { border-bottom: none; }
.articolo-picker-item:hover, .articolo-picker-item:focus { background: var(--c-bg-hover, rgba(0,0,0,.05)); }
.articolo-picker-empty { padding: .5rem .75rem; }

/* Luca, 2026-09-17: "nell'elenco moduli anzichè la tendina, metti dei
   toggle, e allineali a destra" (views/settings.php, controllers/settings.php
   type='toggle') — interruttore booleano allineato a destra, label/help a
   sinistra sulla stessa riga, invece di un <select> a due opzioni. */
.settings-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.settings-toggle-label { flex: 1 1 auto; min-width: 0; }
.settings-toggle-label label { display: block; }
.switch {
    position: relative; display: inline-block; flex-shrink: 0;
    width: 44px; height: 24px;
}
.switch input[type="checkbox"] {
    position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.switch-slider {
    position: absolute; inset: 0; background: var(--c-border);
    border-radius: 24px; transition: background-color .15s ease;
    pointer-events: none;
}
.switch-slider::before {
    content: ""; position: absolute; left: 3px; top: 3px;
    width: 18px; height: 18px; background: #fff; border-radius: 50%;
    transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input[type="checkbox"]:checked + .switch-slider { background: var(--c-primary); }
.switch input[type="checkbox"]:checked + .switch-slider::before { transform: translateX(20px); }
.switch input[type="checkbox"]:focus-visible + .switch-slider { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* Dashboard: blocco azioni (urgente / da fare / bloccato) */
.dash-azioni-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.dash-azioni-col { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--c-border); border-radius: 6px; padding: .75rem 1rem; }
.dash-azioni-col[data-gruppo="urgente"]  { border-left-color: var(--c-error); }
.dash-azioni-col[data-gruppo="fare"]     { border-left-color: var(--c-success); }
.dash-azioni-col[data-gruppo="bloccato"] { border-left-color: var(--c-warning); }
.dash-azioni-col h3 { margin: 0 0 .4rem 0; font-size: 1rem; }
.dash-azioni-col ul { list-style: none; margin: 0; padding: 0; }
.dash-azioni-col li a { display: flex; align-items: center; gap: .6rem; padding: .5rem .25rem; min-height: 44px; color: var(--c-text); text-decoration: none; border-top: 1px solid var(--c-border); }
.dash-azioni-col li:first-child a { border-top: 0; }
.dash-azioni-col li a:hover, .dash-azioni-col li a:focus-visible { background: var(--c-bg); }
.dash-azioni-txt { flex: 1; display: flex; flex-direction: column; }
.dash-azioni-go { color: var(--c-text-muted, var(--c-text)); }

/* Dashboard ufficio: «Riepilogo di oggi» (conteggi cliccabili + confronto con ieri) */
.riepilogo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.riepilogo-tile { display: flex; align-items: center; gap: .6rem; min-height: 56px; padding: .6rem .9rem; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; color: var(--c-text); text-decoration: none; }
.riepilogo-tile:hover, .riepilogo-tile:focus-visible { background: var(--c-bg); }
.riepilogo-tile.is-zero { opacity: .75; }
.riepilogo-num { font-size: 1.6rem; font-weight: 700; min-width: 2ch; text-align: right; }
.riepilogo-txt { flex: 1; display: flex; flex-direction: column; }
.riepilogo-delta { font-weight: 600; white-space: nowrap; }
.riepilogo-delta.is-up { color: var(--c-error); }
.riepilogo-delta.is-down { color: var(--c-success); }

/* Riga avvisi in cima alle pagine interne */
.azioni-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem 0; }
.azioni-chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: .3rem .8rem; border: 1px solid var(--c-border); border-left: 4px solid var(--c-border); border-radius: 6px; background: var(--c-surface); color: var(--c-text); text-decoration: none; font-size: .9rem; }
.azioni-chip[data-gruppo="urgente"]  { border-left-color: var(--c-error); }
.azioni-chip[data-gruppo="fare"]     { border-left-color: var(--c-success); }
.azioni-chip[data-gruppo="bloccato"] { border-left-color: var(--c-warning); }
.azioni-chip:hover, .azioni-chip:focus-visible { background: var(--c-bg); }

/* Scheda cliente: situazione in breve */
.cliente-sit { margin: 0 0 1.5rem 0; }
.cliente-sit-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; justify-content: space-between; margin-bottom: .6rem; }
.cliente-sit-avviso { margin: 0 0 .75rem 0; padding: .5rem .75rem; border-left: 4px solid var(--c-warning); background: var(--c-bg); border-radius: 4px; font-size: .9rem; }
.cliente-sit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.cliente-sit-box { display: flex; flex-direction: column; gap: .15rem; min-height: 44px; padding: .65rem .8rem; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text); text-decoration: none; }
.cliente-sit-box:hover, .cliente-sit-box:focus-visible { background: var(--c-bg); }
.cliente-sit-box-allarme { border-left: 4px solid var(--c-error); }
.cliente-sit-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-text-muted); }
.cliente-sit-fonte { display: inline-block; padding: 0 .35rem; border-radius: 4px; background: var(--c-bg); border: 1px solid var(--c-border); font-size: .7rem; letter-spacing: .04em; }
.cliente-sit-fonte-qui { border-style: dashed; }
.cliente-sit-links { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .75rem; }
.cliente-sit-links a { display: inline-flex; align-items: center; min-height: 44px; }
.cliente-sit-legenda { margin: .5rem 0 0 0; }
.txt-error { color: var(--c-error); }

/* Mobile: campi a 16px (sotto, Safari su iPhone zooma la pagina al tocco) e bersagli touch di almeno 44px.
   !important voluto: le regole dei singoli filtri/form (13-14px) hanno specificita' diversa e sparse. */
@media (max-width: 768px) {
    body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
    body select,
    body textarea { font-size: 16px !important; }
    td > a, th > a { display: inline-block; padding: .6rem 0; min-height: 44px; box-sizing: border-box; }
    .back-link, .user-info, footer a { display: inline-flex; align-items: center; min-height: 44px; }
    button.btn, a.btn { min-width: 44px; }
}

/* Feedback di invio e campi non validi */
button.is-sending, input.is-sending { opacity: .65; cursor: progress; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--c-error); box-shadow: 0 0 0 1px var(--c-error); }

/* ── Pagina «Email automatiche» (retention), Luca 2026-11-16 ─────────────────────────────────────────────── */
.rt-nav { margin-bottom: 1.25rem; }
.rt-sezione { margin-top: 2.25rem; scroll-margin-top: 5rem; }
.rt-sezione > h2 { margin-bottom: .25rem; }
.rt-stato { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; margin-bottom: 1.25rem;
            border-radius: var(--radius); border: 1px solid var(--c-border); background: var(--c-surface); box-shadow: var(--shadow-sm); }
.rt-stato-on  { border-left: 5px solid var(--c-success); }
.rt-stato-off { border-left: 5px solid var(--c-warning); background: color-mix(in srgb, var(--c-warning) 8%, var(--c-surface)); }
.rt-stato-testo { display: flex; align-items: center; gap: .85rem; }
.rt-dot { width: .9rem; height: .9rem; border-radius: 50%; flex: none; }
.rt-dot-on  { background: var(--c-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-success) 25%, transparent); }
.rt-dot-off { background: var(--c-warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-warning) 25%, transparent); }
.rt-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.rt-kpi-card { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; background: var(--c-surface); border: 1px solid var(--c-border);
               border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.rt-kpi-ico { font-size: 1.6rem; line-height: 1; }
.rt-kpi-val { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.rt-kpi-lbl { color: var(--c-muted); font-size: .85rem; }
.rt-kpi-ok .rt-kpi-val { color: var(--c-success); }
.rt-kpi-ko .rt-kpi-val { color: var(--c-error); }
.rt-triggers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0 1.25rem; }
.rt-trigger { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
              display: flex; flex-direction: column; gap: .35rem; }
.rt-trigger p { margin: 0; }
.rt-param { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; font-size: .9rem; color: var(--c-muted); }
.rt-param input { width: 5rem; padding: .35rem .5rem; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); font: inherit; }
.rt-switch { display: flex; align-items: center; gap: .65rem; cursor: pointer; }
.rt-switch input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 2.6rem; height: 1.5rem; flex: none; margin: 0; border-radius: 999px;
    background: var(--c-border); position: relative; cursor: pointer; transition: background .15s; }
.rt-switch input[type="checkbox"]::before { content: ""; position: absolute; top: .18rem; left: .2rem; width: 1.14rem; height: 1.14rem; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.rt-switch input[type="checkbox"]:checked { background: var(--c-success); }
.rt-switch input[type="checkbox"]:checked::before { transform: translateX(1.1rem); }
.rt-switch input[type="checkbox"]:focus-visible { outline: 3px solid color-mix(in srgb, var(--c-primary) 45%, transparent); outline-offset: 2px; }
.rt-switch-titolo { font-weight: 600; }
.rt-limiti { margin-top: 0; }
.rt-limiti small { display: block; margin-top: .25rem; }
.rt-tecnico { margin-top: 1rem; }
.rt-tecnico summary { cursor: pointer; color: var(--c-muted); font-size: .9rem; }
.rt-template { padding: 0; margin-bottom: .6rem; }
.rt-template > summary { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; cursor: pointer; list-style: none; }
.rt-template > summary::-webkit-details-marker { display: none; }
.rt-template-nome { flex: 1; display: flex; flex-direction: column; gap: .1rem; }
.rt-template-modifica { color: var(--c-primary); font-size: .85rem; white-space: nowrap; }
.rt-template[open] > summary { border-bottom: 1px solid var(--c-border); }
.rt-template > form { padding: 0 1.1rem 1.1rem; }
.rt-switch-inline { align-self: end; }
@media (max-width: 640px) { .rt-stato { padding: .85rem 1rem; } .rt-kpi-val { font-size: 1.4rem; } }

/* Schede/filtri a pillola (nav.chips > a.chip): usate da Spedizioni, Incassi, Segnalazioni, Email automatiche (prima senza stile). */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--c-border);
        background: var(--c-surface); color: var(--c-text); font-size: .9rem; text-decoration: none; transition: background .12s, border-color .12s; }
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chip.chip-active, .chip[aria-current="page"] { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600; }
.chip .badge { margin-left: .1rem; }
.rt-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.rt-card h3 { margin: 0 0 .75rem; font-size: 1.05rem; }
.rt-template { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.rt-sezione > p { margin-bottom: .85rem; }

/* ═══ Base grafica comune (Luca 2026-11-16: «migliora la grafica di tutte le sezioni attive») ═══════════════════════════════════
   Classi usate nelle viste ma prive di stile (box «card», campi nudi, utilita' tipo Bootstrap, pillole di stato...). Specificita' bassa
   (:where) dove possibile, cosi' gli stili specifici delle singole pagine continuano a vincere. */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.1rem 1.25rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-header { font-weight: 600; padding-bottom: .6rem; margin-bottom: .75rem; border-bottom: 1px solid var(--c-border); }
.card-title { margin: 0 0 .5rem; font-size: 1.05rem; font-weight: 600; }
.card-body { padding: 0; }
.card-warn { border-left: 4px solid var(--c-warning); }

:where(main) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="color"]), select, textarea) {
    padding: .5rem .7rem; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text);
    font: inherit; font-size: .92rem; max-width: 100%;
}
:where(main) :where(input, select, textarea):focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(109,40,217,.12); }
:where(main) textarea { width: 100%; }
:where(main) :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--c-primary); }
.form-control { width: 100%; }
.form-row { margin-bottom: 1rem; }
.form-row > label { display: block; font-weight: 600; margin-bottom: .3rem; }
.form-help { margin-top: .25rem; }
.field-error { color: var(--c-error); font-size: .85rem; margin-top: .25rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.form-inline, .inline-form { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.form-row-inline, .form-row.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; }
.check-inline, .check-line, .inline-check { display: inline-flex; align-items: center; gap: .4rem; font-weight: normal; margin-right: .75rem; }
.entity-form > label:not(.checkbox-row) { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }

/* utilita' tipo Bootstrap usate da alcune viste */
.container { max-width: 1200px; margin-inline: auto; padding-inline: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.row > [class*="col-md-"] { flex: 1 1 18rem; min-width: 0; }
.col-md-12 { flex-basis: 100% !important; } .col-md-6 { flex-basis: calc(50% - .5rem) !important; }
.col-md-4 { flex-basis: calc(33% - .5rem) !important; } .col-md-3 { flex-basis: calc(25% - .75rem) !important; }
@media (max-width: 720px) { .row > [class*="col-md-"] { flex-basis: 100% !important; } }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: .5rem !important; } .mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: .5rem !important; } .mt-5 { margin-top: 3rem !important; }
.text-right { text-align: right; } .text-center { text-align: center; } .text-muted { color: var(--c-muted); }
.section-title { font-size: 1.05rem; margin: 0 0 .6rem; }
.span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }

/* tabelle e liste */
.table, .table-sm { width: 100%; border-collapse: collapse; }
.table th, .table td, .table-sm th, .table-sm td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--c-border); font-size: .9rem; }
.table th, .table-sm th { color: var(--c-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.table-sm th, .table-sm td { padding: .35rem .6rem; }
.table-wrap, .table-responsive { overflow-x: auto; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); margin-bottom: 1rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--c-border); }
.list-row:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.kv dt { color: var(--c-muted); } .kv dd { margin: 0; }

/* pulsanti, pillole e badge */
.page-header-btns { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-secondary, .btn-outline-secondary { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
.btn-secondary:hover, .btn-outline-secondary:hover { background: var(--c-bg); }
.btn-warning { background: var(--c-warning); color: #fff; border: 1px solid var(--c-warning); }
.status-pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--c-bg); color: var(--c-muted); border: 1px solid var(--c-border); }
.status-pill.status-confermato { background: var(--c-success-bg); color: #065f46; border-color: transparent; }
.status-pill.status-annullato { background: var(--c-error-bg); color: var(--c-error); border-color: transparent; }
.badge-danger { background: var(--c-error-bg); color: var(--c-error); }
.badge-ok { background: var(--c-success-bg); color: #065f46; }
.badge-secondary { background: var(--c-bg); color: var(--c-muted); }

/* impostazioni: riga di un modulo con interruttore a destra (prima l'interruttore andava a capo sotto il testo lungo) */
.settings-toggle-row { flex-wrap: nowrap; padding: .85rem 0; border-bottom: 1px solid var(--c-border); margin-bottom: 0; }
.settings-toggle-row:last-child { border-bottom: none; }
.settings-toggle-label { flex: 1 1 0; }
.settings-toggle-label label { font-weight: 600; }
.settings-toggle-row .switch { margin-left: 1rem; align-self: center; }
.po-provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.po-provider { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.po-provider-testa { display: flex; align-items: center; gap: .6rem; }
.entity-form > label:has(> input[type="checkbox"]), .entity-form > label:has(> input[type="radio"]) { flex-direction: row; align-items: center; }
.entity-form section.card { margin-bottom: 1rem; }
.rt-coda-link { margin-left: .5rem; white-space: nowrap; }

/* Dashboard ufficio: blocco unico «Cosa richiede attenzione» con il confronto con ieri (Luca 2026-11-16) */
.dash-azioni .riepilogo-delta { margin-left: auto; padding-left: .5rem; font-size: .8rem; }
.dash-azioni-col li a.dash-voce { gap: .6rem; }
.dash-zero { margin-top: 1rem; color: var(--c-muted); }
.dash-zero > summary { cursor: pointer; font-size: .9rem; }
.dash-zero ul { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .25rem 1rem; }
.dash-zero li a { display: flex; align-items: center; gap: .4rem; padding: .3rem .25rem; color: var(--c-text); text-decoration: none; font-size: .88rem; border-radius: 6px; }
.dash-zero li a:hover { background: var(--c-bg); }

/* Pagina «Punti aperti» (superadmin) */
.pa-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.pa-kpi-card { display: flex; align-items: baseline; gap: .6rem; padding: .85rem 1.1rem; background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--c-border);
               border-radius: var(--radius); text-decoration: none; color: var(--c-text); box-shadow: var(--shadow-sm); }
.pa-kpi-card.is-attivo { outline: 2px solid var(--c-primary); }
.pa-kpi-val { font-size: 1.6rem; font-weight: 700; } .pa-kpi-lbl { color: var(--c-muted); font-size: .85rem; }
.pa-p-alta { border-left-color: var(--c-error) !important; } .pa-p-media { border-left-color: var(--c-warning) !important; } .pa-p-bassa { border-left-color: var(--c-info) !important; }
.pa-voce { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--c-border); border-radius: var(--radius); margin-bottom: .5rem; box-shadow: var(--shadow-sm); }
.pa-voce > summary { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .7rem 1rem; cursor: pointer; list-style: none; }
.pa-voce > summary::-webkit-details-marker { display: none; }
.pa-id { font-family: ui-monospace, monospace; font-size: .85rem; color: var(--c-muted); min-width: 3.2rem; }
.pa-titolo { flex: 1 1 22rem; font-weight: 600; }
.pa-prio-alta { background: var(--c-error-bg); color: var(--c-error); } .pa-prio-media { background: #fef3c7; color: #92400e; } .pa-prio-bassa { background: var(--c-info-bg); color: #1e40af; }
.pa-stato { margin: 0; padding: 0 1rem .5rem; color: var(--c-muted); font-size: .9rem; }
.pa-testo { margin: 0; padding: .75rem 1rem 1rem; white-space: pre-wrap; word-break: break-word; font-size: .82rem; max-height: 28rem; overflow: auto; border-top: 1px solid var(--c-border); background: var(--c-bg); }

/* Pagina «Registro attività» */
.ra-cat { background: var(--c-bg); color: var(--c-muted); font-weight: 600; margin-right: .35rem; }
.ra-cat-ordini { background: var(--c-info-bg); color: #1e40af; } .ra-cat-incassi { background: var(--c-success-bg); color: var(--c-success); }
.ra-cat-provvigioni { background: #fef3c7; color: #92400e; } .ra-cat-utenti, .ra-cat-impostazioni { background: var(--c-error-bg); color: var(--c-error); }
