/* ==========================================================================
   RED ALGO — CLEAN WHITE INSTITUTIONAL FINANCIAL DESIGN SYSTEM
   Brand Colors: Crimson Red (#E5252A) & Deep Royal Navy (#002D62)
   Inspired by: Red Algo Official Poster (Clean White Canvas, High Contrast)
   ========================================================================== */

:root {
  /* Brand Core Tokens */
  --brand-red: #E5252A;
  --brand-red-dark: #C61B20;
  --brand-red-glow: rgba(229, 37, 42, 0.25);
  --brand-red-soft: #FEE2E2;
  
  --brand-navy: #002D62;
  --brand-navy-dark: #0A192F;
  --brand-navy-light: #004085;
  --brand-blue-accent: #0284C7;
  --brand-blue-soft: #E0F2FE;
  
  /* Canvas & Card Surfaces (Clean White Financial Theme) */
  --bg-primary: #F4F7FB;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FFFFFF;
  --border-light: #E2E8F0;
  --border-subtle: #EDF2F7;
  --border-highlight: #CBD5E1;

  /* Status Accents */
  --accent-green: #16A34A;
  --accent-green-bg: #DCFCE7;
  --accent-green-border: #86EFAC;
  --accent-red: #DC2626;
  --accent-red-bg: #FEE2E2;
  --accent-red-border: #FCA5A5;
  --accent-amber: #D97706;
  --accent-amber-bg: #FEF3C7;

  /* Typography Colors */
  --text-main: #0A192F;
  --text-muted: #334155;
  --text-dim: #64748B;
  
  /* Fonts */
  --font-heading: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 10px 30px -4px rgba(0, 45, 98, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 18px 38px -4px rgba(0, 45, 98, 0.12), 0 6px 12px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow-red: 0 8px 24px -2px var(--brand-red-glow);
}

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

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Subtle Ambient Lights for White Canvas */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}
.glow-top-left {
  width: 500px;
  height: 500px;
  top: -100px;
  left: -100px;
  background: radial-gradient(circle, var(--brand-red) 0%, rgba(229, 37, 42, 0) 70%);
}
.glow-bottom-right {
  width: 600px;
  height: 600px;
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, var(--brand-navy) 0%, rgba(0, 45, 98, 0) 70%);
}
.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(rgba(0, 45, 98, 0.02) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0, 45, 98, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* Navbar — Pure White with Crisp Border */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 2px 12px rgba(0, 45, 98, 0.04);
}
.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  transition: transform 0.2s ease;
}
.brand-logo:hover {
  transform: scale(1.02);
}
.brand-tagline-col {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-light);
  padding-left: 14px;
}
.brand-slogan {
  font-size: 0.72rem;
  letter-spacing: 1.8px;
  font-weight: 800;
  color: var(--brand-navy);
  font-family: var(--font-mono);
}
.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
  background: var(--brand-red-soft);
  color: var(--brand-red);
  border: 1px solid #FECACA;
}
.badge-tag.engine-tag {
  background: var(--brand-blue-soft);
  color: var(--brand-blue-accent);
  border-color: #BAE6FD;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.market-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
}
.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-indicator-dot.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.status-text {
  color: var(--brand-navy);
  font-weight: 700;
}
.live-clock {
  color: var(--text-dim);
  border-left: 1px solid var(--border-light);
  padding-left: 10px;
  font-weight: 600;
}
.view-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  color: var(--brand-navy);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.view-switch-btn:hover {
  background: #F8FAFC;
  border-color: var(--brand-navy);
  color: var(--brand-navy);
}
.view-switch-btn svg {
  color: var(--brand-navy);
}

/* Layout */
.main-layout {
  position: relative;
  z-index: 10;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}
.view-container {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}
.view-container.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Security Banner — Clean Pastel Card */
.security-banner {
  background: #FFFFFF;
  border: 1px solid #DCFCE7;
  border-left: 4px solid var(--accent-green);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.06);
  width: 100%;
  box-sizing: border-box;
}
.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-green-bg);
  color: var(--accent-green);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid var(--accent-green-border);
}
.security-note {
  font-size: 0.88rem;
  color: var(--text-muted);
  width: 100%;
  box-sizing: border-box;
}
.security-note strong {
  color: var(--brand-navy);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  width: 100%;
  box-sizing: border-box;
}
.grid-col-left,
.grid-col-right {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
}

/* Pure White Cards with Elevated Soft Shadows */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  overflow: hidden;
  transition: all 0.25s ease;
}
.glass-card:hover {
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-card-hover);
}
.card-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
}
.card-header.border-bottom {
  border-bottom: 1px solid var(--border-subtle);
}
.card-body {
  padding: 24px;
  background: #FFFFFF;
}
.card-body.no-padding {
  padding: 0;
}
.sub-heading {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 800;
  color: var(--brand-red);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.card-heading {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand-navy);
  letter-spacing: -0.3px;
}
.card-heading-sm {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand-navy);
}
.card-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Form Groups */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 8px;
}
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 14px;
  color: var(--brand-navy);
  pointer-events: none;
}
.form-input {
  width: 100%;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.98rem;
  padding: 13px 14px 13px 44px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s ease;
}
.form-input:focus {
  background: #FFFFFF;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px var(--brand-red-glow);
}

/* Zerodha Primary Connect Button (Poster Red Style) */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.btn-primary-zerodha {
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-glow-red);
}
.btn-primary-zerodha:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(229, 37, 42, 0.35);
  filter: brightness(1.05);
}
.btn-primary-zerodha:active {
  transform: translateY(0);
}
.btn-content {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-text {
  font-size: 1.08rem;
  letter-spacing: 0.2px;
}
.btn-subtext {
  font-size: 0.74rem;
  opacity: 0.92;
  font-weight: 500;
  margin-top: 3px;
  font-family: var(--font-body);
}

/* Guarantee row */
.auth-guarantee-row {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guarantee-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}
.guarantee-item svg {
  stroke: var(--accent-green);
}

/* Status Pills */
.auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
}
.auth-pill.disconnected {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
}
.auth-pill.connected {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-border);
}
.auth-pill.connected.sm {
  padding: 3px 10px;
  font-size: 0.72rem;
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-red);
  animation: pulse 1.6s infinite;
}
.pulse-dot.green {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Connected State Card */
.account-summary-box {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.account-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-avatar {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-navy-light) 100%);
  border: 2px solid #FFFFFF;
  box-shadow: 0 4px 12px rgba(0, 45, 98, 0.15);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-heading);
  font-size: 1.1rem;
}
.user-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-navy);
}
.user-kite-id {
  font-size: 0.82rem;
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-weight: 700;
}
.account-margin {
  text-align: right;
}
.margin-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}
.margin-val {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--brand-navy);
}

/* Settings Panel */
.settings-panel {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  margin-bottom: 20px;
}
.settings-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--brand-navy);
  font-weight: 800;
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-navy);
}
.setting-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.lot-stepper {
  display: flex;
  align-items: center;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.step-btn {
  background: none;
  border: none;
  color: var(--brand-navy);
  padding: 6px 14px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.step-btn:hover {
  background: #E2E8F0;
}
.lot-count {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 800;
  padding: 0 12px;
  color: var(--brand-navy);
}
.badge-value {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  background: #F1F5F9;
  border: 1px solid var(--border-light);
  color: var(--brand-navy);
  padding: 4px 12px;
  border-radius: 4px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #CBD5E1;
  transition: .3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider {
  background-color: var(--accent-green);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* Connected Actions */
.connected-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}
.btn-secondary-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--accent-red-border);
  color: var(--accent-red);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
}
.btn-secondary-outline:hover {
  background: var(--accent-red-bg);
}
.session-timer {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.session-timer strong {
  color: var(--brand-navy);
}

/* Strategy Metrics Grid */
.strategy-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.metric-card {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}
.metric-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 700;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--brand-navy);
}
.radar-status-bar {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}
.radar-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}
.radar-ping {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-red);
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}
.radar-text {
  font-size: 0.82rem;
  color: var(--brand-navy);
  font-weight: 700;
}

/* Tables — Crisp Light Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.algo-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.algo-table th {
  background: #F8FAFC;
  padding: 14px 18px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--brand-navy);
  border-bottom: 1px solid var(--border-light);
  font-weight: 800;
}
.algo-table td {
  padding: 15px 18px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.symbol-col strong {
  display: block;
  font-size: 0.96rem;
  color: var(--brand-navy);
}
.opt-strike {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 600;
}
.order-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
}
.order-badge.buy {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-border);
}
.pnl-summary-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-green-bg);
  border: 1px solid var(--accent-green-border);
  padding: 6px 16px;
  border-radius: 30px;
}
.pnl-label {
  font-size: 0.78rem;
  color: var(--accent-green);
  font-weight: 700;
}
.pnl-value {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.08rem;
}
.pnl-value.positive, .mono.positive {
  color: var(--accent-green);
}
.mono {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Terminal Console (Sleek Dark Box like Laptop in Poster) */
.terminal-card {
  background: #FFFFFF;
}
.terminal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}
.terminal-status {
  font-size: 0.76rem;
  color: var(--brand-navy);
  font-family: var(--font-mono);
  font-weight: 700;
}
.terminal-console {
  padding: 16px 20px;
  height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.8;
  background: #0B132B;
  color: #E2E8F0;
  border-top: 1px solid var(--border-light);
}
.log-line {
  color: #CBD5E1;
}
.log-time {
  color: #64748B;
}
.log-tag {
  color: #38BDF8;
  font-weight: 700;
}
.log-line.success .log-tag {
  color: #4ADE80;
}
.log-line.warn .log-tag {
  color: #FBBF24;
}
.log-line.highlight {
  background: rgba(229, 37, 42, 0.15);
  padding: 2px 8px;
  border-left: 3px solid var(--brand-red);
}

/* Feature Strip */
.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}
@media (max-width: 768px) {
  .feature-strip {
    grid-template-columns: 1fr;
  }
}
.feature-box {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  padding: 18px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
}
.feature-box:hover {
  border-color: var(--brand-navy);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.feature-icon {
  font-size: 1.6rem;
}
.feature-text h5 {
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--brand-navy);
}
.feature-text p {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Admin Dashboard Specific */
.admin-top-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.admin-title {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--brand-navy);
}
.admin-subtitle {
  font-size: 0.92rem;
  color: var(--text-dim);
}
.btn-danger-kill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-red-bg);
  border: 1px solid var(--accent-red-border);
  color: var(--accent-red);
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
}
.btn-danger-kill:hover {
  background: var(--accent-red);
  color: #FFF;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
.stat-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  padding: 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.stat-title {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 700;
}
.stat-number {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--brand-navy);
}
.stat-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-left: 8px;
}
.stat-sub.positive {
  color: var(--accent-green);
  font-weight: 700;
}
.action-btn-sm {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  color: var(--brand-navy);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn-sm.danger {
  border-color: var(--accent-red-border);
  color: var(--accent-red);
  background: var(--accent-red-bg);
}
.action-btn-sm.danger:hover {
  background: var(--accent-red);
  color: #FFF;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 25, 47, 0.6);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden {
  display: none;
}
.modal-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 25px 60px -10px rgba(0, 45, 98, 0.25);
  overflow: hidden;
  animation: modalScale 0.25s ease forwards;
}
@keyframes modalScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  padding: 16px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-logo {
  height: 30px;
  width: auto;
}
.arrow-exchange {
  color: var(--brand-navy);
  font-size: 1.3rem;
  font-weight: 700;
}
.zerodha-brand {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
  color: #388E3C;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  transition: color 0.2s ease;
}
.modal-close:hover {
  color: var(--brand-navy);
}
.modal-body {
  padding: 24px;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--brand-navy);
}
.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.oauth-permission-list {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}
.permission-item {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.permission-item:last-child {
  margin-bottom: 0;
}
.perm-icon {
  color: var(--accent-green);
  font-weight: 800;
  font-size: 1.1rem;
}
.perm-icon-red {
  color: var(--brand-red);
  font-weight: 800;
  font-size: 1.1rem;
}
.permission-item strong {
  display: block;
  font-size: 0.86rem;
  color: var(--brand-navy);
}
.permission-item p {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.oauth-disclaimer {
  font-size: 0.76rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 14px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 45, 98, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease forwards;
  color: var(--text-main);
  font-weight: 600;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--brand-red); }
.toast.info { border-left: 4px solid var(--brand-navy); }

.hidden {
  display: none !important;
}

/* 365-Day Subscription Verification Banner */
.sub-verification-box {
  background: var(--accent-green-bg);
  border: 1px solid var(--accent-green-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  transition: all 0.25s ease;
}
.sub-verification-box.initial {
  background: #F8FAFC;
  border-color: #E2E8F0;
}
.sub-verification-box.restricted {
  background: #FFF1F2;
  border-color: #FECDD3;
}
.sub-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sub-badge.neutral {
  color: var(--text-dim);
}
.sub-badge.restricted {
  color: var(--brand-red);
}
.lock-icon {
  font-size: 13px;
}
.empty-trades-cell {
  padding: 36px 16px !important;
  text-align: center;
  color: var(--text-dim);
  background: #FAFBFD;
}
.empty-state-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}
.radar-dot {
  width: 10px;
  height: 10px;
  background: #3B82F6;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
  animation: pulseRadar 2s infinite;
}
@keyframes pulseRadar {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
.pnl-value.neutral {
  color: var(--text-muted);
}
.btn-disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
.cross-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--brand-red);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}
.sub-days-left {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-green);
  background: #FFFFFF;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--accent-green-border);
}
.sub-details {
  font-size: 0.82rem;
  color: #1E293B;
  line-height: 1.4;
}
.sub-details.error-msg {
  color: #B91C1C;
  font-weight: 500;
}
.btn-whatsapp-sub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  background: #25D366;
  color: #FFFFFF;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
  transition: all 0.2s ease;
}
.btn-whatsapp-sub:hover {
  background: #1EBE5D;
  transform: translateY(-1px);
}

/* Master Admin 365-Day Subscriber Manager */
.admin-subscribers-card {
  margin-bottom: 24px;
}
.active-sub-count {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-border);
  font-weight: 700;
}
.add-sub-box {
  background: #F8FAFC;
  border: 1px dashed var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.add-sub-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--brand-navy);
  margin-bottom: 12px;
  font-weight: 700;
}
.form-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: flex-end;
}
.form-group-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label-sm {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.form-input-sm {
  height: 38px;
  padding: 6px 12px;
  font-size: 0.84rem;
  font-family: var(--font-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--text-main);
  outline: none;
}
.form-input-sm:focus {
  border-color: var(--brand-red);
}
.readonly-input {
  background: #F1F5F9;
  color: var(--brand-navy);
  font-weight: 600;
  cursor: not-allowed;
}
.btn-sm-action {
  height: 38px;
  padding: 0 16px;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}
.btn-sub-wrap {
  min-width: 170px;
}
.margin-top-md {
  margin-top: 14px;
}
.action-btn-sm.renew {
  background: var(--brand-blue-soft);
  color: var(--brand-navy);
  border: 1px solid #BAE6FD;
}
.action-btn-sm.renew:hover {
  background: #0284C7;
  color: #fff;
}
.action-btn-sm.warning {
  background: var(--accent-amber-bg);
  color: #B45309;
  border: 1px solid #FDE68A;
}
.action-btn-sm.warning:hover {
  background: #D97706;
  color: #fff;
}
.action-group-flex {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE SYSTEM (Fully Optimized for All Screen Sizes)
   ========================================================================== */

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .feature-strip {
    grid-template-columns: 1fr 1fr;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Navbar */
  .navbar {
    position: sticky;
    top: 0;
  }
  .nav-container {
    padding: 10px 14px;
    gap: 8px;
  }
  .brand-group {
    gap: 8px;
  }
  .brand-logo {
    height: 32px;
  }
  .brand-tagline-col,
  .brand-group .badge-tag {
    display: none !important; /* Hide slogan and engine tag on mobile to keep header clean & sleek */
  }
  .header-badges {
    display: none !important;
  }
  .market-status-pill {
    padding: 4px 10px;
    font-size: 0.74rem;
    gap: 6px;
  }
  .live-clock {
    display: none; /* Clean up navbar space on mobile */
  }
  .view-switch-btn {
    padding: 6px 12px;
    font-size: 0.76rem;
    gap: 5px;
    white-space: nowrap;
  }
  .view-switch-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Main Container */
  .main-layout {
    padding: 12px 10px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Security Banner */
  .security-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .security-badge {
    font-size: 0.78rem;
    padding: 5px 12px;
    align-self: flex-start;
  }
  .security-note {
    font-size: 0.82rem;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
  }

  /* Dashboard Grid on Mobile */
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    gap: 16px;
  }
  .grid-col-left,
  .grid-col-right {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Cards */
  .glass-card {
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .card-header {
    padding: 14px 16px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }
  .card-header .card-title-group {
    flex: 1;
    min-width: 0;
  }
  .card-body {
    padding: 16px 14px;
  }
  .card-heading {
    font-size: 1.18rem;
  }
  .card-desc {
    font-size: 0.84rem;
    margin-bottom: 14px;
  }

  /* Forms & Touch Inputs */
  .form-label {
    font-size: 0.78rem;
  }
  .form-input {
    height: 48px;
    font-size: 0.95rem;
    padding-left: 42px;
  }
  .input-wrapper .input-icon {
    left: 12px;
  }
  .btn-primary-zerodha {
    padding: 14px 16px;
    border-radius: var(--radius-md);
  }
  .btn-primary-zerodha .btn-text {
    font-size: 0.95rem;
  }
  .btn-primary-zerodha .btn-subtext {
    font-size: 0.72rem;
  }

  /* Strategy Metrics */
  .strategy-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .metric-card {
    padding: 10px 12px;
  }
  .metric-label {
    font-size: 0.7rem;
  }
  .metric-value {
    font-size: 0.88rem;
  }
  .radar-status-bar {
    padding: 10px 12px;
  }
  .radar-text {
    font-size: 0.78rem;
  }

  /* Tables & Terminal */
  .algo-table th,
  .algo-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    width: 100%;
    overflow-x: auto;
  }
  .empty-trades-cell {
    padding: 24px 12px !important;
  }
  .empty-state-content {
    font-size: 0.82rem;
    line-height: 1.4;
  }
  .terminal-console {
    height: 160px;
    font-size: 0.72rem;
    padding: 12px;
    line-height: 1.6;
  }

  /* Account Armed State (When Connected) */
  .account-summary-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }
  .account-margin {
    text-align: left;
    width: 100%;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
  }
  .setting-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .connected-actions {
    flex-direction: column-reverse;
    gap: 12px;
    align-items: stretch;
  }
  .btn-secondary-outline {
    width: 100%;
    justify-content: center;
  }
  .session-timer {
    text-align: center;
  }

  /* Feature Strip */
  .feature-strip {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
  }

  /* Admin View */
  .admin-top-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .admin-title {
    font-size: 1.35rem;
  }
  .btn-danger-kill {
    width: 100%;
    justify-content: center;
  }
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
  }
  .stat-number {
    font-size: 1.3rem;
  }
  .stat-sub {
    font-size: 0.72rem;
    margin-left: 0;
    display: block;
    margin-top: 2px;
  }
  .form-row-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .btn-sub-wrap {
    min-width: 100%;
  }
  .btn-sm-action {
    width: 100%;
    height: 42px;
  }
  .table-search {
    width: 100%;
    margin-top: 8px;
  }
  .table-search .search-input {
    width: 100%;
  }

  /* OAuth Modal */
  .modal-overlay {
    padding: 12px;
  }
  .modal-card {
    max-height: 92vh;
    overflow-y: auto;
    border-radius: var(--radius-md);
  }
  .modal-body {
    padding: 16px;
  }
  .modal-title {
    font-size: 1.15rem;
  }
  .modal-desc {
    font-size: 0.82rem;
  }
  .permission-item {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  /* Toast Notification */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 14px;
  }
  .toast {
    width: 100%;
    font-size: 0.8rem;
    padding: 10px 14px;
  }
}

@media (max-width: 420px) {
  .brand-logo {
    height: 28px;
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
  .strategy-metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* Master Admin Auth Modal & Logout */
.admin-auth-card {
  max-width: 440px;
}
.auth-lock-icon {
  font-size: 1.5rem;
}
.admin-logout-btn {
  background: #FFFFFF;
  color: var(--brand-navy);
  border: 1px solid var(--border-light);
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.admin-logout-btn:hover {
  background: var(--brand-red-soft);
  color: var(--brand-red);
  border-color: var(--accent-red-border);
}
.admin-back-row {
  margin-top: 14px;
  text-align: center;
}
.btn-text-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  transition: color 0.2s ease;
}
.btn-text-link:hover {
  color: var(--brand-red);
  text-decoration: underline;
}
.auth-error-msg {
  color: var(--accent-red);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--accent-red-bg);
  border: 1px solid var(--accent-red-border);
  border-radius: 6px;
}
.action-btn-sm.danger {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
}
.action-btn-sm.danger:hover {
  background: var(--accent-red);
  color: #FFFFFF;
}

