/* ══════════════════════════════════════════════════════════════════════
   Pannello userbot — design "glass"
   Sfondo lavanda con sfumature, schede di vetro, navigazione blu notte,
   titoli in Inter con l'accento in Instrument Serif corsivo.
   Chiaro e scuro seguono il tema di Telegram (data-scheme).
   ══════════════════════════════════════════════════════════════════════ */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("/static/fonts/Inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/static/fonts/InstrumentSerif-Italic-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --page: #eceefb;
  --page-2: #e3e6f8;
  --blob-1: #d9ddff;
  --blob-2: #efe4ff;
  --blob-3: #dff3ff;
  --glass: rgba(255, 255, 255, .72);
  --glass-strong: rgba(255, 255, 255, .9);
  --glass-border: rgba(255, 255, 255, .85);
  --surface: #ffffff;
  --surface-2: #f3f4fb;
  --text: #0e1124;
  --muted: #7a7f9a;
  --line: rgba(20, 28, 80, .08);
  --line-strong: rgba(20, 28, 80, .14);
  --shadow: 0 1px 2px rgba(22, 30, 80, .04), 0 10px 30px rgba(22, 30, 80, .07);
  --accent: #4f5ee8;
  --accent-2: #6d7bff;
  --accent-text: #ffffff;
  --accent-soft: rgba(79, 94, 232, .1);
  --link: #4351d6;
  --serif: #5463e6;
  --navy: #1c2257;
  --navy-2: #262d6e;
  --navy-text: #e8ebff;
  --navy-muted: #a3aada;

  --ok: #16a34a;
  --warn: #d48806;
  --bad: #dc3c3d;
  --ok-soft: rgba(22, 163, 74, .12);
  --warn-soft: rgba(242, 166, 0, .16);
  --bad-soft: rgba(220, 60, 61, .11);

  /* serie dei grafici (validate per daltonismo e contrasto) */
  --series-1: #4f5ee8;
  --series-2: #f47230;
  --status-warning: #fbb315;
  --status-critical: #dc3c3d;
  --mon-1: #12b293;
  --mon-2: #7c86ee;
  --grid: rgba(20, 28, 80, .07);
  --axis: rgba(20, 28, 80, .18);

  --cat-1: #257de0; --cat-2: #f47230; --cat-3: #00b894; --cat-4: #f2a600;
  --cat-5: #ee7fac; --cat-6: #008a17; --cat-7: #6a4ce2; --cat-8: #ec4647;

  --radius: 22px;
  --radius-sm: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif-font: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rail-w: 76px;
  --nav-h: 66px;
}
:root[data-scheme="dark"] {
  color-scheme: dark;
  --page: #0b0e22;
  --page-2: #0e1230;
  --blob-1: #1d2466;
  --blob-2: #2a1d55;
  --blob-3: #10325a;
  --glass: rgba(255, 255, 255, .055);
  --glass-strong: rgba(28, 33, 74, .92);
  --glass-border: rgba(255, 255, 255, .09);
  --surface: #161a3d;
  --surface-2: rgba(255, 255, 255, .06);
  --text: #eef0ff;
  --muted: #9aa0c6;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .15);
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
  --accent: #6d7bff;
  --accent-2: #8c98ff;
  --accent-soft: rgba(109, 123, 255, .16);
  --link: #9aa6ff;
  --serif: #a4adff;
  --navy: #12163b;
  --navy-2: #1c2257;
  --ok: #34c467;
  --warn: #fbb315;
  --series-1: #8a8ff5;
  --series-2: #e76624;
  --grid: rgba(255, 255, 255, .07);
  --axis: rgba(255, 255, 255, .2);
  --cat-1: #338ced; --cat-2: #e76624; --cat-3: #00a888; --cat-4: #d28e05;
  --cat-5: #e24d8b; --cat-6: #0aac23; --cat-7: #9887ef; --cat-8: #eb6263;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page-2);
  color: var(--text);
  font: 15px/1.45 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* sfondo con sfumature morbide */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 36% at 12% 8%, var(--blob-1) 0%, transparent 70%),
    radial-gradient(38% 34% at 92% 18%, var(--blob-2) 0%, transparent 70%),
    radial-gradient(46% 40% at 70% 96%, var(--blob-3) 0%, transparent 70%),
    linear-gradient(180deg, var(--page) 0%, var(--page-2) 100%);
}

/* ── navigazione: pillola blu notte ── */
.rail {
  position: fixed; z-index: 30; background: linear-gradient(180deg, var(--navy-2), var(--navy));
  box-shadow: 0 16px 40px rgba(18, 22, 60, .35);
  left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
  border-radius: 999px; padding: 7px; width: min(420px, calc(100% - 28px));
}
.rail-logo { display: none; }
.rail-items { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.rail-items button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 52px; border: 0; border-radius: 999px; background: transparent; color: var(--navy-muted);
  font-size: 10.5px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s;
}
.rail-items button svg.ic { width: 21px; height: 21px; }
.rail-items button.active { background: #fff; color: var(--navy); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.rail-items button .label { line-height: 1; }
.rail-items button .dot { position: absolute; top: 8px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: #ff5a5f; box-shadow: 0 0 0 2px var(--navy); }

.shell { padding: 0 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); max-width: 1340px; margin: 0 auto; }

@media (min-width: 900px) {
  .rail {
    left: 18px; top: 18px; bottom: 18px; transform: none; width: var(--rail-w); border-radius: 999px;
    padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 22px;
  }
  .rail-logo {
    display: block; width: 44px; height: 44px; border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #fff 0 3px, transparent 4px), conic-gradient(from 45deg, #fff 0 25%, #c9cfff 0 50%, #fff 0 75%, #c9cfff 0);
    mask: radial-gradient(circle, #000 64%, transparent 65%); opacity: .95;
  }
  .rail-items { display: flex; flex-direction: column; gap: 10px; }
  .rail-items button { width: 50px; height: 50px; border-radius: 50%; }
  .rail-items button .label { display: none; }
  .rail-items button::after {
    content: attr(data-label); position: absolute; left: 62px; top: 50%; transform: translateY(-50%);
    background: var(--navy); color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 8px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .15s;
  }
  .rail-items button:hover::after { opacity: 1; }
  .shell { padding: 0 28px 40px calc(var(--rail-w) + 44px); }
}

/* ── barra superiore ── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 6px; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumb {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 13px; color: var(--muted); white-space: nowrap; box-shadow: var(--shadow);
}
.crumb b { color: var(--text); font-weight: 700; }
.crumb-sep { opacity: .6; }
#crumb-page { color: var(--text); font-weight: 600; }
.clock { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.clock b { color: var(--text); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; }
.live-dot.stale { background: var(--muted); box-shadow: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bell, .icon-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--text); flex: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.bell .count {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ff4d55; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--page);
}
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.who {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 999px; min-width: 0;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow); cursor: pointer;
}
.who select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.who select:disabled { cursor: default; }
.who-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; background: var(--accent); flex: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.who-text b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.who-text small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.who-caret { width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); margin-left: 2px; }
@media (max-width: 560px) {
  .clock, .crumb { display: none; }
  .topbar-right { flex: 1; justify-content: flex-end; }
  .who { flex: 0 1 auto; }
  .who-text small { display: none; }
  .who-text b { max-width: 92px; }
}

/* ── contenuto ── */
.view { transition: opacity .2s; }
.view.loading { opacity: .6; }

/* intestazione di pagina: "Bentornato, Mattia" */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 14px 2px 18px; flex-wrap: wrap; }
.head-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.head-chip .sep { opacity: .5; }
.head-chip .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--glass-strong); color: var(--text); font-weight: 600; border: 1px solid var(--glass-border); }
.head-chip .pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.head-chip .pill.ok i { background: var(--ok); }
.head-chip .pill.warn i { background: var(--warn); }
.head-chip .pill.bad i { background: var(--bad); }
.page-head h1 { margin: 0; font-size: clamp(34px, 7vw, 54px); line-height: 1.02; letter-spacing: -.035em; font-weight: 700; }
.page-head h1 em {
  display: block; font-family: var(--serif-font); font-style: italic; font-weight: 400; letter-spacing: -.01em;
  color: var(--serif); background: linear-gradient(90deg, var(--accent) 0%, #8a6cf0 100%); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; padding-right: .08em;
}
.page-head h1 em.inline { display: inline; }
.page-head .sub { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 4px 12px; }
.section-title h2 { font-size: 17px; letter-spacing: -.01em; margin: 0; font-weight: 700; }
.section-title .aside { font-size: 12.5px; color: var(--muted); }

.card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px; box-shadow: var(--shadow); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.card.flush { padding: 6px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-text { color: var(--bad); font-size: 12.5px; word-break: break-word; margin-top: 6px; }
.clickable { cursor: pointer; }

/* griglia della dashboard: contenuto + colonna del monitor */
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 0 18px; }
.dash-grid > div { min-width: 0; }
@media (min-width: 1040px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 370px; grid-template-rows: auto 1fr; align-items: start; }
  .dash-a { grid-column: 1; grid-row: 1; }
  .dash-b { grid-column: 1; grid-row: 2; }
  .dash-side { grid-column: 2; grid-row: 1 / span 2; }
  .dash-side .section-title:first-child { margin-top: 0; }
}
.dash-a > .kpis { margin-bottom: 14px; }

/* ── tile dei numeri ── */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.view, .dash-a, .dash-b { container-type: inline-size; }
@container (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 16px; min-width: 0;
  box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); position: relative; overflow: hidden;
}
.kpi-label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text); }
.kpi-label .kicon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--glass-strong); border: 1px solid var(--line); color: var(--text); }
.kpi-label .kicon svg.ic { width: 15px; height: 15px; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 14px; }
.kpi-value { font-size: 34px; font-weight: 700; letter-spacing: -.04em; line-height: 1; white-space: nowrap; }
.kpi-chart { flex: 1; max-width: 110px; height: 40px; }
.kpi-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 5px; }
.kpi-foot .up { color: var(--ok); font-weight: 700; }
.kpi.alert .kpi-value { color: var(--bad); }
.kpi.alert .kicon { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

/* ── monitor scuro (come il "Patient Monitor") ── */
.monitor {
  background: radial-gradient(120% 80% at 100% 0%, #2c3488 0%, transparent 60%), linear-gradient(170deg, var(--navy-2) 0%, var(--navy) 100%);
  color: var(--navy-text); border-radius: 26px; padding: 18px; margin-bottom: 14px; box-shadow: 0 20px 50px rgba(18, 22, 60, .35);
  border: 1px solid rgba(255, 255, 255, .08);
}
.monitor .live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: #ff7a80; letter-spacing: .06em; }
.monitor .live i { width: 7px; height: 7px; border-radius: 50%; background: #ff5a5f; box-shadow: 0 0 0 3px rgba(255, 90, 95, .25); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 90, 95, 0); } }
.monitor h3 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.01em; }
.monitor .mon-tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, .07); border-radius: 999px; padding: 3px; }
.monitor .mon-tabs button { border: 0; background: transparent; color: var(--navy-muted); font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.monitor .mon-tabs button.active { background: #fff; color: var(--navy); }
.monitor .screen { margin-top: 14px; background: rgba(6, 10, 34, .45); border-radius: 18px; padding: 12px 10px 6px; border: 1px solid rgba(255, 255, 255, .06); }
.monitor .chart text { fill: var(--navy-muted); }
.monitor .chart text.end-label { fill: var(--navy-text); }
.monitor .chart .grid { stroke: rgba(255, 255, 255, .06); }
.monitor .chart .axis, .monitor .chart .crosshair { stroke: rgba(255, 255, 255, .2); }
.monitor .legend { color: var(--navy-muted); }
.monitor details.table-view summary { color: #b7c0ff; }
.monitor details.table-view th, .monitor details.table-view td { border-color: rgba(255, 255, 255, .08); }
.mon-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.mon-tile { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06); border-radius: 16px; padding: 10px 12px; }
.mon-tile .k { font-size: 11px; color: var(--navy-muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mon-tile .k i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.mon-tile .v { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 2px; }
.mon-tile .v small { font-size: 13px; color: var(--navy-muted); font-weight: 600; margin-left: 2px; }
.mon-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--navy-muted); }
.mon-foot .btn { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .1); }

/* ── badge di stato ── */
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: 999px; white-space: nowrap; background: var(--glass-strong); color: var(--muted); border: 1px solid var(--line);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status svg.ic { display: none; }
.status.ok { color: var(--text); } .status.ok::before { background: var(--ok); }
.status.warn { color: var(--text); } .status.warn::before { background: var(--warn); }
.status.bad { color: var(--bad); } .status.bad::before { background: var(--bad); }

/* ── barre ── */
.meter + .meter { margin-top: 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 13px; }
.meter-head b { font-weight: 600; }
.track { height: 7px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; margin-top: 7px; }
.track > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s ease; }
.track.warn { background: var(--warn-soft); } .track.warn > i { background: var(--warn); }
.track.bad { background: var(--bad-soft); } .track.bad > i { background: var(--bad); }
.track.ok { background: var(--ok-soft); } .track.ok > i { background: var(--ok); }

/* ── anelli ── */
.ring { position: relative; flex: none; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring .ring-label b { font-size: 20px; letter-spacing: -.03em; }
.ring .ring-label small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }

/* ── grafici ── */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart text.end-label { fill: var(--text); font-weight: 600; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .col.active { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.chart-empty { display: grid; place-items: center; height: 150px; color: inherit; opacity: .7; font-size: 13px; text-align: center; padding: 0 20px; }
details.table-view { margin-top: 10px; font-size: 12.5px; }
details.table-view summary { cursor: pointer; color: var(--link); font-weight: 600; }
details.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
details.table-view th, details.table-view td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
details.table-view th:first-child, details.table-view td:first-child { text-align: left; }
details.table-view .scroll { max-height: 220px; overflow: auto; }

.tooltip {
  position: fixed; z-index: 90; pointer-events: none; min-width: 120px; background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--glass-border); border-radius: 14px; padding: 9px 11px; font-size: 12.5px;
  box-shadow: 0 14px 34px rgba(18, 22, 60, .22); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tooltip .t-head { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; min-width: 36px; }
.tooltip .t-row i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip .t-row i.box { width: 9px; height: 9px; border-radius: 3px; }

.hbar { display: grid; grid-template-columns: minmax(70px, 130px) 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.hbar + .hbar { margin-top: 11px; }
.hbar .track { margin: 0; height: 10px; background: var(--accent-soft); }
.hbar code { font-family: var(--mono); font-size: 12.5px; }

/* ── liste ── */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.li-icon { width: 38px; height: 38px; border-radius: 50%; background: var(--glass-strong); border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent); flex: none; }
.li-icon svg.ic { width: 17px; height: 17px; }
.li-icon.muted-icon { color: var(--muted); }
.li-icon.warn-icon { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.li-title { font-weight: 600; }
.li-sub { font-size: 12.5px; color: var(--muted); }
.list-item.clickable:hover { background: var(--accent-soft); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; color: var(--muted); text-align: center; font-size: 14px; }
.empty-state svg.ic { width: 30px; height: 30px; opacity: .55; }
.check { display: flex; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check .ci { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check .ci svg.ic { width: 15px; height: 15px; stroke-width: 2.6; }
.check.ok .ci { background: var(--ok-soft); color: var(--ok); }
.check.warn .ci { background: var(--warn-soft); color: var(--warn); }
.check.bad .ci { background: var(--bad-soft); color: var(--bad); }
.check .ct { font-weight: 600; font-size: 14px; }
.check .cd { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--link); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; margin: 5px 4px 0 0; }
code { font-family: var(--mono); font-size: 13px; }

/* ── schede account (come le schede persona) ── */
.acc-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@container (min-width: 520px) { .acc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 820px) { .acc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.acc-card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 18px; cursor: pointer;
  box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); transition: transform .15s ease, box-shadow .15s;
}
.acc-card:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(22, 30, 80, .12); }
.acc-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.acc-card .name { font-weight: 700; font-size: 16px; margin-top: 12px; letter-spacing: -.01em; }
.acc-card .role { font-size: 12.5px; color: var(--muted); }
.acc-card .chips-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.mini-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--link); font-weight: 600; font-size: 11.5px; }
.acc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.acc-stats > div { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; padding: 9px 10px; display: flex; flex-direction: column; }
.acc-stats b { font-size: 17px; letter-spacing: -.02em; }
.acc-stats span { font-size: 11px; color: var(--muted); }
.acc-stats .alert b { color: var(--bad); }
.card > .acc-stats:first-child { margin-top: 0; }
.acc-stats > div.clickable:hover { border-color: var(--accent); }
.acc-card .uptime { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.acc-card .uptime .track { flex: 1; margin: 0; height: 5px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  color: #fff; font-weight: 700; font-size: 19px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ring, transparent);
}
.avatar.sm { width: 38px; height: 38px; font-size: 15px; box-shadow: 0 0 0 2px var(--surface); }
.avatar.dark-text { color: #0b0b0b; }
.avatar .presence { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 2.5px var(--surface); }
.avatar .presence.ok { background: var(--ok); } .avatar .presence.warn { background: var(--warn); } .avatar .presence.bad { background: var(--bad); }
.acc-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-right: 8px; }
.acc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.acc-row { padding: 16px 18px; border-top: 1px solid var(--line); }
.acc-row:first-child { border-top: 0; }
.acc-row .job-actions { margin-top: 12px; }

/* riepilogo stati (anello multicolore, come "Shift coverage") */
.coverage { display: flex; align-items: center; gap: 18px; }
.coverage-list { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.coverage-list .row { font-size: 13px; }
.coverage-list .row span { display: inline-flex; align-items: center; gap: 8px; }
.coverage-list .row i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ── job di clone (come le schede dei reparti) ── */
.job-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@container (min-width: 640px) { .job-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1000px) { .job-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.job-card { background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.job-card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-card .title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.job-card .title .badge-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #7b6cf0); color: #fff; flex: none; }
.job-card .title .badge-ic svg.ic { width: 18px; height: 18px; }
.job-card .body { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.job-card .facts { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 0; }
.job-card .facts .row span:first-child { color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.job-card .facts .row b { font-variant-numeric: tabular-nums; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ── pulsanti ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; padding: 10px 16px;
  border-radius: 999px; font-weight: 600; font-size: 13.5px; background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--line-strong); transition: transform .1s ease, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn svg.ic { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff; border-color: transparent; box-shadow: 0 8px 20px rgba(79, 94, 232, .3); }
.btn.danger { color: var(--bad); }
.btn.danger-fill { background: var(--bad); color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.btn-grid .btn { flex-direction: column; padding: 16px 6px; font-size: 12.5px; gap: 8px; border-radius: 18px; }
.btn-grid .btn svg.ic { width: 21px; height: 21px; }
.link-btn { border: 0; background: none; color: var(--link); font-weight: 600; cursor: pointer; padding: 0; font-size: 13px; }

.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + span { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }

/* filtri: segmenti e chip con conteggio */
.seg { display: flex; gap: 4px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 999px; padding: 4px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; white-space: nowrap; border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(22, 30, 80, .1); }
:root[data-scheme="dark"] .seg button.active { background: rgba(255, 255, 255, .12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--glass-border); background: var(--glass); border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.active { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: 0 2px 8px rgba(22, 30, 80, .08); }
:root[data-scheme="dark"] .chip.active { background: rgba(255, 255, 255, .12); }
.search { display: flex; align-items: center; gap: 9px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 999px; padding: 0 16px; margin-bottom: 12px; color: var(--muted); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.search input { flex: 1; border: 0; background: transparent; padding: 11px 0; outline: none; color: var(--text); min-width: 0; }
.field { display: flex; gap: 8px; align-items: center; flex: none; }
.field input[type="number"], .field input[type="text"] { width: 104px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--glass-strong); text-align: right; }
.field input[type="text"] { width: 136px; text-align: left; }
@media (max-width: 380px) { .field input[type="number"] { width: 78px; } .field input[type="text"] { width: 98px; } }
textarea { width: 100%; min-height: 90px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line-strong); background: var(--glass-strong); resize: vertical; }

.event { padding: 13px 18px; border-top: 1px solid var(--line); cursor: pointer; }
.event:first-child { border-top: 0; }
.event-title { font-weight: 600; font-size: 14px; }
.event pre { display: none; }
.event.open pre { display: block; }
pre { margin: 10px 0 0; padding: 11px 13px; background: var(--glass-strong); border-radius: 14px; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11.5px; max-height: 340px; overflow: auto; }
.logbox { max-height: 62vh; overflow: auto; padding: 10px 14px; background: var(--navy); color: #dfe3ff; border-radius: var(--radius); box-shadow: var(--shadow); }
.logline { font-family: var(--mono); font-size: 11.5px; padding: 3px 0; white-space: pre-wrap; word-break: break-word; }
.logline time { color: #8c93c7; margin-right: 8px; }
.logline .lvl { margin-right: 6px; font-weight: 700; }
.logline.warn .lvl { color: #ffc24b; }
.logline.bad .lvl { color: #ff7a80; }
.logbox .empty-state { color: #a3aada; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .chips { margin-bottom: 0; }
.toggle-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.more-btn { margin: 0 0 12px; }
.list-foot { margin: 4px 4px 0; }

.kv + .kv { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.kv b { font-weight: 600; max-width: 60%; text-align: right; }
.list-item .icon-btn { width: 36px; height: 36px; box-shadow: none; color: var(--muted); }
.list-item .icon-btn svg.ic { width: 17px; height: 17px; }
.list-item .switch + .icon-btn { margin-left: -4px; }

/* ── banner, toast, foglio ── */
.banner { margin: 6px 0 0; }
.banner > div { display: flex; gap: 10px; align-items: center; padding: 11px 16px; border-radius: 999px; background: var(--warn-soft); color: var(--text); font-size: 13.5px; border: 1px solid rgba(242, 166, 0, .25); }
.banner > div.bad { background: var(--bad-soft); border-color: rgba(220, 60, 61, .25); }
.banner svg.ic { color: var(--warn); flex: none; }
.banner > div.bad svg.ic { color: var(--bad); }
@media (max-width: 560px) { .banner > div { border-radius: 16px; } }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom)); z-index: 95; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { display: flex; align-items: center; gap: 10px; max-width: 480px; width: 100%; background: var(--navy); color: #fff; padding: 13px 16px; border-radius: 18px; font-size: 13.5px; box-shadow: 0 14px 36px rgba(18, 22, 60, .35); animation: toast-in .22s ease-out; }
.toast svg.ic { width: 18px; height: 18px; }
.toast.ok svg.ic { color: #4bd865; } .toast.bad svg.ic { color: #ff7b7c; } .toast.info svg.ic { color: #9aa6ff; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(14, 17, 45, .42); z-index: 80; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85; max-height: 86vh; overflow: auto;
  background: var(--glass-strong); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 28px 28px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; animation: sheet-in .25s ease-out; border: 1px solid var(--glass-border);
}
:root:not([data-scheme="dark"]) .sheet { background: rgba(255, 255, 255, .95); }
@media (min-width: 900px) { .sheet { bottom: 50%; transform: translateY(50%); border-radius: 28px; padding-bottom: 18px; } }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.sheet .sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet .sheet-actions .btn { flex: 1; padding: 13px 16px; }
.sheet-actions.sticky { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: inherit; padding: 12px 0 calc(6px + env(safe-area-inset-bottom)); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 900px) { @keyframes sheet-in { from { opacity: 0; } } }

.skeleton { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--glass) 0%, var(--glass-strong) 50%, var(--glass) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin-bottom: 14px; border: 1px solid var(--glass-border); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── messaggi in evidenza e procedura guidata ── */
.callout { display: flex; align-items: center; gap: 14px; border-left: 4px solid var(--bad); }
.callout.warn { border-left-color: var(--warn); }
.callout > svg.ic { color: var(--warn); }
.add-card h3 { margin: 0 0 2px; font-size: 16px; }
.add-card .btn { margin-top: 16px; }
.add-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.pick-title { margin: 0 0 4px; }
.stepper { display: flex; gap: 6px; margin: 12px 0 16px; }
.step { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-radius: 999px; background: var(--surface-2); }
.step i { font-style: normal; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; background: var(--line-strong); color: var(--surface); flex: none; }
.step.current { color: var(--text); background: var(--accent-soft); }
.step.current i { background: var(--accent); color: #fff; }
.step.done i { background: var(--ok); color: #fff; }
.form-field { display: flex; flex-direction: column; gap: 7px; margin: 14px 0; font-size: 13px; font-weight: 600; }
.form-field input { width: 100%; padding: 13px 16px; border-radius: 16px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 16px; font-weight: 500; outline: none; }
.form-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-field small { font-weight: 400; color: var(--muted); font-size: 12px; }
.code-input { letter-spacing: .45em; font-variant-numeric: tabular-nums; text-align: center; font-size: 24px !important; }
details.advanced { margin-top: 6px; font-size: 13px; }
details.advanced summary { cursor: pointer; color: var(--link); font-weight: 600; }
.form-error { display: flex; gap: 8px; align-items: flex-start; padding: 11px 14px; border-radius: 16px; background: var(--bad-soft); color: var(--text); font-size: 13.5px; margin-top: 8px; }
.form-error svg.ic { color: var(--bad); flex: none; }
.done-box { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 14px 6px 4px; }
.done-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.done-icon svg.ic { width: 30px; height: 30px; stroke-width: 2.6; }
.check-row { display: flex; gap: 10px; align-items: center; font-size: 14px; margin: 12px 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* pannello aperto fuori da Telegram o senza permesso */
body.locked .rail, body.locked .bell, body.locked .who, body.locked #refresh { display: none; }
.who.single { cursor: default; }
.who.single .who-caret { display: none; }
