/* =====================================================================
   ExciseFlow – tema applicativo (Bootstrap 5.3)
   ===================================================================== */
@font-face {
    font-family: "InterVar";
    src: url("../lib/inter/inter-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --rd-primary: #1d4ed8;
    --rd-primary-rgb: 29, 78, 216;
    --rd-accent: #0ea5a4;
    --rd-accise: #b45309;
    --rd-dogane: #0369a1;
    --rd-sidebar: #0b1f3a;
    --rd-sidebar-2: #12305a;
    --rd-sidebar-text: #c7d4ea;
    --rd-bg: #f3f5f9;
    --rd-card: #ffffff;
    --rd-border: #e3e8f0;
    --rd-muted: #64748b;
    --rd-radius: .75rem;
    --bs-primary: var(--rd-primary);
    --bs-primary-rgb: var(--rd-primary-rgb);
    --bs-link-color: var(--rd-primary);
    --bs-link-color-rgb: var(--rd-primary-rgb);
    --bs-body-font-family: "InterVar", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-font-monospace: var(--bs-body-font-family);
    --bs-body-font-size: .875rem;
    --bs-border-radius: .5rem;
}

[data-bs-theme="dark"] {
    --rd-bg: #0d1420;
    --rd-card: #131c2b;
    --rd-border: #223047;
    --rd-muted: #93a3bb;
    --rd-sidebar: #070f1c;
    --rd-sidebar-2: #0f1d33;
}

body { background: var(--rd-bg); }
.btn-primary { --bs-btn-bg: var(--rd-primary); --bs-btn-border-color: var(--rd-primary); --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; }
.btn-outline-primary { --bs-btn-color: var(--rd-primary); --bs-btn-border-color: var(--rd-primary); --bs-btn-hover-bg: var(--rd-primary); --bs-btn-hover-border-color: var(--rd-primary); }
.text-primary { color: var(--rd-primary) !important; }

/* ---------- struttura ---------- */
.app { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 264px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--rd-sidebar), var(--rd-sidebar-2));
    color: var(--rd-sidebar-text);
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) {
    .app-sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; --bs-offcanvas-bg: var(--rd-sidebar); }
}
.sidebar-brand { display: flex; align-items: center; padding: 1.1rem 1.1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-link { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, var(--rd-accent)); font-size: 1.2rem; box-shadow: 0 6px 16px rgba(14,165,164,.35); }
.brand-text { line-height: 1.1; font-size: 1.05rem; letter-spacing: .01em; }
.brand-text small { display: block; font-size: .72rem; color: var(--rd-sidebar-text); opacity: .75; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-nav { padding: .6rem .6rem 1rem; flex: 1; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: rgba(199,212,234,.55); padding: 1rem .75rem .35rem; }
.nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .52rem .75rem; margin: 1px 0;
    color: var(--rd-sidebar-text); text-decoration: none; border-radius: .55rem; font-size: .9rem;
    transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(59,130,246,.22); color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.sidebar-foot { padding: .8rem 1.1rem; color: rgba(199,212,234,.5); border-top: 1px solid rgba(255,255,255,.06); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem;
    background: color-mix(in srgb, var(--rd-card) 88%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--rd-border);
}
.app-content { padding: 1.25rem 1.5rem 3rem; }
@media (max-width: 575.98px) { .app-content { padding: 1rem .75rem 3rem; } .app-topbar { padding: .5rem .75rem; } }

.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: .6rem; color: inherit; border: 0; background: transparent; }
.btn-icon:hover { background: rgba(var(--rd-primary-rgb), .08); }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, var(--rd-accent)); color: #fff; font-size: .78rem; font-weight: 600; }

/* ---------- barra contesto ---------- */
.ctxbar { display: flex; align-items: center; gap: .35rem; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.ctx-chip {
    display: inline-flex; align-items: center; gap: .4rem; max-width: 260px; padding: .32rem .7rem;
    border: 1px solid var(--rd-border); border-radius: 999px; background: var(--rd-card);
    color: inherit; text-decoration: none; font-size: .85rem; white-space: nowrap;
}
.ctx-chip:hover { border-color: var(--rd-primary); color: var(--rd-primary); }
.ctx-empty { border-style: dashed; color: var(--rd-muted); }
.ctx-accise { border-color: color-mix(in srgb, var(--rd-accise) 40%, transparent); color: var(--rd-accise); }
.ctx-dogane { border-color: color-mix(in srgb, var(--rd-dogane) 40%, transparent); color: var(--rd-dogane); }
.ctx-sep { color: var(--rd-muted); font-size: .7rem; }

/* ---------- componenti ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .9rem; margin-bottom: .8rem; }
.page-header h1 { font-size: 1.3rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--rd-muted); margin: .1rem 0 0; font-size: .84rem; }
.page-header .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

.card { border: 1px solid var(--rd-border); border-radius: var(--rd-radius); background: var(--rd-card); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
/* intestazione di sezione: stessa grafica dei pannelli dei gruppi di campi, in tutta l'applicazione */
.card-header { background: color-mix(in srgb, var(--rd-bg) 55%, var(--rd-card)); border-bottom: 1px solid var(--rd-border);
    font-weight: 600; padding: .5rem .85rem; display: flex; align-items: center; gap: .5rem; }
.card-header::before { content: ""; width: 3px; height: 1.05em; border-radius: 2px; flex-shrink: 0;
    background: color-mix(in srgb, var(--rd-primary) 55%, transparent); }
.card-header.senza-barra::before, .card-header.toolbar::before { display: none; }
@media print { .fgroup, .fgroup-title, .card-header { background: #fff !important; } }
.card-header .bi { color: var(--rd-primary); }

.kpi { display: flex; gap: .9rem; align-items: center; }
.kpi .kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.kpi .kpi-label { color: var(--rd-muted); font-size: .82rem; }
.bg-soft-primary { background: rgba(29,78,216,.1); color: #1d4ed8; }
.bg-soft-success { background: rgba(22,163,74,.12); color: #15803d; }
.bg-soft-warning { background: rgba(217,119,6,.14); color: #b45309; }
.bg-soft-danger { background: rgba(220,38,38,.12); color: #b91c1c; }
.bg-soft-info { background: rgba(3,105,161,.12); color: #0369a1; }
.bg-soft-secondary { background: rgba(100,116,139,.14); color: #475569; }
.bg-soft-accise { background: rgba(180,83,9,.1); color: var(--rd-accise); }
.bg-soft-dogane { background: rgba(3,105,161,.1); color: var(--rd-dogane); }

.mode-card { display: block; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; height: 100%; }
.mode-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16,24,40,.09); border-color: var(--rd-primary); color: inherit; }
.mode-card .mode-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem; }
.pick-card { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem; text-decoration: none; color: inherit; height: 100%; transition: border-color .15s, box-shadow .15s; }
.pick-card:hover { border-color: var(--rd-primary); box-shadow: 0 6px 18px rgba(16,24,40,.07); color: inherit; }
.pick-card .pick-icon { width: 42px; height: 42px; flex-shrink: 0; border-radius: 11px; display: grid; place-items: center; font-size: 1.2rem; }
.pick-card.selected { border-color: var(--rd-primary); box-shadow: 0 0 0 3px rgba(var(--rd-primary-rgb), .15); }

/* righe annullate da una cancellazione: stessa resa della stampa del registro */
.riga-annullata > td:not(.row-actions) { text-decoration: line-through; color: var(--rd-muted); }
.riga-annullata .badge { text-decoration: none; }

/* pulsanti e campi delle barre azioni tutti della stessa misura */
.page-header .actions .btn, .page-header .actions .form-control, .page-header .actions .form-select,
.toolbar .btn, .toolbar .form-control, .toolbar .form-select {
    font-size: .82rem; padding: .25rem .65rem; min-height: 32px; line-height: 1.45; }
.page-header .actions .btn-icon { padding: .25rem .5rem; }
/* i menu a tendina hanno bisogno di spazio per la freccia, altrimenti il testo ci finisce sotto */
.page-header .actions .form-select, .toolbar .form-select { padding-right: 2rem; }

/* ---------- densità dell'interfaccia ----------
   controlli e spaziature compatti: più dati visibili e meno scorrimento orizzontale */
.form-control-sm, .form-select-sm, .btn-sm, .input-group-sm > .form-control, .input-group-sm > .btn {
    font-size: .82rem; padding-top: .2rem; padding-bottom: .2rem; }
.form-control, .form-select { font-size: .86rem; }
.form-label { font-size: .8rem; margin-bottom: .2rem; font-weight: 550; }
.ts-wrapper.form-control-sm .ts-control, .form-select-sm + .ts-wrapper .ts-control { font-size: .82rem; }
.card > .p-3 { padding: .8rem !important; }
.card.p-3 { padding: .8rem !important; }
.card.p-4 { padding: 1.1rem !important; }
.alert { padding: .55rem .8rem; }
.badge { font-weight: 550; }

/* ---------- tabelle ---------- */
.table-card .table { margin: 0; }
.table > :not(caption) > * > * { padding: .38rem .55rem; }
.table thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rd-muted); font-weight: 600; background: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); border-bottom-width: 1px; white-space: nowrap; }
.table-hover tbody tr { cursor: default; }
.table-card tbody tr.riga-apribile { cursor: pointer; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; }
.table-responsive-max { max-height: 70vh; overflow: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* codici e numeri: stesso carattere dell'applicazione, cifre a larghezza costante per l'allineamento */
.mono { font-family: inherit; font-size: inherit; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { padding: .2rem .45rem; }
/* la colonna delle azioni resta visibile anche quando la tabella scorre in orizzontale */
@media (min-width: 768px) {
    .table > :not(caption) > * > .row-actions { position: sticky; right: 0; z-index: 3;
        background-color: var(--rd-card);
        /* mantiene l'evidenziazione della riga sotto il cursore (Bootstrap usa --bs-table-bg-state) */
        background-image: linear-gradient(var(--bs-table-bg-state, transparent), var(--bs-table-bg-state, transparent));
        box-shadow: -10px 0 10px -10px rgba(15,23,42,.25); }
    .table thead > tr > .row-actions { z-index: 4; background-color: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); }
    /* niente ombra se non c'è nulla da scorrere */
    .table-responsive:not(.scorre) > .table > :not(caption) > * > .row-actions { box-shadow: none; }
}
/* ---------- visita guidata ---------- */
.tour-buco { position: fixed; z-index: 2000; border-radius: .6rem; pointer-events: auto;
    box-shadow: 0 0 0 9999px rgba(15,23,42,.6), 0 0 0 3px var(--rd-primary); transition: all .25s ease; }
.tour-card { position: fixed; z-index: 2001; width: 340px; max-width: calc(100vw - 24px);
    background: var(--rd-card); color: inherit; border-radius: .7rem; padding: .9rem 1rem;
    box-shadow: 0 18px 44px rgba(15,23,42,.28); }
.tour-card .tour-passo { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rd-muted); }
.tour-card .tour-titolo { font-weight: 650; margin: .15rem 0 .35rem; }
.tour-card .tour-testo { font-size: .86rem; line-height: 1.5; margin: 0; }

/* ---------- guida in linea ---------- */
.guida-pannello { width: min(460px, 100vw); }
.guida-pannello .offcanvas-header { border-bottom: 1px solid var(--rd-border); }
.guida-testo { line-height: 1.65; }
.guida-testo h2 { font-size: 1.25rem; font-weight: 650; margin: 0 0 .75rem; }
.guida-testo h3 { font-size: 1.02rem; font-weight: 650; margin: 1.6rem 0 .5rem; }
.guida-testo h4 { font-size: .94rem; font-weight: 650; margin: 1.2rem 0 .4rem; color: var(--rd-muted); }
.guida-testo p { margin-bottom: .85rem; }
.guida-testo .guida-elenco { margin: 0 0 .9rem; padding-left: 1.15rem; }
.guida-testo .guida-elenco li { margin-bottom: .3rem; }
.guida-testo code { background: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); border-radius: .3rem; padding: .05rem .3rem; font-size: .88em; color: inherit; }
.guida-testo .guida-codice { background: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); border-radius: .5rem; padding: .7rem .9rem; font-size: .84rem; }
.guida-testo .guida-tabella { font-size: .88rem; }
.guida-testo .guida-nota, .guida-testo .guida-consiglio, .guida-testo .guida-attenzione {
    border-left: 3px solid var(--rd-primary); background: rgba(29,78,216,.06);
    border-radius: .45rem; padding: .7rem .9rem; margin: 0 0 1rem; font-size: .92rem; }
.guida-testo .guida-consiglio { border-left-color: #16a34a; background: rgba(22,163,74,.08); }
.guida-testo .guida-attenzione { border-left-color: #d97706; background: rgba(217,119,6,.1); }
.guida-testo .guida-consiglio::before { content: "Consiglio — "; font-weight: 650; color: #15803d; }
.guida-testo .guida-attenzione::before { content: "Attenzione — "; font-weight: 650; color: #b45309; }
.guida-testo-sm { font-size: .88rem; }
.guida-testo-sm h2 { font-size: 1.05rem; }
.guida-testo-sm h3 { font-size: .95rem; margin-top: 1.1rem; }
.passo-num { width: 2rem; height: 2rem; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
    background: color-mix(in srgb, var(--rd-bg) 60%, var(--rd-card)); color: var(--rd-muted); font-weight: 650; font-size: .9rem; }
.passo-num.fatto { background: rgba(22,163,74,.15); color: #15803d; }
#guidaRisultati .list-group-item { border: 0; border-radius: .4rem; }

/* riquadro informativo dei campi: discorsivo, non tecnico */
.popover.aiuto-campo { max-width: 340px; box-shadow: 0 12px 32px rgba(16,24,40,.18); }
.popover.aiuto-campo .popover-header { font-size: .86rem; font-weight: 600; }
.popover.aiuto-campo .popover-body { font-size: .82rem; line-height: 1.5; }
.popover.aiuto-campo .aiuto-quando { padding: .4rem .55rem; border-radius: .4rem; background: rgba(29,78,216,.08); }
.popover.aiuto-campo .aiuto-come { color: var(--rd-muted); }
.field-label .aiuto { cursor: help; }
.field-label .aiuto:focus { outline: none; color: var(--rd-primary) !important; }

/* menu di riga: sopra la tabella e non ritagliato dal contenitore scorrevole */
.table-card .dropdown-menu, .table-responsive .dropdown-menu, .table-responsive-max .dropdown-menu { z-index: 1065; }
.table-card .dropdown-menu { box-shadow: 0 12px 32px rgba(16,24,40,.18); }

/* tabelle -> schede su mobile */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack tbody tr { display: block; border: 1px solid var(--rd-border); border-radius: .6rem; margin: .6rem; padding: .35rem .5rem; background: var(--rd-card); }
    .table-stack tbody td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .25rem; text-align: right; }
    .table-stack tbody td::before { content: attr(data-label); font-weight: 600; color: var(--rd-muted); text-align: left; font-size: .8rem; }
    .table-stack tbody td.row-actions { justify-content: flex-end; }
    .table-stack tbody td.row-actions::before { content: none; }
}

/* ---------- badge stato ---------- */
.badge-state { font-weight: 600; font-size: .72rem; padding: .35em .6em; border-radius: 999px; }
.st-Bozza { background: #e2e8f0; color: #334155; }
.st-Validato { background: rgba(29,78,216,.12); color: #1d4ed8; }
.st-InErrore { background: rgba(220,38,38,.12); color: #b91c1c; }
.st-Trasmesso { background: rgba(124,58,237,.12); color: #6d28d9; }
.st-Accettato { background: rgba(22,163,74,.14); color: #15803d; }
.st-Scartato { background: rgba(234,88,12,.14); color: #c2410c; }
.st-Annullato { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.mov-C { color: #15803d; font-weight: 600; }
.mov-S { color: #b91c1c; font-weight: 600; }
.mov-G { color: #6d28d9; font-weight: 600; }

/* ---------- form dinamico ---------- */
/* ---------- pannelli dei gruppi di campi ----------
   Ogni gruppo (Movimento, Prodotto, Documento...) è un riquadro con intestazione propria:
   si vede dove comincia e dove finisce, senza colori sgargianti. */
.card-body > .fgroup:last-child { margin-bottom: 0; }
/* Niente overflow:hidden qui: ritaglierebbe tutto cio' che esce dal riquadro,
   comprese le tendine dei campi che si aprono verso il basso. Gli angoli
   dell'intestazione vengono arrotondati direttamente su .fgroup-title. */
.fgroup { margin-bottom: .7rem; border: 1px solid var(--rd-border); border-radius: .6rem;
    background: var(--rd-card); transition: box-shadow .15s, border-color .15s; }
.fgroup:hover { border-color: color-mix(in srgb, var(--rd-primary) 22%, var(--rd-border)); }
.fgroup:focus-within { border-color: color-mix(in srgb, var(--rd-primary) 40%, var(--rd-border));
    box-shadow: 0 0 0 3px rgba(var(--rd-primary-rgb), .07); }

.fgroup-title { display: flex; align-items: center; gap: .5rem;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 650;
    color: color-mix(in srgb, var(--rd-muted) 75%, var(--bs-body-color));
    margin: 0; padding: .45rem .75rem;
    background: color-mix(in srgb, var(--rd-bg) 75%, var(--rd-card));
    border-bottom: 1px solid var(--rd-border);
    border-radius: calc(.6rem - 1px) calc(.6rem - 1px) 0 0; }
.fgroup-title::before { content: ""; width: 3px; height: 1em; border-radius: 2px; flex-shrink: 0;
    background: color-mix(in srgb, var(--rd-primary) 55%, transparent); }
.fgroup-title:hover { background: color-mix(in srgb, var(--rd-bg) 85%, var(--rd-card)); }
.fgroup-title .conteggio { color: var(--rd-muted); font-weight: 500; letter-spacing: 0; text-transform: none; font-size: .72rem; }
.fgroup > .fgroup-corpo { padding: .7rem .75rem .75rem; }
.fgroup:not([open]) .fgroup-title { border-bottom-color: transparent; border-radius: calc(.6rem - 1px); }
.fgroup:not([open]) { background: color-mix(in srgb, var(--rd-bg) 35%, var(--rd-card)); }
.field-label { display: flex; align-items: baseline; gap: .35rem; font-size: .82rem; font-weight: 550; margin-bottom: .25rem; }
.field-label .fnum { font-size: .68rem; color: var(--rd-muted); font-weight: 500; border: 1px solid var(--rd-border); border-radius: 4px; padding: 0 .3rem; }
.field-label .req { color: #dc2626; }
.field-label .cond { color: #d97706; font-size: .7rem; }
.field-help { font-size: .72rem; color: var(--rd-muted); margin-top: .15rem; }
.form-control[readonly], .form-select[disabled] { background-color: color-mix(in srgb, var(--rd-bg) 60%, var(--rd-card)); }
.is-auto { border-style: dashed; }
.iter-table td { vertical-align: top; }
.iter-table .form-control, .iter-table .form-select { min-width: 120px; }
.field-error { font-size: .75rem; color: #dc2626; margin-top: .15rem; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
/* nelle iterazioni (tabelle di righe) il messaggio non deve allargare la colonna */
.iter-block .field-error { max-width: 100%; }
.issues-list { max-height: 260px; overflow: auto; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: color-mix(in srgb, var(--rd-card) 94%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--rd-border); padding: .75rem 1rem; margin: 0 -1rem -1rem; border-radius: 0 0 var(--rd-radius) var(--rd-radius); }

.ts-wrapper.form-select { padding: 0; }
.ts-control { border-radius: .5rem; min-height: 31px; padding-top: .18rem; padding-bottom: .18rem; }
/* La tendina viene agganciata al body (vedi rdInitSelects): cosi' nessun contenitore
   puo' ritagliarla. Lo z-index la tiene sopra barre fisse, tabelle e finestre modali. */
.ts-dropdown { font-size: .85rem; z-index: 1060; }
/* Il campo di ricerca dentro la tendina: le regole del tema partono da .ts-wrapper e,
   con la tendina spostata nel body, non lo raggiungono piu'. Lo ridisegniamo qui. */
.ts-dropdown .dropdown-input { display: block; width: 100%; padding: .35rem .75rem;
    background: transparent; border: 0; border-bottom: 1px solid var(--bs-border-color-translucent);
    border-radius: 0; box-shadow: none; outline: 0; }
.ts-dropdown .dropdown-input:focus { border-bottom-color: rgba(var(--rd-primary-rgb), .55); box-shadow: none; }
.ts-dropdown .option small { color: var(--rd-muted); }

/* ---------- anteprima file ---------- */
.file-preview { background: #0b1220; color: #d1e4ff; border-radius: .6rem; padding: 1rem; overflow: auto; max-height: 65vh; font-size: .8rem; line-height: 1.55; white-space: pre; }
.file-preview .tab { color: #f59e0b; }
.file-preview .ln { color: #64748b; user-select: none; display: inline-block; width: 3.2em; }
.file-preview .hdr { color: #86efac; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(circle at 20% 20%, #1d4ed8 0, transparent 45%), radial-gradient(circle at 80% 80%, #0ea5a4 0, transparent 45%), #0b1f3a; color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h2 { font-weight: 700; font-size: 2rem; letter-spacing: -.02em; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: var(--rd-bg); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- stampa ---------- */
.print-only { display: none; }
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body { background: #fff; font-size: 9pt; }
    .app-sidebar, .app-topbar, .no-print, .alert, .page-header .actions { display: none !important; }
    .app-content { padding: 0; }
    .card { border: 0; box-shadow: none; }
    .print-only { display: block; }
    .table > :not(caption) > * > * { padding: .15rem .3rem; }
    .register-page { page-break-after: always; }
    .register-page:last-child { page-break-after: auto; }
    a { text-decoration: none; color: inherit; }

    /* in stampa niente barre di scorrimento: la pagina occupa tutta la larghezza del foglio */
    html, body, .app, .app-main, .app-content { display: block !important; width: auto !important; height: auto !important; min-height: 0 !important;
        margin: 0 !important; padding: 0 !important; overflow: visible !important; position: static !important; }
    .table-responsive, .table-responsive-max { overflow: visible !important; max-height: none !important; }
    .sticky-actions, .sticky-actions-card, .toast-container { display: none !important; }

    /* registro: tutte le colonne sul foglio A4 orizzontale */
    .register-page { padding: 0 !important; margin: 0 0 4mm 0 !important; }
    .register-head { font-size: 8pt !important; padding: 1.5mm 2mm !important; margin-bottom: 1.5mm !important; }
    .register-table { width: 100% !important; table-layout: auto; font-size: 6.8pt !important; border-collapse: collapse; }
    .register-table th, .register-table td { padding: .6mm 1mm !important; white-space: normal !important; overflow-wrap: anywhere; vertical-align: top; line-height: 1.2; }
    .register-table th { font-size: 6.2pt !important; letter-spacing: 0 !important; text-transform: none !important; }
    .register-table td.text-end, .register-table th.text-end { white-space: nowrap !important; }
    .register-table .badge { font-size: 6.5pt; padding: 0 .5mm; }
    .register-table small, .register-table .small { font-size: 6pt !important; }

    /* stampa sempre in chiaro anche se l'applicazione usa il tema scuro */
    :root, [data-bs-theme="dark"] { color-scheme: light; }
    body, .register-page, .register-page * { color: #000 !important; background: #fff !important; border-color: #777 !important; box-shadow: none !important; }
}
.register-head { border: 1px solid #000; padding: .4rem .6rem; margin-bottom: .4rem; font-size: .85rem; }
.register-table th, .register-table td { border: 1px solid #94a3b8 !important; }

/* ---------- maschere dinamiche ---------- */
details.fgroup > summary { list-style: none; cursor: pointer; user-select: none; }
details.fgroup > summary::-webkit-details-marker { display: none; }
details.fgroup > summary .chev { transition: transform .15s; font-size: .7rem; }
details.fgroup[open] > summary .chev { transform: rotate(90deg); }
.auto-chip { background: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); border: 1px dashed var(--rd-border); border-radius: .5rem; padding: .15rem .5rem; }
.border-dashed { border-style: dashed !important; }
.mov-radio .btn { flex: 1 1 0; white-space: nowrap; }
.btn-check:checked + .btn.mov-C { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-check:checked + .btn.mov-S { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-check:checked + .btn.mov-G { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.is-warning { border-color: #d97706 !important; box-shadow: 0 0 0 .15rem rgba(217,119,6,.15); }
.mov-radio.is-invalid .btn { border-color: #dc2626; }
.iter-block .field-error { font-size: .7rem; }
.file-preview .err { background: rgba(220,38,38,.28); display: inline-block; min-width: 100%; }
.sticky-actions-card { position: sticky; bottom: .5rem; z-index: 6; }
.sticky-actions-card .sticky-actions { position: static; margin: 0; }
.min-w-0 { min-width: 0; }
.field-label > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.pick-card { flex-direction: row; }
.pick-card > span:last-child { min-width: 0; flex: 1 1 auto; }
button.pick-card { font: inherit; }
@media (max-width: 767.98px) {
    .table-stack, .table-stack tbody { display: block; width: 100%; }
    .table-stack tbody td { min-width: 0; overflow-wrap: anywhere; align-items: flex-start; }
    .table-stack tbody td::before { flex: 0 0 38%; }
    .table-stack tbody td > * { max-width: 62% !important; }
    .table-stack tbody td .text-truncate { white-space: normal; }
    .table-stack tbody td[colspan] { justify-content: center; text-align: center; }
    .table-stack tbody td[colspan]::before { content: none; }
    .page-header .actions { margin-left: 0; width: 100%; }
}

/* stato dinamico dei campi secondo le regole */
.fcol { transition: opacity .15s; }
.fcol.fld-absent { opacity: .45; }
.fcol.fld-absent .form-control, .fcol.fld-absent .form-select, .fcol.fld-absent .ts-control { background-color: color-mix(in srgb, var(--rd-bg) 80%, var(--rd-card)) !important; cursor: not-allowed; }
.fcol.fld-required .cond, .fcol.fld-absent .cond { display: none; }
.dyn-state { font-size: .66rem; font-weight: 600; border-radius: 4px; padding: 0 .3rem; }
.dyn-state:empty { display: none; }
.dyn-state.required { color: #b91c1c; background: rgba(220,38,38,.1); }
.dyn-state.absent { color: var(--rd-muted); background: color-mix(in srgb, var(--rd-bg) 70%, var(--rd-card)); border: 1px solid var(--rd-border); }

/* etichette su più righe con campi allineati in basso */
/* le colonne dei campi restano allineate anche quando compaiono i messaggi di errore:
   etichetta di altezza fissa (due righe) e messaggio su una riga sola, fuori dal calcolo dell'allineamento */
.fcol { display: flex; flex-direction: column; }
.fcol > .field-label { min-height: 2.5em; align-items: flex-start; margin-bottom: .2rem; }
.fcol > .field-label > span:nth-child(2) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fcol > .fwrap { position: relative; }
.fcol .field-label { align-items: flex-start; }
.fcol .field-label > span:nth-child(2) { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; }
.field-label .req, .field-label .cond, .dyn-state { white-space: nowrap; flex-shrink: 0; }
.field-label .fnum { flex-shrink: 0; }
.mov-radio .btn:last-of-type { flex: 0 0 2.6rem; }

/* requisiti password */
.pwd-box { border: 1px solid var(--rd-border); border-radius: .6rem; padding: .75rem 1rem; background: color-mix(in srgb, var(--rd-bg) 60%, var(--rd-card)); height: 100%; }
.pwd-rules li { padding: .15rem 0; color: var(--rd-muted); }
.pwd-rules li i { margin-right: .35rem; }
.pwd-rules li.ok { color: #15803d; }
.pwd-rules li.ko { color: #b91c1c; }
.validation-summary-valid { display: none !important; }

/* menu a tendina con ricerca (Tom Select): colori leggibili anche con il tema scuro */
.ts-control, .ts-control input, .ts-control .item, .ts-dropdown, .ts-dropdown .option, .ts-dropdown .create, .ts-dropdown .no-results { color: var(--bs-body-color) !important; }
.ts-dropdown .option small { color: var(--bs-secondary-color); }
.ts-dropdown .active, .ts-dropdown .active.create { background-color: var(--bs-tertiary-bg); color: var(--bs-emphasis-color) !important; }
.ts-dropdown [data-selectable] .highlight { background: rgba(250, 204, 21, .35); }
.plugin-dropdown_input .dropdown-input { color: var(--bs-body-color); background: var(--bs-body-bg); border-color: var(--bs-border-color); }
.ts-control input::placeholder, .plugin-dropdown_input .dropdown-input::placeholder { color: var(--bs-secondary-color); }
.ts-dropdown { border-color: var(--bs-border-color) !important; }
[data-bs-theme="dark"] .ts-wrapper.single .ts-control { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
[data-bs-theme="dark"] .ts-wrapper.disabled .ts-control { opacity: .6; }
.ts-wrapper.single .ts-control { flex-wrap: nowrap; }
.ts-wrapper.single .ts-control .item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 100%; display: block; }

/* nessun carattere monospazio nell'applicazione */
code, kbd, samp, pre, .file-preview, .font-monospace { font-family: var(--bs-body-font-family) !important; font-variant-numeric: tabular-nums; }
.form-control.mono, .form-select.mono { font-size: 1rem; }
.form-control-sm.mono { font-size: .875rem; }

/* logo ExciseFlow */
.brand-logo { width: 38px; height: 38px; flex-shrink: 0; display: block; border-radius: 22%; box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 4px 12px rgba(13,148,136,.35); }
.auth-hero .brand-logo { width: 44px; height: 44px; }
