/* Salute: stile del portale */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #667385;
  --line: #dfe4ea;
  --brand: #0b5cad;
  --brand-dark: #084a8d;
  --topbar: #12263f;
  --ok: #1e7d4f;
  --warn: #9a6700;
  --error: #b42318;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); }

/* ---- barra laterale (menu) ---- */
.sl-brand { color: #fff; font-weight: 700; font-size: 19px; text-decoration: none; letter-spacing: .3px; }
.sl-badge {
  background: rgba(255, 255, 255, .18);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
}
body.sl-has-sidebar { display: block; }
.sl-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 248px; z-index: 30;
  background: var(--topbar); color: #fff;
  display: flex; flex-direction: column; overflow-y: auto;
}
.sl-side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px 20px; }
.sl-side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.sl-side-nav a { color: #c9d6e6; text-decoration: none; padding: 10px 12px; border-radius: 8px; }
.sl-side-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sl-side-nav a.is-active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.sl-side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, .12); }
.sl-side-foot form { margin: 10px 0 0; }
.sl-side-user { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; color: #fff; text-decoration: none; word-break: break-word; }
.sl-side-name { font-weight: 600; }
.sl-main { margin-left: 248px; min-height: 100vh; display: flex; flex-direction: column; }
.sl-mobilebar { display: none; }
.sl-iconbtn { background: transparent; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0; }
.sl-iconbtn:hover { background: rgba(255, 255, 255, .12); }

/* ---- campanella e pannello degli allarmi ---- */
.sl-bell { position: relative; background: transparent; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0; }
.sl-bell:hover { background: rgba(255, 255, 255, .12); }
.sl-bell-count {
  position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--error); color: #fff; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
  animation: sl-blink 1.2s ease-in-out infinite;
}
.sl-bell-count[hidden] { display: none; }
@keyframes sl-blink { 0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .7); } 50% { box-shadow: 0 0 0 6px rgba(180, 35, 24, 0); } }
.sl-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 20, 35, .4); opacity: 0; visibility: hidden; transition: opacity .2s; }
body.sl-panel-open .sl-scrim, body.sl-side-open .sl-scrim { opacity: 1; visibility: visible; }
.sl-alarm-panel {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(400px, 100vw); z-index: 50;
  background: #fff; color: var(--ink); box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column;
  transform: translateX(-105%); visibility: hidden; transition: transform .25s ease, visibility .25s;
}
body.sl-panel-open .sl-alarm-panel { transform: none; visibility: visible; }
.sl-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--error); color: #fff; font-size: 17px; }
.sl-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.sl-panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.sl-alarm-card { border: 1px solid #f0b4ae; border-left: 5px solid var(--error); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fff8f7; }
.sl-alarm-card.is-calling { border-color: #f1d98f; border-left-color: #d98a00; background: #fffaf0; }
.sl-alarm-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.sl-alarm-card .sl-btn { margin-top: 8px; }

/* ---- contenuto ---- */
.sl-wrap { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 28px 40px; }
.sl-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.sl-title { margin: 0 0 2px; font-size: 24px; line-height: 1.25; }
.sl-muted { color: var(--muted); margin: 0; }
.sl-hint { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }

.sl-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.sl-card-narrow { max-width: 420px; margin: 0 auto; }

.sl-login { display: flex; justify-content: center; padding-top: 6vh; }
.sl-login .sl-card { width: 100%; }

/* ---- statistiche ---- */
.sl-stats > .sl-card, .sl-stats > .sl-card + .sl-card { margin-top: 0; }
.sl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.sl-stat { display: flex; flex-direction: column; gap: 4px; }
.sl-stat-value { font-size: 34px; font-weight: 700; line-height: 1.1; }
.sl-stat-label { color: var(--muted); }

/* ---- form ---- */
.sl-label { display: block; font-weight: 600; margin: 14px 0 6px; }
.sl-input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c4ccd6;
  border-radius: 8px;
}
.sl-input:focus { outline: 2px solid rgba(11, 92, 173, .25); border-color: var(--brand); }
.sl-form-inline { margin: 10px 0 0; }

/* ---- pulsanti ---- */
.sl-btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.sl-btn:hover { background: #f1f4f8; }
.sl-btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.sl-btn-primary.sl-btn-block { margin-top: 18px; }
.sl-btn-primary:hover { background: var(--brand-dark); }
.sl-btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .35); color: #fff; padding: 6px 12px; }
.sl-btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.sl-card .sl-btn-ghost { border-color: var(--line); color: var(--ink); }
.sl-card .sl-btn-ghost:hover { background: #f1f4f8; }
.sl-btn-block { display: block; width: 100%; text-align: center; }

.sl-btn-sm { padding: 4px 10px; font-size: 13px; }
.sl-btn-ghost-dark { background: transparent; }
.sl-btn-danger { background: #fff; border-color: #f0b4ae; color: var(--error); }
.sl-btn-danger:hover { background: #fdecea; }

/* ---- filtri ---- */
.sl-filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.sl-filter { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.sl-filter--grow { flex: 1; min-width: 220px; }
.sl-filter-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }

/* ---- form a griglia ---- */
.sl-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }
.sl-check { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.sl-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.sl-actions form { margin: 0; }
.sl-card + .sl-card { margin-top: 16px; }
.sl-subtitle { margin: 0 0 8px; font-size: 17px; }
.sl-empty { padding: 20px 0 4px; }
.sl-nowrap { white-space: nowrap; }

/* ---- etichette di stato ---- */
.sl-pill { display: inline-block; padding: 1px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.sl-pill-ok   { background: #e8f6ee; color: var(--ok); }
.sl-pill-off  { background: #eef0f3; color: var(--muted); }
.sl-pill-warn { background: #fff5dc; color: var(--warn); }
.sl-pill-err  { background: #fdecea; color: var(--error); }

/* ---- password mostrata una sola volta ---- */
.sl-reveal { background: #fff8e1; border: 1px solid #f1d98f; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.sl-reveal code { font-size: 18px; letter-spacing: .5px; user-select: all; background: #fff; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }
.sl-reveal p { margin: 6px 0 0; }

/* ---- paginazione ---- */
.sl-pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.sl-pagination a, .sl-pagination span { padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; color: var(--ink); }
.sl-pagination a:hover { background: #f1f4f8; }
.sl-pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.sl-pagination .is-disabled { color: var(--muted); background: #f4f6f9; }

/* ---- scheda sensore ---- */
.sl-section { margin: 18px 0 4px; font-size: 15px; }
.sl-code { display: inline-block; max-width: 100%; word-break: break-all; user-select: all; background: #f4f6f9; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 14px; }
.sl-kv { border-collapse: collapse; margin: 6px 0 10px; }
.sl-kv th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 18px 4px 0; vertical-align: top; }
.sl-kv td { padding: 4px 0; }
.sl-input-sub { margin-top: 6px; font-size: 14px; }
textarea.sl-input { resize: vertical; font-family: inherit; }

/* ---- allarmi ---- */
.sl-stat-alert .sl-stat-value { color: var(--error); }
.sl-input-short { max-width: 320px; }
.sl-small { font-size: 13px; color: var(--muted); }

/* ---- area utente ---- */
.sl-sensor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.sl-audio { width: 100%; max-width: 520px; margin: 4px 0 12px; }
.sl-choice { display: block; margin: 18px 0 4px; font-size: 15px; }
.sl-choice input { margin-right: 6px; }
.sl-hint code, .sl-muted code { background: #f4f6f9; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ---- mappa ---- */
.sl-map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.sl-map { height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #e8edf3; }
.sl-map-side { max-height: 560px; overflow-y: auto; }
.sl-map-list { list-style: none; margin: 0; padding: 0; }
.sl-map-list li { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sl-map-list a { text-decoration: none; }
.sl-dot { display: inline-block; flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.sl-dot-ok { background: #1e7d4f; } .sl-dot-alarm { background: #b42318; } .sl-dot-open { background: #d98a00; } .sl-dot-off { background: #8a94a3; }
.sl-legend { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.sl-legend .sl-dot { margin: 0 6px 0 0; width: 10px; height: 10px; flex-basis: 10px; vertical-align: middle; }
path.sl-pulse { animation: sl-pulse 1.1s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes sl-pulse { 0%, 100% { fill-opacity: .95; stroke-width: 2; } 50% { fill-opacity: .35; stroke-width: 10; stroke-opacity: .45; } }
@media (prefers-reduced-motion: reduce) { path.sl-pulse { animation: none; } }
@media (max-width: 900px) { .sl-map-wrap { grid-template-columns: 1fr; } .sl-map { height: 420px; } .sl-map-side { max-height: none; } }

/* ---- verifica in due passaggi ---- */
.sl-input-code { max-width: 220px; font-size: 20px; letter-spacing: 3px; text-align: center; font-variant-numeric: tabular-nums; }
.sl-card-narrow .sl-input-code { max-width: none; }
.sl-codes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sl-codes code { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 16px; text-align: center; user-select: all; }
.sl-steps { padding-left: 20px; }
.sl-steps li { margin-bottom: 10px; }

/* ---- messaggi ---- */
.sl-alert { padding: 10px 14px; border-radius: 8px; margin: 12px 0; border: 1px solid transparent; }
.sl-alert-ok    { background: #e8f6ee; border-color: #b7e2c8; color: var(--ok); }
.sl-alert-warn  { background: #fff5dc; border-color: #f1d98f; color: var(--warn); }
.sl-alert-error { background: #fdecea; border-color: #f5b9b3; color: var(--error); }

/* ---- tabelle ---- */
.sl-table { width: 100%; border-collapse: collapse; }
.sl-table th, .sl-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sl-table th { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.sl-table tbody tr:hover { background: #f8fafc; }

/* ---- piede ---- */
.sl-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }

@media (max-width: 900px) {
  .sl-main { margin-left: 0; }
  .sl-mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--topbar); color: #fff; padding: 8px 12px; }
  .sl-mobilebar .sl-bell { margin-left: auto; }
  .sl-sidebar { transform: translateX(-100%); transition: transform .25s ease; z-index: 45; width: min(280px, 85vw); }
  body.sl-side-open .sl-sidebar { transform: none; }
  .sl-side-head .sl-bell { display: none; }
  .sl-wrap { padding: 16px 14px 32px; }
  .sl-table { display: block; overflow-x: auto; }
  .sl-table th, .sl-table td { white-space: nowrap; }
}
