/* ═══════════════════════════════════════════════════════════════════
   Burnbreaker — financial circuit breaker for AI agents
   Cool-tinted darks. Green = active/protected. Red = threat stopped.
═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Cool-tinted surface scale — deliberate, not just "lights off" */
  --bg:            #06060A;
  --surface:       #0D0D12;
  --surface-hover: #13131B;
  --elevated:      #18181F;
  --border:        rgba(255,255,255,0.085);
  --border-subtle: rgba(255,255,255,0.05);
  --border-strong: rgba(255,255,255,0.13);

  --text:   #E8E8EC;
  --text-2: #808088;
  --text-3: #4A4A54;

  --green:        #22C55E;
  --green-dim:    rgba(34,197,94,0.08);
  --green-border: rgba(34,197,94,0.18);

  /* Amber — warning / threshold approaching */
  --amber:        #F59E0B;
  --amber-dim:    rgba(245,158,11,0.09);
  --amber-border: rgba(245,158,11,0.3);

  /* Red = threat present / run blocked. Every red element tells a story. */
  --red:        #EF4444;
  --red-dim:    rgba(239,68,68,0.08);
  --red-border: rgba(239,68,68,0.3);
  --red-glow:   rgba(239,68,68,0.12);

  --mono: 'Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
  --sans: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;

  --r:    6px;
  --r-sm: 4px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  letter-spacing: -0.008em;
}

/* 2px green stripe at the very top — always present, shows the system is live */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--green);
  z-index: 2000;
}

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

/* ── Wordmark ─────────────────────────────────────────────────────────── */
/* Used in both nav and auth pages */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.wordmark-icon {
  color: var(--green);
  flex-shrink: 0;
  display: block;
}
.wordmark-text {
  display: flex;
  align-items: baseline;
  gap: 0;
  letter-spacing: 0;
  line-height: 1;
}
.wordmark-ai {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--green);
  letter-spacing: 0.05em;
}
.wordmark-fw {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 12px;
  color: rgba(232,232,236,0.55);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-left: 4px;
}

/* ── Nav ──────────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 54px;
  border-bottom: 1px solid var(--border);
  background: rgba(6,6,10,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 2px;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border-subtle), 0 4px 24px rgba(0,0,0,0.4);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: 32px;
}
.nav-link {
  padding: 5px 12px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.1s, background 0.1s;
  letter-spacing: 0.01em;
}
.nav-link:hover { color: var(--text); background: var(--elevated); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--elevated); }
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-email {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
  letter-spacing: 0;
}
.nav-logout {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
  font-family: var(--sans);
}
.nav-logout:hover { color: var(--text); border-color: var(--text-3); }
.nav-support {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--sans);
  text-decoration: none;
  transition: color 0.1s;
}
.nav-support:hover { color: var(--text-2); }

/* ── Page chrome ──────────────────────────────────────────────────────── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 56px;
}

/* ── Auth pages ───────────────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background-color: var(--bg);
  /* fine dot-grid — circuit board motif */
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(34,197,94,0.06) 0%, transparent 100%),
    radial-gradient(circle, rgba(34,197,94,0.06) 1px, transparent 1px);
  background-size: auto, 24px 24px;
}
.auth-logo-wrap {
  margin-bottom: 36px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 0 0 1px rgba(255,255,255,0.05),
    0 4px 12px rgba(0,0,0,0.4),
    0 20px 56px rgba(0,0,0,0.55);
}
.auth-heading {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.auth-subheading {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 22px;
}
.auth-switch {
  text-align: center;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-2);
}

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  font-family: var(--sans);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.35);
  letter-spacing: -0.005em;
}
.form-input:focus {
  border-color: rgba(34,197,94,0.55);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.25), 0 0 0 3px rgba(34,197,94,0.1), 0 0 0 1px rgba(34,197,94,0.2);
}
.form-input::placeholder { color: var(--text-3); }
.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 10px;
  display: none;
  padding: 8px 10px;
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  border-radius: var(--r-sm);
}
.form-error.visible { display: block; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.12s, box-shadow 0.12s, border-color 0.12s, opacity 0.12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--sans);
  letter-spacing: 0.005em;
}
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary {
  background: var(--green);
  color: #020c06;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(34,197,94,0.25), 0 1px 3px rgba(0,0,0,0.5);
}
.btn-primary:hover:not(:disabled) {
  background: #27d267;
  box-shadow: 0 0 0 1px rgba(34,197,94,0.35), 0 0 24px rgba(34,197,94,0.18), 0 1px 3px rgba(0,0,0,0.5);
}
.btn-secondary {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.09);
}
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-border);
}
.btn-danger:hover:not(:disabled) { background: var(--red-dim); border-color: rgba(239,68,68,0.45); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-full { width: 100%; }

/* ── Dashboard stat cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 10px;
  margin-bottom: 24px;
}
@media (max-width: 700px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.11),
    0 2px 6px rgba(0,0,0,0.35),
    0 8px 24px rgba(0,0,0,0.28);
}

/* Hero threat card — the product's reason for existing */
.stat-card-threat {
  border-left: 3px solid var(--red);
  border-radius: 0 var(--r) var(--r) 0;
  background: color-mix(in srgb, var(--surface) 90%, var(--red) 10%);
  position: relative;
  padding: 20px 22px 20px 18px;
  box-shadow:
    inset 0 1px 0 rgba(239,68,68,0.24),
    0 2px 6px rgba(0,0,0,0.35),
    0 8px 24px rgba(0,0,0,0.28),
    -8px 0 24px rgba(239,68,68,0.07);
}

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  font-family: var(--mono);
}
.stat-value {
  font-size: 30px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -1.5px;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value-threat {
  font-size: 38px;
  letter-spacing: -2px;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
  font-family: var(--mono);
  letter-spacing: 0;
}

/* ── Alert banner ─────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.5;
}
.alert-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.alert-success {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  color: var(--green);
}
.alert-danger {
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  color: var(--red);
}
.alert-info {
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.section { margin-bottom: 32px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-count {
  font-size: 10px;
  color: var(--text-3);
  background: var(--elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--mono);
  letter-spacing: 0;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.09),
    0 2px 8px rgba(0,0,0,0.25);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,13,18,0.8);
  white-space: nowrap;
  font-family: var(--mono);
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  vertical-align: middle;
  background: var(--surface);
  transition: background 0.08s;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

/* Red inset left accent on blocked rows — only first cell gets the border */
tr.row-blocked td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}

.cell-mono { font-family: var(--mono); font-size: 12px; }
.cell-muted { color: var(--text-2); }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  font-family: var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: transparent;
}
.badge-blocked {
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.38);
  box-shadow: inset 0 0 8px rgba(239,68,68,0.04);
}
.badge-completed {
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.32);
}
.badge-active {
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-revoked {
  color: var(--text-3);
  border: 1px solid var(--border-subtle);
}

/* ── Progress bar ─────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 2px;
  background: var(--elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill { height: 100%; background: var(--green); }
.progress-fill-blocked { background: var(--red); }

/* ── Chart ────────────────────────────────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px 12px;
}
.chart-wrap { position: relative; height: 170px; }

/* ── Code snippet ─────────────────────────────────────────────────────── */
.snippet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.09),
    0 2px 8px rgba(0,0,0,0.3);
}
.snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--elevated);
}
.snippet-tabs { display: flex; }
.snippet-tab {
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.1s, border-color 0.1s;
  user-select: none;
  font-family: var(--mono);
  font-weight: 500;
}
.snippet-tab.active { color: var(--green); border-bottom-color: var(--green); }
.snippet-tab:hover { color: var(--text); }
.snippet-body {
  background: var(--bg);
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.8;
  white-space: pre;
  overflow-x: auto;
  color: #c8c8c8;
  position: relative;
}
.snippet-copy {
  padding: 4px 12px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
  font-family: var(--mono);
  height: 100%;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.snippet-copy:hover { color: var(--text); background: var(--surface); }
/* syntax tokens */
.kw { color: #C586C0; }
.st { color: #CE9178; }
.cm { color: #5a8a5a; }
.fn { color: #DCDCAA; }
.nu { color: #B5CEA8; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  margin: 16px;
  border-top: 2px solid var(--green);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.09),
    0 0 0 1px rgba(255,255,255,0.05),
    0 8px 24px rgba(0,0,0,0.45),
    0 24px 60px rgba(0,0,0,0.55);
}
.modal-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.1px; }
.modal-desc { font-size: 12.5px; color: var(--text-2); margin-bottom: 16px; line-height: 1.55; }
.key-display {
  background: var(--bg);
  border: 1px solid var(--green-border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(34,197,94,0.12);
}
.key-text {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  word-break: break-all;
  line-height: 1.6;
}
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Empty states ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  text-align: center;
}
.empty-icon {
  color: var(--text-3);
  margin-bottom: 14px;
  opacity: 0.6;
}
.empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: -0.1px;
}
.empty-desc {
  font-size: 12.5px;
  color: var(--text-3);
  max-width: 320px;
  line-height: 1.55;
}

/* ── Loading ──────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px;
  gap: 10px;
  color: var(--text-3);
  font-size: 12.5px;
  font-family: var(--mono);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page header (keys page) ──────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-head-text { flex: 1; }
.page-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin-bottom: 4px;
  color: var(--text);
}
.page-subtitle { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.page-subtitle code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
}

/* ── Billing page ─────────────────────────────────────────────────────────── */
.billing-plan-card { display: flex; flex-direction: column; gap: 20px; }

.billing-plan-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.billing-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.billing-status-text {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
}
.billing-plan-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 5px;
}
.billing-plan-desc {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  max-width: 420px;
}
.billing-plan-price {
  text-align: right;
  flex-shrink: 0;
  padding-top: 4px;
}
.billing-price-amount {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
}
.billing-price-period { font-size: 12px; color: var(--text-3); }

.billing-quota {
  padding: 16px 0 4px;
  border-top: 1px solid var(--border-subtle);
}
.billing-quota-label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 8px;
  font-family: var(--mono);
}
.billing-quota-label strong { color: var(--text); font-variant-numeric: tabular-nums; }

.billing-upgrade-btn { align-self: flex-start; }

/* Feature comparison table */
.cell-center { text-align: center; }
.feat-yes { color: var(--green); font-weight: 700; font-family: var(--mono); }
.feat-no  { color: var(--text-3); }

/* ── Pro event tags (run log) ─────────────────────────────────────────────── */
.event-tag {
  display: inline-block;
  font-size: 10px;
  font-family: var(--mono);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 16px;
}
.event-tag-downgrade {
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber-border);
}
.event-tag-kill {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-border);
}

/* ── Utils ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-right { text-align: right; }
