/* Console gestore.
 *
 * Foglio di stile scritto per questa applicazione, non copiato dal gestionale.
 * Il precedente erano 6200 righe ereditate, con due blocchi :root in conflitto
 * (il secondo sovrascriveva il primo: raggi, ombre e colori cambiavano a meta'
 * file) e centinaia di regole per schermate che qui non esistono — contratti,
 * calendario, parco auto.
 *
 * Qui ci sono sette pagine e 73 classi. Tenerle tutte sotto controllo vale piu'
 * della comodita' di copiare.
 */

/* ========================================================================== */
/* Fondamenta                                                                 */
/* ========================================================================== */

:root {
  color-scheme: light;

  /* La imposta initFontScale() da JS, ma la pagina di accesso non carica la
     barra laterale: senza un valore qui, ogni calc() che la usa verrebbe
     scartato e la pagina resterebbe senza quelle proprieta'. */
  --ui-font-scale: 1;

  --bg: #f5f7fb;
  --card: #ffffff;
  --surface: #f9fafc;
  --surface-strong: #eef2f8;

  --text: #101828;
  --text-soft: #344054;
  --muted: #667085;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff4ff;

  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;

  --border: #e4e7ec;
  --border-strong: #d0d5dd;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --focus: 0 0 0 3px rgba(37, 99, 235, .18);

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

.eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2px;
}

/* ========================================================================== */
/* Impianto: barra laterale + contenuto                                       */
/* ========================================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; flex-direction: column; gap: 4px; padding: 2px 6px 4px; }
/* Variante chiara: sulla barra scura quella normale sparirebbe, perche' "Car"
   e' blu notte. */
.brand__img { width: 168px; height: auto; }
.brand__sub { font-size: 11px; color: #94a3b8; letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav__item[aria-current="page"],
.nav__item.is-active { background: var(--accent); color: #fff; }

.nav__icon { display: inline-flex; width: 17px; height: 17px; flex: 0 0 17px; }
.nav__icon svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.sidebar__footer { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 48px; max-width: 1400px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.topbar__meta { display: flex; gap: 26px; flex-wrap: wrap; }
.meta { display: flex; flex-direction: column; gap: 1px; }
.meta strong { font-size: 14px; font-weight: 600; }

.section { margin-bottom: 22px; }

.section__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ========================================================================== */
/* Pulsanti                                                                    */
/* ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text-soft);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-strong); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-strong); }

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.actions-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ========================================================================== */
/* Moduli                                                                      */
/* ========================================================================== */

.form { display: flex; flex-direction: column; gap: 18px; }

.grid { display: grid; gap: 16px; }
.grid.two-columns { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.accounting-form-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.full-width { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
input[readonly] { background: var(--surface-strong); color: var(--muted); }

label small { font-weight: 400; font-size: 12px; line-height: 1.45; }

.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Campo con un pulsante accanto: la prova di invio email. */
.campo-con-azione { display: flex; gap: 8px; align-items: stretch; }
.campo-con-azione input { flex: 1; }

/* ========================================================================== */
/* Tabelle                                                                     */
/* ========================================================================== */

.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }

.table--compact tbody td { padding: 9px 14px; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-meta { font-size: 12px; color: var(--muted); }

/* ========================================================================== */
/* Licenze                                                                     */
/* ========================================================================== */

.license-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.license-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .14s, border-color .14s;
}
.license-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

.license-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.license-card__name { font-size: 16px; font-weight: 650; }
.license-card__url { font-size: 12.5px; color: var(--muted); word-break: break-all; }

.license-card__foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.license-card__error {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.license-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.license-stat { display: flex; flex-direction: column; gap: 1px; }
.license-stat strong { font-size: 17px; font-weight: 650; }
.license-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Pastiglie di stato ------------------------------------------------------- */

.license-badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-strong);
  color: var(--text-soft);
}

.license-badge--online { background: var(--ok-soft); color: var(--ok); }
.license-badge--offline { background: var(--danger-soft); color: var(--danger); }
.license-badge--warning { background: var(--warn-soft); color: var(--warn); }
.license-badge--paused { background: var(--surface-strong); color: var(--muted); }

.license-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.auto-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.auto-status__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ========================================================================== */
/* Dettagli                                                                    */
/* ========================================================================== */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }

/* Filiali ------------------------------------------------------------------ */

.branch-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.branch-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 600;
}
.branch-tag--all { background: var(--surface-strong); color: var(--muted); }

.branch-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.branch-picker label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.branch-picker input { width: auto; }

/* ========================================================================== */
/* Accesso                                                                     */
/* ========================================================================== */
/* Stessa pagina del gestionale (static/style.css, blocco "Accesso"): stessa
   foto, stessa scheda, stesso marchio. Toccarne una vuol dire toccare l'altra. */
/* Foto a sinistra che sfuma nel blu a destra, scheda bianca sopra. Non e' una
   colonna netta: la sfumatura e' una velatura stesa su tutta la scena, cosi'
   la foto non finisce con un taglio. */
.login-body {
  min-height: 100vh;
  margin: 0;
  background: #071125;
}
.login-scena {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr min(470px, 100%) 0.5fr;
  grid-template-rows: 1fr auto;
  padding: clamp(24px, 4vw, 48px) clamp(24px, 5vw, 96px) clamp(20px, 3vw, 34px);
  background: #071125;
}
.login-scena::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 62%;
  background: url("/static/img/login-sfondo.jpg?v=3") left center / cover no-repeat;
  -webkit-mask-image: linear-gradient(to right, #000 38%, rgba(0, 0, 0, 0.55) 68%, transparent 100%);
  mask-image: linear-gradient(to right, #000 38%, rgba(0, 0, 0, 0.55) 68%, transparent 100%);
}
.login-scena::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(7, 17, 37, 0) 0%,
    rgba(7, 17, 37, 0) 30%,
    rgba(9, 24, 52, 0.3) 46%,
    rgba(11, 27, 58, 0.72) 58%,
    #0a1a35 70%,
    #071125 100%);
}
/* Archi in alto a destra e trama di puntini in basso: sono nel mockup, e
   riempiono il blu senza aggiungere un'altra immagine da scaricare. */
.login-scena__trama {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-radial-gradient(circle at 116% -14%,
      rgba(150, 190, 255, 0) 0 34px, rgba(150, 190, 255, 0.07) 34px 35px) no-repeat,
    radial-gradient(circle at 1px 1px, rgba(160, 200, 255, 0.16) 1px, transparent 1.6px)
      right 3% bottom 5% / 15px 15px;
  background-repeat: no-repeat, repeat;
  z-index: 1;
  -webkit-mask-image: linear-gradient(to right, transparent 52%, #000 78%);
  mask-image: linear-gradient(to right, transparent 52%, #000 78%);
}

.login-main {
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  width: 100%;
  min-width: 0;
}
.login-card {
  width: 100%;
  display: grid;
  gap: 20px;
  padding: clamp(28px, 3.2vw, 40px) clamp(24px, 2.8vw, 36px);
  border-radius: 18px;
  background: #fdfdfd;
  box-shadow: 0 30px 70px -24px rgba(2, 8, 20, 0.65);
}
.login-logo {
  display: block;
  justify-self: center;
  width: min(310px, 76%);
  height: auto;
  margin-bottom: 2px;
}

.login-occhiello {
  margin: -8px 0 0;
  text-align: center;
  font-size: calc(12px * var(--ui-font-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7a90;
}

.login-form { display: grid; gap: 17px; }
.login-field { display: grid; gap: 8px; }
.login-field__label {
  font-size: calc(14px * var(--ui-font-scale));
  font-weight: 700;
  color: #1b2637;
}
.login-field__box { position: relative; display: block; }
.login-field__icona {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  fill: none;
  stroke: #9aa5b5;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.login-form input {
  width: 100%;
  border: 1px solid #e4e8f0;
  border-radius: 10px;
  background: #fdfdfd;
  padding: calc(13px * var(--ui-font-scale)) calc(14px * var(--ui-font-scale));
  padding-left: 46px;
  font-size: calc(15px * var(--ui-font-scale));
  min-height: calc(50px * var(--ui-font-scale));
  color: #1b2637;
}
.login-form input::placeholder { color: #9aa5b5; }
.login-form input:focus {
  outline: none;
  border-color: #0c65d6;
  box-shadow: 0 0 0 3px rgba(12, 101, 214, 0.15);
}
#login-password { padding-right: 48px; }

.login-occhio {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: #9aa5b5;
}
.login-occhio:hover { color: #1b2637; background: rgba(154, 165, 181, 0.14); }
.login-occhio svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-error {
  margin: 0;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: calc(13px * var(--ui-font-scale));
  font-weight: 600;
}

.login-actions { justify-content: stretch; }
.login-actions .btn {
  width: 100%;
  justify-content: center;
  min-height: calc(52px * var(--ui-font-scale));
  border-radius: 10px;
  background: #0c65d6;
  border-color: #0c65d6;
  font-size: calc(16px * var(--ui-font-scale));
  font-weight: 700;
}
.login-actions .btn:hover:not(:disabled) { background: #0a56b8; border-color: #0a56b8; }

.login-foot {
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 2;
  margin: 24px 0 0;
  font-size: calc(13px * var(--ui-font-scale));
  color: rgba(203, 216, 235, 0.62);
  text-align: center;
}

/* Sotto i 900px la scena diventa una colonna: la foto resta in alto come
   fascia, la scheda sotto. */
@media (max-width: 900px) {
  .login-scena {
    grid-template-columns: min(470px, 100%);
    justify-content: center;
    padding-top: clamp(180px, 34vw, 260px);
  }
  /* Qui la foto e' una fascia in alto: la sfumatura va verso il basso, non
     verso destra. */
  .login-scena::before {
    width: 100%;
    height: clamp(220px, 42vw, 310px);
    bottom: auto;
    background-position: center 32%;
    -webkit-mask-image: linear-gradient(to bottom, #000 64%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 64%, transparent 100%);
  }
  .login-scena::after {
    background: linear-gradient(184deg,
      rgba(7, 17, 37, 0) 0%,
      rgba(7, 17, 37, 0) 19%,
      rgba(9, 24, 52, 0.42) 30%,
      #0f2246 42%,
      #071125 78%);
  }
  .login-scena__trama { display: none; }
  .login-main, .login-foot { grid-column: 1; }
}

/* -------------------------------------------------------------------------- */
/* Solo console: recupero password                                             */
/* -------------------------------------------------------------------------- */
/* Il gestionale non ha questa pagina — il recupero e' un servizio che la
   console offre alle istanze. Queste regole stanno **fuori** dal blocco
   "Accesso": quello e' copiato dal gestionale, e una ricopiatura le
   cancellerebbe. */

.login-istruzioni {
  margin: -6px 0 0;
  text-align: center;
  font-size: calc(13px * var(--ui-font-scale));
  line-height: 1.55;
  color: #6b7a90;
}

.login-esito {
  margin: 0;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  font-size: calc(13px * var(--ui-font-scale));
  font-weight: 600;
}

.login-nota {
  margin: 2px 0 0;
  text-align: center;
  font-size: calc(12px * var(--ui-font-scale));
  line-height: 1.5;
  color: #8a97a9;
}

.login-scelte { display: grid; gap: 10px; }
.login-scelte__elenco { display: grid; gap: 8px; }
.login-scelte__elenco .btn { width: 100%; justify-content: center; }

.login-torna { margin: -2px 0 0; text-align: center; }
.login-torna a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #136de4;
  font-size: calc(14px * var(--ui-font-scale));
  font-weight: 600;
}
.login-torna a:hover { text-decoration: underline; }
.login-torna svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ========================================================================== */
/* Dialoghi (generati da core/dialog.js)                                      */
/* ========================================================================== */

.app-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.app-dialog {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 48px -12px rgba(16, 24, 40, .3);
}

.app-dialog__header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.app-dialog__title { font-size: 16px; }
.app-dialog__message { color: var(--text-soft); white-space: pre-wrap; line-height: 1.55; }
.app-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* ========================================================================== */
/* Backup: una riga per concessionaria, si apre                               */
/* ========================================================================== */

.backup-gruppo {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--card);
}

.backup-gruppo__testa {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background .12s;
}
.backup-gruppo__testa:hover { background: var(--surface); }
.backup-gruppo__testa:focus-visible { outline: none; box-shadow: var(--focus) inset; }

.backup-gruppo__freccia {
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform .16s;
  font-size: 11px;
}
.backup-gruppo.is-aperto .backup-gruppo__freccia { transform: rotate(90deg); }

.backup-gruppo__nome { font-weight: 650; font-size: 14.5px; }
.backup-gruppo__istanza { font-size: 12px; color: var(--muted); }
.backup-gruppo__spazio { flex: 1; }
.backup-gruppo__conteggio { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.backup-gruppo__corpo { display: none; border-top: 1px solid var(--border); }
.backup-gruppo.is-aperto .backup-gruppo__corpo { display: block; }
.backup-gruppo__corpo .table-wrapper { border: none; border-radius: 0; }

.backup-vuoto { padding: 22px; text-align: center; color: var(--muted); }

/* ========================================================================== */
/* Schermi stretti                                                             */
/* ========================================================================== */

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    overflow-x: auto;
  }
  .nav { flex-direction: row; gap: 4px; }
  .nav__item span:not(.nav__icon) { display: none; }
  .sidebar__footer { border: none; padding: 0; }
  .main { padding: 18px 16px 40px; }
  .license-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Impostazioni: indice a gruppi, come nel gestionale.
   -------------------------------------------------------------------------- */

.settings-groups {
  display: grid;
  gap: 18px;
}

.settings-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-group__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.settings-group__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.settings-group__head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.settings-group__list {
  display: grid;
}

.settings-link {
  display: grid;
  grid-template-columns: 38px 1fr 18px;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}

.settings-group__list > .settings-link:first-child { border-top: 0; }
.settings-link:hover { background: var(--surface); }
.settings-link:focus-visible { outline: 0; box-shadow: var(--focus); }

.settings-link__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-link__icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-link__body { display: grid; gap: 2px; min-width: 0; }
.settings-link__title { font-weight: 600; font-size: 14px; }
.settings-link__desc { font-size: 12.5px; color: var(--muted); }

.settings-link__chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-link:hover .settings-link__chevron { stroke: var(--accent); }

/* Intestazione delle sottopagine: il ritorno all'indice. */
.settings-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 6px;
}

.settings-back:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Menu account nella barra in alto. Montato da core/sidebar.js, non scritto
   nelle pagine: un punto solo da modificare.
   -------------------------------------------------------------------------- */

.account { position: relative; display: inline-flex; margin-left: auto; }

.account__btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.account__btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.account__btn[aria-expanded="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.account__btn:focus-visible { outline: 0; box-shadow: var(--focus); }
.account__btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 210px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.account__who {
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.account__name { font-weight: 650; font-size: 13.5px; overflow-wrap: anywhere; }
.account__role { font-size: 12px; color: var(--muted); }

.account__action {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.account__action:hover { background: var(--surface); }
.account__action--exit { color: var(--danger); }
.account__action--exit:hover { background: var(--danger-soft); }

.app-dialog__input {
  width: 100%;
  margin: 0 0 4px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.app-dialog__input:focus-visible { outline: 0; border-color: var(--accent); box-shadow: var(--focus); }

.riga-spunta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.riga-spunta input { width: 16px; height: 16px; margin: 0; cursor: pointer; }

.small-note { font-size: 13px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.chiave-pubblica {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  resize: vertical;
  min-height: 84px;
}

/* --------------------------------------------------------------------------
   Monitoraggio: una scheda per concessionaria, gravita' a colpo d'occhio.
   -------------------------------------------------------------------------- */

.salute { display: flex; flex-direction: column; gap: 10px; }

.salute__riga {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  overflow: hidden;
}

/* La striscia di sinistra porta la gravita': si legge scorrendo, senza contare
   pastiglie o leggere testo. */
.salute__riga--ok { border-left-color: var(--ok); }
.salute__riga--attenzione { border-left-color: var(--warn); }
.salute__riga--critico,
.salute__riga--irraggiungibile { border-left-color: var(--danger); }

.salute__testa {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
}
.salute__testa:hover { background: var(--surface); }

.salute__nome { font-weight: 600; font-size: 14.5px; }
.salute__sotto { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.salute__numeri {
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.salute__numeri b { color: var(--text); font-weight: 600; }

.salute__corpo {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
}

.salute__controlli { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 0; }
.salute__controllo {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  font-size: 13px;
  align-items: baseline;
}
.salute__esito {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  text-align: center;
}
.salute__esito--ok { background: var(--ok-soft); color: var(--ok); }
.salute__esito--attenzione { background: var(--warn-soft); color: var(--warn); }
.salute__esito--critico { background: var(--danger-soft); color: var(--danger); }
.salute__esito--sconosciuto { background: var(--surface-strong); color: var(--muted); }

.salute__errori {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--muted);
}
.salute__errori li { margin-bottom: 4px; word-break: break-word; }
.salute__errori code { font-size: 11.5px; }

/* Da dove arriva il codice: percorso, remoto, ramo, chiave. */
.repo-scheda {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.repo-scheda dt { color: var(--muted); white-space: nowrap; }
.repo-scheda dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.repo-scheda .assente { color: var(--danger); font-family: inherit; }
.repo-scheda .presente { color: var(--ok); font-family: inherit; }
.repo-scheda .sporco { color: var(--warn); font-family: inherit; }
