:root {
  --bg: #07111f;
  --panel: #0e1b2c;
  --panel2: #12243a;
  --border: #233750;

  --text: #ecf4ff;
  --muted: #91a5bd;

  --ok: #22c55e;
  --warning: #f59e0b;
  --critical: #f97316;
  --down: #ef4444;
  --stale: #94a3b8;
  --suppressed: #a78bfa;

  --shadow: 0 14px 40px rgba(0,0,0,.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top right, #123052 0, transparent 34%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.topbar {
  min-height: 86px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7,17,31,.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.brand {
  color: #6db7ff;
  font-weight: 800;
  letter-spacing: .18em;
  font-size: 12px;
}

h1 {
  margin: 3px 0 0;
  font-size: 24px;
}

h2 {
  margin: 0;
  font-size: 19px;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: right;
}

.system-status small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 15px currentColor;
}

.status-dot.ok {
  color: var(--ok);
  background: var(--ok);
}

.status-dot.error {
  color: var(--down);
  background: var(--down);
}

.status-dot.unknown {
  color: var(--stale);
  background: var(--stale);
}

main {
  width: min(1800px, calc(100% - 34px));
  margin: 20px auto 30px;
}

.section,
.panel {
  background: linear-gradient(180deg, rgba(18,36,58,.94), rgba(14,27,44,.95));
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.section {
  padding: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 16px;
}

.counter {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #07111f;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 800;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(100px, 1fr));
  gap: 11px;
}

.kpi {
  min-height: 84px;
  padding: 13px;
  background: rgba(7,17,31,.55);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 29px;
}

.kpi.ok {
  border-bottom: 3px solid var(--ok);
}

.kpi.warning {
  border-bottom: 3px solid var(--warning);
}

.kpi.critical {
  border-bottom: 3px solid var(--critical);
}

.kpi.down {
  border-bottom: 3px solid var(--down);
}

.kpi.stale {
  border-bottom: 3px solid var(--stale);
}

.kpi.suppressed {
  border-bottom: 3px solid var(--suppressed);
}

.pops-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.pop-card {
  padding: 17px;
  border: 1px solid var(--border);
  background: rgba(7,17,31,.5);
  border-radius: 12px;
}

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pop-name {
  font-size: 22px;
  font-weight: 800;
}

.pop-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.pop-stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.pop-stat {
  padding: 9px;
  border-radius: 8px;
  background: rgba(18,36,58,.9);
  text-align: center;
}

.pop-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.pop-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11px;
  border: 1px solid currentColor;
}

.state-ok {
  color: var(--ok);
  background: rgba(34,197,94,.10);
}

.state-warning {
  color: var(--warning);
  background: rgba(245,158,11,.11);
}

.state-critical {
  color: var(--critical);
  background: rgba(249,115,22,.11);
}

.state-down {
  color: var(--down);
  background: rgba(239,68,68,.12);
}

.state-stale,
.state-unknown {
  color: var(--stale);
  background: rgba(148,163,184,.10);
}

.table-wrap {
  overflow: auto;
}

.alarm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

.alarm-table th {
  padding: 9px 11px;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.alarm-table td {
  padding: 12px 11px;
  border-bottom: 1px solid rgba(35,55,80,.65);
  vertical-align: top;
  font-size: 13px;
}

.alarm-table tbody tr:hover {
  background: rgba(255,255,255,.025);
}

.customer-name {
  font-weight: 700;
}

.secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, .8fr);
  gap: 18px;
}

.scroll-list {
  max-height: 490px;
  overflow-y: auto;
  padding-right: 4px;
}

.event {
  display: grid;
  grid-template-columns: 72px 95px 1fr;
  gap: 12px;
  padding: 12px 5px;
  border-bottom: 1px solid rgba(35,55,80,.65);
}

.event-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event-title {
  font-weight: 700;
}

.event-message {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  margin-bottom: 12px;
  background: rgba(7,17,31,.6);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.audio-status {
  font-size: 12px;
  color: var(--muted);
}

.audio-buttons {
  display: flex;
  gap: 6px;
}

button {
  border: 1px solid #36506f;
  background: #18314e;
  color: var(--text);
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 11px;
}

button:hover {
  background: #214466;
}

button:disabled {
  opacity: .45;
  cursor: default;
}

.push-list {
  max-height: 430px;
  overflow-y: auto;
}

.push-event {
  border: 1px solid rgba(239,68,68,.45);
  background: rgba(239,68,68,.07);
  border-radius: 11px;
  padding: 13px;
  margin-bottom: 10px;
}

.push-event.acked {
  border-color: var(--border);
  background: rgba(7,17,31,.5);
  opacity: .72;
}

.push-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.push-customer {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 800;
}

.push-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.push-actions {
  margin-top: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ack-label {
  color: var(--ok);
  font-weight: 700;
  font-size: 11px;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.loading {
  padding: 18px;
  color: var(--muted);
}

footer {
  padding: 15px 20px 25px;
  text-align: center;
  color: #60758e;
  font-size: 11px;
}

@media (max-width: 1250px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  main {
    width: calc(100% - 18px);
  }

  .topbar {
    padding: 14px;
  }

  .kpi-grid,
  .pops-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pop-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .audio-controls {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* ===== COMPACT DESKTOP V1 =====
   Riduzione spazi verticali senza modificare font/colori.
   Applicata solo ai layout desktop.
*/
@media (min-width: 1251px) {

  /* Header: stato e timestamp sulla stessa riga */
  .topbar {
    min-height: 64px;
    padding: 10px 22px;
  }

  .system-status > div {
    display: flex;
    align-items: baseline;
    gap: 12px;
  }

  .system-status small {
    display: inline;
    margin-top: 0;
    white-space: nowrap;
  }


  /* Area pagina: meno vuoto verticale,
     riduzione orizzontale volutamente più contenuta */
  main {
    width: min(1840px, calc(100% - 24px));
    margin: 10px auto 16px;
  }

  .section,
  .panel {
    margin-bottom: 10px;
  }

  .section,
  .panel {
    padding: 11px 16px;
  }


  /* Titolo + descrizione sulla medesima riga */
  .section-title {
    gap: 10px;
    margin-bottom: 8px;
  }

  .section-title > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 14px;
    min-width: 0;
  }

  .section-title > div:first-child p {
    margin: 0;
    white-space: nowrap;
  }


  /* KPI principali:
     etichetta e valore sulla stessa riga */
  .kpi-grid {
    gap: 9px;
  }

  .kpi {
    min-height: 52px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .kpi strong {
    margin-top: 0;
  }


  /* POP */
  .pops-grid {
    gap: 12px;
  }

  .pop-card {
    padding: 10px 14px;
  }

  .pop-head {
    gap: 10px;
  }

  .pop-head > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
  }

  .pop-sub {
    margin-top: 0;
    white-space: nowrap;
  }

  .pop-stats {
    margin-top: 8px;
    gap: 6px;
  }

  /* Mini KPI POP:
     nome stato + numero sulla stessa riga */
  .pop-stat {
    min-height: 36px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .pop-stat strong {
    margin-top: 0;
  }


  /* Badge leggermente meno alti,
     font invariato */
  .state-badge {
    padding-top: 4px;
    padding-bottom: 4px;
  }


  /* Allarmi */
  .alarms-section .section-title {
    margin-bottom: 5px;
  }

  .alarm-table th {
    padding: 6px 10px;
  }

  .alarm-table td {
    padding: 7px 10px;
    vertical-align: middle;
  }

  /* Cliente + codice sulla stessa riga */
  .alarm-table td:nth-child(2) .secondary {
    display: inline;
    margin: 0 0 0 8px;
  }

  /* PUBLIC + SERV3 / PTP2 + PTP2 sulla stessa riga */
  .alarm-table td:nth-child(3) .secondary {
    display: inline;
    margin: 0 0 0 8px;
  }


  /* Parte bassa: sale nello spazio recuperato */
  .bottom-grid {
    gap: 12px;
  }

  .bottom-grid .panel {
    padding: 11px 16px;
  }


  /* Timeline */
  .event {
    padding-top: 8px;
    padding-bottom: 8px;
  }


  /* Push / Escalation */
  .audio-controls {
    padding: 7px 9px;
    margin-bottom: 8px;
  }

  .push-event {
    padding: 9px 11px;
    margin-bottom: 7px;
  }

  .push-customer {
    margin-top: 6px;
  }

  .push-meta {
    margin-top: 4px;
    line-height: 1.35;
  }

  .push-actions {
    margin-top: 7px;
  }

  button {
    padding-top: 5px;
    padding-bottom: 5px;
  }


  /* Empty state meno dispersivo */
  .empty {
    padding: 20px;
  }


  footer {
    padding-top: 8px;
    padding-bottom: 12px;
  }
}



/* ===== RESOLVED_EVENTS_FINAL_CSS_V1 ===== */

.resolved-events-list {
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.event-resolved-header,
.event-resolved-row {
  display: grid;

  grid-template-columns:
    105px
    90px
    minmax(210px,1.25fr)
    135px
    155px
    95px
    95px
    minmax(260px,1.65fr);

  column-gap: 12px;
  min-width: 1260px;
  align-items: start;
}

.event-resolved-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 9px 5px;

  background: rgba(7,17,31,.98);
  border-bottom: 1px solid var(--border);

  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.event-resolved-row {
  padding: 12px 5px;
  border-bottom: 1px solid rgba(35,55,80,.65);
}

.event-resolved-row:hover {
  background: rgba(255,255,255,.025);
}

.event-resolved-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event-resolved-row .event-message {
  margin-top: 0;
}

.dashboard-legend {
  margin-top: 18px;
}

.dashboard-legend-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit,minmax(220px,1fr));
  gap: 10px;
}

.dashboard-legend-item {
  padding: 10px 12px;
  border: 1px solid rgba(35,55,80,.65);
  border-radius: 8px;
  background: rgba(7,17,31,.35);
}

.dashboard-legend-item strong {
  display: block;
  margin-bottom: 4px;
}

.dashboard-legend-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}


/* NETMON_PRESENTATION_V1 */
.state-badge.state-down-parziale {color:#ffcf33!important;background:rgba(255,191,0,.14)!important;border-color:rgba(255,191,0,.5)!important;white-space:nowrap}
.admin-userbar {flex-wrap:wrap;row-gap:6px}
.admin-userbar .admin-nav-link {white-space:nowrap}
