/* ==========================================================
   KPI Commerciali — foglio di stile
   Palette istituzionale Credit System (#375d96).
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Marchio */
  --brand:       #375d96;
  --brand-700:   #2a4875;
  --brand-300:   #8fb0d9;
  --brand-50:    #f1f5fa;

  /* Testo */
  --ink:         #1b1d21;
  --ink-2:       #5c6470;
  --ink-3:       #8d949f;

  /* Superfici */
  --bg:          #f6f7f9;
  --card:        #ffffff;
  --line:        #e7eaee;      /* divisori, bordi delle card: non deve gridare */
  --line-soft:   #f0f2f5;
  --line-strong: #c7ccd4;      /* bordo di input, select, pulsanti, pannelli: deve leggersi bene */

  /* Semantici */
  --pos:         #2f7d4f;
  --pos-bg:      #edf6f1;
  --neg:         #b42318;
  --neg-bg:      #fdf0ee;
  --warn-bg:     #fff6e8;
  --warn:        #8a5a12;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --sh-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --sh:    0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 8px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Cifre a larghezza fissa: le colonne di numeri restano allineate */
.num, table td, .stat-value, .kpi-value, .vol-value { font-variant-numeric: tabular-nums; }

h1 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 10px; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 650; letter-spacing: -.01em; margin: 0; }

p { margin: 0 0 12px; }
code {
  background: var(--brand-50);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hidden { display: none !important; }
.muted { color: var(--ink-2); font-size: 13px; }

/* Etichetta minuscola maiuscoletta, usata per i titoli di sezione */
.eyebrow {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
}

/* ==========================================================
   Struttura
   ========================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--sh-sm);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-head p { margin: 2px 0 0; }

.content { max-width: 1320px; margin: 0 auto; padding: 24px 22px 72px; }

/* ---------------- Barra superiore ---------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  height: 60px;
}
.topbar-brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.topbar-brand img { height: 19px; width: auto; display: block; }
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  padding-left: 13px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-name { font-weight: 600; font-size: 13.5px; }

.badge {
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-soft { background: var(--line-soft); color: var(--ink-2); }

/* ---------------- Schede ---------------- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  background: none;
  border: none;
  padding: 13px 14px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}
.tab::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: transparent;
  border-radius: 2px 2px 0 0;
  transition: background .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); font-weight: 650; }
.tab.active::after { background: var(--brand); }

.panel { display: none; }
.panel.active { display: block; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   Campi
   ========================================================== */
.field { display: block; margin-bottom: 15px; }
.field > .field-label,
label > .field-label { display: block; margin-bottom: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -.005em;
}
.field-hint { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }

/* Nota "campi bloccati" in Correzioni: leggibile ma senza il peso di un
   alert vero e proprio, che qui sarebbe già occupato da #ctrl-state. */
#ctrl-locked-note {
  background: var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

input[type="text"], input[type="password"], input[type="number"], select, .input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"] { font-variant-numeric: tabular-nums; }

/* Le frecce native dei campi numerici appesantiscono la griglia */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

input:focus, select:focus, .input:focus, .btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13);
}
input:disabled, select:disabled, input[readonly] {
  background: var(--line-soft);
  color: var(--ink-3);
  cursor: not-allowed;
}
input::placeholder { color: var(--ink-3); }

/* Menu a tendina con indicatore disegnato, non quello di sistema */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6470' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
select::-ms-expand { display: none; }

/* ==========================================================
   Menu a tendina disegnato
   Un CSS può ridecorare la casella chiusa di un <select>, ma la lista che
   si apre al click resta disegnata dal sistema operativo. Questo componente
   nasconde il <select> nativo (che resta la fonte di verità per valore ed
   eventi — il resto del codice continua a leggerlo/ascoltarlo invariato) e
   lo sostituisce con un pulsante e un pannello coerenti col resto dell'app.
   ========================================================== */
.xselect { position: relative; display: block; }
.xselect select { display: none; }

.xselect-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.xselect-btn:hover { border-color: #d8dce2; }
.xselect-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13);
}
.xselect-btn:disabled { background: var(--line-soft); color: var(--ink-3); cursor: not-allowed; }
.xselect-btn svg { flex: none; color: var(--ink-3); transition: transform .15s; }
.xselect-btn.is-open svg { transform: rotate(180deg); }
.xselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Compatta nella barra dei filtri, allineata al pulsante del calendario */
.toolbar .xselect-btn { height: 36px; font-size: 13px; }
.toolbar .xselect { width: auto; min-width: 165px; }
/* Ogni pulsante della barra filtri (es. "Esporta") alla stessa altezza di
   select, data e segmented control li' accanto: 36px, non un pixel diverso. */
.toolbar .btn { height: 36px; }

/* Ancora più compatta nelle righe di tabella (modifica ruolo in linea) */
.table-wrap .xselect-btn { height: 32px; padding: 0 8px; font-size: 12.5px; border-radius: 7px; }
.table-wrap .xselect { width: auto; min-width: 138px; }

/* position:fixed e coordinate in pixel calcolate da JS (positionPop()):
   il pannello è agganciato a <body>, mai a un antenato che potrebbe
   tagliarlo con un overflow impostato per lo scorrimento orizzontale. */
.xselect-pop {
  position: fixed;
  z-index: 120;
  max-height: 280px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 6px;
  animation: rise .16s ease both;
}
.xselect-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.xselect-item:hover, .xselect-item:focus-visible { background: var(--brand-50); outline: none; }
.xselect-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

fieldset { border: none; padding: 0; margin: 0 0 22px; }
fieldset legend { padding: 0; margin-bottom: 12px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.narrow { max-width: 260px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 15px;
}
.checkbox-label input { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); cursor: pointer; }

/* ==========================================================
   Pulsanti
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;            /* vale anche quando .btn è su un link */
  box-shadow: var(--sh-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { background: #fbfcfd; border-color: #b7bdc7; }
.btn:active { transform: translateY(.5px); }
.btn svg { flex: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(55, 93, 150, .25);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-primary:disabled { background: var(--brand-300); border-color: var(--brand-300); cursor: not-allowed; transform: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }
.btn-danger { color: var(--neg); }
.btn-danger:hover { background: var(--neg-bg); border-color: #f3d3ce; }

/* Gruppo di scelta compatto (periodo, metrica) */
.seg {
  display: inline-flex;
  align-items: center;
  background: var(--line-soft);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
/* Altezza esplicita (non affidata a padding+line-height): con i 3px di
   respiro di .seg, il gruppo risulta alto 36px come select, data e pulsanti
   della stessa barra — non un pixel in più o in meno. */
.seg button {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 0 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--sh-sm);
}

/* ==========================================================
   Messaggi
   ========================================================== */
/* Blocco, non flex: così un avviso che mescola testo e <code> resta
   un normale paragrafo e va a capo correttamente. */
.alert {
  border-radius: var(--r);
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
}
.alert svg { vertical-align: -3px; margin-right: 8px; }
.alert code { background: rgba(27, 29, 33, .07); }
.alert-ok    { background: var(--pos-bg);  color: #1f5c39; }
.alert-error { background: var(--neg-bg);  color: #8c1c14; }
.alert-info  { background: var(--brand-50); color: var(--brand-700); }
.alert-warn  { background: var(--warn-bg); color: var(--warn); }

.form-msg { font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.form-msg:not(:empty) { margin: 0 0 14px; }
.form-msg.ok { color: var(--pos); }
.form-msg.error { color: var(--neg); }

/* ==========================================================
   KPI — gerarchia a tre livelli
   ========================================================== */

/* Livello 1: indicatori principali */
.kpi-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.kpi-cell { background: var(--card); padding: 18px 20px 16px; }
.kpi-cell .kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
}
/* Pallino dello stesso colore della linea nel grafico: il numero e la sua
   traccia si riconoscono a colpo d'occhio, senza dover leggere le etichette. */
.kpi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--ink-3)); flex: none; }
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.15;
  margin-top: 7px;
  color: var(--dot, var(--ink));
}
.kpi-cell.is-missing .kpi-value { color: var(--ink-3); font-weight: 500; }
.kpi-cell.is-missing .kpi-dot { background: var(--ink-3); }
.kpi-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; }
.trend.up   { color: var(--pos); }
.trend.down { color: var(--neg); }
.trend.flat { color: var(--ink-3); }

/* Livello 2: indicatori secondari, riga sottile */
.kpi-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fcfdfe;
}
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 550; }
.stat-value { font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: var(--dot, var(--ink)); }
.stat.is-missing .stat-value { color: var(--ink-3); font-weight: 500; }
.stat.is-missing .kpi-dot { background: var(--ink-3); }

/* Livello 3: volumi, striscia compatta senza riquadri */
.vol-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.vol-item { padding: 0 20px; border-left: 1px solid var(--line-soft); flex: 0 0 auto; }
.vol-item:first-child { padding-left: 0; border-left: none; }
.vol-label {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
}
.vol-value { font-size: 18px; font-weight: 650; letter-spacing: -.025em; margin-top: 2px; }
.vol-item.is-missing .vol-value { color: var(--ink-3); font-weight: 500; }

/* ==========================================================
   Grafici
   ========================================================== */
.chart-wrap { position: relative; height: 330px; margin-top: 4px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 330px; color: var(--ink-3); font-size: 13.5px;
}

/* ==========================================================
   Tabelle
   ========================================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th.text, td.text { text-align: left; }
thead th {
  background: #fbfcfd;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfdfe; }
td.na { color: var(--ink-3); }

/* Riga "Totale complessivo" del Report giornaliero: stessa evidenziazione
   gialla usata nel foglio che si compilava a mano, per restare riconoscibile
   a chi legge l'email. */
tfoot .report-total td { background: #fff8b0; font-weight: 700; border-top: 2px solid var(--line-strong); }
td.strong { font-weight: 650; }
.empty-state {
  text-align: center;
  color: var(--ink-3);
  padding: 44px 20px;
  font-size: 13.5px;
}

/* ==========================================================
   Filtri
   ========================================================== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .field { margin-bottom: 0; }
.toolbar-sep { width: 1px; height: 24px; background: var(--line); }

/* ==========================================================
   Selettore periodo con calendario disegnato
   ========================================================== */
.daterange { position: relative; }
.daterange-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 13px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  font-variant-numeric: tabular-nums;
}
/* Compatto nella barra dei filtri, alla stessa altezza del select e della
   segmented control li' accanto — stesso schema di .toolbar .xselect-btn. */
.toolbar .daterange-btn { height: 36px; font-size: 13px; }
.daterange-btn:hover { border-color: #b7bdc7; }
.daterange-btn svg { color: var(--ink-3); flex: none; }

.cal {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: 0;
  width: 290px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 14px;
  animation: rise .16s ease both;
}
.cal.align-right { left: auto; right: 0; }
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title { font-size: 13.5px; font-weight: 650; }
.cal-nav {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}
.cal-nav:hover { background: var(--line-soft); }
.cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  padding-bottom: 6px;
}
.cal-day {
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.cal-day:hover:not(:disabled) { background: var(--brand-50); }
.cal-day.muted-day { color: var(--ink-3); opacity: .45; }
.cal-day:disabled { color: var(--ink-3); opacity: .3; cursor: not-allowed; }
.cal-day.in-range { background: var(--brand-50); border-radius: 0; }
.cal-day.edge { background: var(--brand); color: #fff; font-weight: 650; }
.cal-day.edge.start { border-radius: 7px 0 0 7px; }
.cal-day.edge.end   { border-radius: 0 7px 7px 0; }
.cal-day.edge.only  { border-radius: 7px; }
.cal-foot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.cal-preset {
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.cal-preset:hover { background: var(--brand-50); color: var(--brand); border-color: var(--brand-300); }
.cal-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; }

/* ==========================================================
   Accesso e installazione
   ========================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, #eaeff7 0%, rgba(234, 239, 247, 0) 62%),
    var(--bg);
}
.login-card, .setup-card {
  width: 100%;
  max-width: 394px;
  margin: 0 auto;
  padding: 32px;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
}
.setup-card { max-width: 520px; }
.login-logo { height: 30px; width: auto; display: block; margin: 0 auto 26px; }
.login-card h1 { font-size: 19px; margin-bottom: 5px; }
.login-card .muted { margin-bottom: 24px; }
.auth-foot { margin: 22px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-3); }

/* ==========================================================
   Finestra modale
   ========================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 26, 31, .5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade .15s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal.dialog-out { animation: fade-out .15s ease both; }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
.modal-box {
  max-width: 400px;
  width: 100%;
  margin: 0;
  box-shadow: var(--sh-lg);
  animation: rise .2s ease both;
}
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* Finestre modali create da JS (notifiche, conferme, richieste di un
   valore, domande in sequenza): stessa base visiva di .modal/.modal-box,
   sopra z-index più alto perché possono aprirsi da dentro un modale
   già presente (es. "Nuovo account"). Niente alert/confirm/prompt nativi
   del browser né notifiche a scomparsa automatica in tutto il progetto:
   ogni riscontro resta a schermo finché la persona non lo chiude lei. */
.dialog { z-index: 200; }
.dialog-title { font-size: 15.5px; font-weight: 700; margin-bottom: 10px; }
.dialog-body { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.dialog-body p { margin: 0 0 10px; }
.dialog-body p:last-child { margin-bottom: 0; }
.dialog-notify { display: flex; align-items: flex-start; gap: 10px; }
.dialog-notify svg { flex: none; margin-top: 2px; }
.dialog-notify-ok svg { color: var(--pos, #2f7d4f); }
.dialog-notify-error svg { color: var(--neg); }
.dialog-progress { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; margin: -4px 0 12px; }
.dialog-subject { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.dialog-error { margin-top: 8px; font-size: 12.5px; color: var(--neg); }
.dialog-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
}
.dialog-input:focus { outline: 2px solid var(--brand-300); outline-offset: 1px; }

/* ==========================================================
   Selettore di file custom (niente <input type=file> a vista)
   ========================================================== */
.filepick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filepick-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.filepick-name { font-size: 13px; color: var(--ink-3); }
.filepick-name.has-file { color: var(--ink); font-weight: 600; }

/* ==========================================================
   Adattamento a schermi stretti
   ========================================================== */
@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 60px; }
  .card { padding: 18px; border-radius: var(--r); }
  .toolbar { align-items: stretch; }
  .toolbar-sep { display: none; }
  .vol-item { padding: 8px 16px 8px 0; border-left: none; }
  .chart-wrap { height: 270px; }
}
@media (max-width: 560px) {
  .topbar { height: auto; padding: 12px 16px; }
  .topbar-title { display: none; }
  .tabs { padding: 0 10px; }
  .kpi-value { font-size: 26px; }
  .cal { width: calc(100vw - 44px); left: 0; }
  .login-card, .setup-card { padding: 24px; }
}
