/* Gestionale Noleggio — stile base pulito (login + dashboard) */
:root { --brand: #84586c; --bg: #f4f5f7; --card: #ffffff; --text: #1f2430; --muted: #6b7280; --border: #e5e7eb; }
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }

/* ---- Login / pagine centrate ---- */
.login-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, #2b2230 100%); padding: 20px; }
.login-card { background: var(--card); width: 100%; max-width: 380px; border-radius: 14px; padding: 32px 28px;
    box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo i { font-size: 30px; color: var(--brand); display: block; margin-bottom: 8px; }
.login-logo span { font-size: 19px; font-weight: 700; }
.login-sub { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.fld { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 12px;
    padding: 0 12px; background: #fbfbfc; position: relative; }
.fld span { color: var(--muted); margin-right: 8px; }
.fld input { border: 0; outline: 0; background: transparent; padding: 13px 0; width: 100%; font-size: 14px; }
.toggle-eye { position: absolute; right: 12px; color: var(--muted); cursor: pointer; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.btn-login { width: 100%; border: 0; border-radius: 9px; background: var(--brand); color: #fff; font-size: 15px;
    font-weight: 600; padding: 13px; cursor: pointer; transition: filter .15s; }
.btn-login:hover { filter: brightness(1.08); }
.login-error { background: #fdecec; color: #b42318; border: 1px solid #f5c2c0; border-radius: 9px;
    padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.login-recover { text-align: center; margin-top: 14px; font-size: 12px; }
.login-recover a, .login-sub a { color: var(--brand); text-decoration: none; }
.login-footer { color: rgba(255,255,255,.8); font-size: 12px; margin-top: 18px; }

/* ---- Dashboard ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff;
    padding: 12px 20px; }
.topbar-brand { font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.btn-logout { color: #fff; text-decoration: none; background: rgba(255,255,255,.15); padding: 7px 12px; border-radius: 8px; }
.btn-logout:hover { background: rgba(255,255,255,.28); }
.content { max-width: 900px; margin: 26px auto; padding: 0 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 26px; }
.card h1 { font-size: 20px; margin: 0 0 8px; }
.card h2 { font-size: 15px; margin: 22px 0 10px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.55; }
.small { font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { border: 1px solid var(--border); border-radius: 11px; padding: 15px; background: #fbfbfc; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 19px; font-weight: 700; margin-top: 4px; }
.lista-aziende { list-style: none; padding: 0; margin: 0; }
.lista-aziende li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.lista-aziende li i { color: var(--brand); margin-right: 6px; }
.badge { background: var(--brand); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-left: 8px; }

/* ============================================================
   APP SHELL (topbar + sidenav + main)
   ============================================================ */
body.app { background: var(--bg); }
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 100;
    display: flex; align-items: center; gap: 14px; padding: 0 16px;
    background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.topbar-brand { font-weight: 700; font-size: 15px; text-decoration: none; color: inherit; cursor: pointer; }
.topbar-brand:hover { opacity: .85; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar-azienda { background: rgba(255,255,255,.16); padding: 5px 10px; border-radius: 8px; }
.azienda-switch { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.16); padding: 3px 8px; border-radius: 8px; margin: 0; }
.azienda-switch i { font-size: 12px; opacity: .9; }
.azienda-switch select { background: transparent; border: 0; color: #fff; font-size: 13px; font-family: inherit; cursor: pointer; max-width: 200px; outline: 0; }
.azienda-switch select option { color: #222; }
.menu-toggle { display: none; background: transparent; border: 0; color: #fff; font-size: 18px; cursor: pointer; }

.sidenav { position: fixed; top: 56px; bottom: 0; left: 0; width: 240px; overflow-y: auto;
    background: #fff; border-right: 1px solid var(--border); padding: 14px 10px; z-index: 90; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    padding: 14px 10px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
    color: var(--text); text-decoration: none; font-size: 14px; margin-bottom: 2px; }
.nav-item i { width: 18px; text-align: center; color: var(--muted); }
.nav-item:hover { background: #f1eef1; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.active i { color: #fff; }
.nav-soon { color: #aab0bb; cursor: default; }
.nav-soon i { color: #cfd4dc; }
.soon-badge { font-size: 10px; background: #eef0f3; color: #8a92a0; padding: 1px 7px; border-radius: 20px; margin-left: auto; }

.app-main { margin-left: 240px; margin-top: 56px; padding: 22px 26px; }
.nav-backdrop { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 4px 0 0; }
.page-head h1 i { color: var(--brand); margin-right: 6px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.back-link { font-size: 12px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--brand); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
    background: #fff; color: var(--text); border-radius: 9px; padding: 8px 14px; font-size: 13px;
    cursor: pointer; text-decoration: none; }
.btn:hover { background: #f6f6f8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn-danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1eef1; color: var(--text); }
.icon-btn { color: var(--brand); text-decoration: none; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: #f1eef1; }

/* Toolbar / search */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 240px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; }
.toolbar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; }

/* Table */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table.grid { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.grid td.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid td.nowrap, table.grid th { white-space: nowrap; }
table.grid thead th { text-align: left; background: #faf9fa; color: var(--muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: .03em; padding: 11px 14px; border-bottom: 1px solid var(--border); }
table.grid tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f0f2; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #faf7f9; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid .center { text-align: center; }
table.grid .empty { text-align: center; color: var(--muted); padding: 26px; }
.col-az { width: 70px; }
.badge-tipo { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; margin: 0 2px; color: #fff; }
.b-cli { background: #28a745; } .b-for { background: #007bff; } .b-par { background: #d99400; }

/* ------------------------------------------------------------------
   Lista a griglia (dlist) — base RIUTILIZZABILE per tutte le tabelle.
   Intestazione e righe usano le STESSE colonne => sempre allineate.
   Ogni lista definisce le proprie colonne con .dlist-<nome>.
   ------------------------------------------------------------------ */
.dlist-wrap { overflow-x: auto; }
.dlist { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 13px; min-width: 760px; }
.dlist-head, .dlist-row { display: grid; align-items: center; }
.dlist-head { background: #faf9fa; border-bottom: 1px solid var(--border); }
.dlist-head > div { padding: 11px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.dlist-row { border-bottom: 1px solid #f0f0f2; cursor: pointer; }
.dlist-row:last-child { border-bottom: 0; }
.dlist-row:hover { background: #faf7f9; }
.dlist-row > div { padding: 11px 14px; min-width: 0; }   /* min-width:0 = permette l'ellissi nella griglia */
.dlist .ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlist .center { text-align: center; }
.dlist .nowrap { white-space: nowrap; }
.dlist-empty { padding: 26px; text-align: center; color: var(--muted); }

/* Colonne della lista Clienti */
.dlist-clienti .dlist-head, .dlist-clienti .dlist-row {
    grid-template-columns: 2fr 1.1fr 1fr 1.2fr 1.1fr 1.7fr 64px;
}
/* Colonne della lista Articoli */
.dlist-articoli .dlist-head, .dlist-articoli .dlist-row {
    grid-template-columns: 56px 1fr 2.4fr 1.3fr 0.9fr 0.7fr 0.7fr 56px;
}
.dlist .right { text-align: right; }
.dlist .ok { color: #28a745; }
.dlist .ko { color: #c0392b; }
.thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; display: inline-block; }
.thumb-ph { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; background: #f0eef1; color: #c3c8d0; }

/* Utility */
.hidden { display: none !important; }

/* Box immagine scheda articolo */
.foto-box { border: 1px dashed var(--border); border-radius: 10px; min-height: 150px; display: flex; align-items: center; justify-content: center; background: #fbfbfc; overflow: hidden; }
.foto-preview { max-width: 100%; max-height: 220px; border-radius: 8px; }
.foto-ph { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #c3c8d0; }
.foto-ph i { font-size: 34px; }
.foto-actions { display: flex; gap: 10px; margin-top: 12px; }
.foto-actions .btn { position: relative; overflow: hidden; }

/* Tabella editabile in linea (tabelle di supporto) */
.etable-wrap { overflow-x: auto; }
.etable { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 640px; }
.etable-head { display: grid; align-items: center; background: #faf9fa; border-bottom: 1px solid var(--border); }
.etable-head > div { padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.etable-head > div.center { text-align: center; }
.etable-row { display: grid; align-items: center; border-bottom: 1px solid #f0f0f2; }
.etable-row:last-child { border-bottom: 0; }
.ecell { padding: 6px 8px; min-width: 0; }
.ecell.center { text-align: center; }
.ecell input[type=text], .ecell input[type=number], .ecell textarea { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 13px; font-family: inherit; }
.ecell textarea { resize: vertical; }
.ecell input[type=checkbox] { width: 16px; height: 16px; }
.ecell input:focus, .ecell textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(132,88,108,.12); }
.etable-row.saved { animation: savedflash .9s ease; }

/* ---- Lista Commesse ---- */
.dlist-documenti .dlist-head, .dlist-documenti .dlist-row {
    grid-template-columns: 70px 110px 2fr 110px 110px 120px 56px;
}
.dlist-preventivi .dlist-head, .dlist-preventivi .dlist-row {
    grid-template-columns: 70px 110px 2fr 100px 100px 120px 110px 56px;
}
.dlist-utenti .dlist-head, .dlist-utenti .dlist-row {
    grid-template-columns: 1.4fr 1fr 1.6fr 120px 110px 150px 56px;
}
.dlist-accessi .dlist-head, .dlist-accessi .dlist-row {
    grid-template-columns: 160px 1.4fr 1fr 2.2fr;
}
/* Luoghi di consegna: lista modificabile inline */
.lgh-wrap { overflow-x: auto; }
.lgh-table { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 960px; }
.lgh-head, .lgh-row { display: grid; grid-template-columns: 1.3fr 1.2fr 1.5fr 72px 1fr 60px 120px 76px; align-items: center; }
.lgh-head { background: #faf8f9; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--muted); }
.lgh-head > div { padding: 9px 8px; }
.lgh-row { border-bottom: 1px solid #f0f0f2; }
.lgh-row:last-child { border-bottom: 0; }
.lgh-row > div { padding: 6px 8px; min-width: 0; }
.lgh-row input { width: 100%; border: 1px solid transparent; border-radius: 7px; padding: 7px 8px; font-size: 13px; font-family: inherit; background: transparent; }
.lgh-row input:hover { border-color: var(--border); background: #fff; }
.lgh-row input:focus { outline: 0; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(132,88,108,.12); }
.lgh-cli a { color: var(--brand); text-decoration: none; font-weight: 600; }
.lgh-gen { display: inline-block; font-size: 11px; font-weight: 700; color: #46617f; background: #e8eff6; border-radius: 12px; padding: 2px 10px; }
.lgh-act { display: flex; align-items: center; gap: 6px; justify-content: center; }
.lgh-status { font-size: 12px; font-weight: 700; min-width: 12px; }
.lgh-status.ok { color: #1a9d5a; } .lgh-status.err { color: #c0392b; } .lgh-status.saving { color: var(--muted); }

/* Calendario */
.cal-title { font-weight: 700; font-size: 15px; margin-left: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg-btn { padding: 8px 14px; font-size: 13px; color: #555; text-decoration: none; background: #fff; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--brand); color: #fff; }
.btn.btn-on { background: #f4eef1; border-color: var(--brand); color: #4a2e3c; }
.cal { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: #faf8f9; border-bottom: 1px solid var(--border); }
.cal-head > div { padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 108px; border-right: 1px solid #f0eef0; border-bottom: 1px solid #f0eef0; padding: 6px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-dim { background: #fcfbfc; }
.cal-dim .cal-daynum { color: #c4c4c8; }
.cal-today { background: #f7f1f4; }
.cal-daynum { font-size: 12px; font-weight: 700; color: #555; margin-bottom: 2px; }
.cal-today .cal-daynum { color: var(--brand); }
.cal-lanes { display: flex; flex-direction: column; gap: 3px; }
.cal-lane-empty { height: 18px; }
.cal-ev { display: block; height: 18px; font-size: 11px; line-height: 18px; padding: 0 6px; background: #eef; color: #33418a;
    text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev:hover { filter: brightness(.96); }
/* barre continue: inizio / intermedio / fine / singolo */
.cal-ev.is-start  { margin-left: -6px; padding-left: 8px; border-top-left-radius: 5px; border-bottom-left-radius: 5px; border-left: 3px solid rgba(0,0,0,.18); }
.cal-ev.is-mid    { margin: 0 -6px; }
.cal-ev.is-end    { margin-right: -6px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; box-shadow: inset -3px 0 0 rgba(0,0,0,.12); }
.cal-ev.is-single { margin: 0; border-radius: 5px; border-left: 3px solid rgba(0,0,0,.18); }
/* Eventi: testo bianco sui colori pieni (singolo / sfumatura multi-giorno via stile inline) */
.cal-evt { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.14); }
.cal-evt.is-start, .cal-evt.is-single { border-left: 3px solid rgba(0,0,0,.22); }
/* Scadenze: colore dedicato (viola), scadute in rosa/rosso */
.cal-scad { background: #e7ddf5 !important; color: #58399a; border-radius: 5px; margin-top: 2px; }
.cal-scad.is-overdue { background: #f7d6e6 !important; color: #a12468; font-weight: 700; }
.cal-scad i { font-size: 10px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cal-dot.st-confermato { background: #d9f0e2; } .cal-dot.st-bozza { background: #ece6ea; } .cal-dot.st-completato { background: #e2eaf3; }
.cal-dot-scad { background: #fdeccf; }
.cal-dot-grad { background: linear-gradient(90deg, #7ab3d3, #9a8fc7, #d68494); }
/* Vista settimana: celle più alte */
.cal-week .cal-cell { min-height: 340px; }
/* Widget compatto (dashboard) */
.cal-compact { border: 0; }
.cal-compact .cal-cell { min-height: 62px; padding: 4px; }
.cal-compact .cal-daynum { font-size: 11px; margin-bottom: 1px; }
.cal-compact .cal-ev { height: 15px; line-height: 15px; font-size: 10px; }
.cal-compact .cal-lane-empty { height: 15px; }
@media (max-width: 640px) { .cal-cell { min-height: 80px; } .cal-ev { font-size: 10px; } .cal-week .cal-cell { min-height: 200px; } }
/* Dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.kpi:hover { box-shadow: 0 6px 18px rgba(40,20,30,.08); transform: translateY(-1px); }
.kpi-ico { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #f4eef1; color: var(--brand); font-size: 17px; flex-shrink: 0; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.kpi-value { font-size: 22px; font-weight: 700; color: #2b2b2b; line-height: 1.1; }
.kpi-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-alert .kpi-ico { background: #fbeaea; color: #c0392b; }
.kpi-alert .kpi-value { color: #c0392b; }
.kpi-warn .kpi-ico { background: #fdf3e3; color: #b9770e; }
.dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .dash-2col { grid-template-columns: 1fr; } }
.dash-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid #f0f0f2; text-decoration: none; color: inherit; }
.dash-row:last-child { border-bottom: 0; }
.dash-row:hover { background: #faf7f9; }
.dash-date { font-size: 12.5px; font-weight: 600; color: #555; width: 82px; flex-shrink: 0; }
.dash-date.is-overdue { color: #c0392b; }
.dash-main { flex: 1; font-size: 13.5px; min-width: 0; }
.dash-amt { font-size: 13.5px; font-weight: 600; white-space: nowrap; }

/* CRM: invio campagna (barra progresso) */
.send-prog { margin-top: 12px; }
.send-bar { height: 10px; background: #eee; border-radius: 6px; overflow: hidden; }
.send-bar-fill { height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }

/* CRM: liste template/campagne + anteprima email */
.dlist-templates .dlist-head, .dlist-templates .dlist-row { grid-template-columns: 1.4fr 2fr 150px 56px; }
.dlist-campagne .dlist-head, .dlist-campagne .dlist-row { grid-template-columns: 1.4fr 1.8fr 1fr 100px 100px 110px 56px; }
.mail-prev { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mail-prev-subj { padding: 10px 14px; background: #faf8f9; border-bottom: 1px solid var(--border); font-size: 14px; }
.mail-prev-body { padding: 16px 18px; font-size: 14px; line-height: 1.55; }
.mail-prev-body a { color: var(--brand); }

/* Controllo disponibilità in riga documento */
.qta-cell { display: flex; flex-direction: column; gap: 2px; }
.disp-badge { font-size: 10px; line-height: 1.1; white-space: nowrap; text-align: right; cursor: pointer; }
.disp-badge:hover { text-decoration: underline; }
.disp-badge.db-ok { color: #2b7a4b; }
.disp-badge.db-neg { color: #b02a2a; font-weight: 700; }
.disp-badge.db-cal { color: var(--brand); }
.rtable-row.row-overbook { box-shadow: inset 3px 0 0 #d9534f; background: #fdf5f5; }

/* Righe documento: griglia con handle drag + azioni, blocco/modifica */
.rtable-doc { min-width: 920px; }
.rtable-doc .rtable-head, .rtable-doc .rtable-row { grid-template-columns: 26px 32px 82px 2fr 56px 70px 80px 54px 82px 96px 62px; }
.drag-h { display: flex; align-items: center; justify-content: center; color: #c3c0c4; cursor: grab; }
.drag-h:active { cursor: grabbing; }
.rtable-row.dragging { opacity: .55; background: #f4eef1; }
.row-act { display: flex; gap: 4px; justify-content: center; }
.rtable-row.locked input, .rtable-row.locked select {
    background: transparent; border-color: transparent; color: #2b2b2b; -webkit-text-fill-color: #2b2b2b; opacity: 1; cursor: default;
}
.rtable-row.locked .c-iva { -webkit-appearance: none; appearance: none; }
.rtable-row:not(.locked) { background: #fbf7f9; }
.rtable-row:not(.locked) input, .rtable-row:not(.locked) select { border-color: var(--border); background: #fff; }
.icon-btn.edit:hover { color: var(--brand); }

/* Box aggiungi riga: campi con etichetta */
.riga-add { align-items: end; }
.add-fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; margin: 0; }
.add-fld > span { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Modale generico */
.modal-overlay { position: fixed; inset: 0; background: rgba(30,18,26,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 500; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.hidden { display: none; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 20px 22px; }
.modal-close { position: absolute; top: 10px; right: 14px; border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: #333; }

/* Pop-up disponibilità articolo */
.pop-head { margin-bottom: 12px; padding-right: 24px; }
.pop-head > div:first-child { font-size: 15px; }
.pop-sec-h { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; font-weight: 700; font-size: 13px; color: #4a2e3c; }
.pop-nav { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 12px; color: #555; }
.pop-nav a { cursor: pointer; color: var(--brand); }
.pop-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pop-cell { border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px; text-align: center; }
.pop-dow { display: block; font-size: 10px; color: var(--muted); }
.pop-av { display: block; font-size: 15px; font-weight: 700; }
.pop-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 2px; }
.pop-mdow { font-size: 10px; color: var(--muted); text-align: center; font-weight: 600; padding: 2px 0; }
.pop-mcell { border: 1px solid #f0eef0; border-radius: 6px; min-height: 40px; padding: 3px; text-align: center; }
.pop-mnum { display: block; font-size: 10px; color: #888; }
.pop-mav { display: block; font-size: 13px; font-weight: 700; }
.pop-dim { background: #fcfbfc; color: #c4c4c8; }
/* riuso colori disp-* per pop-cell/pop-mcell */
.pop-cell.disp-full, .pop-mcell.disp-full { color: #2b7a4b; }
.pop-cell.disp-part, .pop-mcell.disp-part { background: #f4ecf1; color: #6a4b5c; }
.pop-cell.disp-zero, .pop-mcell.disp-zero { background: #fdecc7; color: #8a5a08; }
.pop-cell.disp-neg,  .pop-mcell.disp-neg  { background: #f7caca; color: #a11; }
.pop-cell.disp-today, .pop-mcell.disp-today { box-shadow: inset 0 0 0 2px rgba(132,88,108,.35); }

/* Disponibilità articoli (griglia) */
.disp-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.disp-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.disp-table th, .disp-table td { border-bottom: 1px solid #f0eef0; border-right: 1px solid #f4f2f4; padding: 7px 8px; text-align: center; white-space: nowrap; }
.disp-table thead th { background: #faf8f9; font-size: 11px; color: var(--muted); position: sticky; top: 0; z-index: 2; }
.disp-table .disp-dow { display: block; font-weight: 600; }
.disp-table .disp-dnum { display: block; font-size: 13px; color: #444; }
.disp-art { text-align: left !important; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 200px; max-width: 260px; }
.disp-table thead .disp-art { z-index: 3; background: #faf8f9; }
.disp-art a { text-decoration: none; color: inherit; }
.disp-art .disp-descr { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.disp-gia { position: sticky; left: 200px; background: #fff; z-index: 1; font-weight: 600; color: #555; }
.disp-table thead .disp-gia { z-index: 3; background: #faf8f9; left: 200px; }
.disp-cell { font-weight: 600; }
.disp-full { color: #2b7a4b; }
.disp-part { background: #f4ecf1; color: #6a4b5c; }
.disp-zero { background: #fdecc7; color: #8a5a08; }
.disp-neg  { background: #f7caca; color: #a11; }
.disp-we { background: #fbfafb; }
.disp-today { box-shadow: inset 0 0 0 2px rgba(132,88,108,.25); }

/* Badge tipo documento (specchietto documenti cliente) */
.doc-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: #4a2e3c; background: #f4eef1; border-radius: 20px; padding: 3px 10px; white-space: nowrap; flex-shrink: 0; min-width: 96px; }
.doc-badge i { font-size: 10px; color: var(--brand); }

/* Tag picker (scheda cliente) */
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-picker .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 13px; cursor: pointer; background: #fff; }
.tag-picker .chip:has(input:checked) { background: #f4eef1; border-color: var(--brand); color: #4a2e3c; font-weight: 600; }

/* Editor testo formattato (rte.js) */
.rte-native { display: none !important; }
.rte-wrap { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.rte-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; background: #faf8f9; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rte-btn { border: 0; background: transparent; color: #4a2e3c; width: 30px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.rte-btn:hover { background: #f0e7ec; }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rte-area { min-height: 120px; max-height: 320px; overflow-y: auto; padding: 12px 14px; font-size: 14px; line-height: 1.5; outline: 0; }
.rte-area:focus { box-shadow: inset 0 0 0 2px rgba(132,88,108,.10); }
.rte-area a { color: var(--brand); }
.rte-area ul, .rte-area ol { margin: 6px 0 6px 22px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .f-full { grid-column: 1 / -1; }
.form-grid .hint { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.badge-stato { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; color: #fff; }
.st-bozza { background: #8a92a0; }
.st-confermato { background: #2c7be5; }
.st-completato { background: #28a745; }
.st-annullato { background: #c0392b; }
.date-lab { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.date-lab input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* ---- Editor righe commessa ---- */
.riga-add { display: grid; grid-template-columns: 2fr 2.2fr 70px 70px 90px 70px 80px 44px; gap: 8px; margin-bottom: 14px; }
.riga-add select, .riga-add input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; font-size: 13px; width: 100%; font-family: inherit; }
.riga-add .btn { padding: 8px; }

.rtable-wrap { overflow-x: auto; }
.rtable { min-width: 860px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.rtable-head, .rtable-row { display: grid; grid-template-columns: 40px 90px 2fr 70px 70px 90px 70px 100px 100px 44px; align-items: center; }
.rtable-head { background: #faf9fa; border-bottom: 1px solid var(--border); }
.rtable-head > div { padding: 8px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.rtable-row { border-bottom: 1px solid #f0f0f2; }
.rtable-row:last-child { border-bottom: 0; }
.rtable-row > div { padding: 4px 6px; min-width: 0; }
.rtable-row .num { color: var(--muted); font-size: 12px; }
.rtable-row .cod { font-size: 12px; }
.rtable-row .imp { font-weight: 600; white-space: nowrap; }
.rtable-row input, .rtable-row select { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 7px; font-size: 13px; font-family: inherit; }
.rtable-row input.right { text-align: right; }
.rtable .right { text-align: right; }
.rtable-row.saved { animation: savedflash .9s ease; }

/* ---- Totali ---- */
.tot-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.tot-row.tot-tot { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 12px; font-size: 16px; }
.tot-row.tot-tot strong { color: var(--brand); }

/* ---- Scadenze ---- */
.sub-row-scad { grid-template-columns: 150px 1fr 120px 90px 40px; }
.sub-row input[type=checkbox] { width: auto; padding: 0; }
.scad-pag { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; border: 0 !important; }
.quadr { margin-top: 12px; font-size: 13px; font-weight: 600; }
.quadr.ok { color: #28a745; }
.quadr.warn { color: #b8860b; }

/* ---- Lista DDT ---- */
.dlist-ddt .dlist-head, .dlist-ddt .dlist-row {
    grid-template-columns: 60px 100px 130px 1.6fr 1fr 110px 50px;
}
.badge-tipo.b-eme { background: #2c7be5; }
.badge-tipo.b-ric { background: #8a92a0; }

/* ---- Rientro merce ---- */
.dlist-rientri .dlist-head, .dlist-rientri .dlist-row {
    grid-template-columns: 60px 100px 1.6fr 100px 110px 110px 110px 50px;
}
.dlist .rott { color: #b45309; font-weight: 600; }
.rtable-rientro .rtable-head, .rtable-rientro .rtable-row {
    grid-template-columns: 40px 90px 2fr 80px 90px 90px 100px 90px 100px 44px;
}
.rtable-gen .rtable-head, .rtable-gen .rtable-row {
    grid-template-columns: 90px 2fr 90px 90px 100px 110px;
}
.rtable-row .ro { color: var(--muted); padding: 8px 6px; font-size: 13px; white-space: nowrap; }
.rtable-row .rott { color: #b45309; font-weight: 600; white-space: nowrap; }
.rott-tot { color: #b45309 !important; }

/* ---- Fatture ---- */
.dlist-fatture .dlist-head, .dlist-fatture .dlist-row {
    grid-template-columns: 60px 90px 110px 1.5fr 100px 90px 110px 110px 50px 50px;
}
.badge-tipo.b-imm { background: #2c7be5; }
.badge-tipo.b-dif { background: #d99400; }
.rtable-fattura { min-width: 980px; }
.rtable-fattura .rtable-head, .rtable-fattura .rtable-row {
    grid-template-columns: 40px 90px 80px 2fr 60px 60px 85px 60px 90px 100px 40px;
}
.riga-add-f { grid-template-columns: 90px 1.6fr 1.6fr 60px 60px 85px 60px 80px 40px; }
.fe-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 12px; background: #faf7f9; }
.fe-title { font-size: 12px; font-weight: 700; color: var(--brand); margin-bottom: 10px; }
.rtable-genf { min-width: 640px; }
.rtable-genf .rtable-head, .rtable-genf .rtable-row { grid-template-columns: 44px 80px 110px 1fr 130px; }
.rtable-genf input[type=checkbox] { width: 16px; height: 16px; }
.rtable-gendt { min-width: 720px; }
.rtable-gendt .rtable-head, .rtable-gendt .rtable-row { grid-template-columns: 44px 70px 100px 1fr 120px 160px; }
.rtable-gendt input[type=checkbox] { width: 16px; height: 16px; }
.rtable-gennc { min-width: 560px; }
.rtable-gennc .rtable-head, .rtable-gennc .rtable-row { grid-template-columns: 44px 80px 110px 120px 1fr; }
.rtable-gennc input[type=radio] { width: 16px; height: 16px; }
.rtable-xml { min-width: 680px; }
.rtable-xml .rtable-head, .rtable-xml .rtable-row { grid-template-columns: 44px 70px 100px 90px 1fr 120px 50px; }
.rtable-xml input[type=checkbox] { width: 16px; height: 16px; }
.chk-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dlist-notecr .dlist-head, .dlist-notecr .dlist-row {
    grid-template-columns: 60px 90px 1.4fr 130px 100px 90px 110px 100px 50px 50px;
}
.fe-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---- Menu a tendina cercabili (searchselect) ---- */
.ss-native { display: none !important; }
.ss-wrap { position: relative; width: 100%; }
.ss-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
    border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit;
    background: #fff; cursor: pointer; text-align: left; color: var(--text); }
.ss-control:hover { border-color: #cbd0d8; }
.ss-open .ss-control { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(132,88,108,.12); }
.ss-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-val.ss-ph { color: var(--muted); }
.ss-caret { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.ss-pop { position: absolute; z-index: 200; top: calc(100% + 4px); left: 0; right: 0; min-width: 220px; background: #fff;
    border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.16); overflow: hidden; }
.ss-search-wrap { position: relative; padding: 8px; border-bottom: 1px solid var(--border); }
.ss-search-wrap i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.ss-search { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px 7px 30px; font-size: 13px; font-family: inherit; }
.ss-search:focus { outline: 0; border-color: var(--brand); }
.ss-list { max-height: 260px; overflow-y: auto; }
.ss-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-opt:hover { background: #f4eef1; }
.ss-opt.sel { background: #f1eef1; font-weight: 600; }
.ss-more { padding: 8px 12px; font-size: 12px; color: var(--muted); font-style: italic; }

/* Pager */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; gap: 10px; }
.pager-info { color: var(--muted); font-size: 13px; }
.pager-btns { display: flex; gap: 8px; }
.per-form { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
.per-form label { color: var(--muted); font-size: 13px; }
.per-form select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; }

/* Panels / form */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 18px; overflow: visible; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; background: #faf9fa;
    border-top-left-radius: 12px; border-top-right-radius: 12px; }
.panel-h i { color: var(--brand); margin-right: 6px; }
.panel-b { padding: 16px; }
.panel-soon { opacity: .7; }
.panel-soon .panel-h { color: var(--muted); }

/* Pulsante piccolo + sotto-sezioni scheda (sconti / luoghi) */
.btn-sm { padding: 5px 10px; font-size: 12px; }
.sub-row { display: grid; align-items: center; gap: 8px; margin-bottom: 8px; }
.sub-row-sconto { grid-template-columns: 1fr 130px 40px; }
.sub-row select, .sub-row input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; width: 100%; font-family: inherit; }
.sub-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fbfbfc; }
.sub-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sub-card-grid .full { grid-column: 1 / -1; }
.f2 { display: flex; flex-direction: column; }
.f2 > span { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.f2 input { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 13px; width: 100%; font-family: inherit; }
.sub-card-act { margin-top: 8px; text-align: right; }
.icon-btn.del { color: #b42318; }
.saved { animation: savedflash .9s ease; border-radius: 8px; }
@keyframes savedflash { 0% { box-shadow: 0 0 0 2px rgba(40,167,69,.55); } 100% { box-shadow: 0 0 0 2px rgba(40,167,69,0); } }
@media (max-width: 700px) { .sub-card-grid { grid-template-columns: 1fr 1fr; } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr 1fr; } }
.f { margin-bottom: 12px; display: flex; flex-direction: column; }
.f label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.f input, .f select, .f textarea { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
    font-size: 14px; font-family: inherit; background: #fff; width: 100%; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(132,88,108,.12); }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
    border-radius: 20px; padding: 7px 13px; font-size: 13px; cursor: pointer; background: #fff; }

/* Save status */
.save-status { font-size: 12px; color: var(--muted); min-width: 90px; text-align: right; }
.save-status.saving { color: #b8860b; }
.save-status.ok { color: #28a745; }
.save-status.err { color: #b42318; }

/* Notice / tiles / quick links */
.notice { background: #eef4fb; border: 1px solid #cfe0f3; color: #245; border-radius: 10px; padding: 11px 14px; font-size: 13px; margin-bottom: 16px; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 4px; }
.quick-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); }
.quick-card i { font-size: 26px; color: var(--brand); }
.quick-card:hover { border-color: var(--brand); }
.quick-card.disabled { color: var(--muted); opacity: .65; }
.quick-card.disabled i { color: #cbd0d8; }

@media (max-width: 860px) {
    .menu-toggle { display: inline-block; }
    .sidenav { transform: translateX(-100%); transition: transform .2s; }
    body.nav-open .sidenav { transform: translateX(0); }
    .app-main { margin-left: 0; }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.3); z-index: 80; }
}

/* Generatore documenti — scelta destinazione (nuovo / accoda) */
.gen-target { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px;
    padding: 12px 14px; background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px; }
.gen-target .radio-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; cursor: pointer; }
.gen-target .radio-line input[type="radio"] { margin: 0; }
.gen-target select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; max-width: 100%; }
.gen-target select:disabled { background: #eef1f5; color: var(--muted); }

/* Riga cliente con pulsante "nuovo cliente" nella scheda documento */
.cli-row { display: flex; gap: 6px; align-items: stretch; }
.cli-row select { flex: 1; min-width: 0; }
.cli-row .btn-sm { flex: 0 0 auto; padding: 0 10px; }

/* ===== Statistiche ===== */
.stat-badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-badge { background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-badge-lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-badge-val { font-size: 20px; font-weight: 700; margin-top: 4px; }
.stat-yoy { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-yoy-box { background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-yoy-val { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-yoy-val.st-up { color: #1a7f37; }
.stat-yoy-val.st-down { color: #b42318; }
.stat-chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: 8px 4px 0; border-bottom: 1px solid var(--border); }
.stat-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.stat-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.stat-bar { width: 42%; min-height: 1px; border-radius: 3px 3px 0 0; }
.bar-prev { background: #cfd8e6; }
.bar-cur { background: #5b9bd5; }
.stat-chart-lab { font-size: 10px; color: var(--muted); margin-top: 5px; }
.stat-legend { display: flex; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.stat-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 3px; }
.stat-rank { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid #f0f0f2; text-decoration: none; color: var(--text); }
.stat-rank:last-child { border-bottom: none; }
.stat-rank:hover { background: #fafbfd; }
.stat-rank-n { flex: 0 0 22px; height: 22px; line-height: 22px; text-align: center; background: #eef2f8; border-radius: 6px; font-size: 12px; font-weight: 700; color: #567; }
.stat-rank-main { flex: 1; min-width: 0; }
.stat-rank-name { display: block; font-size: 13px; }
.stat-rank-bar { display: block; height: 6px; background: #eef1f5; border-radius: 4px; margin-top: 5px; overflow: hidden; }
.stat-rank-bar > span { display: block; height: 100%; background: #5b9bd5; border-radius: 4px; }
.stat-rank-val { flex: 0 0 auto; text-align: right; font-weight: 600; font-size: 13px; white-space: nowrap; }
@media (max-width: 720px) {
    .stat-badges { grid-template-columns: repeat(2, 1fr); }
    .stat-yoy { grid-template-columns: 1fr; }
}

/* Grafico a linee statistiche (SVG) */
.stat-line-wrap { width: 100%; }
.stat-line { width: 100%; height: auto; display: block; }

/* Barra strumenti CSV (articoli) */
.csv-toolbar { gap: 8px; flex-wrap: wrap; }
.csv-toolbar .csv-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.csv-toolbar .btn-imp { background: #fff8f0; border-color: #f0ddc4; }
.csv-toolbar .btn-imp:hover { border-color: #d97706; }

/* Impostazioni PDF — logo */
.pdf-logo-row { display: flex; gap: 18px; align-items: flex-start; }
.pdf-logo-prev { flex: 0 0 auto; width: 150px; height: 90px; border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fafbfc; overflow: hidden; }
.pdf-logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pdf-logo-prev .thumb-ph { color: #cbd0d8; font-size: 28px; }
