/* kagex-monitoring — sober dark admin chrome.
 *
 * Deliberately minimal so the page reads as "operator console", not
 * marketing surface. No tilt, no glow, no flourishes.
 */

:root {
  --bg: #0a0a0b;
  --panel: #131316;
  --panel-2: #1a1a1e;
  --border: rgba(255, 255, 255, 0.08);
  --fg: #e7e7ea;
  --muted: rgba(231, 231, 234, 0.62);
  --accent: oklch(0.65 0.21 28);
  --danger: #ff5a5a;
  --warn: #f59e0b;
  --success: #4ade80;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  padding: 2px 5px;
}

.muted { color: var(--muted); }

/* ── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--fg);
}

.brand-mark { color: var(--accent); }
.brand-subtle { color: var(--muted); font-weight: 500; }

.topbar-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.env-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

.who {
  font-size: 0.85rem;
  color: var(--muted);
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.ghost:hover { background: rgba(255, 255, 255, 0.04); }
.ghost:disabled { opacity: 0.5; cursor: progress; }

/* ── Sign-in card ─────────────────────────────────────────────────────── */
.signin-card {
  max-width: 460px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.signin-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.signin-card .footnote {
  font-size: 0.8rem;
  margin: 1.5rem 0 0;
}

#google-button { margin: 1.4rem 0 0.6rem; }

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

/* ── Dashboard layout ─────────────────────────────────────────────────── */
.dashboard {
  max-width: 1180px;
  margin: 1.4rem auto;
  padding: 0 1.4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
}

.card.muted-card { background: var(--panel-2); }

.card-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.3rem;
}

.card h2 {
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
}

/* ── KPI strip ────────────────────────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
}

.kpi-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 120ms ease, background 120ms ease;
}

.kpi-tile .kpi-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-tile strong {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--fg);
}

.kpi-tile.is-danger {
  border-color: rgba(255, 90, 90, 0.4);
  background: linear-gradient(180deg, rgba(255, 90, 90, 0.06), var(--panel));
}
.kpi-tile.is-danger strong { color: var(--danger); }

.kpi-tile.is-warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06), var(--panel));
}
.kpi-tile.is-warn strong { color: var(--warn); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 0.4rem -0.4rem -0.4rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table .sub {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.18rem;
}

.empty {
  margin: 0.4rem 0;
  color: var(--muted);
}

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-active {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.3);
}

.badge-error {
  background: rgba(255, 90, 90, 0.12);
  color: var(--danger);
  border-color: rgba(255, 90, 90, 0.3);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-color: var(--border);
}

/* ── Reason chip (mirrors labs admin.js styling) ─────────────────────── */
.reason {
  display: inline-block;
  max-width: 22rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 90, 90, 0.08);
  color: oklch(0.6 0.16 25.3);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

.footnote {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
}

ol { margin: 0.4rem 0 0 1.1rem; padding: 0; }
ol li { margin: 0.25rem 0; }

/* ── Section heading (Analytics divider) ────────────────────────────── */
.section-heading {
  margin: 1.2rem 0 -0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ── Multi-column grids ─────────────────────────────────────────────── */
.card-grid-2,
.card-grid-3 {
  display: grid;
  gap: 1.1rem;
}
.card-grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ── Funnel bars ───────────────────────────────────────────────────── */
.funnel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.funnel-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.funnel-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.82rem;
}

.funnel-stage { color: var(--fg); }
.funnel-count {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--fg);
  font-weight: 600;
}

.funnel-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg,
    oklch(0.65 0.21 28) 0%,
    oklch(0.7 0.16 35) 100%);
  border-radius: 4px;
  transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.funnel-drop {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Key/value stack (OAuth mix, Sub health) ────────────────────────── */
.kv-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.kv-row:last-child { border-bottom: none; }

.kv-label { color: var(--muted); }

.kv-val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--fg);
  font-weight: 600;
}

.kv-pct {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.3rem;
}

.kv-val.kv-warn   { color: var(--warn); }
.kv-val.kv-danger { color: var(--danger); }

/* ── Weekly trend mini-bars ────────────────────────────────────────── */
.trend-table td .cell-bar {
  position: relative;
  display: block;
  height: 22px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.trend-table td .cell-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg,
    oklch(0.65 0.21 28 / 0.7) 0%,
    oklch(0.65 0.21 28 / 0.3) 100%);
  border-radius: 3px;
}

.trend-table td .cell-bar em {
  position: relative;
  display: block;
  padding: 2px 6px;
  font-style: normal;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--fg);
  z-index: 1;
}
