/* ── Reset & Variables ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --surface: #16213e;
  --surface2: #1a1a2e;
  --border: #2a2a4a;
  --accent: #4a9eff;
  --accent-dim: #2a5a99;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --red: #e74c3c;
  --text: #e0e0f0;
  --text-dim: #8888aa;
  --sidebar-w: 220px;
  --bottom-nav-h: 60px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
}

.logo-text { font-weight: 700; font-size: 16px; }

.status-dot { font-size: 10px; margin-left: auto; }
.status-dot.running { color: var(--green); }
.status-dot.paused  { color: var(--red); }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links a {
  display: block;
  padding: 10px 20px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover  { background: var(--surface); color: var(--text); }
.nav-links a.active { background: var(--surface); color: var(--accent); border-left: 3px solid var(--accent); }

.bot-controls { padding: 16px 20px; }

/* ── Bottom Nav (mobile) ─────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}
.bottom-nav a {
  font-size: 22px;
  text-decoration: none;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.bottom-nav a.active { background: var(--surface); }

/* ── Main Content ────────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  padding: 28px;
  flex: 1;
  max-width: 1100px;
}

h1 { font-size: 22px; margin-bottom: 20px; }
h2 { font-size: 16px; color: var(--text-dim); margin-bottom: 12px; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-value.green { color: var(--green); }
.stat-value.accent { color: var(--accent); }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.03); }

/* ── Event Log ───────────────────────────────────────────────────── */
.event-list { display: flex; flex-direction: column; gap: 8px; }
.event-item {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface2);
  font-size: 13px;
  align-items: flex-start;
}
.event-date { color: var(--text-dim); white-space: nowrap; min-width: 42px; font-variant-numeric: tabular-nums; }
.event-time { color: var(--text-dim); white-space: nowrap; min-width: 40px; font-variant-numeric: tabular-nums; }
.event-badge {
  padding: 2px 8px; border-radius: 4px; font-size: 11px;
  font-weight: 600; white-space: nowrap;
}
.badge-compound    { background: #1a3a2a; color: var(--green); }
.badge-snap_trade  { background: #2a2a1a; color: var(--yellow); }
.badge-claim       { background: #1a2a3a; color: var(--accent); }
.badge-error       { background: #3a1a1a; color: var(--red); }
.badge-info        { background: #2a2a2a; color: var(--text-dim); }

/* ── Form ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="password"] { font-family: monospace; }

/* ── Buttons ─────────────────────────────────────────────────────── */
button, .btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a8eef; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-ghost   { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }

#btn-pause { width: 100%; background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
#btn-pause:hover { background: var(--border); }

/* ── Loan Card ───────────────────────────────────────────────────── */
.loan-card { padding: 16px 20px; }
.loan-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.loan-amount { font-size: 20px; font-weight: 700; }
.loan-rate { font-size: 14px; color: var(--green); }
.loan-meta { display: flex; gap: 20px; font-size: 13px; color: var(--text-dim); }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 12px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── Chart ───────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }

/* ── Market Tiles ────────────────────────────────────────────────── */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.market-tile { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.market-tile .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
.market-tile .value { font-size: 20px; font-weight: 700; margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar    { display: none; }
  .bottom-nav { display: flex; }
  .content    { margin-left: 0; padding: 16px; padding-bottom: calc(var(--bottom-nav-h) + 16px); }
  .card-grid  { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
}

@media (max-width: 400px) {
  .card-grid { grid-template-columns: 1fr; }
}
