/* admin.specter.fit — Specter Command.
   Identity carried over from my.specter.fit: near-black, emerald primary,
   gold accent, IBM Plex Sans. Data surfaces use IBM Plex Mono, matching the
   field-log feel of the app. Dependency-free except Leaflet on the map desks.

   Two themes. Dark is the SpecterUserWeb palette verbatim. Light is NOT the
   same hues lightened — emerald #2fd072 on white is about 1.9:1 and
   unreadable. The light accents below are deepened equivalents, the same
   method the previous admin theme used, because an operator console gets read
   for hours at a time. */

:root {
  --bg:        #070908;
  --bg-elev:   #0f1311;
  --surface:   #121714;
  --hairline:  #20271f;
  --green:     #2fd072;
  --green-deep:#1f6f4e;
  --gold:      #d9a657;
  --danger:    #d96a57;
  --warn:      #d9a657;
  --info:      #5aa2ff;
  --ink:       #e9ece8;
  --muted:     #8c948c;
  --max-w:     1240px;
  --narrow:    760px;
}

:root[data-theme="light"] {
  --bg:        #f7f8f6;
  --bg-elev:   #eef1ed;
  --surface:   #ffffff;
  --hairline:  #dfe3de;
  --green:     #10783f;
  --green-deep:#0b5c30;
  --gold:      #8a6520;
  --danger:    #b23b33;
  --warn:      #8a6520;
  --info:      #2f6aa8;
  --ink:       #131614;
  --muted:     #5b625b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 12px; }
h1 { font-size: 30px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: var(--narrow); }
.wrap.center { text-align: center; }
.section { padding: 40px 0; }
main { min-height: 60vh; }

.eyebrow {
  text-transform: uppercase; letter-spacing: 2px; font-size: 11px;
  font-weight: 700; color: var(--green); margin: 0 0 10px;
}
.lead { color: var(--muted); font-size: 17px; max-width: 68ch; }
.fineprint { color: var(--muted); font-size: 13px; line-height: 1.55; }
.page-head { margin-bottom: 24px; }
.stamp {
  font-size: 12px; color: var(--muted);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 400;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 20px;
  justify-content: space-between; min-height: 60px; flex-wrap: wrap;
}
.brand {
  font-weight: 800; letter-spacing: 3px; color: var(--ink); font-size: 15px;
  white-space: nowrap;
}
.brand span { color: var(--gold); margin: 0 4px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 14px; }
.nav a:hover, .nav a.active { color: var(--ink); text-decoration: none; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--green); padding-bottom: 2px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.whoami { font-size: 13px; color: var(--muted); white-space: nowrap; }
.whoami b { color: var(--ink); font-weight: 600; }
.signout { color: var(--muted); font-size: 13px; white-space: nowrap; }

.theme-toggle {
  background: var(--bg-elev); color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--green-deep); }

.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 28px 0; margin-top: 40px;
  color: var(--muted); font-size: 13px;
}

/* ---------- panels + cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 20px;
  margin: 0 0 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }
.accent-panel { border-left: 3px solid var(--green); }
.danger-panel { border-left: 3px solid var(--danger); }
.gold-panel   { border-left: 3px solid var(--gold); }

.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 18px;
}
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px;
}
.card.drillable { cursor: pointer; }
.card.drillable:hover { border-color: var(--green-deep); }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.card-head h3 { margin: 0; }
.card-head .chev { color: var(--muted); font-size: 12px; }

/* ---------- stats ---------- */
.stat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.stat-grid.primary {
  background: var(--bg-elev); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 20px; margin-bottom: 18px;
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); font-weight: 600;
}
.stat-value { font-size: 21px; font-weight: 600; }
.stat-grid.primary .stat-value { font-size: 26px; }
.stat-delta { font-size: 12px; }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--danger); }

/* ---------- status lamps ---------- */
.lamp {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); margin-right: 7px; vertical-align: middle;
}
.lamp.ok   { background: var(--green); }
.lamp.warn { background: var(--warn); }
.lamp.crit { background: var(--danger); }

.pill {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--hairline); color: var(--muted);
}
.pill-green { color: var(--green); border-color: var(--green-deep); }
.pill-gold  { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.pill-red   { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--hairline);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--hairline); }
td.num { text-align: right; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev); }

/* ---------- bar breakdowns ---------- */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 1fr 3fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar .bl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .bt { background: var(--bg-elev); border-radius: 999px; height: 7px; overflow: hidden; }
.bar .bf { display: block; height: 100%; background: var(--green); }
.bar .bv { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }

/* ---------- misc ---------- */
.empty {
  color: var(--muted); font-size: 14px; text-align: center;
  padding: 32px 20px; border: 1px dashed var(--hairline); border-radius: 10px;
}
.note {
  font-size: 13px; color: var(--muted); padding: 10px 0 0;
}
.btn {
  display: inline-block; padding: 11px 20px; border-radius: 10px;
  background: var(--green); color: #06210f; font-weight: 700; text-align: center;
  border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer;
}
/* Light mode needs white text on the green fill — but ONLY on filled buttons.
   Applying it to every .btn also hit .btn-provider, which sits on --surface
   (#ffffff in light mode), so the sign-in button rendered white on white and
   looked like it had disappeared. */
:root[data-theme="light"] .btn:not(.btn-provider) { color: #ffffff; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn-provider {
  background: var(--surface); color: var(--ink);
  border-color: var(--hairline); display: flex; align-items: center; gap: 12px;
  justify-content: center; width: 100%;
}
.btn-provider:hover { border-color: var(--green-deep); filter: none; }
.signin-buttons { display: flex; flex-direction: column; gap: 12px; max-width: 320px; margin: 28px auto 20px; }
.signin-section { padding-top: 72px; }
.banner {
  background: var(--bg-elev); border: 1px solid var(--hairline);
  border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 12px 16px; margin: 18px 0;
  font-size: 14px;
}
.banner.err { border-left-color: var(--danger); }
.banner.ok  { border-left-color: var(--green); }

/* ---------- leaflet ---------- */
.map { height: 420px; border-radius: 10px; overflow: hidden; background: var(--bg-elev); margin: 8px 0 12px; }
.leaflet-container { background: var(--bg-elev); }
:root[data-theme="light"] .leaflet-container { background: #e9e2d2; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.leaflet-popup-content { margin: 14px 16px; font-family: inherit; }
.leaflet-popup-close-button { color: var(--muted) !important; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  h1 { font-size: 25px; }
  .section { padding: 28px 0; }
  .site-header .wrap { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .nav { order: 3; width: 100%; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
  .card-grid { grid-template-columns: 1fr; }
  /* Tables genuinely can't reflow — let them scroll inside their panel
     rather than forcing the page to scroll sideways. */
  .panel, .card { overflow-x: auto; }
}

/* ---------- the pulse ---------- */
.lens-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin: 18px 0; }
.lens .panel-head { align-items: baseline; }
.lens-headline { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 6px; }
.lens-val { font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--ink); }
.lens .lead { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
/* A flat delta is "no comparison window", not "no change" — muted, never
   coloured, so it cannot be misread as a real trend of zero. */
.stat-delta.flat { color: var(--muted); }
.attention { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.attention li { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }

/* ---------- ops desk tabs ---------- */
.desk-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; border-bottom: 1px solid var(--hairline); }
.desk-tabs a {
  color: var(--muted); font-size: 14px; padding: 8px 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.desk-tabs a:hover { color: var(--ink); text-decoration: none; }
.desk-tabs a.active { color: var(--ink); border-bottom-color: var(--green); font-weight: 600; }

/* ---------- filter form ---------- */
.filters {
  display: grid; gap: 12px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px; margin-bottom: 18px;
}
.filters label { display: flex; flex-direction: column; gap: 5px; }
.filters label span {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); font-weight: 600;
}
.filters input, .filters select {
  background: var(--bg-elev); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 14px; width: 100%;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--green); }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-actions .btn { padding: 8px 16px; }
