/* token dei grafici (palette di riferimento validata: serie blu, colori di stato riservati) */
:root, [data-bs-theme="light"] {
  --viz-series-1: #2a78d6; --viz-series-2: #eb6834; --viz-series-3: #1baf7a; --viz-series-4: #eda100;
  --viz-good: #0ca30c; --viz-warn: #fab219; --viz-crit: #d03b3b; --viz-off: #8c959f;
  --viz-track: #e8e7e3; --viz-grid: #e3e2de; --viz-axis: #52514e; --viz-area: rgba(42,120,214,.14);
}
[data-bs-theme="dark"] {
  --viz-series-1: #3987e5; --viz-series-2: #d95926; --viz-series-3: #199e70; --viz-series-4: #c98500;
  --viz-track: #383835; --viz-grid: #34342f; --viz-axis: #c3c2b7; --viz-area: rgba(57,135,229,.20);
}
:root {
  --sn-sidebar-w: 230px;
  --sn-bottom-h: 62px;
  --sn-ok: var(--viz-good);
  --sn-warn: var(--viz-warn);
  --sn-crit: var(--viz-crit);
  --sn-off: var(--viz-off);
}
body { background: var(--bs-tertiary-bg); min-height: 100vh; }
.bi { width: 1em; height: 1em; fill: currentColor; vertical-align: -.125em; flex-shrink: 0; }

/* layout */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sn-sidebar-w);
  background: var(--bs-body-bg); border-right: 1px solid var(--bs-border-color);
  padding: 1rem .75rem; z-index: 1030;
}
.sidebar .brand, .topbar .brand {
  font-weight: 600; font-size: 1.1rem; color: var(--bs-body-color); text-decoration: none;
  display: inline-flex; gap: .5rem; align-items: center;
}
.sidebar .brand { padding: .25rem .5rem 1rem; }
.sidebar .brand .bi, .topbar .brand .bi { color: var(--bs-primary); width: 1.25em; height: 1.25em; }
.sidebar .nav-link {
  color: var(--bs-secondary-color); border-radius: .5rem; padding: .5rem .75rem;
  display: flex; gap: .65rem; align-items: center;
}
.sidebar .nav-link:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.sidebar .nav-link.active { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-weight: 500; }
.sidebar-foot { border-top: 1px solid var(--bs-border-color); padding-top: .75rem; }

.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; justify-content: space-between;
  background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color);
  padding: .65rem 1rem; padding-top: max(.65rem, env(safe-area-inset-top));
}
.topbar-title { color: var(--bs-secondary-color); font-size: .9rem; }

.content { padding: 1rem; max-width: 1400px; }
.with-nav .content { padding-bottom: calc(var(--sn-bottom-h) + 1.5rem + env(safe-area-inset-bottom)); }
@media (min-width: 992px) {
  .with-nav .content { margin-left: var(--sn-sidebar-w); padding: 1.5rem 2rem; }
}

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 1030; display: flex;
  background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--sn-bottom-h); font-size: .7rem; color: var(--bs-secondary-color); text-decoration: none;
  background: none; border: 0;
}
.bottom-nav .bi { width: 1.35em; height: 1.35em; }
.bottom-nav .active { color: var(--bs-primary); font-weight: 500; }

.page-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 1rem; display: flex; gap: .5rem; align-items: center; }
.page-title .bi { color: var(--bs-secondary-color); }
.card { border-color: var(--bs-border-color-translucent); box-shadow: 0 1px 2px rgba(0,0,0,.04); }

/* contatori */
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); }

/* semaforo */
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--sn-off); }
.dot-ok { background: var(--sn-ok); }
.dot-warn { background: var(--sn-warn); }
.dot-crit { background: var(--sn-crit); }

/* barre risorse */
.meter { height: 6px; border-radius: 3px; background: var(--bs-secondary-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--viz-series-1); width: 0; border-radius: 3px; }
.meter > span.warn { background: var(--sn-warn); }
.meter > span.crit { background: var(--sn-crit); }

/* autenticazione */
.auth-page { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-page .content { width: 100%; max-width: 400px; padding: 0; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; font-weight: 600; font-size: 1.4rem; }
.auth-brand .bi { color: var(--bs-primary); width: 1.4em; height: 1.4em; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.qr-box { background: #fff; padding: .75rem; border-radius: .5rem; display: inline-block; }
.qr-box img { width: 200px; height: 200px; display: block; }
.secret-text { font-family: var(--bs-font-monospace); word-break: break-all; font-size: .9rem; }
.recovery-list { columns: 2; font-family: var(--bs-font-monospace); font-size: 1rem; list-style: none; padding: 0; }
.recovery-list li { padding: .2rem 0; }

@media print {
  .sidebar, .bottom-nav, .topbar, .no-print { display: none !important; }
  .with-nav .content { margin: 0; }
}
.card-narrow { max-width: 560px; }
.offcanvas.offcanvas-bottom { --bs-offcanvas-height: auto; max-height: 85vh; }
.offcanvas-bottom .offcanvas-body { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.setup-step { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; }
.setup-num {
  flex: 0 0 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-weight: 600; font-size: .85rem;
}
.setup-step > div { min-width: 0; }
.input-group .secret-text { white-space: normal; word-break: break-all; height: auto; }
details summary { cursor: pointer; }

/* indicatori circolari */
.gauges { display: flex; flex-wrap: wrap; gap: .75rem 1rem; }
.gauge { margin: 0; text-align: center; width: 72px; }
.gauge > svg { width: 72px; height: 72px; display: block; }
.gauge-track { fill: none; stroke: var(--viz-track); stroke-width: 7; }
.gauge-arc { fill: none; stroke: var(--viz-series-1); stroke-width: 7; stroke-linecap: round; }
.gauge-arc.warn { stroke: var(--viz-warn); }
.gauge-arc.crit { stroke: var(--viz-crit); }
.gauge-val { fill: var(--bs-body-color); font-size: 17px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.gauge-unit { font-size: 10px; font-weight: 400; fill: var(--bs-secondary-color); }
.gauge figcaption { font-size: .75rem; color: var(--bs-secondary-color); line-height: 1.2; margin-top: .15rem; }
.gauge figcaption small { display: block; font-size: .68rem; }
.gauge-flag .bi { width: .85em; height: .85em; margin-left: .2rem; }
.gauge-warn { color: #b07a00; } [data-bs-theme="dark"] .gauge-warn { color: var(--viz-warn); }
.gauge-crit { color: var(--viz-crit); }

/* mini-grafico */
.spark svg { width: 100%; height: 40px; display: block; }
.spark-line { fill: none; stroke: var(--viz-series-1); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-area { fill: var(--viz-area); stroke: none; }
.spark-grid { stroke: var(--viz-grid); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark-legend { display: flex; justify-content: space-between; font-size: .7rem; color: var(--bs-secondary-color); margin-top: .15rem; }
.spark-empty { height: 40px; display: flex; align-items: center; }

/* stato: icona + testo */
.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 500; }
.status-ok .bi { color: var(--viz-good); }
.status-warn .bi { color: var(--viz-warn); }
.status-crit .bi { color: var(--viz-crit); }
.status-off .bi, .status-none .bi { color: var(--viz-off); }
.status-off, .status-none { color: var(--bs-secondary-color); }

/* card server */
.server-card { transition: border-color .15s; }
.server-card:hover { border-color: var(--bs-primary-border-subtle); }
.server-card.is-off { opacity: .7; }
.chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; padding: .1rem .45rem; border-radius: 1rem;
  background: var(--bs-secondary-bg); color: var(--bs-secondary-color); }
.chip-warn { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.chip-crit { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }

/* grafici del dettaglio */
.chart-box { position: relative; height: 220px; }
.range-switch .btn { min-width: 3.2rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; font-size: .85rem; margin: 0; }
.kv dt { color: var(--bs-secondary-color); font-weight: 400; }
.kv dd { margin: 0; }
.cmd-box { font-family: var(--bs-font-monospace); font-size: .78rem; white-space: pre-wrap; word-break: break-all;
  background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: .6rem .75rem; }

/* barra degli stati (Panoramica): segmenti separati da 2px */
.state-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--viz-track); }
.state-bar > span { display: block; height: 100%; }
.state-bar .state-ok { background: var(--viz-good); }
.state-bar .state-warn { background: var(--viz-warn); }
.state-bar .state-crit { background: var(--viz-crit); }
.state-bar .state-off, .state-bar .state-none { background: var(--viz-off); }
a.card .stat-value { color: var(--bs-body-color); }
a.card .stat-value.text-danger { color: var(--bs-danger) !important; }
.proc-name { max-width: 9rem; }
.proc-val { min-width: 9.5rem; font-variant-numeric: tabular-nums; }
.alias-cell, .path-cell { max-width: 22rem; }
.server-actions { min-width: 18rem; }
/* 4 indicatori sempre su una riga nelle card della Panoramica */
.server-card .gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.server-card .gauge { width: auto; }
.server-card .gauge > svg { width: 100%; max-width: 72px; height: auto; margin: 0 auto; }
.server-card .gauge figcaption { font-size: .72rem; }
.server-card .gauge figcaption small { font-size: .64rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* tabelle lunghe: riquadro scorrevole con intestazione fissa */
.table-scroll { max-height: 26rem; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 1; }

/* motivi in chiaro */
.issue { display: flex; gap: .45rem; align-items: flex-start; font-size: .85rem; line-height: 1.35; margin-bottom: .35rem; }
.issue .bi { margin-top: .15rem; }
.issue-crit .bi { color: var(--viz-crit); }
.issue-warn .bi { color: #b07a00; } [data-bs-theme="dark"] .issue-warn .bi { color: var(--viz-warn); }
.issue-todo .bi { color: var(--viz-series-1); }
.issue-off .bi, .issue-none .bi { color: var(--viz-off); }
.server-card .issue { font-size: .8rem; }

/* report */
.load-table td { vertical-align: middle; }
.load-cell { min-width: 6.5rem; }
@media (max-width: 575.98px) {
  .load-cell { min-width: 3.6rem; }
  .load-table th, .load-table td { padding-left: .25rem; padding-right: .25rem; }
  .load-table .status { font-size: .7rem; }
}
.mount-name { max-width: 6rem; font-size: .72rem; }
.load-cell .meter { margin-top: .2rem; }
.load-num { font-variant-numeric: tabular-nums; font-weight: 500; }
.machine-card .kv { font-size: .8rem; }
.summary-line { font-size: 1.05rem; }
.issue-ok .bi { color: var(--viz-good); }
