/* ── Tokens ──────────────────────────────────────────────────────────────── */

:root { color-scheme: dark; }

.blue {
  --bg-main: #0b1220;
  --bg-panel: #111a2e;
  --bg-panel-2: #16223a;
  --border: #263554;

  --text-main: #e8edf5;
  --text-muted: var(--silver);

  --accent-deep: #0d1b3e;
  --accent-mid:  #2a4f8a;
  --accent-main: #4c8dff;

  --gold: #c9a84c;
  --gold-soft: color-mix(in srgb, #c9a84c 65%, var(--bg-main) 35%);
  --silver: #a8b4c0;

  --profit: #2fbe7f;
  --deficit: #d95c5c;

  --status-ok:   #1a9e8a;
  --status-warn: #d6a34a;
  --status-err:  #d95c5c;

  --surface-1: var(--bg-panel);
  --surface-2: var(--bg-panel-2);
  --text-1: var(--text-main);
  --text-2: var(--text-muted);
  --interactive: var(--accent-main);
  --interactive-hover: color-mix(in srgb, var(--accent-main) 78%, #ffffff 22%);
  --focus-ring: var(--accent-main);
}

/* ── Reset / Base ────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--accent-mid) #0b1220; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0b1220; border-radius: 999px; }
::-webkit-scrollbar-thumb { background: var(--accent-mid); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--silver); }
body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #14203a 0%, var(--bg-main) 55%);
  color: var(--text-1);
}
a { color: var(--interactive); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.shell { max-width: 1100px; margin: 0 auto; padding: 24px; min-height: 100vh; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-sm { max-width: 560px; }
.home-grid { grid-template-columns: repeat(2, 1fr); }

/* ── Nav ─────────────────────────────────────────────────────────────────── */

.nav { display: flex; margin-bottom: 24px; align-items: center; }
.nav > a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.nav > a:hover { color: var(--interactive-hover); }
.nav-brand { color: var(--gold) !important; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.nav-brand:hover { color: var(--gold-soft) !important; }
.nav-links { flex: 1; display: flex; justify-content: center; gap: 48px; }
.nav-links a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.nav-links a:hover { color: var(--interactive-hover); }
.nav-avatar { position: relative; }
.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-deep);
  color: var(--gold);
  border: 1px solid var(--gold);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius 150ms ease, background 150ms ease, color 150ms ease, width 150ms ease;
}
.nav-avatar:hover .avatar-btn,
.nav-avatar:focus-within .avatar-btn {
  border-radius: 8px 8px 0 0;
  background: var(--surface-1);
  color: var(--text-1);
  width: 160px;
  border: 1px solid var(--border);
  border-top-color: color-mix(in srgb, var(--gold) 22%, var(--border) 78%);
  border-bottom: none;
  position: relative;
  z-index: 101;
  margin-bottom: -1px;
}
.nav-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  padding: 8px 6px 6px;
  width: 160px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  flex-direction: column;
  gap: 2px;
}
.nav-avatar:hover .nav-dropdown,
.nav-avatar:focus-within .nav-dropdown { display: flex; }
.nav-dropdown::before {
  content: "";
  display: block;
  height: 1px;
  background: var(--border);
  margin: 0 10px 4px;
}
.nav-dropdown a,
.nav-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-1);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.nav-dropdown a:hover,
.nav-dropdown button:hover { background: var(--surface-2); }
.nav-dropdown form { margin: 0; }
.nav-dropdown-dashboard { display: none; }

/* ── Panel ───────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top-color: color-mix(in srgb, var(--gold) 22%, var(--border) 78%);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 16px 36px rgba(3, 8, 18, 0.38);
}
.panel h3 { border-left: 2px solid var(--gold); padding-left: 8px; color: var(--silver); font-weight: 500; }
.panel-narrow { max-width: 480px; margin: 0 auto; }
.panel-mt { margin-top: 16px; }
.panel-empty { text-align: center; padding: 64px 24px; }
.panel-empty > div { max-width: 380px; margin: 0 auto; }
.panel-empty h2 { margin: 0 0 10px; }
.panel-empty p { margin: 0 0 28px; }
.panel-empty .btn { padding: 10px 28px; }

/* ── Typography ──────────────────────────────────────────────────────────── */

h1, h2, h3 { margin-top: 0; margin-bottom: 12px; }
.muted { color: var(--text-2); }
.error { color: var(--deficit); font-weight: 600; }
.nowrap { white-space: nowrap; }
.kpi { font-size: 26px; font-weight: 800; margin: 4px 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-mid), var(--accent-main));
  color: var(--text-1);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.btn:hover { transform: translateY(-1px); filter: saturate(1.08); }
.btn-danger { background: linear-gradient(135deg, #7a1f1f, var(--deficit)); }
.btn-secondary { background: linear-gradient(135deg, var(--accent-deep), var(--accent-mid)); border: 0; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-shrink: 0; }
.btn-group .btn { min-width: 74px; text-align: center; }

/* ── Pills / Status ──────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
}
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.side-buy  { color: var(--profit); font-weight: 700; }
.side-sell { color: var(--deficit); font-weight: 700; }
.pill-err {
  background: color-mix(in srgb, var(--status-err) 18%, transparent);
  color: var(--status-err);
  border: 1px solid color-mix(in srgb, var(--status-err) 42%, transparent);
}
.pill-neutral {
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  color: var(--text-muted);
  border: 1px solid color-mix(in srgb, var(--text-muted) 30%, transparent);
}
.pill-ok {
  background: color-mix(in srgb, var(--status-ok) 18%, transparent);
  color: var(--status-ok);
  border: 1px solid color-mix(in srgb, var(--status-ok) 42%, transparent);
}
.pill-warn {
  background: color-mix(in srgb, var(--status-warn) 18%, transparent);
  color: var(--status-warn);
  border: 1px solid color-mix(in srgb, var(--status-warn) 42%, transparent);
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-list > span { display: inline-flex; gap: 4px; align-items: center; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

label { font-size: 13px; color: var(--text-2); font-weight: 600; }
input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px;
  font-size: 15px;
  background: var(--surface-2);
  color: var(--text-1);
}
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px;
  font-size: 15px;
  background: var(--surface-2);
  color: var(--text-1);
}
#bot_name {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 6px 4px;
}
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.label-row { display: flex; align-items: center; gap: 6px; }
.input-currency { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.input-currency span { padding: 0 10px; color: var(--text-2); font-size: 15px; font-weight: 600; }
.input-currency input { border: 0; background: transparent; border-radius: 0; padding-left: 0; width: 100%; }
.help-btn {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 0 1px 0;
  line-height: 1;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.help-btn:hover { background: var(--bg-panel-2); color: var(--text-1); border-color: var(--interactive-hover); }
.help-btn-active { background: var(--interactive); color: var(--text-1); border-color: var(--interactive); }
.help-btn-active:hover { background: var(--interactive-hover); border-color: var(--interactive-hover); }
.help-body {
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  border-left: 2px solid var(--border);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 12px;
}
.help-list { margin: 6px 0 8px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.footnotes {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
}
.footnote { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.footnote-warn { color: var(--status-warn); }
.form-inline { display: inline; }
.feature-list { padding-left: 1.2em; margin: 16px 0; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; }
.table-scroll-capped { max-height: 123px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); text-align: left; padding: 10px 8px; font-size: 14px; }
th { color: var(--text-1); font-weight: 600; }
tr:hover td { background: color-mix(in srgb, var(--surface-2) 65%, transparent); }
.td-right { text-align: right; }
.mt-sm { margin-top: 12px; }

/* ── Mode switch ─────────────────────────────────────────────────────────── */

.mode-switch { display: inline-flex; gap: 8px; align-items: center; }
.mode-pill {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 700;
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
}
.mode-pill-active {
  color: var(--text-1);
  border-color: color-mix(in srgb, var(--interactive) 70%, var(--border) 30%);
  background: color-mix(in srgb, var(--interactive) 26%, transparent);
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; align-items: center; row-gap: 10px; }
.dash-nav-head { display: flex; align-items: center; gap: 8px; }
.dash-nav-head h1 { margin: 0; }
.bot-card-trigger { display: flex; align-items: center; gap: 10px; cursor: pointer; font: inherit; background: none; border: none; padding: 0; justify-self: end; }
.bot-card-trigger .chevron { transition: transform 200ms ease; }
.bot-card-identity { justify-self: end; font-size: 14px; }
.dash-cols .btn-group { display: none; grid-column: 2; justify-self: end; }
.dash-cols.controls-open .btn-group { display: flex; }
.dash-cols.controls-open .chevron { transform: rotate(180deg); }
.dash-cols .mode-switch { align-self: center; }
.dash-bot-select { margin: 0; max-width: 195px; }
#dashboard-controls-help { margin-top: 16px; }
.dash-section { margin-top: 16px; }

/* ── Metrics ─────────────────────────────────────────────────────────────── */

.recalibrating { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--text-muted); border-top-color: var(--accent, #4f8ef7); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.metric-list { margin: 0; display: grid; gap: 10px; }
.metric-list div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.metric-list dt { margin: 0; color: var(--text-2); font-weight: 600; }
.metric-list dd { margin: 0; font-weight: 700; text-align: right; }

/* ── Dialog ──────────────────────────────────────────────────────────────── */

dialog {
  border: none;
  border-radius: 8px;
  padding: 28px 24px;
  max-width: 380px;
  background: var(--surface-1);
  color: var(--text-1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog p { margin: 0 0 20px; font-weight: 500; }

/* ── Nav login ───────────────────────────────────────────────────────────── */

.nav-login { margin-left: auto; }

/* ── Home ────────────────────────────────────────────────────────────────── */

.home-hero { text-align: center; padding: 64px 24px 48px; }
.home-hero-title { font-size: 42px; font-weight: 800; margin-bottom: 16px; line-height: 1.15; }
.home-accent { color: var(--gold); }
.home-hero-sub { font-size: 18px; color: var(--text-2); max-width: 540px; margin: 0 auto 32px; line-height: 1.6; }
.home-media-row { margin-top: 24px; }
.home-placeholder { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; display: flex; align-items: center; justify-content: center; height: 320px; color: var(--text-2); font-size: 15px; font-weight: 600; }
.home-placeholder-video { height: 420px; }

/* ── Dev ─────────────────────────────────────────────────────────────────── */

.dev-bar { position: fixed; bottom: 16px; right: 16px; z-index: 9999; font-size: 0.8em; opacity: 0.5; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.dev-bar a { color: var(--text-2); }

/* ── Narrow (≤ 550px) ───────────────────────────────────────────────────── */

@media (max-width: 550px) {
  .nav-links { gap: 16px; }
  .home-grid { grid-template-columns: 1fr; }
}

/* ── Mobile (≤ 490px) ────────────────────────────────────────────────────── */

@media (max-width: 490px) {
  .nav-links a[href="/dashboard"] { display: none; }
  .nav-dropdown-dashboard { display: block; }
  .bot-card-identity { grid-column: 1 / -1; justify-self: start; }
  .bot-card-trigger .pill { background: none; border: none; padding: 0; font-size: inherit; }
  .status-label { display: none; }
  .dash-cols .btn-group { grid-column: 1 / -1; justify-self: center; }
}
