/* ==========================================================================
   Beast Trading Bot — Ted Capital Design System
   "Bloomberg meets Linear" — data-dense, operator-grade, numbers first.
   ========================================================================== */

/* ---------- Design Tokens ---------- */

:root {
  --sans: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --bg: #f0f2f5;
  --white: #ffffff;
  --text: #111827;
  --text2: #6b7280;
  --text3: #9ca3af;
  --border: rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.06);
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --radius: 16px;
  --radius-sm: 10px;
}

/* ---------- Reset / Base ---------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Sidebar (72px fixed, icon-only) ---------- */

.sidenav {
  position: fixed;
  top: 0;
  left: 0;
  width: 72px;
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 12px;
  z-index: 50;
}

.nav-logo {
  width: 36px;
  height: 36px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-logo svg {
  width: 100%;
  height: 100%;
}

.nav-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text3);
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

.nav-icon:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-icon.active {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-icon .material-symbols-outlined {
  font-size: 22px;
}

.nav-spacer {
  flex: 1;
}

.nav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

.nav-clock {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.5px;
}

/* ---------- Main Content ---------- */

.main {
  margin-left: 72px;
  padding: 24px;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar-left h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.topbar-left p {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

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

/* ---------- Page Header ---------- */

.page-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-sm {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-sm:hover {
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

/* ---------- Card Icons ---------- */

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.card-icon .material-symbols-outlined {
  font-size: 20px;
}

.ci-blue {
  background: var(--accent-light);
  color: var(--accent);
}

.ci-green {
  background: var(--green-bg);
  color: var(--green);
}

.ci-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.ci-red {
  background: var(--red-bg);
  color: var(--red);
}

.ci-gray {
  background: var(--bg);
  color: var(--text3);
}

/* ---------- KPI Values ---------- */

.kpi-val {
  font-size: 26px;
  font-weight: 600;
  font-family: var(--sans);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text2);
  margin-top: 4px;
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

.warn {
  color: var(--amber);
}

.neu {
  color: var(--text2);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-live {
  background: var(--green-bg);
  color: var(--green);
}

.badge-paused {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-error {
  background: var(--red-bg);
  color: var(--red);
}

/* ---------- Algo Status Pills ---------- */

.algo-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.algo-status-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.asp-live {
  background: var(--green-bg);
  color: var(--green);
}

.asp-live::before {
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

.asp-warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.asp-warn::before {
  background: var(--amber);
}

.asp-error {
  background: var(--red-bg);
  color: var(--red);
}

.asp-error::before {
  background: var(--red);
  animation: pulse-dot 1s infinite;
}

.asp-paused {
  background: var(--bg);
  color: var(--text3);
}

.asp-paused::before {
  background: var(--text3);
}

/* ---------- Data Table (stat-table) ---------- */

.stat-table {
  width: 100%;
  border-collapse: collapse;
}

.stat-table thead th {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.stat-table thead th:last-child {
  text-align: right;
}

.stat-table tbody td {
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.stat-table tbody tr:last-child td {
  border-bottom: none;
}

.stat-table tbody tr:hover {
  background: var(--bg);
}

.stat-table .mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}

.stat-table .right {
  text-align: right;
}

/* ---------- Mini-Stat Rows ---------- */

.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.mini-stat:last-child {
  border-bottom: none;
}

.mini-stat-lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}

.mini-stat-val {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.g { color: var(--green); }
.r { color: var(--red); }
.a { color: var(--amber); }

/* ---------- Risk Bars ---------- */

.rbar-bg {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}

.rbar-fg {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.rbar-g { background: var(--green); }
.rbar-a { background: var(--amber); }
.rbar-r { background: var(--red); }

/* ---------- Log Rows ---------- */

.log-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.log-row:last-child {
  border-bottom: none;
}

.log-time {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
  flex-shrink: 0;
  width: 48px;
}

.log-level {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.log-ok {
  background: var(--green-bg);
  color: var(--green);
}

.log-info {
  background: var(--accent-light);
  color: var(--accent);
}

.log-warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.log-error {
  background: var(--red-bg);
  color: var(--red);
}

/* ---------- Toggle Switch ---------- */

.tog {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.tog-bg {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--text3);
  transition: background 0.2s ease;
}

.tog.active .tog-bg {
  background: var(--green);
}

.tog-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

.tog.active .tog-dot {
  transform: translateX(16px);
}

/* ---------- Kill Zone / Kill Button ---------- */

.kill-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--red-bg);
  border: 1px solid rgba(220, 38, 38, 0.1);
  margin-top: 16px;
}

.kill-zone .kill-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kill-zone .kill-info strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.kill-zone .kill-info span {
  font-size: 12px;
  color: var(--text2);
}

.kill-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.kill-btn:hover {
  opacity: 0.9;
}

.kill-safe {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--green-bg);
  color: var(--green);
}

.kill-warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--amber-bg);
  color: var(--amber);
}

/* ---------- Timeframe Tabs ---------- */

.tf-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tf {
  padding: 5px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tf:hover {
  background: var(--bg);
  color: var(--text);
}

.tf.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Chart Card Header ---------- */

.chart-card-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chart-card-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

/* ---------- Algo Stats Grid ---------- */

.algo-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.algo-stat-box {
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
  text-align: center;
}

.algo-stat-box-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.algo-stat-box-val {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
}

/* ---------- Dividers ---------- */

.sdiv {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ---------- Stage Dots ---------- */

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: 1.5px solid var(--text3);
  display: inline-block;
}

.stage-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Grid System ---------- */

.grid {
  display: grid;
  gap: 20px;
}

.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.cols-21 {
  grid-template-columns: 2fr 1fr;
}

.cols-12 {
  grid-template-columns: 1fr 2fr;
}

/* ---------- Source Indicators ---------- */

.source-env {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  cursor: default;
}

.source-env::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--text3);
  background: transparent;
}

.source-db {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}

.source-db::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.source-db:hover {
  opacity: 0.7;
}

/* ---------- Login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

.login-card .login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-card .login-logo svg {
  width: 32px;
  height: 32px;
}

.login-card .login-logo span {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.login-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.login-card p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 24px;
}

.login-field {
  margin-bottom: 14px;
}

.login-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-input::placeholder {
  color: var(--text3);
}

.login-btn {
  width: 100%;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--white);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-top: 6px;
}

.login-btn:hover {
  background: #1d4ed8;
}

.login-btn:active {
  background: #1e40af;
}

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

.login-error {
  display: none;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}

.login-error.visible {
  display: block;
}

.login-secured {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text3);
}

.login-secured .material-symbols-outlined {
  font-size: 14px;
}

/* ---------- Animations ---------- */

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

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.fade-up {
  animation: fadeUp 0.35s ease both;
}

.stagger-1 { animation-delay: 0.03s; }
.stagger-2 { animation-delay: 0.06s; }
.stagger-3 { animation-delay: 0.09s; }
.stagger-4 { animation-delay: 0.12s; }
.stagger-5 { animation-delay: 0.15s; }
.stagger-6 { animation-delay: 0.18s; }
.stagger-7 { animation-delay: 0.21s; }
.stagger-8 { animation-delay: 0.24s; }

/* ---------- Notification Toast ---------- */

.notification-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  animation: fadeUp 0.25s ease;
}

.notification-toast.success {
  border-left: 3px solid var(--green);
}

.notification-toast.success .material-symbols-outlined {
  color: var(--green);
}

.notification-toast.error {
  border-left: 3px solid var(--red);
}

.notification-toast.error .material-symbols-outlined {
  color: var(--red);
}

.notification-toast.info {
  border-left: 3px solid var(--accent);
}

.notification-toast.info .material-symbols-outlined {
  color: var(--accent);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .algo-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .sidenav {
    display: none;
  }

  .main {
    margin-left: 0;
  }

  .cols-4,
  .cols-3,
  .cols-2,
  .cols-21,
  .cols-12 {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .algo-stats-grid {
    grid-template-columns: 1fr;
  }

  .kill-zone {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}
