/* ── Trading Bot — Custom Theme ─────────────────────────────────── */
:root {
  --bg:        #0a0f1e;
  --surface:   #111827;
  --surface-2: #1a2235;
  --border:    #1e293b;
  --border-2:  #2d3f5a;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --green:     #10b981;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --yellow:    #f59e0b;
  --sidebar-w: 220px;
}

/* ── Reset / Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: #60a5fa; }

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .3px;
}
.sidebar-section { padding: 8px 0; border-bottom: 1px solid var(--border); }
.sidebar-label {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.sidebar-nav a.active {
  color: var(--blue);
  background: rgba(59,130,246,.08);
  border-left-color: var(--blue);
}
.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.sidebar-footer .username { font-weight: 600; color: var(--text); font-size: 13px; }

/* Bot status pill */
.bot-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.bot-pill.running { background: rgba(16,185,129,.15); color: var(--green); }
.bot-pill.stopped { background: rgba(100,116,139,.15); color: var(--muted); }
.bot-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bot-pill.running .dot { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Main area ────────────────────────────────────────────────── */
.main-area { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-spacer { flex: 1; }
.connection-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.connection-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.page-body { padding: 24px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
}

/* ── Stat cards ───────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-sub .up   { color: var(--green); }
.stat-sub .down { color: var(--red); }

/* ── Tables ───────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(30,41,59,.6);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.025); }
.data-table .mono { font-variant-numeric: tabular-nums; font-family: 'Fira Code', 'JetBrains Mono', monospace; }
.data-table .green { color: var(--green); }
.data-table .red   { color: var(--red); }
.data-table .muted { color: var(--muted); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-green  { background: rgba(16,185,129,.15); color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-blue   { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-gray   { background: rgba(100,116,139,.15); color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #2563eb; color: #fff; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-danger:hover  { background: #dc2626; color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--blue); }
.form-control::placeholder { color: var(--muted); }
select.form-control option { background: var(--surface-2); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Auth pages ───────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 28px; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.auth-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
}

/* ── Grid helpers ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state p { font-size: 13px; margin: 0; }

/* ── Portfolio cards ──────────────────────────────────────────── */
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.portfolio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: border-color .15s;
}
.portfolio-card:hover { border-color: var(--border-2); }
.portfolio-card-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.portfolio-card-value { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin: 12px 0 4px; }
.portfolio-card-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
