/* ============================================================================
   Alpha Command · Admin theme
   A faithful port of the Agent Marketplace design system (agents-base.css +
   agents-styles.css) to the admin/operator surface. Deep indigo terminal,
   blue/green/amber/purple accents, Space Grotesk + JetBrains Mono.
   ========================================================================== */

:root {
  --bg-page: var(--mg-bg);
  --bg-base: var(--mg-bg);
  --bg-card: var(--mg-surface);
  --bg-card-2: var(--mg-surface-2);
  --bg-input: var(--mg-input);

  --border: var(--mg-border);
  --border-strong: var(--mg-border-strong);
  --border-faint: rgba(148, 163, 184, 0.10);
  --divider: rgba(148, 163, 184, 0.08);

  --text: var(--mg-text);
  --text-muted: var(--mg-text-muted);
  --text-dim: var(--mg-text-dim);
  --text-faint: var(--mg-text-faint);

  --blue: var(--mg-blue-hi);
  --blue-2: var(--mg-blue);
  --blue-soft: rgba(63, 123, 255, 0.14);
  --indigo: var(--mg-blue-hi);
  --indigo-2: var(--mg-blue);

  --green: var(--mg-green-base);
  --green-bright: var(--mg-green);
  --green-soft: rgba(16, 185, 129, 0.14);

  --red: var(--mg-red-base);
  --red-bright: var(--mg-red);
  --red-soft: rgba(239, 68, 68, 0.14);

  --amber: #f0c674;
  --amber-2: var(--mg-gold);
  --amber-soft: rgba(240, 198, 116, 0.14);

  --purple: var(--mg-blue-hi);
  --purple-2: var(--mg-blue);
  --purple-soft: rgba(63, 123, 255, 0.14);

  --radius: var(--mg-radius);
  --radius-lg: var(--mg-radius-lg);

  --font-sans: var(--mg-font-display);
  --font-mono: var(--mg-font-mono);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 82% -10%, rgba(63,123,255,0.10), transparent 60%),
    radial-gradient(900px 520px at 4% 108%, rgba(63,123,255,0.08), transparent 55%),
    var(--bg-page);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Sticky footer: column layout + .site-footer{margin-top:auto} keeps the
     footer at the viewport bottom on short pages. */
  display: flex;
  flex-direction: column;
}
body > main.main-shell { width: 100%; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; cursor: pointer; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.green { color: var(--green-bright); }
.red { color: var(--red-bright); }
.amber { color: var(--amber); }
.blue { color: var(--blue); }
.purple { color: var(--purple); }
.dim { color: var(--text-dim); }

/* ───────────────────────── Header ───────────────────────── */
.app-header {
  background: linear-gradient(180deg, rgba(8,12,33,0.96) 0%, rgba(10,14,39,0.94) 100%);
  border-bottom: 1px solid rgba(63,123,255,0.18);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px 10px; gap: 18px; flex-wrap: nowrap;
  max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #14244a 0%, #101d3d 100%);
  display: grid; place-items: center; border: 2px solid #f0c674; position: relative;
}
.brand-icon::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid rgba(240,198,116,0.3); }
.brand-block { display: flex; flex-direction: column; gap: 1px; white-space: nowrap; }
.brand-name { font-size: 15px; font-weight: 700; color: #c3d0e8; letter-spacing: 0.02em; line-height: 1.15; }
.brand-name .tm { font-size: 8px; color: var(--text-dim); margin-left: 1px; vertical-align: super; }
.brand-sub { font-size: 10px; font-weight: 700; color: var(--blue); letter-spacing: 0.12em; text-transform: uppercase; }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: nowrap; }
.btn-h {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 7px;
  border: 1px solid var(--border-faint); background: rgba(15,22,51,0.7);
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; transition: all .15s;
}
.btn-h:hover { background: rgba(63,123,255,0.14); color: var(--text); border-color: var(--border-strong); }
.btn-h.green { color: var(--green-bright); border-color: rgba(16,185,129,0.32); background: rgba(16,185,129,0.08); }
.btn-h.green:hover { background: rgba(16,185,129,0.16); }
.btn-h.blue { color: var(--blue); border-color: rgba(63,123,255,0.32); background: rgba(63,123,255,0.08); }
.market-pill {
  display: inline-flex; flex-direction: column; align-items: stretch; gap: 1px;
  padding: 5px 12px; border-radius: 7px;
  background: rgba(15,22,51,0.7); border: 1px solid var(--border-faint);
  font-size: 9px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.market-pill .status { display: inline-flex; align-items: center; gap: 5px; color: var(--green-bright); font-size: 11px; letter-spacing: 0; text-transform: none; margin-top: 1px; }
.market-pill .status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 6px var(--green-bright); }
.user-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 7px;
  background: rgba(15,22,51,0.7); border: 1px solid var(--border-faint);
  text-align: right; color: var(--amber);
}
.user-pill .tier { font-size: 9.5px; font-weight: 700; color: var(--amber); text-transform: uppercase; letter-spacing: 0.04em; }

/* ───────────────────────── Nav tabs (grouped dropdowns) ───────────────────────── */
.nav-tabs {
  display: flex; gap: 2px; padding: 0 28px;
  max-width: 1280px; margin: 0 auto;
  /* overflow must stay visible: an overflow-x:auto here also computes
     overflow-y:auto, which clips the absolutely-positioned dropdown panels
     (they hang below the bar) and makes them invisible. Wrap instead of
     scroll on narrow screens — there are only a few groups. */
  overflow: visible; flex-wrap: wrap;
  border-top: 1px solid rgba(63,123,255,0.10);
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 15px; border: 0; background: transparent;
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  white-space: nowrap; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; flex-shrink: 0;
}
.nav-tab .ic { display: inline-flex; color: var(--text-dim); }
.nav-tab .caret { display: inline-flex; opacity: 0.55; margin-left: -1px; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.nav-tab.active .ic { color: var(--blue); }

.nav-dd { position: relative; flex-shrink: 0; }
.nav-dd-panel {
  position: absolute; top: 100%; left: 8px; z-index: 60;
  min-width: 215px; padding: 6px;
  background: linear-gradient(180deg, #0d1230, #0a0e22);
  border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: 0 24px 50px -18px rgba(0,0,0,0.8);
  display: none; flex-direction: column; gap: 1px;
}
.nav-dd[data-open] .nav-dd-panel { display: flex; }
.nav-dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px;
  color: var(--text-muted); font-size: 12.5px; font-weight: 600;
  transition: background .12s, color .12s;
}
.nav-dd-item .ic { font-size: 13px; width: 17px; text-align: center; }
.nav-dd-item:hover { background: rgba(63,123,255,0.12); color: var(--text); }
.nav-dd-item.active { background: var(--blue-soft); color: var(--blue); }

/* ───────────────────────── Shell ───────────────────────── */
.main-shell {
  max-width: 1240px; margin: 0 auto;
  padding: 24px 28px 56px;
  display: flex; flex-direction: column; gap: 18px;
}

/* page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 2px; }
.page-head > div:first-child { min-width: 0; }
.page-head h1 {
  margin: 0 0 5px; font-size: 25px; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 11px; white-space: nowrap;
}
.page-head h1 .pg-ic {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(63,123,255,0.10); border: 1px solid rgba(63,123,255,0.24); color: var(--blue);
}
.page-head p { margin: 0; font-size: 13px; color: var(--text-dim); max-width: 64ch; line-height: 1.5; }
.page-head .ph-actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ───────────────────────── Cards ───────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(15,22,51,0.7), rgba(13,18,48,0.6));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.card-head .ch-ic {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-size: 14px; color: var(--blue); background: rgba(63,123,255,0.10); border: 1px solid rgba(63,123,255,0.24);
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.card-head .count {
  margin-left: auto; padding: 2px 9px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 700; font-family: var(--font-mono);
  border: 1px solid rgba(63,123,255,0.28);
}
.card-hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; margin: 8px 0 0; }
.card-hint strong { color: var(--text); }

.section-title {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 2px;
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.section-title .count {
  background: rgba(63,123,255,0.14); color: var(--blue); font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(63,123,255,0.28); letter-spacing: 0;
}
.section-title .rule { flex: 1; height: 1px; background: var(--divider); }

/* ───────────────────────── Stat strip ───────────────────────── */
.stat-strip {
  display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr);
  background: rgba(8,12,33,0.4); border: 1px solid var(--border-faint);
  border-radius: 12px; overflow: hidden;
}
.stat-cell { padding: 15px 18px; border-right: 1px solid var(--divider); }
.stat-cell:last-child { border-right: 0; }
.stat-cell .l { font-size: 10px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 7px; }
.stat-cell .v { font-size: 24px; font-weight: 700; color: var(--text); font-family: var(--font-mono); line-height: 1; }
.stat-cell .v.green { color: var(--green-bright); }
.stat-cell .v.red { color: var(--red-bright); }
.stat-cell .v.amber { color: var(--amber); }
.stat-cell .v.blue { color: var(--blue); }
.stat-cell .s { font-size: 10.5px; color: var(--text-dim); font-weight: 600; margin-top: 5px; }
.stat-cell .s.green { color: var(--green-bright); }
@media (max-width: 920px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

/* grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

/* ───────────────────────── Forms ───────────────────────── */
.field-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field-grid.invite { grid-template-columns: 120px 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 10.5px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; }
.input {
  height: 40px; padding: 0 13px;
  background: rgba(8,12,33,0.85); border: 1px solid var(--border-faint); border-radius: 9px;
  color: var(--text); font-size: 13px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-dim); }
.input:focus { border-color: rgba(63,123,255,0.55); box-shadow: 0 0 0 3px rgba(63,123,255,0.12); background: rgba(8,12,33,1); }
textarea.input { height: auto; padding: 10px 13px; resize: vertical; min-height: 80px; }

.check {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 13px;
  padding: 9px 13px; border-radius: 9px; cursor: pointer; user-select: none;
  font-size: 12.5px; color: var(--text-muted);
  background: rgba(8,12,33,0.6); border: 1px solid var(--border-faint);
  transition: border-color .15s, color .15s, background .15s;
}
.check:hover { border-color: rgba(63,123,255,0.4); color: var(--text); }
.check input { accent-color: var(--blue-2); width: 15px; height: 15px; }
.check .note { color: var(--text-dim); font-size: 11.5px; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ───────────────────────── Buttons ───────────────────────── */
.btn {
  height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border-faint);
  background: rgba(15,22,51,0.6); color: var(--text-muted);
  font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter .15s, background .15s, color .15s, border-color .15s, transform .05s;
}
.btn:hover:not(:disabled) { background: rgba(63,123,255,0.14); color: var(--text); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 11.5px; border-radius: 7px; }
.btn.primary { background: linear-gradient(180deg, #3f7bff, #2f63e0); color: #fff; border-color: transparent; box-shadow: 0 4px 14px -4px rgba(63,123,255,0.5); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: #fff; background: linear-gradient(180deg, #3f7bff, #2f63e0); }
.btn.go { background: linear-gradient(180deg, #10b981, #0e9b73); color: #fff; border-color: transparent; box-shadow: 0 4px 14px -4px rgba(16,185,129,0.5); }
.btn.go:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }
.btn.danger { background: rgba(239,68,68,0.10); color: var(--red-bright); border-color: rgba(239,68,68,0.3); }
.btn.danger:hover:not(:disabled) { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.5); color: var(--red-bright); }
.btn.amber { background: rgba(232,181,77,0.10); color: var(--amber); border-color: rgba(232,181,77,0.32); }
.btn.amber:hover:not(:disabled) { background: rgba(232,181,77,0.18); color: var(--amber); }

/* segmented */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: rgba(8,12,33,0.6); border: 1px solid var(--border-faint); border-radius: 9px; }
.seg button { padding: 6px 12px; border: 0; background: transparent; color: var(--text-muted); font-size: 11.5px; font-weight: 700; border-radius: 6px; }
.seg button.active { background: var(--blue-soft); color: var(--blue); }
.select {
  height: 34px; padding: 0 30px 0 12px;
  background: rgba(8,12,33,0.6) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'><path d='M7 10l5 5 5-5z'/></svg>") right 8px center/14px no-repeat;
  border: 1px solid var(--border-faint); border-radius: 8px;
  color: var(--text); font-size: 12px; font-weight: 600; appearance: none; outline: none; cursor: pointer;
}
.select:focus { border-color: rgba(63,123,255,0.5); }

/* ───────────────────────── Result / token cards ───────────────────────── */
.result { margin-top: 16px; padding: 14px 16px; border-radius: 11px; font-size: 13px; line-height: 1.5; border: 1px solid transparent; display: none; }
.result.show { display: block; animation: rpop .22s cubic-bezier(0.16,1,0.3,1); }
@keyframes rpop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.result.ok { background: rgba(16,185,129,0.07); border-color: rgba(16,185,129,0.28); }
.result.err { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.28); color: var(--red-bright); }
.result .t { font-weight: 700; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.result .t .ok-i { color: var(--green-bright); }
.result .b { color: var(--text-muted); margin-bottom: 10px; }
.result .b code { color: var(--text); background: rgba(8,12,33,0.8); border: 1px solid var(--border-faint); border-radius: 5px; padding: 1px 6px; font-family: var(--font-mono); font-size: 12px; }
.token-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding: 10px 12px; background: rgba(4,6,16,0.6); border: 1px solid var(--border-faint); border-radius: 9px; }
.token-row code { flex: 1; font-family: var(--font-mono); font-size: 13px; color: var(--text); word-break: break-all; }

/* ───────────────────────── Tables ───────────────────────── */
.table-card { background: linear-gradient(180deg, rgba(15,22,51,0.7), rgba(13,18,48,0.6)); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 14px; }
.table-head .ch-ic { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 14px; color: var(--blue); background: rgba(63,123,255,0.10); border: 1px solid rgba(63,123,255,0.24); }
.table-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.table-head .count { padding: 2px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 700; font-family: var(--font-mono); border: 1px solid rgba(63,123,255,0.28); }
.table-head .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 7px; min-width: 210px;
  background: rgba(8,12,33,0.75); border: 1px solid var(--border-faint); border-radius: 8px; padding: 7px 11px;
}
.search:focus-within { border-color: rgba(63,123,255,0.5); box-shadow: 0 0 0 3px rgba(63,123,255,0.1); }
.search svg { width: 14px; height: 14px; color: var(--text-dim); flex: none; }
.search input { background: none; border: none; outline: none; color: var(--text); font-size: 12.5px; width: 100%; }
.search input::placeholder { color: var(--text-dim); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl thead th {
  text-align: left; font-size: 9.5px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 16px; white-space: nowrap;
  border-top: 1px solid var(--border-faint); border-bottom: 1px solid var(--border-faint);
  background: rgba(8,12,33,0.4);
}
table.tbl thead th.r { text-align: right; }
table.tbl thead th.c { text-align: center; }
table.tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; color: var(--text); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover td { background: rgba(63,123,255,0.04); }
table.tbl td.r { text-align: right; }
table.tbl td.c { text-align: center; }
table.tbl td.muted { color: var(--text-muted); }
.empty-row td { text-align: center; color: var(--text-dim); font-style: italic; padding: 30px 0; }

/* identity cell */
.id-cell { display: flex; align-items: center; gap: 11px; }
.id-cell .av { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; }
.id-cell .who { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.id-cell .who .nm { font-weight: 700; color: var(--text); font-family: var(--font-mono); font-size: 12.5px; }
.id-cell .who .em { color: var(--text-dim); font-size: 11.5px; }

.row-actions { display: inline-flex; gap: 7px; opacity: .6; transition: opacity .15s; }
table.tbl tbody tr:hover .row-actions { opacity: 1; }

/* code chip */
.code-chip { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 12px; color: var(--text); padding: 4px 9px; border-radius: 7px; background: rgba(8,12,33,0.7); border: 1px solid var(--border-faint); }
.code-chip:hover { border-color: rgba(63,123,255,0.4); }
.code-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 6px var(--green-bright); }
.code-chip.dead .dot { background: var(--text-dim); box-shadow: none; }

/* ───────────────────────── Badges / chips ───────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; letter-spacing: 0.02em; }
.badge .bd { width: 6px; height: 6px; border-radius: 50%; }
.badge.admin { background: rgba(63,123,255,0.14); border-color: rgba(63,123,255,0.34); color: var(--purple); }
.badge.admin .bd { background: var(--purple); }
.badge.user { background: rgba(100,116,139,0.12); border-color: var(--border-faint); color: var(--text-muted); }
.badge.user .bd { background: var(--text-dim); }
.badge.active { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.32); color: var(--green-bright); }
.badge.active .bd { background: var(--green-bright); box-shadow: 0 0 6px var(--green-bright); }
.badge.consumed { background: rgba(100,116,139,0.12); border-color: var(--border-faint); color: var(--text-muted); }
.badge.expired { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.3); color: var(--red-bright); }
.badge.warn { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.32); color: var(--red-bright); }
.badge.warn .bd { background: var(--red-bright); }
.badge.live { font-family: var(--font-mono); background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); color: var(--green-bright); }
.badge.live .bd { background: var(--green-bright); box-shadow: 0 0 6px var(--green-bright); }
.badge.paper { font-family: var(--font-mono); background: rgba(100,116,139,0.12); border-color: var(--border-faint); color: var(--text-muted); }
.badge.draft { background: rgba(232,181,77,0.12); border-color: rgba(232,181,77,0.3); color: var(--amber); }
.badge.draft .bd { background: var(--amber); }
.dash { color: var(--text-faint); }

/* ───────────────────────── Toggle switch ───────────────────────── */
.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; cursor: pointer; background: rgba(15,22,51,0.9); border: 1px solid var(--border-faint); transition: .2s; border-radius: 999px; }
.switch .sl::before { position: absolute; content: ""; height: 15px; width: 15px; left: 2px; top: 2px; background: var(--text-muted); transition: .2s; border-radius: 50%; }
.switch input:checked + .sl { background: rgba(16,185,129,0.3); border-color: rgba(16,185,129,0.5); }
.switch input:checked + .sl::before { transform: translateX(17px); background: var(--green-bright); }
.switch input:focus-visible + .sl { box-shadow: 0 0 0 3px rgba(16,185,129,0.25); }

/* big pill toggle (publishing/live) */
.toggle-pill { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 9px; font-size: 12px; font-weight: 700; border: 1px solid; cursor: pointer; }
.toggle-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.toggle-pill.on { background: rgba(16,185,129,0.12); color: var(--green-bright); border-color: rgba(16,185,129,0.32); }
.toggle-pill.on .dot { box-shadow: 0 0 8px var(--green-bright); }
.toggle-pill.off { background: rgba(100,116,139,0.10); color: var(--text-muted); border-color: var(--border-faint); }

/* footer status line */
.foot-msg { color: var(--text-dim); font-size: 11.5px; padding: 14px 20px; border-top: 1px solid var(--divider); min-height: 1em; }
.foot-msg.err { color: var(--red-bright); }

/* mono block */
.mono-block { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); background: rgba(4,6,16,0.5); border: 1px solid var(--border-faint); border-radius: 9px; padding: 13px 15px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }

/* loading / empty */
.loading { padding: 26px; text-align: center; color: var(--text-dim); font-size: 13px; border: 1px dashed var(--border-faint); border-radius: 10px; }
.empty-note { text-align: center; padding: 34px 16px; color: var(--text-dim); font-size: 13px; background: rgba(8,12,33,0.4); border: 1px dashed var(--border-faint); border-radius: 11px; line-height: 1.6; }

/* ───────────────────────── Bot status card ───────────────────────── */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.bot-card { background: linear-gradient(180deg, rgba(15,22,51,0.7), rgba(13,18,48,0.6)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .15s; }
.bot-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.bot-card.active  { border-left: 3px solid var(--green-bright); }
.bot-card.paused  { border-left: 3px solid var(--amber); }
.bot-card.error   { border-left: 3px solid var(--red-bright); }
.bot-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bot-card-id { display: inline-flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.bot-card-id > div { min-width: 0; }
.bot-card-glyph { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; background: rgba(63,123,255,0.10); border: 1px solid rgba(63,123,255,0.22); flex: none; }
.bot-card-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card-tag { font-size: 10.5px; color: var(--blue); font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-badge { flex: none; font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 5px; }
.st-badge .bd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-badge.active { background: rgba(16,185,129,0.16); color: var(--green-bright); border-color: rgba(16,185,129,0.35); }
.st-badge.active .bd { box-shadow: 0 0 6px var(--green-bright); }
.st-badge.paused { background: rgba(232,181,77,0.15); color: var(--amber); border-color: rgba(232,181,77,0.35); }
.st-badge.error  { background: rgba(239,68,68,0.15); color: var(--red-bright); border-color: rgba(239,68,68,0.3); }
.bot-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: rgba(8,12,33,0.5); border: 1px solid var(--border-faint); border-radius: 10px; overflow: hidden; }
.bot-card-stats .bs { padding: 9px 11px; border-right: 1px solid var(--divider); }
.bot-card-stats .bs:nth-child(2n) { border-right: 0; }
.bot-card-stats .bs:nth-child(-n+2) { border-bottom: 1px solid var(--divider); }
.bot-card-stats .bs .l { font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 3px; }
.bot-card-stats .bs .v { font-size: 15px; font-weight: 700; color: var(--text); font-family: var(--font-mono); }
.bot-card-stats .bs .v.green { color: var(--green-bright); }
.bot-card-stats .bs .v.red { color: var(--red-bright); }
.bot-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--divider); }
.mirror-badge { font-size: 10px; font-weight: 700; padding: 2px 9px; border-radius: 999px; letter-spacing: 0.03em; }
.mirror-badge.on { background: rgba(16,185,129,0.15); color: var(--green-bright); }
.mirror-badge.off { background: rgba(100,116,139,0.12); color: var(--text-dim); }
.bot-card-actions { display: inline-flex; gap: 6px; }

/* ───────────────────────── Alert feed ───────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 7px; }
.alert-row { display: flex; align-items: center; gap: 11px; background: rgba(8,12,33,0.4); border: 1px solid var(--border-faint); border-radius: 11px; padding: 10px 14px; font-size: 12.5px; }
.alert-row:hover { border-color: var(--border); background: rgba(63,123,255,0.04); }
.alert-time { color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; min-width: 46px; }
.alert-rule { flex-shrink: 0; font-size: 9.5px; font-weight: 800; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; background: rgba(63,123,255,0.14); color: var(--indigo); border: 1px solid rgba(63,123,255,0.3); }
.alert-rule.gap { background: rgba(16,185,129,0.12); color: var(--green-bright); border-color: rgba(16,185,129,0.28); }
.alert-rule.gex { background: rgba(232,181,77,0.12); color: var(--amber); border-color: rgba(232,181,77,0.28); }
.alert-rule.sector { background: rgba(63,123,255,0.12); color: var(--purple); border-color: rgba(63,123,255,0.28); }
.alert-rule.allin { background: rgba(249,115,22,0.14); color: #e8b54d; border-color: rgba(249,115,22,0.3); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-detail { color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verdict-chip { flex-shrink: 0; font-size: 9.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.verdict-chip.pass { background: rgba(16,185,129,0.14); color: var(--green-bright); border: 1px solid rgba(16,185,129,0.3); }
.verdict-chip.fail { background: rgba(239,68,68,0.14); color: var(--red-bright); border: 1px solid rgba(239,68,68,0.3); }
.verdict-chip.pending { background: rgba(100,116,139,0.14); color: var(--text-muted); border: 1px solid var(--border-faint); }

/* ───────────────────────── Ladder (gates) ───────────────────────── */
.ladder { background: rgba(8,12,33,0.5); border: 1px solid var(--border-faint); border-radius: 11px; padding: 13px 15px; }
.ladder.triggered { border-left: 3px solid var(--green-bright); }
.ladder.watching, .ladder.armed { border-left: 3px solid var(--amber); }
.ladder.idle { border-left: 3px solid rgba(100,116,139,0.5); opacity: 0.78; }
.ladder.invalidated { border-left: 3px solid var(--red-bright); }
.ladder-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.ladder-id { font-size: 13px; color: var(--text); font-weight: 600; }
.ladder-id .dim { color: var(--text-dim); font-size: 11px; font-weight: 500; }
.ladder-status { font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 5px; }
.ladder-status.triggered { background: rgba(16,185,129,0.16); color: var(--green-bright); }
.ladder-status.watching, .ladder-status.armed { background: rgba(232,181,77,0.16); color: var(--amber); }
.ladder-status.idle { background: rgba(100,116,139,0.14); color: var(--text-muted); }
.ladder-status.invalidated { background: rgba(239,68,68,0.16); color: var(--red-bright); }
.ladder-stages { display: flex; flex-direction: column; gap: 7px; }
.stage { display: flex; align-items: center; gap: 9px; font-size: 11.5px; }
.stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid; }
.stage.passed .stage-dot { background: var(--green-bright); border-color: var(--green-bright); box-shadow: 0 0 5px var(--green-bright); }
.stage.passed .stage-name { color: var(--text); }
.stage.watching .stage-dot { background: var(--amber); border-color: var(--amber); }
.stage.watching .stage-name { color: var(--amber); }
.stage.pending .stage-dot { background: transparent; border-color: rgba(100,116,139,0.5); }
.stage.pending .stage-name { color: var(--text-dim); }
.stage.failed .stage-dot { background: var(--red-bright); border-color: var(--red-bright); }
.stage.failed .stage-name { color: var(--red-bright); }
.stage.skipped .stage-dot { background: transparent; border-color: rgba(100,116,139,0.3); border-style: dashed; }
.stage.skipped .stage-name { color: var(--text-faint); text-decoration: line-through; }

/* bias text helpers */
.bull { color: var(--green-bright); font-weight: 700; }
.bear { color: var(--red-bright); font-weight: 700; }

/* ─────────────────────────────────────────────────────────────────────────
   Shared widgets that the legacy stack (components.css / styles.css) styles but
   the console base intentionally does NOT load: the site footer + the broker-
   connection dialogs. Restyled here in the console design language. (2026-06-10)
   ───────────────────────────────────────────────────────────────────────── */

/* "How this bot works" explainer card — shared across strategy pages
   (channels, pullback, …). Same shape as gex-flip's amber info card but
   blue-tinted for subscribable/scanner bots. */
.bot-info-card {
  background: rgba(63,123,255,0.06);
  border: 1px solid rgba(63,123,255,0.22);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}
.bot-info-card p { margin: 0 0 7px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.bot-info-card p:last-child { margin-bottom: 0; }
.bot-info-card strong { color: var(--blue); }
.bot-info-card .kbd {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  background: rgba(148,163,184,0.10); border: 1px solid var(--border-faint);
  border-radius: 5px; padding: 1px 5px; white-space: nowrap;
}

/* Site footer — margin-top:auto pins it to the viewport bottom on short
   pages (body is a flex column); on long pages it follows the content. */
.site-footer {
  margin-top: auto;
  padding: 22px 28px;
  border-top: 1px solid var(--border-faint);
}
.site-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-footer-copy { font-size: 12px; color: var(--text-dim); }
.site-footer-links { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.site-footer-links a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s ease;
}
.site-footer-links a:hover { color: var(--text); }
.site-footer-disclaimer {
  max-width: 1240px;
  margin: 12px auto 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-dim);
}
.site-footer-disclaimer a { color: var(--text-muted); text-decoration: none; }
.site-footer-disclaimer a:hover { color: var(--text); }

/* Broker-connection dialogs */
dialog#connectionsDialog,
dialog#addConnectionDialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, .7);
}
dialog#connectionsDialog::backdrop,
dialog#addConnectionDialog::backdrop {
  background: rgba(3, 5, 15, .66);
  backdrop-filter: blur(2px);
}
dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-faint);
}
dialog .dialog-header h2,
dialog .dialog-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
dialog .close-btn {
  appearance: none;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card-2);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
}
dialog .close-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(63, 123, 255, .14);
}

/* Dialog body section padding */
#connectionsList { padding: 14px 22px 4px; }
dialog#connectionsDialog #addConnectionBtn { margin: 8px 22px 22px; }
#adapterPicker, #tradierForm, #ibkrForm { padding: 16px 22px 22px; }

/* .btn-primary alias — markup uses `.btn.btn-primary`; console core defines `.btn.primary` */
.btn.btn-primary, .btn-primary {
  background: linear-gradient(180deg, #3f7bff, #2f63e0);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px -4px rgba(63, 123, 255, .5);
}
.btn.btn-primary:hover:not(:disabled), .btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  color: #fff;
}

/* Connection rows (rendered by connections.js) */
.connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-faint);
}
.connection-row:last-of-type { border-bottom: 0; }
.connection-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.connection-info strong { font-size: 13.5px; font-weight: 600; color: var(--text); }
.connection-info small { font-size: 11.5px; color: var(--text-dim); }
.connection-row.status-error .connection-info strong { color: var(--red-bright); }
.connection-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.connection-actions button {
  appearance: none;
  height: 32px;
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.connection-actions button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(63, 123, 255, .14);
}
.connection-actions button:disabled { opacity: .5; cursor: not-allowed; }

/* Add-connection adapter cards + provider forms */
.adapter-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card-2);
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
}
.adapter-card:hover { border-color: var(--border-strong); background: rgba(63, 123, 255, .10); }
.adapter-card h3 { margin: 0 0 4px; font-size: 14px; }
.adapter-card p { margin: 0; font-size: 12px; color: var(--text-dim); }
.dialog-hint { font-size: 12px; color: var(--text-dim); margin: 0 0 14px; }
.dialog-hint a { color: var(--blue); }
.tradier-form label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.tradier-form input[type=text],
.tradier-form input[type=password],
.tradier-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tradier-form input:focus, .tradier-form textarea:focus { outline: none; border-color: var(--blue-2); }
.tradier-form details { margin-bottom: 12px; }
.tradier-form summary { font-size: 12px; color: var(--text-muted); cursor: pointer; }
.tradier-form-actions { display: flex; gap: 10px; margin-top: 6px; }
.tradier-form-result { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
