:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --up: #3ecf8e;
  --down: #f0554e;
  --warn: #f5a623;
  --info: #5b8def;
  --accent: #5b8def;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --border: #e2e5ea;
    --text: #1b1f27;
    --muted: #616a7a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 12px; }

.summary { color: var(--muted); font-size: 14px; }
.summary strong { color: var(--text); }

main { padding: 24px 28px; display: flex; flex-direction: column; gap: 32px; max-width: 1100px; margin: 0 auto; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.status-up { background: var(--up); }
.status-down { background: var(--down); box-shadow: 0 0 0 3px rgba(240,85,78,0.15); }
.status-unknown { background: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-left: 6px; }
.badge-new { background: rgba(245,166,35,0.15); color: var(--warn); }

.rename-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 12px; padding: 0 4px; margin-left: 4px; opacity: 0.55;
}
.rename-btn:hover { color: var(--accent); opacity: 1; }

.port-chip { display: inline-block; background: var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11px; margin: 1px; }

.disk-bar { width: 90px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.disk-bar-fill { height: 100%; background: var(--up); }
.disk-bar-fill.warn { background: var(--warn); }
.disk-bar-fill.crit { background: var(--down); }
.disk-label { font-size: 11px; color: var(--muted); }

.sparkline-col { width: 90px; }

.add-btn {
  margin-left: auto; background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.add-btn:hover { filter: brightness(1.1); }

.hidden { display: none !important; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: min(560px, calc(100vw - 32px)); max-height: 80vh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 20px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 10px 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--border);
}
.btn-primary, .btn-secondary {
  border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border);
}
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:disabled { opacity: 0.45; cursor: default; }
.btn-secondary { background: none; color: var(--text); }

.scan-status { color: var(--muted); font-size: 13px; padding: 10px 0; }
.scan-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer;
}
.scan-row:last-child { border-bottom: none; }
.scan-row.muted { opacity: 0.5; cursor: default; }
.scan-name { font-weight: 600; min-width: 130px; }
.scan-ip { min-width: 110px; }
.scan-mac { color: var(--muted); font-size: 12px; }
.scan-row .badge { background: var(--border); color: var(--muted); margin-left: auto; }

.alerts-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.alerts-list li { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; }
.alerts-list li:last-child { border-bottom: none; }
.alerts-list .ts { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.alerts-list .level-critical { color: var(--down); font-weight: 600; }
.alerts-list .level-warning { color: var(--warn); font-weight: 600; }
.alerts-list .level-info { color: var(--info); font-weight: 600; }
.empty { color: var(--muted); padding: 14px; font-size: 13px; }
