/* ShellyGate — stile condiviso (dashboard, login, pagina ospite). Griglia di 4 px. */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-hover: #f9fafb;
  --border: #e6e8ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #8a94a6;
  --accent: #2f6fed;
  --accent-fg: #ffffff;
  --accent-hover: #2560d6;
  --focus: rgba(47, 111, 237, .35);
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, .25);

  --good: #0ca30c;  --good-fg: #067a06;  --good-bg: #e9f7e9;
  --warn: #fab219;  --warn-fg: #8a5a00;  --warn-bg: #fff6df;
  --crit: #d03b3b;  --crit-fg: #b42323;  --crit-bg: #fdeded;
  --idle: #b8c0cc;  --idle-fg: #5d6878;  --idle-bg: #f0f2f5;
  --info-fg: #2557c7; --info-bg: #eaf1ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12; --surface: #15181d; --surface-2: #1c2026; --surface-hover: #1a1d23;
    --border: #252a31; --border-strong: #343a43;
    --text: #eef1f5; --text-2: #a9b1bd; --text-3: #6d7685;
    --accent: #6f9bff; --accent-fg: #0d0f12; --accent-hover: #8aaeff; --focus: rgba(111, 155, 255, .4);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .5); --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .7);
    --good-fg: #4ade80; --good-bg: #10261a;
    --warn-fg: #facc15; --warn-bg: #2e260c;
    --crit-fg: #f87171; --crit-bg: #331618;
    --idle: #4b5461; --idle-fg: #98a1ae; --idle-bg: #1f232a;
    --info-fg: #8fb2ff; --info-bg: #17223a;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f12; --surface: #15181d; --surface-2: #1c2026; --surface-hover: #1a1d23;
  --border: #252a31; --border-strong: #343a43;
  --text: #eef1f5; --text-2: #a9b1bd; --text-3: #6d7685;
  --accent: #6f9bff; --accent-fg: #0d0f12; --accent-hover: #8aaeff; --focus: rgba(111, 155, 255, .4);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .5); --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .7);
  --good-fg: #4ade80; --good-bg: #10261a;
  --warn-fg: #facc15; --warn-bg: #2e260c;
  --crit-fg: #f87171; --crit-bg: #331618;
  --idle: #4b5461; --idle-fg: #98a1ae; --idle-bg: #1f232a;
  --info-fg: #8fb2ff; --info-bg: #17223a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/20px var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }

/* Bottoni */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-xs); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-hover); }
.btn:disabled { cursor: default; opacity: .55; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { width: 30px; padding: 0; }
.btn.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Campi */
.input { height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-xs); width: 100%; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-3); }

/* Pillole di stato: sempre puntino/icona + testo */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.pill .dot { width: 6px; height: 6px; }
.pill-good { background: var(--good-bg); color: var(--good-fg); } .pill-good .dot { background: var(--good); }
.pill-idle { background: var(--idle-bg); color: var(--idle-fg); } .pill-idle .dot { background: var(--idle); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); } .pill-warn .dot { background: var(--warn); }
.pill-crit { background: var(--crit-bg); color: var(--crit-fg); } .pill-crit .dot { background: var(--crit); }
.pill-info { background: var(--info-bg); color: var(--info-fg); } .pill-info .dot { background: var(--accent); }

/* Interruttore on/off */
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .5; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--text); color: var(--surface); }
.brand-mark svg { width: 16px; height: 16px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--surface); font-weight: 500; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--crit); color: #fff; }

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