/* ==========================================================================
   NiceGest Manage — design system
   --------------------------------------------------------------------------
   Un solo foglio di stile, organizzato in strati:
     1. token        variabili di colore, spazio, tipografia
     2. reset        normalizzazione minima
     3. layout       shell dell'applicazione
     4. componenti   bottoni, tabelle, form, card, badge…
     5. utility      poche classi di supporto, non un framework
   ========================================================================== */

/* ---------------------------------------------------------------- 1. token */

:root {
  /* Palette del marchio, dedotta dal logo: blu profondo e ciano. */
  --brand-50:  #eef4ff;
  --brand-100: #dbe6fe;
  --brand-200: #bfd3fe;
  --brand-300: #93b4fd;
  --brand-400: #608cfa;
  --brand-500: #3b66f6;
  --brand-600: #2b5ce6;
  --brand-700: #1e46c8;
  --brand-800: #1e3ba2;
  --brand-900: #1e3580;

  --cyan-400: #22c7da;
  --cyan-500: #0ea5bf;

  /* Grigi neutri, leggermente freddi. */
  --gray-25:  #fcfcfd;
  --gray-50:  #f7f8fa;
  --gray-100: #eff1f4;
  --gray-200: #e3e6ea;
  --gray-300: #cfd4da;
  --gray-400: #a3abb5;
  --gray-500: #737d8a;
  --gray-600: #545d6b;
  --gray-700: #3d4653;
  --gray-800: #262d38;
  --gray-900: #171b22;
  --gray-950: #0e1117;

  --green-50:  #ecfdf3;
  --green-500: #12b76a;
  --green-600: #039855;
  --green-700: #027a48;

  --amber-50:  #fffaeb;
  --amber-500: #f79009;
  --amber-600: #dc6803;
  --amber-700: #b54708;

  --red-50:  #fef3f2;
  --red-500: #f04438;
  --red-600: #d92d20;
  --red-700: #b42318;

  --violet-50:  #f4f3ff;
  --violet-500: #7a5af8;
  --violet-600: #6938ef;

  --pink-500: #e0529c;

  /* Ruoli semantici — è a questi che si riferisce il resto del foglio. */
  --canvas:        var(--gray-50);
  --surface:       #ffffff;
  --surface-raised:#ffffff;
  --surface-sunken:var(--gray-50);
  --surface-hover: var(--gray-50);
  --surface-active:var(--gray-100);

  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --border-subtle: var(--gray-100);

  --text:          var(--gray-900);
  --text-secondary:var(--gray-600);
  --text-muted:    var(--gray-500);
  --text-faint:    var(--gray-400);
  --text-inverse:  #ffffff;

  --accent:        var(--brand-600);
  --accent-hover:  var(--brand-700);
  --accent-soft:   var(--brand-50);
  --accent-border: var(--brand-200);
  --accent-text:   var(--brand-700);

  --success:       var(--green-600);
  --success-soft:  var(--green-50);
  --success-text:  var(--green-700);
  --warning:       var(--amber-600);
  --warning-soft:  var(--amber-50);
  --warning-text:  var(--amber-700);
  --danger:        var(--red-600);
  --danger-soft:   var(--red-50);
  --danger-text:   var(--red-700);
  --info:          var(--cyan-500);
  --info-soft:     #ecfeff;
  --info-text:     #0e7490;

  /* Elevazione: ombre corte e a bassa opacità, mai diffuse. */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);
  --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, .10), 0 8px 8px -4px rgba(16, 24, 40, .04);

  --ring: 0 0 0 3px rgba(43, 92, 230, .18);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --sidebar-width: 244px;
  --topbar-height: 60px;
  --content-max: 1400px;

  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

/* Tema scuro: si ridefiniscono solo i ruoli, mai i singoli componenti. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas:         var(--gray-950);
    --surface:        #161a21;
    --surface-raised: #1b2028;
    --surface-sunken: #12151b;
    --surface-hover:  #1f242d;
    --surface-active: #242a34;

    --border:         #262c36;
    --border-strong:  #333b47;
    --border-subtle:  #1e232b;

    --text:           #e9edf3;
    --text-secondary: #a8b1bd;
    --text-muted:     #8b95a3;
    --text-faint:     #6b7482;

    --accent:         var(--brand-500);
    --accent-hover:   var(--brand-400);
    --accent-soft:    rgba(59, 102, 246, .14);
    --accent-border:  rgba(59, 102, 246, .32);
    --accent-text:    #93b4fd;

    --success-soft:   rgba(18, 183, 106, .13);
    --success-text:   #6ce9a6;
    --warning-soft:   rgba(247, 144, 9, .13);
    --warning-text:   #fdb022;
    --danger-soft:    rgba(240, 68, 56, .13);
    --danger-text:    #fda29b;
    --info-soft:      rgba(34, 199, 218, .13);
    --info-text:      #67e3f9;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 16px -4px rgba(0, 0, 0, .5);
    --shadow-xl: 0 20px 24px -4px rgba(0, 0, 0, .55);

    --ring: 0 0 0 3px rgba(59, 102, 246, .3);
  }
}

/* Scelta esplicita dell'utente: vince sulla preferenza di sistema. */
:root[data-theme="dark"] {
  --canvas:         var(--gray-950);
  --surface:        #161a21;
  --surface-raised: #1b2028;
  --surface-sunken: #12151b;
  --surface-hover:  #1f242d;
  --surface-active: #242a34;

  --border:         #262c36;
  --border-strong:  #333b47;
  --border-subtle:  #1e232b;

  --text:           #e9edf3;
  --text-secondary: #a8b1bd;
  --text-muted:     #8b95a3;
  --text-faint:     #6b7482;

  --accent:         var(--brand-500);
  --accent-hover:   var(--brand-400);
  --accent-soft:    rgba(59, 102, 246, .14);
  --accent-border:  rgba(59, 102, 246, .32);
  --accent-text:    #93b4fd;

  --success-soft:   rgba(18, 183, 106, .13);
  --success-text:   #6ce9a6;
  --warning-soft:   rgba(247, 144, 9, .13);
  --warning-text:   #fdb022;
  --danger-soft:    rgba(240, 68, 56, .13);
  --danger-text:    #fda29b;
  --info-soft:      rgba(34, 199, 218, .13);
  --info-text:      #67e3f9;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 16px -4px rgba(0, 0, 0, .5);
  --shadow-xl: 0 20px 24px -4px rgba(0, 0, 0, .55);

  --ring: 0 0 0 3px rgba(59, 102, 246, .3);
}

/* ---------------------------------------------------------------- 2. reset */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -.006em;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.018em; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }

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

img, svg { vertical-align: middle; max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button { background: none; border: 0; padding: 0; cursor: pointer; }

table { border-collapse: collapse; border-spacing: 0; width: 100%; }

hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-size: .92em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  vertical-align: -.22em;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* --------------------------------------------------------------- 3. layout */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* --- barra laterale --- */

.sidebar {
  /* La barra laterale è sempre scura, a prescindere dal tema della pagina:
     il logo è chiaro e su fondo chiaro sparirebbe. Ridefinendo i token in
     locale, tutte le voci figlie si adattano da sole. */
  --surface:        #0e1016;
  --surface-hover:  rgba(255, 255, 255, .06);
  --surface-sunken: rgba(255, 255, 255, .09);
  --border:         rgba(255, 255, 255, .10);
  --border-subtle:  rgba(255, 255, 255, .07);
  --text:           #f4f6fa;
  --text-secondary: #c4cad4;
  --text-faint:     #868f9e;
  --accent:         #7d9dff;
  --accent-soft:    rgba(89, 124, 246, .20);
  --accent-text:    #a9c2ff;

  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar__brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
}

.sidebar__brand img { height: 26px; width: auto; }

.sidebar__brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
}

.sidebar__brand-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 1px 7px;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__section {
  margin: 18px 0 6px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar__section:first-child { margin-top: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link .icon { color: var(--text-faint); transition: color var(--transition); }
.nav-link:hover .icon { color: var(--text-secondary); }

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-link.is-active .icon { color: var(--accent); }

.nav-link__count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  padding: 0 7px;
  min-width: 22px;
  text-align: center;
}
.nav-link.is-active .nav-link__count {
  background: var(--surface);
  color: var(--accent-text);
}

.sidebar__footer {
  flex: none;
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* --- barra superiore --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  /* Sfondo pieno: la topbar sticky non deve mai lasciar trasparire il
     contenuto sottostante durante lo scroll (il blur non è affidabile su
     tutti i browser/contesti di stacking). */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__toggle {
  display: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.topbar__toggle:hover { background: var(--surface-hover); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--text-faint); }
.breadcrumb__current {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- area principale --- */

.main { min-width: 0; display: flex; flex-direction: column; }

/* Overlay del menu mobile: fuori dal flusso sempre, così non occupa una
   colonna della griglia sul desktop. Diventa visibile solo sotto 820px. */
.scrim { display: none; }

.page {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 24px 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-header__text { min-width: 0; flex: 1; }

.page-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-header__subtitle {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-title h2 { font-size: 14px; font-weight: 600; }
.section-title__hint { font-size: 12.5px; color: var(--text-muted); }
.section-title__action { margin-left: auto; font-size: 13px; }

/* ----------------------------------------------------------- 4. componenti */

/* --- bottoni --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 16px; height: 16px; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover { background: var(--surface-hover); border-color: var(--gray-400); }

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

.btn--danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-xs); }
.btn--danger:hover { background: var(--red-700); }

.btn--danger-ghost { background: transparent; color: var(--danger-text); }
.btn--danger-ghost:hover { background: var(--danger-soft); }

.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn--sm .icon { width: 14px; height: 14px; }
.btn--lg { height: 40px; padding: 0 18px; font-size: 14.5px; }

.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }

.btn--block { width: 100%; }

.btn[disabled], .btn.is-disabled {
  opacity: .5;
  pointer-events: none;
}

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.btn-group > * {
  height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
}
.btn-group > *:last-child { border-right: 0; }
.btn-group > *:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.btn-group > .is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* --- card --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.card__header h2, .card__header h3 { font-size: 14px; font-weight: 600; }
.card__header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__body--tight { padding: 12px 18px; }

.card__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- riquadri statistica --- */

.stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}
/* Ogni card cresce a riempire la riga: niente celle vuote quando il numero di
   card non è multiplo delle colonne. min 210px prima di andare a capo. */
.stat-grid > .stat { flex: 1 1 210px; }

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); text-decoration: none; }

/* Overlay bloccante durante un'operazione (es. "Esegui ora"). */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 11, 16, .38);
}
.busy-overlay__box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  font-weight: 500;
}
.busy-spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: busy-spin .7s linear infinite;
  flex: none;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }

/* Indicatore di aggiornamento automatico (nel page-header). */
.autorefresh { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.autorefresh__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: autorefresh-pulse 2s ease-in-out infinite; flex: none; }
@keyframes autorefresh-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Barra di stato sintetica (dashboard). */
.sysbar-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}
.sysbar-row .sysbar { margin-bottom: 0; }
.sysbar-updated { margin-bottom: 24px; }
@media (max-width: 720px) { .sysbar-row { grid-template-columns: minmax(0, 1fr); } }

.sysbar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sysbar:hover { text-decoration: none; box-shadow: var(--shadow-sm); }
.sysbar__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--gray-400); }
.sysbar__label { font-weight: 600; font-size: 14px; flex: none; }
.sysbar__detail { color: var(--text-muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sysbar__meta { color: var(--text-faint); font-size: 12px; white-space: nowrap; flex: none; }
.sysbar .icon { color: var(--text-faint); flex: none; }

.sysbar--ok       { border-color: var(--success); background: var(--success-soft); }
.sysbar--ok       .sysbar__dot { background: var(--success); }
.sysbar--ok       .sysbar__label { color: var(--success-text); }
.sysbar--degraded { border-color: var(--warning); background: var(--warning-soft); }
.sysbar--degraded .sysbar__dot { background: var(--warning); }
.sysbar--degraded .sysbar__label { color: var(--warning-text); }
.sysbar--critical { border-color: var(--danger); background: var(--danger-soft); }
.sysbar--critical .sysbar__dot { background: var(--danger); }
.sysbar--critical .sysbar__label { color: var(--danger-text); }
.sysbar--unknown .sysbar__label { color: var(--text-muted); }

.stat__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.stat__label .icon { width: 15px; height: 15px; color: var(--text-faint); }

.stat__value {
  margin-top: 8px;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.028em;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat__value small {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -.01em;
}
.stat__value .stat__hint { font-size: 12.5px; color: var(--text-faint); }

.stat__meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.stat__bar {
  margin-top: 12px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  overflow: hidden;
  display: flex;
}
.stat__bar span { display: block; height: 100%; }
.stat__bar span:first-child { border-radius: var(--radius-full) 0 0 var(--radius-full); }
.stat__bar span:last-child { border-radius: 0 var(--radius-full) var(--radius-full) 0; }

.stat--accent  .stat__value { color: var(--accent-text); }
.stat--success .stat__value { color: var(--success-text); }
.stat--warning .stat__value { color: var(--warning-text); }
.stat--danger  .stat__value { color: var(--danger-text); }

/* --- badge --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.badge .icon { width: 12px; height: 12px; }

.badge--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: transparent; }
.badge--info    { background: var(--info-soft);    color: var(--info-text);    border-color: transparent; }
.badge--accent  { background: var(--accent-soft);  color: var(--accent-text);  border-color: transparent; }
.badge--neutral { background: var(--surface-sunken); color: var(--text-muted); }

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

.badge--square { border-radius: var(--radius-xs); }

/* Pastiglia per valori tecnici copiabili. */
.chip-mono {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  color: var(--text-secondary);
}

.copy-btn {
  color: var(--text-faint);
  display: inline-flex;
  padding: 1px;
  border-radius: 3px;
  transition: color var(--transition), background var(--transition);
}
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }
.copy-btn .icon { width: 13px; height: 13px; }
.copy-btn.is-copied { color: var(--success); }

/* --- avatar --- */

.avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  flex: none;
  letter-spacing: 0;
}
.avatar { position: relative; }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: var(--surface);
}
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; border-radius: var(--radius-sm); }
.avatar--lg { width: 48px; height: 48px; font-size: 16px; border-radius: var(--radius-md); }
.avatar--round { border-radius: 50%; }
.avatar--accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }

/* --- tabelle --- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.table { font-size: 13.5px; }

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-sunken);
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .035em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }

.table tbody tr.is-muted td { color: var(--text-faint); }
.table tbody tr.is-muted .cell-title { color: var(--text-muted); font-weight: 500; }

.table th.is-numeric, .table td.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table th.is-actions, .table td.is-actions { text-align: right; width: 1%; white-space: nowrap; }
.table th.is-compact, .table td.is-compact { width: 1%; white-space: nowrap; }

.cell-primary { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-title {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-stack { min-width: 0; }

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: .55;
  transition: opacity var(--transition);
}
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.row-action:hover { background: var(--surface-active); color: var(--text); text-decoration: none; }
.row-action--danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.row-action .icon { width: 15px; height: 15px; }

/* Righe cliccabili: il link copre la cella principale. */
.row-link { color: inherit; }
.row-link:hover { text-decoration: none; }
.row-link:hover .cell-title { color: var(--accent-text); }

/* Colonna con testo potenzialmente lungho (es. endpoint + User-Agent):
   larghezza massima così l'ellissi scatta e la tabella non sfora a destra. */
.col-truncate { max-width: 380px; }
.col-truncate .cell-title, .col-truncate .cell-sub { max-width: 100%; }
@media (max-width: 1200px) { .col-truncate { max-width: 280px; } }

/* Colonna di testo che si adatta alla larghezza della card: prende lo spazio
   residuo e tronca (ellissi), così la tabella non sfora mai in orizzontale
   anche con contenuti lunghi (User-Agent, nomi cliente). Le altre colonne
   restano dimensionate sul contenuto. */
.table td.col-flex { max-width: 0; width: 100%; }
.table td.col-flex .row-link { display: block; min-width: 0; }

/* --- verifica in due passaggi (2FA) --- */
.secret-box { display: inline-flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.secret-key {
  font-size: 18px; letter-spacing: 2px; font-weight: 600;
  background: var(--surface-sunken); padding: 10px 14px; border-radius: var(--radius-md);
}
.recovery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-width: 540px; }
.recovery-code {
  font-size: 15px; letter-spacing: 1px; text-align: center;
  background: var(--surface-sunken); padding: 8px 10px; border-radius: var(--radius-sm);
}
.steps { margin: 0 0 12px; padding-left: 18px; }
.steps li { margin-bottom: 6px; }
.inline-form .field { margin-bottom: 0; }
.twofa-setup { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.qr-box { flex: none; width: 190px; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); }
.qr-box svg { display: block; width: 100%; height: auto; }
.twofa-manual { flex: 1; min-width: 240px; }
.remember-check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; }
.remember-check input { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.trusted-list { display: flex; flex-direction: column; gap: 8px; }
.trusted-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.trusted-item__meta { min-width: 0; }
.trusted-item__name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- barra filtri --- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.toolbar__spacer { margin-left: auto; }
.toolbar__count { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Nella toolbar i controlli stanno in riga: i select si dimensionano al
   contenuto invece di occupare tutta la larghezza (default dei form). */
.toolbar .select { width: auto; flex: none; min-width: 150px; max-width: 240px; }

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
.search input { padding-left: 33px; }

/* --- form --- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.label__optional { font-weight: 400; color: var(--text-faint); margin-left: 4px; }
.label__required { color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.textarea { height: auto; min-height: 88px; padding: 9px 11px; line-height: 1.55; resize: vertical; }

.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.input:disabled, .select:disabled, .textarea:disabled,
.input[readonly] {
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737d8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}

.select--sm, .input--sm {
  height: 32px;
  font-size: 13px;
}

.field--error .input, .field--error .select, .field--error .textarea {
  border-color: var(--danger);
}
.field--error .input:focus, .field--error .select:focus, .field--error .textarea:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field__hint { margin-top: 6px; font-size: 12.5px; color: var(--text-muted); }
.field__error {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--danger-text);
  display: flex;
  align-items: center;
  gap: 5px;
}
.field__error .icon { width: 13px; height: 13px; }

/* Gruppo con prefisso testuale (es. https://). */
.input-group { display: flex; }
.input-group__addon {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  height: 36px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  white-space: nowrap;
}
.input-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Griglia di campi affiancati. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}
.field-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field--full { grid-column: 1 / -1; }

/* Checkbox e radio disegnati. */
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
}
.check:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }

.check__box {
  width: 16px; height: 16px;
  margin-top: 1px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.check__box::after {
  content: "";
  width: 9px; height: 9px;
  background: #fff;
  clip-path: polygon(14% 46%, 0 60%, 40% 100%, 100% 22%, 86% 8%, 38% 70%);
  transform: scale(0);
  transition: transform var(--transition);
}
.check input:checked ~ .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked ~ .check__box::after { transform: scale(1); }
.check input:focus-visible ~ .check__box { box-shadow: var(--ring); }
.check:has(input:checked) { border-color: var(--accent-border); background: var(--accent-soft); }

.check__text { min-width: 0; }
.check__title { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; }
.check__title .icon { width: 14px; height: 14px; color: var(--text-faint); }
.check:has(input:checked) .check__title .icon { color: var(--accent); }
.check__hint { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

/* Campo attenuato quando un'altra opzione lo rende ininfluente. */
.is-muted { opacity: .5; transition: opacity var(--transition); }

/* Riga di tabella attenuata (es. server spento da tempo). */
.table tr.is-dim td { opacity: .55; }

/* Interruttore on/off. */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 34px; height: 20px;
  border-radius: var(--radius-full);
  background: var(--gray-300);
  position: relative;
  transition: background var(--transition);
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition);
}
.switch input:checked ~ .switch__track { background: var(--accent); }
.switch input:checked ~ .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible ~ .switch__track { box-shadow: var(--ring); }

/* Scelta segmentata (radio in forma di gruppo di bottoni). */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 2px;
}
.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label:hover { color: var(--text); }
.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.segmented label:has(input:focus-visible) { box-shadow: var(--ring); }

/* --- messaggi --- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}
.alert .icon { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 600; margin-bottom: 2px; }
.alert__close { color: currentColor; opacity: .5; padding: 2px; border-radius: var(--radius-xs); }
.alert__close:hover { opacity: 1; }

.alert--success { background: var(--success-soft); color: var(--success-text); }
.alert--error   { background: var(--danger-soft);  color: var(--danger-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--info    { background: var(--info-soft);    color: var(--info-text); }

/* --- stato vuoto --- */

.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty__icon {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.empty__icon .icon { width: 21px; height: 21px; }
.empty__title { font-size: 14.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty__text { font-size: 13px; max-width: 380px; margin: 0 auto; }
.empty__action { margin-top: 16px; }

/* --- paginazione --- */

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.pagination__pages { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.pagination__link {
  min-width: 30px; height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.pagination__link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.pagination__link.is-current { background: var(--accent); color: #fff; }
.pagination__link.is-disabled { color: var(--text-faint); pointer-events: none; }
.pagination__gap { padding: 0 3px; color: var(--text-faint); }

/* --- menu a discesa --- */

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.dropdown.is-open .dropdown__menu { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.dropdown__item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.dropdown__item .icon { width: 15px; height: 15px; color: var(--text-faint); }
.dropdown__item:hover .icon { color: var(--text-secondary); }
.dropdown__item--danger { color: var(--danger-text); }
.dropdown__item--danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.dropdown__item--danger .icon, .dropdown__item--danger:hover .icon { color: var(--danger-text); }

.dropdown__divider { height: 1px; background: var(--border-subtle); margin: 5px 0; }
.dropdown__header {
  padding: 8px 9px 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.dropdown__header strong { display: block; color: var(--text); font-size: 13px; font-weight: 600; }

.user-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.user-button:hover { background: var(--surface-hover); }
.user-button__name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-button .icon { color: var(--text-faint); width: 14px; height: 14px; }

/* --- pannelli chiave/valore --- */

.detail-list { display: grid; gap: 0; }
.detail-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13.5px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row__label { color: var(--text-muted); }
.detail-row__value { color: var(--text); min-width: 0; word-break: break-word; }
.detail-row__value--empty { color: var(--text-faint); }

/* --- grafici essenziali --- */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
}
.bars__bar {
  flex: 1;
  min-width: 3px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--accent-soft);
  border-radius: 2px 2px 0 0;
  position: relative;
  transition: background var(--transition);
}
.bars__bar > span { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; position: relative; }
.bars__bar:hover { background: var(--accent-border); }
/* Fascia con errori: puntino rosso sopra la barra (non tutta rossa: fuorviante
   per pochi errori). La quantità è nel tooltip. */
.bars__bar--err > span::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--danger);
}

.bars-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.meter {
  display: flex;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-sunken);
}
.meter span { display: block; height: 100%; }
.meter--sm { height: 5px; margin-top: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12.5px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.legend__swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.legend__value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Barra di distribuzione dei moduli. */
.rank-list { display: flex; flex-direction: column; gap: 11px; }
.rank-list--compact { gap: 8px; }
.rank-list--compact .rank__label { font-size: 12.5px; }
.rank { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 12px; align-items: center; }
.rank__label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); min-width: 0; }
.rank__label .icon { width: 14px; height: 14px; color: var(--text-faint); }
.rank__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__track { height: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); margin-top: 5px; }
.rank__fill { height: 100%; border-radius: var(--radius-full); background: var(--accent); }
.rank__value { text-align: right; font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Uso delle API per cliente. */
.usage-list { display: flex; flex-direction: column; gap: 6px; }
.usage {
  display: block;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.usage:hover { background: var(--surface-sunken); border-color: var(--border); text-decoration: none; }
.usage__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.usage__name { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage__total { flex: none; font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.usage__total small { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }
.usage__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.usage__meta > span { position: relative; }
.usage__meta > span + span::before { content: ""; position: absolute; left: -8px; top: 50%; width: 2px; height: 2px; border-radius: 50%; background: var(--text-faint); transform: translateY(-50%); }
.usage__errors { color: var(--danger-text); font-weight: 500; }

/* Sparkline andamento chiamate. */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; padding-top: 7px; border-bottom: 1px solid var(--border-subtle); }
.spark--empty { align-items: center; border-bottom: 0; }
.spark__bar {
  position: relative;
  flex: 1;
  min-width: 2px;
  min-height: 0;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  opacity: .5;
  transition: opacity var(--transition);
}
.usage:hover .spark__bar { opacity: .78; }
/* Giorno con errori: puntino rosso sopra la barra. La quantità esatta è nel
   testo "N in errore (x%)" sotto: qui basta segnalare il giorno, senza
   colorare di rosso l'intera barra (fuorviante per pochi errori). */
.spark__bar--err::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--danger);
}
/* Periodo senza dati: stub basso e tenue, così la timeline mostra tutti gli slot
   (es. 7 giorni) e si capisce che i dati coprono solo gli ultimi. */
.spark__bar--none {
  height: 3px;
  opacity: .35;
  background: var(--text-faint);
  border-radius: 2px;
}
.usage:hover .spark__bar--none { opacity: .35; }
/* Asse temporale condiviso sopra la lista (orientamento: vecchio → oggi). */
.usage-axis { display: flex; justify-content: space-between; }

/* Sotto-intestazione all'interno di una card. */
.subhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.subhead h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }

/* Ripartizione per endpoint (grafico a barre orizzontali). */
.endpoints { display: flex; flex-direction: column; gap: 13px; }
.ep { display: block; }
.ep__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.ep__name { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep__method { font-weight: 700; color: var(--text-faint); margin-right: 6px; }
.ep__value { flex: none; font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ep__share { margin-left: 6px; font-weight: 500; color: var(--text-muted); }
.ep__track { display: flex; height: 8px; border-radius: var(--radius-full); overflow: hidden; background: var(--surface-sunken); }
.ep__track span { display: block; height: 100%; }
.ep__err { margin-top: 5px; font-size: 11.5px; color: var(--danger-text); }

/* --- timeline attività --- */

.timeline { display: flex; flex-direction: column; }
.timeline__item {
  display: flex;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.timeline__item:last-child { border-bottom: 0; }
.timeline__icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex: none;
}
.timeline__icon .icon { width: 14px; height: 14px; }
.timeline__icon--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.timeline__icon--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: transparent; }
.timeline__icon--accent  { background: var(--accent-soft);  color: var(--accent-text);  border-color: transparent; }
.timeline__body { min-width: 0; flex: 1; }
.timeline__text { color: var(--text); }
.timeline__text strong { font-weight: 600; }
.timeline__meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* --- tabs --- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 9px 13px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab__count {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  color: var(--text-muted);
}
.tab.is-active .tab__count { background: var(--accent-soft); color: var(--accent-text); }

/* --- griglie di pagina --- */

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
/* Tre colonne: contenuto largo, feed medio, riquadro accessorio stretto. */
.grid--triple { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 0.9fr); align-items: start; }

/* --- pagina di accesso --- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--surface);
}

.login__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.login__form { width: 100%; max-width: 348px; }

.login__brand { margin-bottom: 30px; }
.login__brand img { height: 34px; }

.login__title { font-size: 21px; font-weight: 600; letter-spacing: -.022em; }
.login__subtitle { margin-top: 6px; margin-bottom: 26px; color: var(--text-muted); font-size: 13.5px; }

.login__footer { margin-top: 26px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

.login__aside {
  position: relative;
  background:
    radial-gradient(120% 110% at 15% 10%, rgba(34, 199, 218, .35), transparent 55%),
    radial-gradient(110% 120% at 85% 80%, rgba(122, 90, 248, .30), transparent 55%),
    linear-gradient(150deg, var(--brand-800), var(--brand-600) 55%, var(--cyan-500));
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  overflow: hidden;
}

.login__aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 100% at 70% 30%, #000, transparent 70%);
  -webkit-mask-image: radial-gradient(120% 100% at 70% 30%, #000, transparent 70%);
}

.login__aside-content { position: relative; z-index: 1; max-width: 420px; }
.login__aside h2 { font-size: 25px; letter-spacing: -.025em; line-height: 1.25; }
.login__aside p { margin-top: 12px; font-size: 14.5px; opacity: .82; line-height: 1.6; }

.login__aside-stats {
  display: flex;
  gap: 32px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, .18);
}
.login__aside-stat strong { display: block; font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.login__aside-stat span { font-size: 12.5px; opacity: .75; }

/* --- pagina di errore --- */

.error-page { text-align: center; padding: 72px 24px; }
.error-page__code {
  font-size: 60px;
  font-weight: 600;
  letter-spacing: -.04em;
  color: var(--text-faint);
  line-height: 1;
}
.error-page__title { margin-top: 12px; font-size: 19px; }
.error-page__text { margin-top: 8px; color: var(--text-muted); }
.error-page__action { margin-top: 24px; }

/* ------------------------------------------------------------- 5. utility */

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: 2px; } .stack-4 { gap: 4px; } .stack-8 { gap: 8px; }
.stack-12 { gap: 12px; } .stack-16 { gap: 16px; } .stack-24 { gap: 24px; }

.row { display: flex; align-items: center; }
.row-8 { gap: 8px; } .row-12 { gap: 12px; } .row-16 { gap: 16px; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.push { margin-left: auto; }

.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-strong { font-weight: 600; color: var(--text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-right { text-align: right; }
.text-nowrap { white-space: nowrap; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

.hide { display: none !important; }

/* ---------------------------------------------------------- 6. responsive */

@media (max-width: 1180px) {
  .grid--sidebar, .grid--main { grid-template-columns: minmax(0, 1fr); }
  .grid--triple { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .grid--2, .grid--3, .grid--triple { grid-template-columns: minmax(0, 1fr); }
  .field-grid--2 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login__aside { display: none; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.is-open { transform: translateX(0); }

  .topbar__toggle { display: inline-flex; }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
  }
  .scrim.is-open { opacity: 1; visibility: visible; }

  .page { padding: 18px 16px 48px; }
  .topbar { padding: 0 16px; }
  .user-button__name { display: none; }
}

@media (max-width: 620px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header__actions { justify-content: flex-start; }
  .detail-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .search { max-width: none; }
  .toolbar .select { width: 100%; max-width: none; flex: 1 1 100%; }
}

@media print {
  .sidebar, .topbar, .page-header__actions, .row-actions, .pagination { display: none !important; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .card { box-shadow: none; border-color: #ddd; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Honeypot anti-bot: fuori schermo, non visibile e non focalizzabile. */
.hp { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }
