/* AlertMe dashboard — "dispatch console" visual system.
   Calm midnight-navy while watching; lights amber when a zone is breached. */
:root {
  --ink: #0b1017;
  --panel: #121a24;
  --panel-2: #0e151e;
  --line: #223041;
  --line-soft: #1a2531;
  --text: #eaf1f8;
  --muted: #8095a8;
  --muted-2: #5a6b7d;
  --phosphor: #34e5b7; /* live / healthy / watching */
  --amber: #ffb020; /* trigger / primary action */
  --vermilion: #ff5c43; /* critical */
  --info: #57b6ff;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--ink);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  /* Subtle radar grid so the console never feels flat. */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(52, 229, 183, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(255, 176, 32, 0.05), transparent 55%);
  background-attachment: fixed;
}

h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- radar mark ---------------------------------------------------------*/
.radar {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.radar::before {
  content: '';
  position: absolute; inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(52, 229, 183, 0.35);
}
.radar-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--phosphor);
  box-shadow: 0 0 0 0 rgba(52, 229, 183, 0.6); animation: ping 2.6s ease-out infinite; }
.radar-dot.offline { background: var(--muted-2); animation: none; box-shadow: none; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(52, 229, 183, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(52, 229, 183, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 229, 183, 0); }
}
@media (prefers-reduced-motion: reduce) { .radar-dot { animation: none; } }

/* ---- top bar ------------------------------------------------------------*/
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  background: rgba(11, 16, 23, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand b { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.brand .tag { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.spacer { flex: 1; }
.conn { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono);
  font-size: 12px; color: var(--muted); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.conn.live .dot { background: var(--phosphor); box-shadow: 0 0 10px rgba(52,229,183,0.7); }
.conn.live { color: var(--phosphor); }

/* ---- layout -------------------------------------------------------------*/
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 61px); }
.side { border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--r-md);
  color: var(--muted); cursor: pointer; font-weight: 500; font-size: 14px;
  border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel); color: var(--text); border-color: var(--line); }
.nav-item .ico { width: 18px; text-align: center; }
.nav-item .count { margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--amber); color: #201400; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted-2); font-family: var(--font-mono); padding: 10px 13px; }

.main { padding: 26px 30px 60px; max-width: 980px; }
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; }

/* ---- buttons ------------------------------------------------------------*/
.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 10px 16px; border-radius: var(--r-md); cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--muted-2); }
.btn.primary { background: var(--amber); color: #201400; border-color: var(--amber); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--vermilion); border-color: rgba(255,92,67,0.4); }
.btn.danger:hover { background: rgba(255,92,67,0.1); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- cards --------------------------------------------------------------*/
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px;
}
.grid { display: grid; gap: 14px; }

/* ---- alert (telemetry ping) --------------------------------------------*/
.alert {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px 18px; align-items: start; position: relative;
}
.alert.unread { border-color: rgba(255,176,32,0.35); }
.alert .bar { border-radius: 4px; align-self: stretch; background: var(--info); }
.alert.sev-warning .bar { background: var(--amber); }
.alert.sev-critical .bar { background: var(--vermilion); }
.alert .title { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; }
.alert .body { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.alert .meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); margin-top: 9px;
  display: flex; flex-wrap: wrap; gap: 4px 14px; }
.alert .when { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.alert.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 2px rgba(255,176,32,0.8) inset; background: rgba(255,176,32,0.08); }
  100% { box-shadow: none; }
}

/* ---- watcher row --------------------------------------------------------*/
.watcher { display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.watcher .info { flex: 1; min-width: 0; }
.watcher .info .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.watcher .info .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px;
  font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watcher .status { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono);
  font-size: 11.5px; color: var(--muted); }
.pill { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.live { color: var(--phosphor); border-color: rgba(52,229,183,0.4); }
.pill.err { color: var(--vermilion); border-color: rgba(255,92,67,0.4); }

/* ---- source catalog card -----------------------------------------------*/
.source-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.source-card:hover { border-color: var(--phosphor); transform: translateY(-2px); }
.source-card .cat { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--phosphor); }
.source-card h3 { font-size: 16px; margin: 8px 0 6px; }
.source-card p { color: var(--muted); font-size: 13px; }

/* ---- forms --------------------------------------------------------------*/
label.field { display: block; margin-bottom: 16px; }
label.field .lab { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
label.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 14px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--phosphor); }
input.mono { font-family: var(--font-mono); }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }

/* ---- map ----------------------------------------------------------------*/
#map, .mini-map { height: 320px; border-radius: var(--r-md); border: 1px solid var(--line); overflow: hidden; z-index: 1; }
.mini-map { height: 180px; }
.map-hint { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin: 8px 0; }
.radius-row { display: flex; align-items: center; gap: 12px; }
.radius-row input[type=range] { flex: 1; accent-color: var(--amber); }
.radius-row .val { font-family: var(--font-mono); font-size: 13px; color: var(--amber); min-width: 84px; text-align: right; }

/* ---- modal --------------------------------------------------------------*/
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 12, 0.72); backdrop-filter: blur(4px);
  z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  width: min(680px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal .m-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal .m-head h2 { font-size: 18px; flex: 1; }
.modal .m-body { padding: 22px; }
.modal .m-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--panel); }
.x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; }
.x:hover { color: var(--text); }

/* ---- empty state --------------------------------------------------------*/
.empty { text-align: center; padding: 70px 20px; }
.empty .sweep { width: 120px; height: 120px; margin: 0 auto 22px; border-radius: 50%;
  border: 1px solid var(--line); position: relative; overflow: hidden; }
.empty .sweep::after { content: ''; position: absolute; inset: 0;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(52,229,183,0.25) 40deg, transparent 60deg);
  animation: sweep 4s linear infinite; }
.empty .sweep .c { position: absolute; inset: 30%; border-radius: 50%; border: 1px solid rgba(52,229,183,0.25); }
.empty .sweep .c2 { position: absolute; inset: 12%; border-radius: 50%; border: 1px solid var(--line-soft); }
@keyframes sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .empty .sweep::after { animation: none; } }
.empty h2 { font-size: 20px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 380px; margin: 0 auto 18px; }

/* ---- auth ---------------------------------------------------------------*/
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth { width: min(400px, 100%); }
.auth .brand { justify-content: center; margin-bottom: 8px; }
.auth h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth .lead { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.auth .switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth .switch a { color: var(--phosphor); cursor: pointer; }
.err { color: var(--vermilion); font-size: 13px; margin: 4px 0 12px; min-height: 18px; font-family: var(--font-mono); }

/* ---- toast --------------------------------------------------------------*/
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: var(--r-sm); padding: 12px 16px; min-width: 260px; box-shadow: var(--shadow); animation: rise .25s ease-out; }
.toast .t { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.toast .b { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ---- responsive ---------------------------------------------------------*/
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); position: sticky; top: 61px; background: var(--ink); z-index: 30; }
  .side .foot { display: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 20px 16px 50px; }
}
