:root {
  --bg: #070b14;
  --surface: #0d1320;
  --surface-2: #121a2b;
  --surface-3: #182338;
  --border: #1e2b45;
  --border-strong: #2b3d61;
  --text: #edf2fa;
  --text-muted: #93a4c3;
  --text-dim: #64748b;

  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.35);

  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --rose-border: rgba(244, 63, 94, 0.35);

  --cyan: #22d3ee;
  --cyan-bg: rgba(34, 211, 238, 0.12);
  --cyan-border: rgba(34, 211, 238, 0.35);

  --violet: #a78bfa;
  --violet-bg: rgba(167, 139, 250, 0.13);
  --violet-border: rgba(167, 139, 250, 0.38);

  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.13);
  --amber-border: rgba(245, 158, 11, 0.38);

  --blue: #3b82f6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 360px;
  animation: fadeSlideUp 0.2s ease;
}

.toast.ok { border-color: var(--emerald-border); }
.toast.err { border-color: var(--rose-border); }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Buttons & Inputs ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 9px;
  padding: 9px 15px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }

.btn-outline {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--cyan);
  background: var(--surface-3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.btn-emerald {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: #34d399;
}
.btn-emerald:hover { background: rgba(16, 185, 129, 0.22); }

.btn-rose {
  background: var(--rose-bg);
  border-color: var(--rose-border);
  color: #fb7185;
}
.btn-rose:hover { background: rgba(244, 63, 94, 0.22); }

.btn-amber {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: #fbbf24;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-icon:hover { color: var(--text); }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.field input, .input-select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .input-select:focus {
  border-color: var(--cyan);
}
.input-select {
  padding: 7px 12px;
  cursor: pointer;
}
.input-select.full { width: 100%; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ---- Auth Screen ---- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-bg-glow {
  position: absolute;
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.12) 0%, rgba(59, 130, 246, 0.06) 40%, transparent 72%);
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-switch {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--surface-3);
  color: var(--cyan);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #22d3ee, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #04101d;
  flex-shrink: 0;
}
.brand-logo.sm { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }

.brand-title { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.brand-title.sm { font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12.5px; color: var(--text-muted); }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.auth-tab.active {
  background: var(--surface-3);
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}

.auth-footer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}

.alert {
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.alert.err { background: var(--rose-bg); border-color: var(--rose-border); color: #fda4af; }
.alert.warn { background: var(--amber-bg); border-color: var(--amber-border); color: #fcd34d; }
.alert.ok { background: var(--emerald-bg); border-color: var(--emerald-border); color: #6ee7b7; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 11, 20, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1420px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand-compact {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-pill-row {
  display: flex;
  gap: 5px;
  margin-top: 2px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.nav-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav-tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.badge-count {
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--cyan);
}
.user-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ---- Main Layout ---- */
.main-container {
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px 22px 48px;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Pills & Badges ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-emerald { background: var(--emerald-bg); color: #34d399; border-color: var(--emerald-border); }
.pill-rose { background: var(--rose-bg); color: #fb7185; border-color: var(--rose-border); }
.pill-cyan { background: var(--cyan-bg); color: #22d3ee; border-color: var(--cyan-border); }
.pill-violet { background: var(--violet-bg); color: #c4b5fd; border-color: var(--violet-border); }
.pill-amber { background: var(--amber-bg); color: #fbbf24; border-color: var(--amber-border); }
.pill-muted { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }

.mono-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--text-muted);
}

/* ---- Legend Panel ---- */
.legend-panel {
  background: linear-gradient(180deg, rgba(18, 26, 43, 0.98), rgba(13, 19, 32, 0.98));
  border: 1px solid var(--cyan-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.legend-header h3 { margin: 0; font-size: 15px; }
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.legend-item {
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.legend-item p {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.legend-item strong { color: var(--text); }

/* ---- Hero Regime Banner ---- */
.hero-card {
  background: linear-gradient(135deg, #0f172a 0%, #111c33 55%, #0d1628 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.regime-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.regime-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.regime-scores {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.score-chip {
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
}
.score-chip span { font-size: 11px; color: var(--text-muted); }
.score-chip strong { font-size: 15px; font-family: 'JetBrains Mono', monospace; }

.hero-summary {
  margin: 0;
  font-size: 13.5px;
  color: #dbe6f7;
  line-height: 1.6;
}

.hero-leaders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.leader-box {
  background: rgba(7, 11, 20, 0.5);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
}
.leader-box strong { display: block; margin-bottom: 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.filter-pill:hover { border-color: var(--border-strong); color: var(--text); }
.filter-pill.active {
  background: var(--surface-3);
  border-color: var(--cyan);
  color: var(--text);
}
.filter-pill.track-mt5.active { background: var(--cyan-bg); border-color: var(--cyan); color: #67e8f9; }
.filter-pill.track-cash.active { background: var(--violet-bg); border-color: var(--violet); color: #ddd6fe; }

.pill-cnt {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

.filter-meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---- Section Headers & Cards ---- */
.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.block-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}
.dot-emerald { background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }
.dot-rose { background: var(--rose); box-shadow: 0 0 10px var(--rose); }
.dot-amber { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.dot-muted { background: var(--text-dim); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}
.cards-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  transition: border-color 0.15s, transform 0.15s;
}
.setup-card:hover {
  border-color: var(--border-strong);
}
.setup-card.buy { border-top: 3px solid var(--emerald); }
.setup-card.sell { border-top: 3px solid var(--rose); }
.setup-card.watch { border-top: 3px solid var(--amber); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ticker-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ticker-symbol {
  font-size: 20px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.02em;
}
.company-name {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.price-block {
  text-align: right;
  flex-shrink: 0;
}
.price-main {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}
.price-chg {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.level-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 9px;
}
.level-box span {
  display: block;
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}
.level-box strong {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  margin-top: 2px;
}
.level-box small {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
}

.debate-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.debate-item {
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}
.debate-item.bull { border-left: 3px solid var(--emerald); }
.debate-item.bear { border-left: 3px solid var(--rose); }
.debate-item.thesis { border-left: 3px solid var(--cyan); }
.debate-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
  display: block;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.sec-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
}
.sec-link {
  color: var(--cyan);
  text-decoration: none;
  background: var(--cyan-bg);
  border: 1px solid var(--cyan-border);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.sec-link:hover { filter: brightness(1.15); }

/* ---- Veto Grid ---- */
.veto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
}
.veto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rose);
  border-radius: 11px;
  padding: 13px 15px;
}
.veto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.veto-reason {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- Panels & Grids ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-header.wrap { flex-wrap: wrap; }
.panel-header h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.panel-sub { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }

.two-col-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}
.two-col-grid.equal { grid-template-columns: 1fr 1fr; }
.two-col-grid.admin-layout { grid-template-columns: 1.7fr 1fr; align-items: start; }
.stack-col { display: flex; flex-direction: column; gap: 16px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }

.chart-box {
  position: relative;
  height: 290px;
  width: 100%;
}
.chart-box.tall { height: 320px; }

/* ---- Metals & Status ---- */
.metals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
}
.metal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.metal-price { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; }
.metal-sub { font-size: 11.5px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
}
.status-key {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  min-width: 96px;
  color: var(--text-muted);
}

/* ---- KPI Grids ---- */
.track-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.track-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.track-kpi-card.mt5 { border-top: 3px solid var(--cyan); }
.track-kpi-card.cash { border-top: 3px solid var(--violet); }
.track-kpi-card.all { border-top: 3px solid var(--blue); }

.kpi-big {
  font-size: 28px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.03em;
}

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kpi-mini {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.kpi-mini span { display: block; font-size: 10.5px; color: var(--text-dim); }
.kpi-mini strong { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }

.kpi-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi-card .k-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.kpi-card .k-val { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; margin-top: 4px; }
.kpi-card .k-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }

/* ---- Tables ---- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 700;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(30, 43, 69, 0.55);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.compact-table td, .compact-table th {
  padding: 7px 8px;
  font-size: 12px;
}

/* ---- SL -> TP Progress Bar ---- */
.range-bar-wrap {
  min-width: 140px;
}
.range-bar-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.45) 0%, rgba(148, 163, 184, 0.25) 33%, rgba(16, 185, 129, 0.48) 100%);
  border: 1px solid var(--border);
}
.range-bar-entry {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 33.3%;
  width: 2px;
  background: rgba(255, 255, 255, 0.5);
}
.range-bar-dot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid #070b14;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}
.range-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ---- Audit Hero & Stage 4 Gauge ---- */
.audit-hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.stage4-bar {
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.stage4-fill {
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #10b981);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.compare-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 13px;
}
.compare-card h4 { margin: 0 0 10px; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }

.funnel-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ---- Color helpers ---- */
.pos { color: #34d399; }
.neg { color: #fb7185; }
.muted { color: var(--text-muted); }
.empty-box {
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- Footer ---- */
.app-footer {
  max-width: 1420px;
  margin: 0 auto;
  padding: 18px 22px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- Responsive ---- */
@media (max-width: 1060px) {
  .two-col-grid, .two-col-grid.equal, .two-col-grid.admin-layout, .audit-hero-grid {
    grid-template-columns: 1fr;
  }
  .track-kpi-grid { grid-template-columns: 1fr; }
  .kpi-row-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .cards-grid, .cards-grid.compact { grid-template-columns: 1fr; }
  .levels-grid { grid-template-columns: repeat(2, 1fr); }
  .compare-grid, .metals-grid { grid-template-columns: 1fr; }
  .kpi-row-4 { grid-template-columns: 1fr; }
}
