/* ──────────────────────────────────────────────────────────
   TRQ Bot Trading — design system
   Inspired by Linear / Vercel, dark by default
   ────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg-0:        #06080d;   /* page bg */
  --bg-1:        #0c1018;   /* sidebar */
  --bg-2:        #11151f;   /* card */
  --bg-3:        #161b27;   /* card hover / nested */
  --bg-elev:     #1a2030;   /* elevated (modal) */

  /* Borders */
  --border:      rgba(148, 163, 184, 0.12);
  --border-2:    rgba(148, 163, 184, 0.20);

  /* Text */
  --text:        #e5e7eb;
  --text-2:      #cbd5e1;
  --muted:       #6b7280;
  --muted-2:     #94a3b8;

  /* Accents */
  --accent:      #38bdf8;
  --accent-2:    #22d3ee;
  --pos:         #4ade80;
  --pos-bg:      rgba(74, 222, 128, 0.12);
  --neg:         #f87171;
  --neg-bg:      rgba(248, 113, 113, 0.12);
  --warn:        #fbbf24;
  --warn-bg:     rgba(251, 191, 36, 0.12);

  /* Layout */
  --sidebar-w:   240px;
  --topbar-h:    64px;
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   14px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.3);
  --shadow:      0 4px 16px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg:   0 16px 48px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-2); }

.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 12px; }
.mono { font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.center { text-align: center; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.hidden { display: none !important; }
.pad { padding: 32px 16px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }

code {
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-2);
}

/* ─── App shell ─── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.3);
}
.brand-mark.big {
  width: 56px; height: 56px;
  font-size: 28px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub  { color: var(--muted-2); font-size: 12px; margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active {
  background: var(--bg-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-2);
}
.nav-item.active .nav-ico { filter: brightness(1.4); }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-block {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 14px;
}
.user-info { flex: 1; min-width: 0; }
.user-email {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-2);
}
.user-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.user-role.role-admin { color: var(--accent-2); font-weight: 600; }

/* ─── Main + topbar ─── */
.main { min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: rgba(6, 8, 13, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; flex-direction: column; }
.page-title { font-size: 18px; font-weight: 600; margin: 0; line-height: 1.2; }
.page-sub { margin: 2px 0 0 0; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
}
.status-dot.dot-ok   { background: var(--pos); color: var(--pos); }
.status-dot.dot-warn { background: var(--warn); color: var(--warn); }
.status-dot.dot-bad  { background: var(--neg); color: var(--neg); }
.status-label { font-size: 13px; color: var(--muted-2); font-family: "JetBrains Mono", monospace; }

.page { padding: 20px 24px 40px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s;
}
.card:hover { border-color: var(--border-2); }
.card.card-tall { min-height: 380px; display: flex; flex-direction: column; }
.card.card-tall .chart { flex: 1; min-height: 320px; }

.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2);
}
.card-head-meta { font-family: "JetBrains Mono", monospace; }

/* ─── Grid utilities ─── */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.gap-md { gap: 16px; }

/* ─── KPI tiles ─── */
.kpi { display: flex; flex-direction: column; gap: 4px; min-height: 130px; position: relative; }
.kpi-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2);
}
.kpi-value {
  font-size: 26px; font-weight: 600;
  line-height: 1.1;
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
}
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-action { margin-top: auto; padding-top: 12px; display: flex; align-items: center; gap: 10px; }

/* ─── Switch ─── */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  transition: .2s; border-radius: 12px;
}
.slider:before {
  position: absolute; content: "";
  height: 14px; width: 14px;
  left: 2px; bottom: 2px;
  background: var(--text-2);
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider { background: var(--pos-bg); border-color: var(--pos); }
input:checked + .slider:before { transform: translateX(16px); background: var(--pos); }
.switch-label { font-size: 12px; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  font-weight: 600;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  background: rgba(0,0,0,0.15);
}
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--bg-3); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Pills (status / side / mode) ─── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.pill.side-BUY  { color: var(--pos); background: var(--pos-bg); border-color: rgba(74,222,128,0.3); }
.pill.side-SELL { color: var(--neg); background: var(--neg-bg); border-color: rgba(248,113,113,0.3); }
.pill.side-HOLD { color: var(--muted-2); background: var(--bg-3); border-color: var(--border-2); }

.pill.mode-LIVE { color: var(--neg); background: var(--neg-bg); border-color: rgba(248,113,113,0.3); }
.pill.mode-DRY  { color: var(--muted-2); background: var(--bg-3); border-color: var(--border-2); }

.pill.status-CONFIRMED { color: var(--pos); background: var(--pos-bg); }
.pill.status-PENDING   { color: var(--warn); background: var(--warn-bg); }
.pill.status-FAILED    { color: var(--neg); background: var(--neg-bg); }
.pill.status-DRY_OK    { color: var(--muted-2); background: var(--bg-3); }
.pill.blocked          { color: var(--warn); background: var(--warn-bg); border-color: rgba(251,191,36,0.3); }

.pill.pill-on  { color: var(--pos); background: var(--pos-bg); border-color: rgba(74,222,128,0.3); }
.pill.pill-off { color: var(--muted); background: var(--bg-3); border-color: var(--border-2); }

/* ─── Badges (alt style) ─── */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 8px;
}
.badge-ok   { background: var(--pos-bg); color: var(--pos); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

.tx-link { color: var(--accent); font-family: "JetBrains Mono", monospace; font-size: 12px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
}
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; }
.btn-primary { background: var(--accent); color: #06141b; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--bg-elev); border-color: var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--muted-2);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-3); }

/* ─── Filters / selects ─── */
.filters { display: flex; gap: 8px; }
.select, input[type=text], input[type=email], input[type=password], textarea {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}
textarea { font-family: "JetBrains Mono", ui-monospace, monospace; resize: vertical; }

/* ─── Settings layout ─── */
.settings-list { display: flex; flex-direction: column; }
.settings-group + .settings-group { margin-top: 12px; }
.settings-group-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: 12px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label {
  font-weight: 500; font-size: 14px;
  display: flex; align-items: center;
}
.settings-row-value { font-family: "JetBrains Mono", monospace; }
.settings-row-actions { display: flex; gap: 6px; }

/* Single-column key/value grid (e.g. wallet info) */
.kv-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px;
}
.kv-key { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); margin-bottom: 4px; }
.kv-val { font-family: "JetBrains Mono", monospace; font-size: 13px; word-break: break-all; }
.kv-val a { margin-left: 6px; }

/* ─── Modal ─── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(480px, 90vw);
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; }
.modal-card .field { margin: 14px 0; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 18px;
}

/* ─── Forms ─── */
.field { display: block; }
.field-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--muted-2);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select { width: 100%; }

/* ─── Login ─── */
.login-body {
  background: var(--bg-0);
  display: grid; place-items: center;
  min-height: 100vh;
  position: relative; overflow: hidden;
}
.login-bg {
  position: fixed; inset: -50%;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(56, 189, 248, 0.15), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.10), transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.login-card {
  position: relative; z-index: 1;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: min(400px, 90vw);
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 24px; display: flex; flex-direction: column; align-items: center; }
.login-brand h1 { margin: 16px 0 4px; font-size: 20px; }
.login-brand p { margin: 0; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; }
.error-banner {
  padding: 10px 12px;
  background: var(--neg-bg);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--neg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  display: flex; gap: 8px; align-items: center;
}

/* ─── Toasts ─── */
.toast-host {
  position: fixed; top: 72px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateX(20px);
  transition: opacity .25s, transform .25s;
  min-width: 180px;
}
.toast.toast-show { opacity: 1; transform: translateX(0); }
.toast-ok    { border-left: 3px solid var(--pos); }
.toast-error { border-left: 3px solid var(--neg); }

/* ─── Link-arrow ─── */
.link-arrow {
  font-size: 12px;
  color: var(--muted-2);
  transition: color .15s, transform .15s;
}
.link-arrow:hover { color: var(--accent); }

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    height: auto; flex-direction: row;
    justify-content: space-around;
    border-right: none; border-top: 1px solid var(--border);
    z-index: 50;
  }
  .sidebar-brand, .sidebar-footer { display: none; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 6px; gap: 4px; flex: 1; justify-content: space-around; }
  .nav-item { padding: 8px 12px; flex-direction: column; gap: 2px; font-size: 11px; }
  .nav-item span:not(.nav-ico) { font-size: 10px; }
  .page { padding: 14px; padding-bottom: 80px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; height: 56px; }
}
