/* MyDesk Control Center — componenti, layout, pagine, motion. I token sono in tokens.css */

/* ================= base ================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-grad), var(--bg); background-attachment: fixed;
  color: var(--text); font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01"; overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -.01em; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent-2); }
button, input, select { font: inherit; color: inherit; }
.ic { flex: none; display: block; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ================= pulsanti e campi ================= */
.btn {
  --b: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid transparent; background: var(--b); color: #fff; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 6px 16px -8px var(--accent-ring);
  transition: transform var(--d1) var(--ease), background var(--d2), box-shadow var(--d2), opacity var(--d2);
  white-space: nowrap;
}
.btn:hover { background: var(--accent-2); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 10px 22px -10px var(--accent-ring); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn.lg { height: 44px; font-size: var(--fs-md); border-radius: var(--r); }
.btn .spin { display: none; }
.btn.loading .spin { display: block; }
.btn.loading .btn-label { opacity: .75; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--d2), color var(--d2), border-color var(--d2), transform var(--d1) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }

.field { display: grid; gap: 6px; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted);
  transition: border-color var(--d2), box-shadow var(--d2), background var(--d2);
}
.input:hover { border-color: var(--faint); }
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--text-2); }
.input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.input input::placeholder { color: var(--faint); }
.input.sm { height: 32px; }
.input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.select {
  height: 32px; padding: 0 28px 0 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border-strong);
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%; background-size: 4px 4px; background-repeat: no-repeat;
}
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-2); }

/* switch */
.switch { position: relative; width: 38px; height: 22px; flex: none; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background var(--d2), border-color var(--d2); padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--d3) var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

/* controllo segmentato con indicatore che scorre */
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { position: relative; z-index: 1; height: 28px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; border-radius: 6px; transition: color var(--d2); }
.seg button[aria-pressed="true"] { color: var(--text); }
.seg .seg-ind { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 6px; background: var(--surface-3); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong); transition: transform var(--d3) var(--ease), width var(--d3) var(--ease); }

/* badge e indicatori di stato */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-2); }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }

.dot { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); transition: background var(--d3); }
.dot.on { background: var(--ok); }
.dot.on::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); animation: pulse 2.6s var(--ease) infinite; }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
@keyframes pulse { 0% { transform: scale(1); opacity: .55; } 70%, 100% { transform: scale(2.8); opacity: 0; } }

/* tooltip: testo da attributo, mai HTML */
[data-tip] { position: relative; }
[data-tip]::before {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 60; pointer-events: none;
  padding: 5px 9px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.35;
  white-space: nowrap; max-width: 280px; opacity: 0; transform: translate(-50%, 4px); transition: opacity var(--d1), transform var(--d2) var(--ease);
}
[data-tip]:hover::before, [data-tip]:focus-visible::before { opacity: 1; transform: translate(-50%, 0); transition-delay: .25s; }
[data-tip-pos="bottom"]::before { bottom: auto; top: calc(100% + 8px); }
[data-tip-pos="right"]::before { left: calc(100% + 10px); bottom: 50%; transform: translate(4px, 50%); }
[data-tip-pos="right"]:hover::before, [data-tip-pos="right"]:focus-visible::before { transform: translate(0, 50%); }
[data-tip-wrap]::before { white-space: normal; width: max-content; }

/* skeleton */
.sk { display: inline-block; height: 10px; border-radius: 6px; background: var(--sk); position: relative; overflow: hidden; vertical-align: middle; }
.sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--sk-hi), transparent); transform: translateX(-100%); animation: shimmer 1.4s infinite; }
.sk.block { display: block; height: 100%; min-height: 20px; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* spinner */
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ================= superfici ================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5) 0; flex-wrap: wrap; }
.card-head h3 { font-size: var(--fs-md); display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { color: var(--muted); }
.card-head p { color: var(--muted); font-size: var(--fs-sm); }
.card-body { padding: var(--s4) var(--s5) var(--s5); }
.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); }

.empty { display: grid; justify-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; margin-bottom: 6px; color: var(--accent-2);
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 70%), var(--surface-2); border: 1px solid var(--border); }
.empty strong { color: var(--text); font-size: var(--fs-md); }
.empty p { max-width: 380px; font-size: var(--fs-sm); }

/* ================= toast ================= */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.toast-ic { color: var(--info); margin-top: 1px; }
.toast.ok .toast-ic { color: var(--ok); } .toast.bad .toast-ic { color: var(--bad); } .toast.warn .toast-ic { color: var(--warn); }
.toast-body { flex: 1; display: grid; gap: 2px; font-size: var(--fs-sm); color: var(--text-2); }
.toast-body strong { color: var(--text); font-size: var(--fs); }

/* ================= popover / menu ================= */
.popover { position: fixed; z-index: 80; min-width: 220px; max-width: min(380px, calc(100vw - 16px)); padding: 6px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); transform-origin: top right; }
.menu { display: grid; gap: 1px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; cursor: pointer; color: var(--text-2); }
.menu-item .ic { color: var(--muted); }
.menu-item span { flex: 1; }
.menu-item small { color: var(--faint); font-size: 11px; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-hover); color: var(--text); outline: none; }
.menu-item:disabled { opacity: .45; cursor: not-allowed; }
.menu-item.danger { color: var(--bad); } .menu-item.danger .ic { color: var(--bad); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-title { padding: 8px 10px 4px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.check-item:hover { background: var(--surface-hover); }
.check-item input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ================= drawer ================= */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(3,6,14,.55); backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 75; width: min(520px, 100vw); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: var(--fs-lg); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; align-content: start; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: var(--fs-sm); }
.dl dt { color: var(--muted); } .dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 650; margin-bottom: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stat { padding: 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.mini-stat b { display: block; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.mini-stat span { font-size: var(--fs-xs); color: var(--muted); }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--text-2); font-size: var(--fs-sm); border: 1px solid var(--border); }
.note .ic { color: var(--info); margin-top: 1px; }
.note.warn { background: var(--warn-soft); } .note.warn .ic { color: var(--warn); }

/* ================= LOGIN ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr); }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px;
  background: radial-gradient(700px 500px at 50% 50%, rgba(61,123,255,.13), transparent 70%), linear-gradient(160deg, var(--navy-900), var(--navy-950));
  border-right: 1px solid var(--border); color: #e7ecf6; }
:root[data-theme="light"] .auth-hero { --net-line: rgba(130,170,255,.16); --net-node: #8fb0ff; }
.auth-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(6,10,19,.65), transparent 30%, transparent 62%, rgba(6,10,19,.9)); }
.auth-hero > *:not(canvas) { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.brand-name small { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8ea2c8; font-weight: 600; }
.logo-mark { filter: drop-shadow(0 6px 16px rgba(61,123,255,.35)); flex: none; }
.hero-copy { max-width: 520px; }
.hero-copy .eyebrow { display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #a9c4ff; background: rgba(61,123,255,.12); border: 1px solid rgba(61,123,255,.25); margin-bottom: 18px; }
.hero-copy h1 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.12; font-weight: 700; letter-spacing: -.03em; }
.hero-copy h1 em { font-style: normal; background: linear-gradient(90deg, #6f9dff, #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-copy p { margin-top: 14px; color: #a3b0c8; font-size: var(--fs-md); max-width: 440px; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 10px 22px; color: #a3b0c8; font-size: var(--fs-sm); }
.hero-facts span { display: inline-flex; align-items: center; gap: 8px; }
.hero-facts .ic { color: #6fe0f2; }

.auth-side { display: grid; place-items: center; padding: 32px 24px; position: relative; }
.auth-top { position: absolute; top: 20px; right: 20px; }
.auth-card { width: min(420px, 100%); padding: 36px 36px 30px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); position: relative; }
.auth-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(61,123,255,.5), transparent 35%, transparent 70%, rgba(34,211,238,.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.auth-card .mobile-brand { display: none; margin-bottom: 24px; }
.auth-card h2 { font-size: var(--fs-xl); letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); margin: 6px 0 26px; }
.auth-card form { display: grid; gap: 16px; }
.pw-toggle { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 5px; display: grid; }
.pw-toggle:hover { color: var(--text); }
.caps { font-size: var(--fs-xs); color: var(--warn); display: flex; align-items: center; gap: 6px; }
.auth-err { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: var(--fs-sm); font-weight: 500; }
.auth-err.warn { background: var(--warn-soft); color: var(--warn); }
.auth-foot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--faint); font-size: var(--fs-xs); display: flex; gap: 8px; align-items: flex-start; }
.auth-foot .ic { margin-top: 1px; }
.shake { animation: shake .42s var(--ease); }
@keyframes shake { 15%, 55% { transform: translateX(-6px); } 35%, 75% { transform: translateX(5px); } 90% { transform: translateX(-2px); } }

/* ================= SHELL ================= */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--d3) var(--ease); }
.shell.collapsed { grid-template-columns: var(--sidebar-min) minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); overflow: hidden; z-index: 30; }
.sb-brand { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; margin-bottom: 8px; }
.sb-brand .brand-name { font-size: 16px; white-space: nowrap; }
.sb-brand .brand-name small { color: var(--faint); font-size: 10px; }
.sb-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 650; padding: 12px 10px 6px; white-space: nowrap; }
.nav { position: relative; display: grid; gap: 2px; }
.nav-ind { position: absolute; left: 0; right: 0; top: 0; height: 36px; border-radius: 8px; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(61,123,255,.22); transition: transform var(--d3) var(--ease), opacity var(--d2); pointer-events: none; }
.nav-ind::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 550; white-space: nowrap; transition: color var(--d2), background var(--d2); }
.nav a:hover { color: var(--text); background: var(--surface-hover); }
.nav a[aria-current="page"] { color: var(--text); background: transparent; }
.nav a[aria-current="page"] .ic { color: var(--accent-2); }
.nav a .count { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.nav a .count.ok { background: var(--ok-soft); color: var(--ok); }
.nav a .count.bad { background: var(--bad-soft); color: var(--bad); }
.nav a .soon { margin-left: auto; font-size: 10px; color: var(--faint); border: 1px solid var(--border); padding: 0 6px; border-radius: 999px; }
.sb-foot { margin-top: auto; display: grid; gap: 8px; }
.sb-ver { font-size: var(--fs-xs); color: var(--faint); padding: 0 10px; white-space: nowrap; }
.collapsed .sidebar .brand-name, .collapsed .sidebar .sb-section, .collapsed .sidebar .nav a span, .collapsed .sidebar .nav a .count,
.collapsed .sidebar .nav a .soon, .collapsed .sidebar .sb-ver { opacity: 0; pointer-events: none; }
.collapsed .sidebar .sb-section { height: 10px; padding: 0; }
.sidebar .brand-name, .sidebar .sb-section, .sidebar .nav a span, .sidebar .nav a .count, .sidebar .sb-ver { transition: opacity var(--d2); }
.collapse-btn .ic { transition: transform var(--d3) var(--ease); }
.collapsed .collapse-btn .ic { transform: rotate(180deg); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.topbar .title { min-width: 0; }
.topbar .title h1 { font-size: var(--fs-lg); white-space: nowrap; }
.topbar .title p { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.search-trigger { display: flex; align-items: center; gap: 10px; height: 34px; width: min(300px, 28vw); padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--faint); cursor: pointer; transition: border-color var(--d2), background var(--d2); }
.search-trigger:hover { border-color: var(--faint); color: var(--muted); }
.search-trigger span { flex: 1; text-align: left; }
.conn { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); white-space: nowrap; }
.conn .dot.on::after { animation-duration: 3.2s; }
.bell { position: relative; }
.bell .bell-count { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--blue-500), var(--teal)); border: 0; cursor: pointer; transition: box-shadow var(--d2); }
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--accent-soft); }
.profile-head { display: flex; gap: 12px; align-items: center; padding: 8px 10px 12px; }
.profile-head b { display: block; } .profile-head span { font-size: var(--fs-xs); color: var(--muted); }

.view { padding: 24px; display: grid; gap: 20px; align-content: start; max-width: 1600px; width: 100%; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-head h2 { font-size: var(--fs-xl); letter-spacing: -.025em; }
.view-head p { color: var(--muted); margin-top: 4px; }

/* ================= KPI e bento ================= */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi { position: relative; padding: 16px 18px; overflow: hidden; display: grid; gap: 10px; transition: border-color var(--d2), transform var(--d2) var(--ease); }
.kpi:hover { border-color: var(--border-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 550; }
.kpi-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-2); }
.kpi[data-tone="ok"] .kpi-ic { background: var(--ok-soft); color: var(--ok); }
.kpi[data-tone="bad"] .kpi-ic { background: var(--bad-soft); color: var(--bad); }
.kpi[data-tone="warn"] .kpi-ic { background: var(--warn-soft); color: var(--warn); }
.kpi[data-tone="muted"] .kpi-ic { background: var(--surface-3); color: var(--muted); }
.kpi[data-tone="cyan"] .kpi-ic { background: var(--cyan-soft); color: var(--cyan); }
.kpi-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value.na { font-size: var(--fs-md); font-weight: 600; color: var(--muted); letter-spacing: 0; line-height: 32px; }
.kpi-foot { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.kpi.alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.kpi.alert::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--bad); }
.kpi .bar-track { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.kpi .bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--ok), var(--teal)); transform-origin: left; transition: transform var(--d4) var(--ease); }

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-12 { grid-column: span 12; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }

/* grafico */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart .grid text, .chart .xlab text { fill: var(--faint); font-size: 10.5px; font-family: var(--font); }
.chart .bar { transform-box: view-box; transform-origin: 0 0; transition: transform 700ms var(--ease); }
.chart .bar.ok { fill: var(--chart-ok); }
.chart .bar.bad { fill: var(--chart-bad); }
.chart .bar.other { fill: var(--chart-other); opacity: .85; }
.chart .hover-col { fill: var(--surface-hover); transition: x var(--d1), opacity var(--d1); }
.chart-tip { position: absolute; top: 0; left: 0; min-width: 160px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); pointer-events: none; opacity: 0; transition: opacity var(--d1), transform var(--d2) var(--ease); display: grid; gap: 4px; }
.chart-tip.show { opacity: 1; }
.tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip-row b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.sw.ok { background: var(--chart-ok); } .sw.bad { background: var(--chart-bad); } .sw.other { background: var(--chart-other); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-sum { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-sum div { display: grid; }
.chart-sum b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.chart-sum span { font-size: var(--fs-xs); color: var(--muted); }

/* feed attività */
.feed { display: grid; max-height: 410px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.feed-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); color: var(--muted); }
.feed-ic.ok { background: var(--ok-soft); color: var(--ok); } .feed-ic.bad { background: var(--bad-soft); color: var(--bad); }
.feed-ic.warn { background: var(--warn-soft); color: var(--warn); } .feed-ic.info { background: var(--info-soft); color: var(--info); }
.feed-ic.accent { background: var(--accent-soft); color: var(--accent-2); }
.feed-text { font-size: var(--fs-sm); color: var(--text-2); min-width: 0; }
.feed-text b { color: var(--text); font-weight: 600; }
.feed-text small { display: block; color: var(--faint); font-size: var(--fs-xs); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* servizi */
.health { display: grid; gap: 2px; }
.health-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.health-row:last-child { border-bottom: 0; }
.health-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.health-row b { display: block; font-weight: 600; font-size: var(--fs); }
.health-row small { color: var(--muted); font-size: var(--fs-xs); }

/* barre orizzontali (versioni client) */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 70px 1fr 34px; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.hbar .track { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar .fill { height: 100%; width: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--cyan)); transform-origin: left; transition: transform var(--d4) var(--ease); }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

/* ================= tabelle ================= */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .input { width: min(320px, 100%); }
.toolbar .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; transition: all var(--d2); }
.chip:hover { color: var(--text); background: var(--surface-hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(61,123,255,.35); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .8; }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
th { position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text-2); vertical-align: middle; }
tbody tr { transition: background var(--d2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover, tbody tr.clickable:focus-visible { background: var(--surface-hover); outline: none; }
tbody tr.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
td.strong { color: var(--text); font-weight: 600; }
.cell-dev { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-dev .dev-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); flex: none; }
.cell-dev b { color: var(--text); font-weight: 600; display: block; }
.cell-dev small { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.status-cell { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.status-cell.on { color: var(--ok); } .status-cell.off { color: var(--muted); }
.risk { display: inline-flex; gap: 3px; align-items: center; }
.risk i { width: 6px; height: 14px; border-radius: 2px; background: var(--surface-3); }
.risk[data-l="1"] i:nth-child(-n+1) { background: var(--info); }
.risk[data-l="2"] i:nth-child(-n+2) { background: var(--warn); }
.risk[data-l="3"] i { background: var(--bad); }
.risk span { margin-left: 6px; font-size: var(--fs-xs); color: var(--muted); }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-xs); }

/* ================= sessioni live ================= */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.live-card { padding: 18px; display: grid; gap: 16px; position: relative; overflow: hidden; }
.live-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, transparent, var(--ok), transparent); opacity: .7; }
.live-card.pending::before { background: linear-gradient(90deg, transparent, var(--warn), transparent); }
.live-ends { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.live-end { min-width: 0; }
.live-end small { display: block; font-size: var(--fs-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.live-end b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-end .mono { color: var(--muted); font-size: 11px; }
.live-end:last-child { text-align: right; }
.wire { position: relative; width: 80px; height: 2px; background: var(--border-strong); border-radius: 2px; overflow: hidden; }
.wire::after { content: ""; position: absolute; top: 0; left: 0; width: 30%; height: 100%; background: linear-gradient(90deg, transparent, var(--ok), transparent); animation: wire 1.8s linear infinite; }
.pending .wire::after { background: linear-gradient(90deg, transparent, var(--warn), transparent); }
@keyframes wire { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.live-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.live-meta div { padding: 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.live-meta small { display: block; font-size: var(--fs-xs); color: var(--faint); }
.live-meta b { font-variant-numeric: tabular-nums; font-size: var(--fs); }
.live-meta b.na { color: var(--faint); font-weight: 500; font-size: var(--fs-sm); }
.live-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ================= sicurezza ================= */
.timeline { display: grid; position: relative; }
.tl-item { display: grid; grid-template-columns: 92px 18px 1fr; gap: 12px; padding: 0 0 18px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 112px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-time { font-size: var(--fs-xs); color: var(--faint); text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; margin: 5px 4px 0; background: var(--faint); box-shadow: 0 0 0 4px var(--surface); }
.tl-dot.critical { background: var(--bad); } .tl-dot.high { background: #ff8a4c; } .tl-dot.medium { background: var(--warn); } .tl-dot.info { background: var(--info); }
.tl-body { min-width: 0; display: grid; gap: 3px; }
.tl-body b { font-size: var(--fs); color: var(--text); font-weight: 600; }
.tl-body span { font-size: var(--fs-sm); color: var(--muted); }
.sev { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sev.critical { color: var(--bad); } .sev.high { color: #ff8a4c; } .sev.medium { color: var(--warn); } .sev.info { color: var(--info); }
:root[data-theme="light"] .sev.high, :root[data-theme="light"] .tl-dot.high { color: #c2410c; }
:root[data-theme="light"] .tl-dot.high { background: #ea580c; }
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row b { display: block; font-weight: 600; }
.list-row small { color: var(--muted); font-size: var(--fs-xs); }

/* ================= impostazioni ================= */
.settings { display: grid; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-weight: 600; }
.set-row small { color: var(--muted); font-size: var(--fs-sm); }
.saved { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: var(--fs-xs); font-weight: 600; opacity: 0; transition: opacity var(--d2); }
.saved.show { opacity: 1; }
.field-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.field-list span { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--muted); font-size: var(--fs-sm); }

/* ================= ricerca globale ================= */
.palette-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(3,6,14,.5); backdrop-filter: blur(3px); display: grid; justify-items: center; align-content: start; padding-top: 12vh; }
.palette { width: min(620px, calc(100vw - 32px)); border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette .input { height: 52px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none; font-size: var(--fs-md); padding: 0 16px; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 8px; border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--text-2); }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.palette-item .grow { flex: 1; min-width: 0; }
.palette-item b { display: block; color: var(--text); font-weight: 600; }
.palette-item small { color: var(--muted); font-size: var(--fs-xs); }
.palette-foot { display: flex; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--faint); }

/* ================= responsive ================= */
@media (max-width: 1180px) {
  .span-8, .span-4, .span-6, .span-5, .span-7 { grid-column: span 12; }
}
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .mobile-brand { display: flex; }
}
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-102%); transition: transform var(--d3) var(--ease); background: var(--surface); box-shadow: var(--shadow-lg); z-index: 60; }
  .shell.nav-open .sidebar { transform: none; }
  .collapsed .sidebar .brand-name, .collapsed .sidebar .sb-section, .collapsed .sidebar .nav a span, .collapsed .sidebar .nav a .count, .collapsed .sidebar .sb-ver { opacity: 1; }
  .collapse-btn { display: none !important; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; gap: 8px; }
  .search-trigger { width: 36px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .conn .conn-label { display: none; }
  .view { padding: 16px; }
  .toolbar .input { width: 100%; }
  .dl { grid-template-columns: 110px 1fr; }
}
@media (max-width: 520px) {
  .auth-card { padding: 28px 22px 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: var(--fs-xl); }
  .live-grid { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .topbar .title p { display: none; }
}
.nav-scrim { display: none; }
@media (max-width: 860px) { .shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3,6,14,.5); } }

/* ================= movimento ridotto ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
}

.ic.flip { transform: rotate(180deg); }
/* tooltip delle voci di menu solo con barra compatta (altrimenti il testo è già visibile) */
.shell:not(.collapsed) .nav a[data-tip]::before { display: none; }
.shell.collapsed .sidebar { overflow: visible; }
@media (max-width: 860px) { .conn { width: 30px; padding: 0; justify-content: center; } }

/* ===== Anteprima VEYRA: lockup in barra, simbolo in barra compatta, avviso di anteprima ===== */
.brand-lockup { display: block; height: 34px; width: auto; max-width: 196px; }
.brand-symbol { display: block; width: 30px; height: 30px; flex: none; }
.sb-brand .brand-symbol { display: none; }
.collapsed .sidebar .sb-brand .brand-lockup { display: none; }
.collapsed .sidebar .sb-brand .brand-symbol { display: block; }
@media (max-width: 860px) { .collapsed .sidebar .sb-brand .brand-lockup { display: block; } .collapsed .sidebar .sb-brand .brand-symbol { display: none; } }
.preview-flag { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); border-radius: 7px; padding: 6px 8px; text-align: center; white-space: normal; line-height: 1.35; }
.collapsed .sidebar .preview-flag { display: none; }
.auth-hero .brand-lockup { height: 44px; max-width: 260px; }
.auth-card .mobile-brand .brand-lockup { height: 34px; }
.hero-claim { font-size: var(--fs-md); color: #7fdcf0; font-weight: 600; margin-top: 10px; letter-spacing: .01em; }
.auth .preview-flag { display: inline-block; margin-top: 14px; }

/* VEYRA Admin Cloud: suggerimenti sotto i campi (login con TOTP, attivazione) */
.code-hint { display: block; font-size: 12px; line-height: 1.45; color: var(--muted); margin-top: 6px; font-weight: 500; }
