/* ─────────────────────────────────────────────
   Crypto Trading Bot Dashboard — Tema Escuro
   ───────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #18181b;
  --bg-surface: #1c1c1f;
  --bg-elevated: #27272a;
  --border: #3f3f46;
  --text-primary: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --ok: #10b981;
  --ok-bg: #064e3b;
  --warn: #f59e0b;
  --warn-bg: #78350f;
  --down: #ef4444;
  --down-bg: #7f1d1d;
  --kill-red: #dc2626;
  --start-green: #16a34a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ─── Header ──────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  font-size: 1.5rem;
  color: var(--accent);
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-username {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ─── Main ────────────────────────────────── */

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* ─── Cards ───────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-elevated);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card h3 {
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.875rem;
}

/* ─── Kill-switch ─────────────────────────── */

.killswitch-card {
  border-color: var(--down-bg);
  background: #1a0a0a;
}

.killswitch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.killswitch-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.killswitch-btns {
  display: flex;
  gap: 0.75rem;
}

/* ─── Buttons ─────────────────────────────── */

.btn {
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: #111;
}

.btn-logout {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}

.btn-full {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
}

.btn-kill {
  background: var(--kill-red);
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.btn-start {
  background: var(--start-green);
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}

.btn-start:hover {
  opacity: 0.85;
}

/* ─── Status pills ────────────────────────── */

.status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok);
}

.status-down {
  background: var(--down-bg);
  color: var(--down);
  border: 1px solid var(--down);
}

.status-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn);
}

.status-ts {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}

/* ─── DB stats ────────────────────────────── */

.db-grid {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.db-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.db-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.db-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ─── Scraper grid ────────────────────────── */

.scraper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
}

.scraper-badge {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scraper-badge.ok {
  background: var(--ok-bg);
  border-left: 3px solid var(--ok);
}

.scraper-badge.down {
  background: var(--down-bg);
  border-left: 3px solid var(--down);
}

.scraper-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scraper-count {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: 0.5rem;
  white-space: nowrap;
}

/* ─── Audit log ───────────────────────────── */

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.audit-entry {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--bg-elevated);
}

.audit-entry:last-child {
  border-bottom: none;
}

.audit-ts {
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 150px;
}

.audit-info   { color: var(--text-primary); }
.audit-warn   { color: var(--warn); }
.audit-error  { color: var(--down); }
.audit-critical { color: var(--down); font-weight: 700; }

/* ─── Balance grid ────────────────────────── */

.balance-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.balance-item {
  display: grid;
  grid-template-columns: 120px 80px 1fr;
  gap: 1rem;
  font-size: 0.85rem;
}

.balance-exchange {
  color: var(--accent);
  font-weight: 600;
}

.balance-asset {
  color: var(--text-muted);
}

.balance-amount {
  font-variant-numeric: tabular-nums;
}

/* ─── Form / Login ────────────────────────── */

.form-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.form-card-wide {
  max-width: 560px;
}

.form-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.form-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.field input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--accent);
}

.field input::placeholder {
  color: #52525b;
}

.error {
  color: #fb7185;
  background: #450a0a;
  border: 1px solid var(--down-bg);
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.form-back {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── QR Code (2FA setup) ─────────────────── */

.qr-section {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.qr-img-wrap {
  flex-shrink: 0;
}

.qr-img {
  display: block;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #18181b;
}

.qr-manual {
  flex: 1;
  min-width: 200px;
}

.qr-label,
.qr-uri-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
}

.qr-label:first-child,
.qr-uri-label:first-child {
  margin-top: 0;
}

.secret-box {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: 'Menlo', 'Consolas', monospace;
  letter-spacing: 0.05em;
  color: var(--accent);
  word-break: break-all;
}

.uri-box {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  font-family: 'Menlo', 'Consolas', monospace;
  color: var(--text-muted);
  word-break: break-all;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ─── Misc ────────────────────────────────── */

.loading-msg {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

.empty-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ─── Responsive ──────────────────────────── */

@media (max-width: 640px) {
  .main { padding: 1rem; }
  .header { padding: 0.75rem 1rem; }
  .killswitch-row { flex-direction: column; align-items: flex-start; }
  .db-grid { gap: 1rem; }
  .qr-section { flex-direction: column; }
  .status-ts { margin-left: 0; }
}
