/* Tecnoside Health: un solo foglio di stile per PWA e app Windows. Tema scuro olografico. */
:root {
  --bg: #04060a;
  --fg: #e9eef6;
  --muted: #8591a4;
  --dim: #5d687a;
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.13);
  --card: linear-gradient(180deg, rgba(24, 28, 36, 0.78), rgba(11, 14, 19, 0.78));
  --tile: rgba(255, 255, 255, 0.035);
  --blue: #3d8bff;
  --blue2: #7cc0ff;
  --gold: #ffc240;
  --red: #ff4a50;
  --good: #3ddc84;
  --warn: #ffc240;
  --bad: #ff5a5f;
  --info: #5aa9ff;
  --r-card: 28px;
  --r-tile: 18px;
  --font: 'Bahnschrift', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--fg); }
a { color: var(--blue2); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; letter-spacing: 0.01em; }
p { margin: 0; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, 'SF Mono', monospace; font-size: 12.5px; }
.mt { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.gap { gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
::selection { background: rgba(61, 139, 255, 0.35); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Struttura ---------- */
.app { position: relative; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.bg-glow { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 600px at 50% 45%, rgba(40, 90, 200, 0.16), transparent 60%),
    radial-gradient(700px 500px at 8% 0%, rgba(40, 90, 200, 0.12), transparent 60%),
    radial-gradient(600px 500px at 100% 100%, rgba(40, 90, 200, 0.10), transparent 60%),
    linear-gradient(180deg, #05070c, #030407);
}
.topbar, .main, .share-banner { position: relative; z-index: 1; }

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 18px 26px 12px; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 22px; letter-spacing: 0.01em; }
.brand b { font-weight: 600; }
.nav { display: flex; gap: 4px; padding: 5px; border-radius: 999px; background: rgba(8, 10, 15, 0.7); border: 1px solid var(--line2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); }
.nav-btn { display: flex; align-items: center; gap: 9px; padding: 11px 20px; border-radius: 999px; color: #c9d2df; font-size: 13.5px; transition: background 0.2s, color 0.2s; border: 1px solid transparent; }
.nav-btn:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-btn.active { color: #fff; background: linear-gradient(180deg, #2b6fe0, #16489f); border-color: rgba(140, 190, 255, 0.55); box-shadow: 0 0 22px rgba(43, 111, 224, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.top-right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 5px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(8, 10, 15, 0.7); }
.who-t { display: flex; flex-direction: column; line-height: 1.25; padding-right: 8px; min-width: 110px; }
.who-t span { font-size: 11px; }
.who-t b { font-weight: 400; font-size: 13.5px; white-space: nowrap; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #cdd6e3; position: relative; transition: background 0.2s; }
.icon-btn:hover, .icon-btn.on { background: rgba(255, 255, 255, 0.07); }
.icon-btn.big { width: 52px; height: 52px; border: 1px solid var(--line2); background: rgba(8, 10, 15, 0.7); }
.icon-btn.sm { width: 30px; height: 30px; }
.bell-dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); font-size: 10px; display: grid; place-items: center; padding: 0 4px; color: #fff; }

.avatar { border-radius: 50%; display: grid; place-items: center; font-weight: 600; letter-spacing: 0.02em; color: #fff; flex: none;
  background: radial-gradient(circle at 30% 25%, #5b9dff, #1d3f86 70%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.avatar.sm { width: 42px; height: 42px; font-size: 14px; }
.avatar.md { width: 44px; height: 44px; font-size: 14px; }
.avatar.lg { width: 62px; height: 62px; font-size: 20px; box-shadow: 0 0 0 3px rgba(61, 139, 255, 0.6), 0 0 22px rgba(61, 139, 255, 0.4); }
.avatar.xs { width: 44px; height: 44px; font-size: 12.5px; opacity: 0.55; background: radial-gradient(circle at 30% 25%, #3a4a66, #161c28 70%); }

.main { flex: 1; min-height: 0; overflow: auto; padding: 8px 26px 26px; }
.main.view-overview { overflow: hidden; }

.share-banner { display: flex; align-items: center; gap: 8px; margin: 0 26px 10px; padding: 9px 16px; border-radius: 14px; font-size: 12.5px; color: #bcd6ff;
  background: rgba(61, 139, 255, 0.09); border: 1px solid rgba(61, 139, 255, 0.25); }

.bottom-nav { display: none; }

/* ---------- Card ---------- */
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 20px 60px rgba(0, 0, 0, 0.35); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 21px; letter-spacing: 0.01em; }
.updated { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 8px var(--blue); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.dot.info { background: var(--info); box-shadow: 0 0 8px var(--info); }
.round-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #d4dce8; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.025); transition: background 0.2s, border-color 0.2s; }
.round-btn:hover, .round-btn.on { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.25); }
.round-btn.big { width: 54px; height: 54px; background: rgba(8, 10, 15, 0.75); }
.sub-h { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; white-space: nowrap; border: 1px solid transparent; }
.badge.sm { padding: 2px 8px; font-size: 10.5px; margin-left: 6px; }
.badge.good { color: #6ff0a8; background: rgba(61, 220, 132, 0.12); border-color: rgba(61, 220, 132, 0.25); }
.badge.warn { color: #ffd479; background: rgba(255, 194, 64, 0.12); border-color: rgba(255, 194, 64, 0.28); }
.badge.bad { color: #ff8a8e; background: rgba(255, 90, 95, 0.12); border-color: rgba(255, 90, 95, 0.3); }
.badge.info { color: #9fcaff; background: rgba(90, 169, 255, 0.12); border-color: rgba(90, 169, 255, 0.3); }

/* ---------- Panoramica ---------- */
.overview { display: grid; grid-template-columns: minmax(290px, 330px) minmax(0, 1fr) minmax(290px, 330px); gap: 22px; height: 100%; }
.col { min-width: 0; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; overflow-x: hidden; min-height: 0; padding-bottom: 4px; scrollbar-width: none; }
.col::-webkit-scrollbar { display: none; }

.patient .avatars { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 999px; border: 1px solid rgba(61, 139, 255, 0.45); background: rgba(61, 139, 255, 0.06); }
.p-name { font-size: 24px; margin-top: 16px; }
.patient .muted { font-size: 13px; margin-top: 4px; }
.p-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.p-stat { background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 12px 10px; display: flex; flex-direction: column; justify-content: space-between; min-height: 84px; }
.p-stat span { font-size: 11px; color: var(--muted); line-height: 1.2; }
.p-stat b { font-weight: 400; font-size: 19px; text-align: right; margin-top: 12px; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { text-align: left; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--r-tile); padding: 14px 12px 8px; display: flex; flex-direction: column; min-height: 150px; transition: border-color 0.2s, background 0.2s; }
.metric:hover { border-color: rgba(61, 139, 255, 0.35); background: rgba(61, 139, 255, 0.05); }
.metric.flag .m-val b { color: #ff9a9d; }
.m-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.m-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line2); color: #cfd8e5; flex: none; }
.m-val { display: flex; align-items: baseline; gap: 6px; margin-top: 16px; }
.m-val b { font-weight: 400; font-size: 26px; letter-spacing: -0.01em; }
.m-val span { font-size: 12px; color: #aab5c5; }
.m-chart { margin-top: auto; height: 46px; display: flex; align-items: flex-end; }
.m-chart svg { width: 100%; }
.spark, .ecg, .minibars { width: 100%; display: block; }
.ecg { height: 44px; }
.gauge { height: 44px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 11px; border-radius: 12px; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.06); font-size: 12.5px; }
.chip b { font-weight: 400; }
.chip .lvl { color: var(--gold); margin-left: 4px; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.4; }
ul.plain b { font-weight: 500; }
ul.plain.dots li { position: relative; padding-left: 14px; }
ul.plain.dots li::before { content: ''; position: absolute; left: 0; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }

.activity .act-list { display: flex; flex-direction: column; gap: 8px; max-height: 176px; overflow: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent); mask-image: linear-gradient(180deg, #000 78%, transparent); padding-bottom: 20px; }
.act { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-tile); background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); text-align: left; transition: background 0.2s; }
.act:hover { background: rgba(255, 255, 255, 0.06); }
.act-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line2); color: #cfd8e5; flex: none; }
.act-t { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.act-t b { font-weight: 400; font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act-t .muted { font-size: 12px; }

.med-row { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin-right: -20px; padding-right: 20px;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.med-row::-webkit-scrollbar { display: none; }
.med { position: relative; flex: 0 0 132px; scroll-snap-align: start; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--r-tile); padding: 12px 12px 12px; min-height: 112px; display: flex; flex-direction: column; overflow: hidden; }
.med b { font-weight: 400; font-size: 15px; line-height: 1.2; padding-right: 30px; }
.med .muted { font-size: 11.5px; margin-top: auto; padding-top: 10px; padding-right: 36px; line-height: 1.25; }
.med-bar { display: flex; gap: 3px; margin-top: 8px; width: 62px; }
.med-bar span { height: 10px; flex: 1; border-radius: 5px; background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 4px); }
.med-bar span.on { background: linear-gradient(90deg, #2f7cff, #7cc0ff); box-shadow: 0 0 10px rgba(61, 139, 255, 0.6); }
.med-img { position: absolute; right: 4px; bottom: 6px; width: 44px; height: 58px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)); }

.summary { padding: 0; overflow: hidden; min-height: 216px; cursor: pointer; border-color: rgba(61, 139, 255, 0.3);
  background: radial-gradient(120% 90% at 100% 100%, rgba(36, 104, 230, 0.55), transparent 55%), linear-gradient(180deg, rgba(20, 30, 50, 0.85), rgba(10, 18, 36, 0.9)); flex: none; }
.sum-body { position: absolute; inset: 0; }
.sum-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.9;
  -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000 60%); mask-image: linear-gradient(90deg, transparent 20%, #000 60%); }
.sum-content { position: relative; padding: 20px; display: flex; flex-direction: column; min-height: 216px; }
.pill-badge { align-self: flex-start; padding: 5px 12px; border-radius: 999px; font-size: 11.5px; color: #9fcaff; background: rgba(61, 139, 255, 0.15); border: 1px solid rgba(61, 139, 255, 0.4); margin-top: -4px; }
.summary h4 { font-size: 20px; margin-top: auto; padding-top: 20px; }
.summary p { font-size: 12.5px; color: #b8c3d4; margin-top: 8px; line-height: 1.45; max-width: 290px; }

/* Palco centrale */
.stage { position: relative; min-width: 0; min-height: 0; border-radius: 30px; overflow: hidden; }
.stage:fullscreen { background: radial-gradient(900px 700px at 50% 50%, rgba(40, 90, 200, 0.2), transparent 70%), #04060a; border-radius: 0; }
.body-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.body-canvas:active { cursor: grabbing; }
.stage-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.stage-lines line { stroke-width: 1; transition: opacity 0.3s; }
.stage-lines .l-idle { stroke: rgba(210, 225, 255, 0.28); }
.stage-lines .l-gold { stroke: rgba(255, 194, 64, 0.85); }
.stage-lines .l-red { stroke: rgba(255, 74, 80, 0.85); }
.stage-lines .l-blue { stroke: rgba(90, 176, 255, 0.85); }
.ruler { position: absolute; top: 8%; bottom: 16%; width: 12px; pointer-events: none; opacity: 0.35;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 9px); -webkit-mask-image: linear-gradient(180deg, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(180deg, transparent, #000 15%, #000 85%, transparent); }
.ruler::after { content: ''; position: absolute; inset: 0; width: 20px; background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0 1px, transparent 1px 45px); }
.ruler.l { left: 0; }
.ruler.r { right: 0; transform: scaleX(-1); }

.marker { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 3; }
.marker .ring { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid rgba(200, 220, 255, 0.55); background: rgba(5, 8, 14, 0.55); box-shadow: 0 0 14px rgba(120, 170, 255, 0.25); transition: transform 0.2s; }
.marker .ring span { width: 7px; height: 7px; border-radius: 50%; background: #dfe8f5; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.marker:hover .ring { transform: scale(1.12); }
.marker.on .ring { width: 38px; height: 38px; left: -19px; top: -19px; animation: pulse 2.2s infinite; }
.marker.m-gold .ring { border-color: var(--gold); background: rgba(255, 194, 64, 0.22); box-shadow: 0 0 22px rgba(255, 194, 64, 0.7); }
.marker.m-gold .ring span { background: var(--gold); box-shadow: 0 0 0 4px rgba(255, 194, 64, 0.25); }
.marker.m-red .ring { border-color: var(--red); background: rgba(255, 74, 80, 0.22); box-shadow: 0 0 22px rgba(255, 74, 80, 0.7); }
.marker.m-red .ring span { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 74, 80, 0.25); }
.marker.m-blue .ring { border-color: var(--blue2); background: rgba(90, 176, 255, 0.22); box-shadow: 0 0 22px rgba(90, 176, 255, 0.7); }
.marker.m-blue .ring span { background: var(--blue2); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 10px currentColor; } 50% { box-shadow: 0 0 28px currentColor; } }
.marker.m-gold { color: rgba(255, 194, 64, 0.8); }
.marker.m-red { color: rgba(255, 74, 80, 0.8); }
.marker.m-blue { color: rgba(90, 176, 255, 0.8); }
.m-label { position: absolute; top: -26px; white-space: nowrap; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: #d9e2ef; padding-bottom: 5px; }
.m-label::after { content: ''; position: absolute; left: 0; bottom: 0; width: 60%; height: 2px; background: #d9e2ef; border-radius: 2px; }
.marker.side-left .m-label { right: 26px; }
.marker.side-right .m-label { left: 26px; }

.callout { position: absolute; z-index: 4; width: 196px; padding: 16px 16px 14px; }
.callout.left { left: 1.5%; top: 34%; background: linear-gradient(180deg, rgba(90, 14, 20, 0.28), rgba(40, 8, 12, 0.12)); }
.callout.right { right: 1.5%; top: 2%; background: linear-gradient(180deg, rgba(90, 64, 10, 0.3), rgba(40, 28, 6, 0.12)); }
.callout.c-red { --c: var(--red); --c-bg: rgba(255, 74, 80, 0.18); }
.callout.c-gold { --c: var(--gold); --c-bg: rgba(255, 194, 64, 0.18); }
.callout.c-blue { --c: var(--blue2); --c-bg: rgba(90, 176, 255, 0.16); }
.callout.c-red.left, .callout.c-red.right { background: linear-gradient(180deg, rgba(90, 14, 20, 0.3), rgba(40, 8, 12, 0.1)); }
.callout.c-gold.left, .callout.c-gold.right { background: linear-gradient(180deg, rgba(90, 64, 10, 0.32), rgba(40, 28, 6, 0.1)); }
.callout.c-blue.left, .callout.c-blue.right { background: linear-gradient(180deg, rgba(20, 60, 120, 0.32), rgba(10, 30, 60, 0.1)); }
.callout.left { border-right: 1px solid var(--c); border-bottom: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.callout.right { border-left: 1px solid var(--c); border-bottom: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.c-bar { width: 20px; height: 2px; background: var(--c); margin-bottom: 10px; }
.c-eyebrow { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c, var(--blue2)); }
.c-title { font-size: 16.5px; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 8px; line-height: 1.25; }
.callout p { font-size: 12px; color: #b3bdcc; margin-top: 12px; line-height: 1.4; }
.c-metric { font-size: 12px; margin-top: 10px; color: #cfd8e4; }
.c-metric b { font-weight: 400; color: var(--c); }
.c-btn { display: block; width: 100%; margin-top: 14px; padding: 8px 12px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--c); background: var(--c-bg); color: #fff; transition: background 0.2s; }
.c-btn:hover { background: color-mix(in srgb, var(--c) 35%, transparent); }

.stage-controls { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 5%; z-index: 5; pointer-events: none; }
.stage-controls > * { pointer-events: auto; }
.ctl-group { display: flex; gap: 10px; }
.mode-pill { display: flex; gap: 2px; padding: 5px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(8, 10, 15, 0.75); overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
.mode-pill::-webkit-scrollbar { display: none; }
.mode-pill button { padding: 10px 18px; border-radius: 999px; font-size: 13px; color: #b8c2d0; white-space: nowrap; border: 1px solid transparent; }
.mode-pill button:hover { color: #fff; }
.mode-pill button.active { color: #fff; background: linear-gradient(180deg, #2b6fe0, #16489f); border-color: rgba(140, 190, 255, 0.55); box-shadow: 0 0 18px rgba(43, 111, 224, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.zoom-pill { display: flex; border-radius: 999px; border: 1px solid var(--line2); background: rgba(8, 10, 15, 0.75); }
.zoom-pill button { width: 54px; height: 52px; display: grid; place-items: center; color: #cfd8e5; }
.zoom-pill button:hover { color: #fff; }

/* ---------- Pagine ---------- */
.page { max-width: 1480px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 6px 4px 0; }
.page-head h1 { font-size: 30px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.04); font-size: 13px; color: #dfe6f0; white-space: nowrap; transition: background 0.2s; }
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn.primary { background: linear-gradient(180deg, #2b6fe0, #16489f); border-color: rgba(140, 190, 255, 0.55); color: #fff; box-shadow: 0 0 18px rgba(43, 111, 224, 0.35); }
.btn.primary:disabled { opacity: 0.55; cursor: default; }
.btn.danger { color: #ff9a9d; border-color: rgba(255, 90, 95, 0.35); }
.btn.sm { padding: 6px 12px; font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(8, 10, 15, 0.7); align-self: flex-start; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs button { padding: 9px 18px; border-radius: 999px; font-size: 13px; color: #b8c2d0; white-space: nowrap; border: 1px solid transparent; }
.tabs button.active { color: #fff; background: rgba(61, 139, 255, 0.2); border-color: rgba(61, 139, 255, 0.5); }

.table-wrap { overflow-x: auto; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.06); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 400; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; background: rgba(255, 255, 255, 0.025); border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: top; line-height: 1.35; }
td b { font-weight: 500; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
tr.dim td { opacity: 0.5; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(255, 255, 255, 0.03); }
tr.total td { font-weight: 600; background: rgba(255, 255, 255, 0.025); }
tr.planned td { background: rgba(61, 139, 255, 0.05); }
.f-H, .f-H b { color: #ff8a8e !important; }
.f-L, .f-L b { color: #ffd479 !important; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 7px; }
.lgd { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.lgd.dupi { background: rgba(78, 168, 255, 0.35); }
.lgd.mepo { background: rgba(255, 194, 64, 0.35); }
.lgd.none { background: rgba(255, 255, 255, 0.08); }
.lgd.ref { height: 0; border-top: 2px dashed rgba(74, 222, 128, 0.6); border-radius: 0; }
.lgd.dash { width: 10px; height: 10px; border-radius: 50%; border: 2px dashed var(--blue); }

.labchart { position: relative; width: 100%; user-select: none; }
.labchart svg { width: 100%; display: block; overflow: visible; }
.labchart .ax { fill: #6f7c90; font-size: 11px; font-family: var(--font); }
.labchart .ph-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--font); }
.tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: rgba(10, 14, 22, 0.95); border: 1px solid var(--line2); border-radius: 12px; padding: 8px 12px; font-size: 12px; pointer-events: none; display: flex; flex-direction: column; gap: 2px; white-space: nowrap; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); z-index: 3; }
.tip b { font-weight: 500; font-size: 14px; }
.warn-t { color: var(--warn); }
.chart-empty { padding: 40px; text-align: center; color: var(--muted); }

.labs-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.lab-list { padding: 14px; position: sticky; top: 0; max-height: calc(100vh - 190px); display: flex; flex-direction: column; }
.lab-scroll { overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.search-in { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(0, 0, 0, 0.25); color: var(--muted); }
.search-in input { background: none; border: 0; outline: 0; flex: 1; min-width: 0; }
.lab-group .sub-h { margin: 14px 6px 6px; }
.lab-item { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-align: left; border: 1px solid transparent; }
.lab-item:hover { background: rgba(255, 255, 255, 0.04); }
.lab-item.active { background: rgba(61, 139, 255, 0.14); border-color: rgba(61, 139, 255, 0.4); }
.li-name { display: flex; flex-direction: column; font-size: 13px; min-width: 0; }
.li-val { font-size: 13.5px; white-space: nowrap; }
.li-val i { font-style: normal; margin-left: 3px; }
.detail-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 14px; flex-wrap: wrap; }
.detail-head h2 { font-size: 26px; margin-top: 6px; }
.detail-head p { margin-top: 6px; max-width: 560px; font-size: 13px; }
.big-val { text-align: right; }
.big-val b { font-weight: 400; font-size: 40px; letter-spacing: -0.02em; }
.big-val > span { margin-left: 6px; color: #aab5c5; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--line2); display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #2a3342; border: 1px solid #56657c; }
.timeline li.key::before { background: var(--blue); border-color: var(--blue2); box-shadow: 0 0 10px var(--blue); }
.timeline li.key .t-text { color: #fff; font-weight: 500; }
.t-date { font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; }
.t-text { color: #cbd4e1; line-height: 1.4; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 12.5px; line-height: 1.45; margin-top: 14px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.03); }
.note svg { flex: none; margin-top: 1px; }
.note.info { border-color: rgba(90, 169, 255, 0.3); background: rgba(90, 169, 255, 0.07); color: #cfe3ff; }
.note.bad { border-color: rgba(255, 90, 95, 0.35); background: rgba(255, 90, 95, 0.08); color: #ffc2c4; margin-top: 8px; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.doctor { display: flex; flex-direction: column; gap: 10px; }
.doctor b { font-weight: 500; }
.doctor .row .badge { margin-left: auto; }
.doctor.primary { border-color: rgba(61, 139, 255, 0.45); box-shadow: 0 0 30px rgba(61, 139, 255, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.d-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c3cddb; word-break: break-word; }
.d-line svg { flex: none; color: var(--muted); }

.img-list { display: flex; flex-direction: column; gap: 10px; }
.img-item { padding: 12px 14px; border-radius: 16px; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); display: flex; flex-direction: column; gap: 8px; border-left: 3px solid var(--line2); }
.img-item.l-good { border-left-color: var(--good); }
.img-item.l-warn { border-left-color: var(--warn); }
.img-item.l-bad { border-left-color: var(--bad); }
.img-item b { font-weight: 500; }
.img-item p { color: #c3cddb; }
.appt { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.appt:last-child { border-bottom: 0; }
.appt b { font-weight: 500; }
.appt-date { width: 54px; height: 58px; flex: none; border-radius: 14px; border: 1px solid rgba(61, 139, 255, 0.4); background: rgba(61, 139, 255, 0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.appt-date b { font-size: 22px; font-weight: 400; }
.appt-date span { font-size: 11px; text-transform: uppercase; color: #9fcaff; }
.num-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.4; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.docs.drag { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(61, 139, 255, 0.4); }
.docs .card-head .btn { margin-left: auto; }
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.doc-item { display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 16px; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); }
.doc-open { flex: 1; display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0; }
.doc-open > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.doc-open b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(61, 139, 255, 0.12); color: var(--blue2); flex: none; }
.doc-actions { display: flex; }
.doc-frame { width: 100%; height: 72vh; border: 0; border-radius: 14px; background: #fff; }
.doc-frame.img { object-fit: contain; background: #000; }

/* ---------- Modali, pannelli ---------- */
.modal-back, .drawer-back, .popover-back { position: fixed; inset: 0; z-index: 50; }
.modal-back { background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.modal { width: min(520px, 100%); max-height: 92vh; overflow: auto; background: linear-gradient(180deg, #151a23, #0c0f15); border: 1px solid var(--line2); border-radius: 26px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.modal.wide { width: min(1100px, 100%); }
.drawer-back { background: rgba(0, 0, 0, 0.35); }
.drawer { position: absolute; right: 16px; top: 16px; bottom: 16px; width: min(440px, calc(100% - 32px)); overflow: auto; background: linear-gradient(180deg, #151a23, #0c0f15); border: 1px solid var(--line2); border-radius: 26px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 10px; }
.popover { position: absolute; right: 80px; top: 78px; width: 340px; max-height: 60vh; overflow: auto; background: linear-gradient(180deg, #151a23, #0c0f15); border: 1px solid var(--line2); border-radius: 20px; padding: 8px 16px 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif svg { flex: none; margin-top: 2px; color: var(--muted); }
.notif.new svg { color: var(--blue2); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); font-size: 13px; }
.form input:not([type='checkbox']), .form select { width: 100%; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(0, 0, 0, 0.3); outline: 0; font-size: 14px; }
.form input:focus, .form select:focus { border-color: rgba(61, 139, 255, 0.6); }
.form select option, .form select optgroup { background: #10141b; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 90px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.new-link { padding: 14px; border-radius: 16px; border: 1px solid rgba(61, 220, 132, 0.35); background: rgba(61, 220, 132, 0.06); }
.new-link .sub-h { margin-top: 0; }
.link-box { padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); word-break: break-all; user-select: all; }
.share-list { display: flex; flex-direction: column; gap: 10px; }
.share { padding: 12px 14px; border-radius: 16px; background: var(--tile); border: 1px solid rgba(255, 255, 255, 0.05); display: flex; flex-direction: column; gap: 4px; }
.share.off { opacity: 0.55; }
.share b { font-weight: 500; }
.log { margin-top: 8px; gap: 4px; }

.search { position: relative; }
.search-pop { position: absolute; right: 0; top: 62px; width: 380px; z-index: 40; background: linear-gradient(180deg, #151a23, #0c0f15); border: 1px solid var(--line2); border-radius: 20px; padding: 10px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.search-pop input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(0, 0, 0, 0.3); outline: 0; }
.search-hits { display: flex; flex-direction: column; margin-top: 6px; max-height: 50vh; overflow: auto; }
.search-hits button { display: flex; flex-direction: column; text-align: left; padding: 9px 12px; border-radius: 12px; }
.search-hits button:hover { background: rgba(255, 255, 255, 0.05); }
.search-hits b { font-weight: 500; }
.pad { padding: 10px 12px; }

.splash { position: relative; z-index: 1; height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center;
  background: radial-gradient(700px 500px at 50% 45%, rgba(40, 90, 200, 0.18), transparent 60%), #04060a; }
.splash h2 { font-size: 24px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 26px; }
.login input { width: 100%; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(0, 0, 0, 0.35); outline: 0; font-size: 15px; text-align: center; }
.login .btn { width: 100%; padding: 13px; }
.pw-field { position: relative; width: 100%; }
.pw-field input { padding-left: 46px; padding-right: 46px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.pw-eye:hover { color: var(--fg, #fff); background: rgba(255, 255, 255, 0.06); }
.loader { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.1); border-top-color: var(--blue); animation: spin 0.9s linear infinite; }
.loader.sm { width: 20px; height: 20px; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* App Windows: barra del titolo trascinabile */
.is-electron .topbar { -webkit-app-region: drag; padding-right: 150px; }
.is-electron .topbar button, .is-electron .topbar input, .is-electron .topbar .search-pop { -webkit-app-region: no-drag; }

/* ---------- Responsive ---------- */
@media (max-width: 1380px) {
  .nav-btn { padding: 10px 14px; }
  .who-t { display: none; }
  .brand span { font-size: 19px; }
}
@media (max-width: 1180px) {
  body { overflow: auto; }
  .main.view-overview { overflow: auto; }
  .overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'stage stage' 'left right'; height: auto; }
  .stage { grid-area: stage; height: 76vh; min-height: 560px; }
  .col-left { grid-area: left; overflow: visible; }
  .col-right { grid-area: right; overflow: visible; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .nav { justify-self: center; }
  .nav-btn span { display: none; }
  .is-electron .topbar { padding-right: 150px; }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .labs-layout { grid-template-columns: 1fr; }
  .lab-list { position: static; max-height: 340px; }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 14px 8px; grid-template-columns: 1fr auto; padding-top: max(12px, env(safe-area-inset-top)); }
  .nav { display: none; }
  .brand span { font-size: 18px; }
  .main { padding: 4px 12px calc(84px + env(safe-area-inset-bottom)); }
  .share-banner { margin: 0 12px 8px; }
  .overview { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'stage' 'left' 'right'; gap: 14px; }
  .stage { height: auto; min-height: 0; display: flex; flex-direction: column; border-radius: 24px; }
  .body-canvas { position: relative; height: 62vh; min-height: 420px; }
  .stage-lines, .ruler { display: none; }
  .callout { position: relative; left: auto !important; right: auto !important; top: auto !important; width: auto; margin: 10px 0 0; border-radius: 18px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent) !important; }
  .stage-controls { position: absolute; top: calc(62vh - 70px); bottom: auto; padding: 0 10px; }
  .ctl-group .round-btn:last-child { display: none; }
  .mode-pill button { padding: 9px 12px; font-size: 12px; }
  .zoom-pill button { width: 44px; height: 46px; }
  .round-btn.big { width: 46px; height: 46px; }
  .m-label { display: none; }
  .page-head h1 { font-size: 24px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .card { padding: 16px; border-radius: 22px; }
  .popover { right: 12px; left: 12px; width: auto; top: 70px; }
  .search-pop { position: fixed; left: 12px; right: 12px; top: 70px; width: auto; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: rgba(6, 8, 12, 0.92); border-top: 1px solid var(--line2); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
  .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); padding: 4px 8px; border-radius: 12px; }
  .bottom-nav button.active { color: #fff; background: rgba(61, 139, 255, 0.18); }
  .p-stat b { font-size: 17px; }
  .doc-list { grid-template-columns: 1fr; }
  .who { padding: 3px; }
  .who .avatar { display: none; }
}
