@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
  box-sizing: border-box;
}

:root {
  --bg-main: #060d1f;
  --bg-sidebar: linear-gradient(180deg, #071225 0%, #0a1830 100%);
  --bg-card: #0f1f3d;
  --bg-card-hover: #152848;
  --bg-input: #0a1628;
  --border-color: #1e3a5f;
  --border-soft: #243f68;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-accent: #34d399;
  --btn-sidebar: rgba(255,255,255,0.04);
  --btn-sidebar-hover: rgba(255,255,255,0.09);
  --shadow: rgba(0, 0, 0, 0.25);
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --gradient-hero: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(16,185,129,0.08));
}

[data-mode="light"] {
  --bg-main: #f0f4f8;
  --bg-sidebar: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-soft: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-accent: #059669;
  --btn-sidebar: #f1f5f9;
  --btn-sidebar-hover: #e2e8f0;
  --shadow: rgba(15, 23, 42, 0.06);
  --gradient-hero: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(16,185,129,0.06));
}

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  padding: 20px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  border-right: 1px solid var(--border-color);
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}

.sidebar-brand strong {
  display: block;
  font-size: 15px;
}

.sidebar-brand small {
  color: var(--text-muted);
  font-size: 11px;
}

.brand-logo-sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #10b981);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn-main {
  width: 100%;
}

.nav-btn-trading .nav-btn-main {
  font-weight: 500;
}

.nav-btn {
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.nav-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}

.nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.3;
}

.nav-badge-pending {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.nav-badge-pos {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.nav-btn:hover {
  background: var(--btn-sidebar-hover);
  color: var(--text-main);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(37,99,235,0.2), rgba(16,185,129,0.1));
  color: var(--text-main);
  border: 1px solid rgba(59,130,246,0.3);
}

.sidebar h2 {
  margin-top: 0;
  margin-bottom: 18px;
}

.sidebar button {
  width: 100%;
  margin: 7px 0;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--btn-sidebar);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.sidebar button:hover {
  background: var(--btn-sidebar-hover);
}

.main {
  margin-left: 260px;
  padding: 20px 24px 32px;
  width: calc(100% - 260px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg-main);
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}

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

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

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

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #10b981 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text-main), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-mode="light"] .brand-title {
  background: linear-gradient(90deg, #0f172a, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
}

.brand-tagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.ticker-bar {
  background: var(--gradient-hero);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-accent);
  font-weight: 600;
  margin-bottom: 20px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.ticker-bar.ticker-open {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08));
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.ticker-bar.ticker-closed {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(127, 29, 29, 0.08));
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Smart Dashboard */
.dash-smart-hero {
  margin-bottom: 4px;
}

.dash-market-pulse {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
}

.dash-market-pulse.is-open {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.6));
  border-color: rgba(16, 185, 129, 0.4);
}

.dash-market-pulse.is-closed {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(15, 23, 42, 0.65));
  border-color: rgba(239, 68, 68, 0.45);
}

.dash-pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: dash-pulse-blink 1.4s ease-in-out infinite;
}

.is-open .dash-pulse-dot {
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.8);
}

.is-closed .dash-pulse-dot {
  background: #f87171;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.85);
}

@keyframes dash-pulse-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.92); }
}

.dash-pulse-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-pulse-body strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.is-open .dash-pulse-body strong { color: #34d399; }
.is-closed .dash-pulse-body strong { color: #f87171; }

.dash-pulse-body span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.dash-pulse-time {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

.dash-stat-grid .dash-stat-card {
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}

.dash-stat-grid .dash-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.dash-smart-split .dash-spot-card,
.dash-smart-split .dash-broker-card {
  border-radius: 14px;
  overflow: hidden;
}

.dash-spot-card .ltp-price {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.mode-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 4px 8px 4px 12px;
}

.mode-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
}

.pill.active {
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-sm {
  padding: 8px 12px !important;
  font-size: 12px !important;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topbar-actions .user-chip,
.user-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

.menu-toggle {
  display: none;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

#newsBox {
  width: 100%;
}

/* Dashboard */
.section-hero,
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}

.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.box-header h2 {
  margin: 0;
}

.terminal-box {
  margin-top: 0 !important;
}

.strategy-symbol-picker {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strategy-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.strategy-symbol-meta {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-grid label input,
.form-grid label select {
  width: 100%;
  margin: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.monitor-table td:first-child {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  width: 45%;
}

.monitor-table td:last-child {
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.strategy-monitor-box .monitor-table {
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.strategy-monitor-box #strategyContract2 {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-size: 13px;
}

.strategy-monitor-box #strategyLtp,
.strategy-monitor-box #strategyBasePrice,
.strategy-monitor-box #strategyGridLive {
  font-weight: 700;
  color: var(--text-main);
}

.stat-value small {
  font-size: 1rem;
  opacity: 0.5;
  margin: 0 2px;
}

.grid-row-next-sell td {
  background: rgba(139, 92, 246, 0.12);
  font-weight: 700;
}

.grid-row-holding td {
  background: rgba(16, 185, 129, 0.08);
}

.strategy-reconcile-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  background: rgba(41, 98, 255, 0.12);
  border: 1px solid rgba(41, 98, 255, 0.35);
  color: #93c5fd;
}

.strategy-reconcile-banner.strategy-reconcile-warn {
  background: rgba(247, 147, 26, 0.12);
  border-color: rgba(247, 147, 26, 0.4);
  color: #fbbf24;
}

.strategy-reconcile-banner.hidden {
  display: none;
}

.strategy-instances-box {
  margin-bottom: 16px;
}

.strategy-instance-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.strategy-instance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.strategy-instance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.strategy-instance-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
}

.strategy-instance-card.active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

.strategy-instance-card.running {
  border-left: 3px solid var(--accent-green);
}

.strategy-instance-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.strategy-instance-meta strong {
  font-size: 14px;
}

.strategy-instance-meta small {
  color: var(--text-muted);
  font-size: 12px;
}

.strategy-instance-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.strategy-inst-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.strategy-inst-badge.run {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.strategy-inst-badge.qty {
  background: rgba(247, 147, 26, 0.15);
  color: #fbbf24;
}

.strategy-inst-badge.kind-script {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.strategy-instance-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.strategy-instance-btns button {
  margin: 0;
}

/* Strategy page */
.strategy-action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.strategy-action-row button {
  margin: 0;
  width: 100%;
  min-height: 44px;
}

.strategy-split {
  min-width: 0;
}

.strategy-split > .box {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.strategy-monitor-box,
.strategy-grid-box {
  padding: 16px;
}

.grid-scroll-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 420px;
  width: 100%;
  min-width: 0;
}

.strategy-grid-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
}

.strategy-grid-table th,
.strategy-grid-table td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 8px 6px;
  font-size: 13px;
  vertical-align: top;
}

.strategy-grid-table th:nth-child(1),
.strategy-grid-table td:nth-child(1) {
  width: 12%;
}

.strategy-grid-table th:nth-child(2),
.strategy-grid-table td:nth-child(3),
.strategy-grid-table td:nth-child(2),
.strategy-grid-table th:nth-child(3) {
  width: 28%;
  font-variant-numeric: tabular-nums;
}

.strategy-grid-table th:nth-child(4),
.strategy-grid-table td:nth-child(4) {
  width: 32%;
  font-size: 11px;
  font-weight: 600;
}

.grid-row-next-buy td {
  background: rgba(245, 158, 11, 0.12);
  font-weight: 700;
}

.strategy-monitor-table tr {
  display: table-row;
}

.strategy-page .stat-value-sm {
  font-size: clamp(0.95rem, 3.5vw, 1.25rem);
  line-height: 1.25;
  word-break: break-word;
}

.strategy-logs-box .log-panel {
  max-height: 280px;
}

.trigger-level-grid {
  margin-top: 0;
}

.stat-card.trigger-near {
  position: relative;
}

.stat-card.trigger-near-buy {
  animation: trigger-pulse-buy 1.1s ease-in-out infinite;
  border-color: rgba(245, 158, 11, 0.85) !important;
}

.stat-card.trigger-near-sell {
  animation: trigger-pulse-sell 1.1s ease-in-out infinite;
  border-color: rgba(139, 92, 246, 0.85) !important;
}

.stat-card.trigger-near::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: trigger-dot 1s ease-in-out infinite;
}

.stat-card.trigger-near-buy::after {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.9);
}

.stat-card.trigger-near-sell::after {
  background: #a78bfa;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.9);
}

.trigger-hint-active {
  color: #fbbf24 !important;
  font-weight: 700;
  animation: trigger-text-blink 1.1s ease-in-out infinite;
}

@keyframes trigger-pulse-buy {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35), 0 4px 20px var(--shadow);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(245, 158, 11, 0), 0 4px 24px rgba(245, 158, 11, 0.25);
  }
}

@keyframes trigger-pulse-sell {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.35), 0 4px 20px var(--shadow);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(139, 92, 246, 0), 0 4px 24px rgba(139, 92, 246, 0.25);
  }
}

@keyframes trigger-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

@keyframes trigger-text-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-blue);
}

.page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge, .mini-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-open, .mini-badge.badge-open {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-closed, .mini-badge.badge-closed {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
}

.badge-live {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.btn-primary {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-soft);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.accent-blue::before { background: var(--accent-blue); }
.accent-green::before { background: var(--accent-green); }
.accent-purple::before { background: var(--accent-purple); }
.accent-amber::before { background: var(--accent-amber); }

.stat-icon {
  font-size: 20px;
  opacity: 0.7;
  display: block;
  margin-bottom: 8px;
}

.stat-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

.stat-value-sm {
  font-size: 1.25rem;
}

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

.pnl-pos { color: #34d399 !important; }
.pnl-neg { color: #f87171 !important; }

.dashboard-split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.ltp-card {
  margin-top: 0 !important;
  background: var(--gradient-hero);
  border-color: rgba(59, 130, 246, 0.25);
}

.ltp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ltp-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ltp-symbol {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ltp-price {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 8px 0;
}

.ltp-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.broker-card {
  margin-top: 0 !important;
}

.broker-card h3.broker-name {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.broker-status-text {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 16px;
}

.broker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ghost-btn {
  background: transparent !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.cards > div,
.card,
.box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 4px 16px var(--shadow);
}

.box h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.cards span {
  display: inline-block;
  margin-top: 8px;
  font-size: 22px;
  font-weight: bold;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  margin: 4px;
}

.green { background: #16a34a; }
.red { background: #dc2626; }
.yellow { background: #f59e0b; color: #111827; }
.blue { background: #2563eb; }
.ghost {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

input,
select {
  padding: 11px;
  margin: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  color: var(--text-main);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

th {
  color: var(--text-muted);
  font-size: 13px;
}

th,
td {
  padding: 11px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.hidden {
  display: none !important;
}

/* Orphan trade UI outside .section — index.html SPA only (not backtest page) */
.main:not(.backtest-page) > .box,
.main:not(.backtest-page) > .table-wrap,
.main:not(.backtest-page) > .terminal-box,
.main:not(.backtest-page) > .action-row {
  display: none !important;
}


.scroll-table {
  max-height: 420px;
  overflow-y: auto;
}

.log-panel {
  height: 250px;
  overflow: auto;
  background: var(--bg-input);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 30px var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.login-card label {
  display: block;
  margin: 12px 0 6px;
  font-size: 14px;
}

.login-card input {
  width: 100%;
  margin: 0 0 8px;
}

.login-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
}

.login-error {
  color: #ef4444;
  min-height: 20px;
  margin-top: 12px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
}

.trade-ledger-box {
  margin-top: 16px;
}

.trade-ledger-table {
  min-width: 720px;
}

.side-buy {
  color: #34d399;
  font-weight: 700;
}

.leg-open {
  color: #60a5fa;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.leg-pending {
  color: #fbbf24;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.leg-closed {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.sidebar-nav a.nav-btn {
  text-decoration: none;
  display: block;
}

.backtest-page .section-hero {
  margin: 16px 0 8px;
}

.bt-prices-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.bt-prices-label small {
  text-transform: none;
  font-weight: 500;
  opacity: 0.85;
}

.bt-prices-input {
  width: 100%;
  min-height: 120px;
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.bt-action-row {
  grid-template-columns: 1fr 1fr;
  max-width: 480px;
}

.bt-action-row {
  grid-template-columns: 1fr 1fr;
  max-width: 480px;
}

.bt-source-box {
  margin-top: 16px;
  padding-top: 0;
}

.bt-source-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.bt-source-toggle .pill {
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.bt-source-toggle .pill.active {
  background: linear-gradient(90deg, rgba(37,99,235,0.25), rgba(16,185,129,0.15));
  color: var(--text-main);
  border-color: rgba(59,130,246,0.4);
}

.bt-source-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.bt-history-panel.hidden,
.bt-prices-label.hidden,
.bt-results.hidden {
  display: none;
}

.bt-mcx-scale {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-main);
  margin: 12px 0 8px;
  text-transform: none;
  font-weight: 500;
}

.bt-mcx-scale input {
  margin: 0;
  width: auto;
}

.bt-proxy-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.bt-fetch-row {
  grid-template-columns: 1fr;
  max-width: 220px;
  margin-bottom: 10px;
}

.bt-fetch-meta {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.bt-results.hidden {
  display: none;
}

.bt-empty {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}

.bt-pipeline-card {
  margin-bottom: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(16, 185, 129, 0.06));
  border: 1px solid var(--border);
}

.bt-pipeline-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.bt-pipe-step b {
  color: var(--accent-blue, #3b82f6);
}

.bt-pipe-arrow {
  color: var(--text-muted);
  opacity: 0.7;
}

.bt-pipe-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.bt-pipe-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
}

.bt-candle-chart {
  margin-top: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.bt-candle-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bt-candle-bars {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 100px;
  overflow-x: auto;
}

.bt-candle {
  position: relative;
  flex: 1 0 6px;
  min-width: 6px;
  max-width: 12px;
  height: 100%;
}

.bt-candle-wick {
  position: absolute;
  left: 50%;
  width: 1px;
  margin-left: -0.5px;
  background: var(--text-muted);
  opacity: 0.6;
}

.bt-candle-body {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 1px;
}

.bt-candle-body.up {
  background: #22c55e;
}

.bt-candle-body.down {
  background: #ef4444;
}

.bt-equity-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding: 12px 4px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.bt-bar-wrap {
  flex: 1 0 8px;
  min-width: 8px;
  max-width: 20px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}

.bt-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: opacity 0.15s;
}

.bt-bar-wrap:hover .bt-bar {
  opacity: 0.75;
}

.bt-bar-pos {
  background: linear-gradient(180deg, #34d399, #059669);
}

.bt-bar-neg {
  background: linear-gradient(180deg, #f87171, #dc2626);
}

.side-sell {
  color: #f87171;
  font-weight: 700;
}

.btn-sm {
  padding: 8px 12px !important;
  font-size: 12px !important;
  margin: 0 !important;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: inline-block;
  }

  .backtest-page .section-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .bt-action-row {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .bt-equity-chart {
    height: 100px;
  }

  .trade-ledger-table {
    min-width: 640px;
    font-size: 12px;
  }

  .trade-ledger-table th,
  .trade-ledger-table td {
    padding: 8px 10px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 12px 14px 24px;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .brand-tagline {
    display: none;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .dash-market-pulse {
    flex-wrap: wrap;
    padding: 12px 14px;
    gap: 10px;
  }

  .dash-pulse-time {
    width: 100%;
    text-align: left;
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .ltp-price {
    font-size: 2rem;
  }

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

  input,
  select {
    width: 100%;
    margin-left: 0;
  }

  button {
    min-height: 44px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap > table,
  .scroll-table .table-wrap > table,
  table.trade-ledger-table {
    min-width: 640px;
  }

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

  .strategy-page .section-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .strategy-page .section-hero .badge {
    align-self: flex-start;
  }

  .strategy-page .box {
    padding: 16px;
    margin-top: 12px;
  }

  .strategy-split {
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }

  .strategy-split > .box {
    margin-top: 12px;
  }

  .strategy-monitor-box {
    overflow: hidden;
    padding: 16px;
  }

  .strategy-monitor-table,
  .strategy-monitor-table tbody {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .strategy-monitor-table tr {
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 60%);
    align-items: start;
    gap: 6px 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .strategy-monitor-table tr:last-child {
    border-bottom: none;
  }

  .strategy-monitor-table td {
    display: block;
    border-bottom: none;
    padding: 0;
    min-width: 0;
  }

  .strategy-monitor-table td:first-child {
    width: auto;
    flex: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    line-height: 1.3;
  }

  .strategy-monitor-table td:last-child {
    flex: none;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
  }

  .grid-scroll-wrap {
    max-height: min(55vh, 480px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .strategy-grid-table {
    min-width: 0;
    width: 100%;
    font-size: 12px;
  }

  .strategy-grid-table th,
  .strategy-grid-table td {
    padding: 7px 5px;
    font-size: 11px;
  }

  .strategy-grid-table th:nth-child(4),
  .strategy-grid-table td:nth-child(4) {
    font-size: 10px;
  }

  .strategy-logs-box .log-panel {
    height: 200px;
    font-size: 12px;
  }

  .main {
    overflow-x: hidden;
  }
}

@media (max-width: 480px) {
  .stat-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .strategy-action-row {
    grid-template-columns: 1fr;
  }

  .strategy-page .stat-card {
    padding: 14px 16px;
  }

  .strategy-page .page-title {
    font-size: 1.45rem;
  }

  .strategy-monitor-table tr {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 0;
  }

  .strategy-monitor-table td:last-child {
    text-align: left;
    font-size: 15px;
  }

  .strategy-monitor-box #strategyContract2 {
    font-size: 12px;
  }

  .strategy-grid-table {
    min-width: 0;
    font-size: 11px;
  }

  .strategy-grid-table th,
  .strategy-grid-table td {
    padding: 6px 4px;
  }

  .topbar-right {
    width: 100%;
  }

  .mode-pills {
    width: 100%;
    justify-content: center;
  }
}

.report-period-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.report-period-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.report-period-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: transparent;
}

.report-custom-dates {
  margin-bottom: 16px;
  align-items: end;
}

.preset-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  flex-wrap: wrap;
}

.preset-row small {
  display: block;
  opacity: 0.7;
  font-size: 11px;
}

.preset-actions {
  display: flex;
  gap: 6px;
}

.script-editor {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}

.holiday-upcoming {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

/* Holidays page */
.holidays-page .section-hero {
  margin-bottom: 16px;
}

.holidays-today-card {
  margin-bottom: 16px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.14), rgba(239, 68, 68, 0.06));
}

.holidays-today-card.hidden {
  display: none !important;
}

.holidays-today-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.holidays-today-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.holidays-today-inner strong {
  display: block;
  font-size: 1rem;
  color: #fcd34d;
  margin-bottom: 4px;
}

.holidays-today-msg {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.holidays-upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.holidays-upcoming-card {
  position: relative;
  padding: 12px 12px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.holidays-upcoming-card.is-today {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), var(--surface-2));
}

.holidays-upcoming-date {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.holidays-upcoming-day {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.holidays-upcoming-name {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
}

.holidays-upcoming-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.holidays-empty {
  margin: 0;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.holidays-table-box .table-wrap {
  max-height: 480px;
  overflow-y: auto;
}

.holidays-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.holidays-table th,
.holidays-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.holidays-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.holidays-table tbody tr:hover {
  background: var(--btn-sidebar-hover);
}

.holidays-row-today td {
  color: #fbbf24;
  font-weight: 600;
}

@media (max-width: 640px) {
  .holidays-upcoming-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Dashboard holiday alert (top) */
.dash-holiday-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(239, 68, 68, 0.08));
}

.dash-holiday-banner.hidden {
  display: none !important;
}

.dash-holiday-banner-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.dash-holiday-banner-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-main);
}

.dash-holiday-banner-body strong {
  font-size: 14px;
  color: #fcd34d;
}

.market-watch-box .mw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mw-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.mw-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mw-tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.mw-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mw-search-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 8px;
}

.mw-option-filters {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.mw-option-filters.hidden {
  display: none;
}

.mw-expiry-select {
  max-height: 42px;
}

.mw-expiry-select:focus {
  max-height: none;
}

.mw-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.mw-select,
.mw-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.mw-search-results {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 240px;
  overflow: auto;
}

.mw-search-results.hidden {
  display: none;
}

.mw-search-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.mw-search-item:hover {
  border-color: var(--accent);
}

.mw-search-exch {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.mw-search-item strong {
  grid-column: 2;
}

.mw-search-item small {
  grid-column: 2;
  opacity: 0.75;
}

.mw-table .mw-symbol {
  font-weight: 700;
}

.mw-sub {
  display: block;
  opacity: 0.65;
  font-size: 11px;
}

.mw-exch {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
}

.mw-ltp {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.positive { color: #22c55e; }
.negative { color: #ef4444; }

@media (max-width: 768px) {
  .mw-search-row,
  .mw-option-filters {
    grid-template-columns: 1fr;
  }

  .mw-actions {
    min-width: 120px;
  }

  .mw-cards {
    grid-template-columns: 1fr;
  }

  .dash-market-day-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard daily market calendar */
.dash-market-day {
  margin-top: 20px;
}

.dash-market-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-market-title {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.dash-market-day-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}

.dash-session-card {
  padding: 16px;
}

.dash-session-line {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.dash-holiday-list {
  margin-top: 14px;
}

.dash-holiday-table {
  font-size: 13px;
}

/* Market Watch page */
.market-page .mw-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.mw-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mw-search-card {
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--bg-card) 100%);
}

.mw-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mw-quote-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}

.mw-quote-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mw-quote-exch {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.mw-quote-chg {
  font-size: 12px;
  font-weight: 700;
}

.mw-quote-symbol {
  margin: 8px 0 4px;
  font-size: 15px;
}

.mw-quote-ltp {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mw-quote-ohlc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.mw-table-box {
  padding: 0;
  overflow: hidden;
}

.mw-table-scroll {
  overflow-x: auto;
}

.mw-ohlc-table {
  min-width: 920px;
  font-size: 13px;
}

.mw-ohlc-table th,
.mw-ohlc-table td {
  padding: 10px 12px;
  white-space: nowrap;
}

.mw-sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-card);
  min-width: 140px;
}

.mw-row-live .mw-ltp {
  color: var(--text);
}

.mw-last-update {
  font-size: 11px;
  color: var(--text-muted);
  align-self: center;
}

.mw-table-hint {
  opacity: 0.65;
  font-weight: 500;
}

/* Order modal */
.mw-modal {
  --kite-green: #4caf50;
  --kite-red: #f44336;
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mw-modal.hidden {
  display: none;
}

.mw-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.mw-modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.mw-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.mw-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.mw-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.mw-modal-body {
  padding: 16px 18px;
}

.mw-order-symbol-block {
  margin-bottom: 12px;
}

.mw-order-symbol-block strong {
  display: block;
  font-size: 18px;
  margin-top: 4px;
}

.mw-order-ltp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
}

.mw-order-ltp-row strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.mw-order-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mw-order-mode {
  font-size: 13px;
  padding-top: 4px;
}

.mw-order-mode small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
}

.mw-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
}

.btn-muted {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
}

.btn-muted:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
}

.mw-modal-actions .btn-muted {
  min-width: 88px;
}

.btn-primary.red {
  background: #dc2626;
}

.btn-primary.green {
  background: #16a34a;
}

.mw-search-loading {
  padding: 12px;
  color: var(--text-muted);
}

.mw-search-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.mw-search-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  margin: 0;
}

.mw-search-item:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* —— Kite Market Watch (mobile-first) —— */
.market-page {
  --kite-bg: #000000;
  --kite-surface: #121212;
  --kite-surface-2: #1a1a1a;
  --kite-border: #2a2a2a;
  --kite-text: #ffffff;
  --kite-muted: #9e9e9e;
  --kite-green: #4caf50;
  --kite-red: #f44336;
  --kite-blue: #2196f3;
  --kite-touch: 44px;
  margin: -4px -8px 0;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.kite-mw-shell {
  background: var(--kite-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--kite-border);
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 140px);
}

.kite-mw-sticky {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--kite-bg);
  border-bottom: 1px solid var(--kite-border);
  padding-top: env(safe-area-inset-top, 0);
}

.kite-indices-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--kite-bg);
  border-bottom: 1px solid var(--kite-border);
  scrollbar-width: none;
}

.kite-indices-bar.hidden {
  display: none;
}

.kite-indices-bar::-webkit-scrollbar {
  display: none;
}

.kite-index-item {
  flex: 0 0 auto;
  min-width: 118px;
  min-height: var(--kite-touch);
  padding: 8px 14px;
  border: none;
  border-right: 1px solid var(--kite-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  margin: 0;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
}

.kite-index-item:active {
  background: rgba(255, 255, 255, 0.06);
}

.kite-index-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--kite-muted);
  text-transform: uppercase;
}

.kite-index-ltp {
  font-size: 15px;
  font-weight: 700;
  color: var(--kite-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.kite-index-chg {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kite-index-status {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  flex-shrink: 0;
}

.kite-status-dot {
  font-size: 10px;
  color: var(--kite-muted);
  line-height: 1;
}

.kite-status-dot.live {
  color: var(--kite-green);
}

.kite-status-dot.error {
  color: var(--kite-red);
}

.kite-live-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--kite-green);
  letter-spacing: 0.03em;
}

.kite-live-pill.muted {
  color: var(--kite-muted);
}

.kite-update-time {
  font-size: 10px;
  color: var(--kite-muted);
}

.kite-mw-toolbar {
  background: var(--kite-bg);
}

.kite-mw-layout {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.kite-mw-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--kite-bg);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.kite-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
  background: var(--kite-bg);
}

.kite-search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--kite-surface-2);
  border: 1px solid var(--kite-border);
  border-radius: 8px;
  padding: 0 12px;
  min-width: 0;
  min-height: var(--kite-touch);
}

.kite-search-bar:focus-within {
  border-color: var(--kite-blue);
}

.kite-search-icon {
  color: var(--kite-muted);
  flex-shrink: 0;
}

.kite-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--kite-text);
  font-size: 16px;
  padding: 10px 0;
  min-width: 0;
  margin: 0;
}

.kite-search-input::placeholder {
  color: var(--kite-muted);
}

.kite-search-input:focus {
  outline: none;
}

.kite-search-add {
  width: var(--kite-touch);
  height: var(--kite-touch);
  min-width: var(--kite-touch);
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--kite-blue);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-weight: 400;
  padding: 0;
  margin: 0 -8px 0 0;
  flex-shrink: 0;
}

.kite-wl-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--kite-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kite-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px;
}

.kite-exch-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.kite-exch-strip::-webkit-scrollbar {
  display: none;
}

.kite-exch-tab {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--kite-border);
  background: transparent;
  color: var(--kite-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  margin: 0;
}

.kite-exch-tab.active {
  background: rgba(33, 150, 243, 0.15);
  color: var(--kite-blue);
  border-color: rgba(33, 150, 243, 0.4);
}

.kite-fo-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 10px;
  background: var(--kite-bg);
}

.kite-fo-filters.hidden {
  display: none;
}

.kite-select-sm,
.kite-input-sm {
  font-size: 13px;
  padding: 8px 10px;
  min-height: 36px;
  flex: 1;
  min-width: 80px;
  background: var(--kite-surface-2);
  border-color: var(--kite-border);
  color: var(--kite-text);
  margin: 0;
  border-radius: 6px;
}

.kite-sort-select {
  font-size: 13px;
  padding: 8px 10px;
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--kite-border);
  background: var(--kite-surface-2);
  color: var(--kite-text);
  margin: 0;
}

.kite-search-dropdown {
  margin: 0 12px 10px;
  max-height: min(280px, 40vh);
  overflow-y: auto;
  background: var(--kite-surface);
  border: 1px solid var(--kite-border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  -webkit-overflow-scrolling: touch;
}

.kite-search-dropdown.hidden {
  display: none;
}

.kite-watchlist {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--kite-bg);
  min-height: 0;
}

.kite-row-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--kite-border);
}

.kite-row-swipe-actions {
  position: absolute;
  inset: 0 0 0 auto;
  width: 140px;
  display: flex;
  align-items: stretch;
  z-index: 0;
}

.kite-swipe-buy,
.kite-swipe-sell {
  flex: 1;
  border: none;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  margin: 0;
  padding: 0;
  min-height: var(--kite-touch);
}

.kite-swipe-buy {
  background: var(--kite-green);
}

.kite-swipe-sell {
  background: var(--kite-red);
}

.kite-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 14px;
  min-height: var(--kite-touch);
  cursor: pointer;
  transition: background 0.1s, transform 0.15s ease;
  position: relative;
  z-index: 1;
  background: var(--kite-bg);
  touch-action: pan-y;
}

.kite-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.kite-row.selected {
  background: rgba(33, 150, 243, 0.08);
}

.kite-row-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kite-sym-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kite-sym {
  font-size: 15px;
  font-weight: 600;
  color: var(--kite-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.kite-holding-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(33, 150, 243, 0.2);
  color: var(--kite-blue);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.kite-exch-label {
  font-size: 11px;
  color: var(--kite-muted);
  line-height: 1;
}

.kite-row-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kite-ltp {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--kite-text);
  line-height: 1.2;
}

.kite-chg {
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-top: 3px;
  line-height: 1.2;
}

.kite-row-actions {
  display: none !important;
}

.kite-row-expand {
  display: none;
  padding: 10px 14px 12px;
  background: var(--kite-surface);
  border-top: 1px solid var(--kite-border);
}

.kite-row-wrap.expanded .kite-row-expand {
  display: block;
}

.kite-row-wrap.expanded .kite-row {
  background: rgba(33, 150, 243, 0.08);
}

.kite-expand-ohlc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  font-size: 11px;
  color: var(--kite-muted);
  margin-bottom: 10px;
}

.kite-expand-ohlc b {
  display: block;
  color: var(--kite-text);
  font-size: 13px;
  margin-top: 2px;
}

.kite-expand-meta {
  font-size: 11px;
  color: var(--kite-muted);
  margin-bottom: 10px;
}

.kite-expand-actions {
  display: flex;
  gap: 8px;
}

.kite-expand-actions .kite-b,
.kite-expand-actions .kite-s {
  flex: 1;
  min-height: 36px;
}

.kite-btn-remove-sm {
  flex: 0 0 36px;
  min-height: 36px;
  border: 1px solid var(--kite-border);
  background: transparent;
  color: var(--kite-muted);
  border-radius: 6px;
  cursor: pointer;
}

.mw-modal-panel {
  width: min(480px, 100%);
  max-height: 92vh;
  overflow-y: auto;
}

.mw-order-ohlc {
  margin: 10px 0;
}

.mw-order-vol {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.mw-order-chg {
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.mw-depth-wrap {
  margin: 8px 0 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
}

.mw-depth-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  background: var(--bg-input);
  color: var(--text-muted);
}

.mw-depth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.mw-depth-title {
  font-size: 10px;
  font-weight: 700;
  padding: 6px 8px;
  text-transform: uppercase;
}

.mw-depth-title.buy { color: var(--kite-green); background: rgba(76,175,80,0.08); }
.mw-depth-title.sell { color: var(--kite-red); background: rgba(244,67,54,0.08); }

.mw-depth-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border-soft);
}

.mw-depth-row:last-child { border-bottom: none; }
.mw-depth-row .price { font-weight: 600; }
.mw-depth-row.buy .price { color: var(--kite-green); }
.mw-depth-row.sell .price { color: var(--kite-red); }

.mw-depth-empty {
  padding: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.kite-b,
.kite-s {
  flex: 1;
  min-height: var(--kite-touch);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  padding: 0 12px;
  margin: 0;
}

.kite-b {
  background: var(--kite-green);
}

.kite-s {
  background: var(--kite-red);
}

.kite-ltp.flash-up {
  animation: kiteFlashUp 0.5s ease;
}

.kite-ltp.flash-down {
  animation: kiteFlashDown 0.5s ease;
}

@keyframes kiteFlashUp {
  0% { background: rgba(76, 175, 80, 0.35); border-radius: 4px; }
  100% { background: transparent; }
}

@keyframes kiteFlashDown {
  0% { background: rgba(244, 67, 54, 0.35); border-radius: 4px; }
  100% { background: transparent; }
}

.kite-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--kite-muted);
  font-size: 14px;
  line-height: 1.6;
}

.kite-empty-icon {
  font-size: 36px;
  margin: 0 0 12px;
  opacity: 0.5;
}

.kite-empty-error {
  color: var(--kite-red);
}

.kite-skeleton-list {
  padding: 0;
}

.kite-skeleton-row {
  height: 56px;
  margin: 0;
  border-bottom: 1px solid var(--kite-border);
  background: linear-gradient(90deg, var(--kite-surface) 0%, var(--kite-surface-2) 50%, var(--kite-surface) 100%);
  background-size: 200% 100%;
  animation: kiteSkeleton 1.2s ease-in-out infinite;
}

@keyframes kiteSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.kite-mw-main {
  display: none;
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  background: var(--kite-surface);
  border: none;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}

.kite-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--kite-muted);
}

.kite-detail-empty-icon {
  font-size: 48px;
  margin: 0 0 12px;
  opacity: 0.4;
}

.kite-detail-empty h3 {
  margin: 0 0 8px;
  color: var(--kite-text);
  font-weight: 600;
}

.kite-detail {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
  color: var(--kite-text);
}

.kite-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.kite-detail-symbol {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--kite-text);
}

.kite-detail-exch {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--kite-muted);
  margin-bottom: 4px;
}

.kite-detail-contract {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--kite-muted);
}

.kite-detail-ltp-block {
  text-align: right;
}

.kite-detail-ltp {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--kite-text);
}

.kite-detail-chg {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.kite-ohlc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.kite-ohlc-cell {
  padding: 12px;
  border-radius: 6px;
  background: var(--kite-surface-2);
  border: 1px solid var(--kite-border);
}

.kite-ohlc-cell span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--kite-muted);
  margin-bottom: 4px;
}

.kite-ohlc-cell strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--kite-text);
}

.kite-detail-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--kite-muted);
}

.kite-detail-meta strong {
  color: var(--kite-text);
}

.kite-detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.kite-detail-actions button {
  flex: 1;
  min-width: 120px;
  min-height: var(--kite-touch);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  margin: 0;
}

.kite-btn-buy {
  background: var(--kite-green);
}

.kite-btn-sell {
  background: var(--kite-red);
}

.kite-btn-remove {
  flex: 0 0 auto;
  min-width: var(--kite-touch);
  padding: 14px 16px;
  background: var(--kite-surface-2);
  color: var(--kite-muted);
  border: 1px solid var(--kite-border);
}

.mw-mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.mw-mobile-sheet:not(.hidden) {
  pointer-events: auto;
}

.mw-mobile-sheet.hidden {
  display: none;
}

.mw-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mw-mobile-sheet:not(.hidden) .mw-sheet-backdrop {
  opacity: 1;
}

.mw-sheet-panel {
  position: relative;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  background: var(--kite-surface);
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 12px);
  color: var(--kite-text);
}

.mw-mobile-sheet:not(.hidden) .mw-sheet-panel {
  transform: translateY(0);
}

.mw-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--kite-border);
  border-radius: 2px;
  margin: 10px auto 0;
}

.mw-sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: var(--kite-touch);
  height: var(--kite-touch);
  border: none;
  background: var(--kite-surface-2);
  color: var(--kite-muted);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
  margin: 0;
  padding: 0;
}

.mw-sheet-panel .kite-detail {
  padding: 16px 16px 24px;
}

.mw-sheet-panel .kite-detail-actions {
  position: sticky;
  bottom: 0;
  background: var(--kite-surface);
  padding: 12px 0 8px;
  margin: 0;
}

.mw-toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 9500;
  padding: 12px 20px;
  background: var(--kite-surface-2);
  color: var(--kite-text);
  border: 1px solid var(--kite-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.mw-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.mw-toast.hidden {
  display: block;
}

.market-page .positive { color: var(--kite-green) !important; }
.market-page .negative { color: var(--kite-red) !important; }

.market-page .kite-search-dropdown .mw-search-item {
  display: block;
  width: 100%;
  text-align: left;
  min-height: var(--kite-touch);
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--kite-border);
  background: transparent;
  color: var(--kite-text);
  cursor: pointer;
  margin: 0;
}

.market-page .kite-search-dropdown .mw-search-item:last-child {
  border-bottom: none;
}

.market-page .kite-search-dropdown .mw-search-item:active {
  background: rgba(33, 150, 243, 0.12);
}

.market-page .mw-search-exch {
  color: var(--kite-blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.kite-search-dropdown .mw-search-loading,
.kite-search-dropdown .mw-search-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--kite-muted);
  line-height: 1.5;
}

@media (min-width: 768px) {
  .market-page {
    margin: 0;
    padding: 0;
  }

  .kite-mw-shell {
    min-height: calc(100vh - 180px);
  }

  .kite-mw-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 280px);
  }

  .kite-mw-sidebar {
    border-right: none;
    max-width: none;
  }

  .kite-index-status {
    display: flex;
  }

  .kite-mw-main {
    display: none !important;
  }

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

  .kite-row {
    grid-template-columns: 1fr auto;
  }

  .kite-row-swipe-actions {
    display: none;
  }

  .mw-mobile-sheet {
    display: none !important;
  }
}

.mw-depth-row.head {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-input);
}

@media (max-width: 767px) {
  .kite-row-swipe-actions {
    display: none !important;
  }

  .kite-row-wrap.swiped .kite-row {
    transform: none;
  }

  .kite-row-expand {
    display: none;
  }

  .kite-row-wrap.expanded .kite-row-expand {
    display: block;
  }

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

  .mw-modal {
    padding: 0;
    align-items: flex-end;
  }

  .mw-modal-panel {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
  }

  .mw-mobile-sheet {
    display: none !important;
  }
}

/* Broker Hub — stable grid (5 cards) */
#broker.section {
  display: none;
}

#broker.section.active {
  display: block;
}

#broker .stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
}

#broker .dashboard-split {
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

#broker .broker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

#broker .broker-actions button {
  flex: 1 1 auto;
  min-width: 120px;
}

#broker #brokerIpNote {
  margin: 12px 0 0;
  line-height: 1.5;
  max-width: 52rem;
}

@media (max-width: 900px) {
  #broker .dashboard-split {
    grid-template-columns: 1fr;
  }

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

/* ── Trading Terminal ── */
#trading.section {
  display: none;
}

#trading.section.active,
#netposition.section.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

#netposition.section {
  display: none;
}

/* Trading terminal — always pro dark (even in light mode) */
.trading-terminal {
  --tt-bg: #070d1a;
  --tt-panel: #0c1528;
  --tt-panel-hover: #111d35;
  --tt-border: #1a2d4d;
  --tt-text: #e8eef7;
  --tt-muted: #8b9cb8;
  --tt-head: #dce6f5;
  --tt-input: #0a1220;
  --tt-row-h: 36px;
  background: var(--tt-bg);
  border-radius: 14px;
  padding: 8px;
  color: var(--tt-text);
  width: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.trading-terminal .tt-header,
.trading-terminal .tt-panel,
.trading-terminal .tt-stat,
.trading-terminal .tt-header-clock,
.trading-terminal .tt-view-tabs,
.trading-terminal .tt-order-stats {
  background: var(--tt-panel);
  border-color: var(--tt-border);
  color: var(--tt-text);
}

.trading-terminal .tt-tagline,
.trading-terminal .tt-stat-label,
.trading-terminal .tt-stat-meta,
.trading-terminal .tt-muted,
.trading-terminal .tt-table .tt-muted {
  color: var(--tt-muted);
}

.trading-terminal .tt-form select,
.trading-terminal .tt-form input {
  background: var(--tt-input);
  border: 1px solid var(--tt-border);
  color: var(--tt-text);
}

.trading-terminal .tt-table th {
  background: #0a1220;
  color: var(--tt-head);
  border-bottom: 1px solid var(--tt-border);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trading-terminal .tt-panel-head h3 {
  color: var(--tt-head);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.trading-terminal .tt-scroll-body {
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
  overflow: auto;
  width: 100%;
}

/* Fixed 14-row viewport — flex min-height was collapsing to content */
.trading-terminal .tt-scroll-body.tt-scroll-15 {
  flex: 0 0 auto !important;
  height: 504px !important;
  min-height: 504px !important;
  max-height: 504px !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  display: block !important;
}

.trading-terminal .tt-data-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.trading-terminal .tt-orderbook-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.trading-terminal .tt-positions-full {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.trading-terminal .tt-mode-live-badge {
  background: rgba(239, 68, 68, 0.25);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.trading-terminal .tt-table td {
  border-bottom: 1px solid rgba(26, 45, 77, 0.6);
  color: var(--tt-text);
}

.trading-terminal .tt-table tbody tr:hover {
  background: var(--tt-panel-hover);
}

.trading-terminal .tt-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.trading-terminal .tt-scroll-body {
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.trading-terminal .tt-scroll-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.trading-terminal .tt-scroll-body::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 99px;
}

.trading-terminal .tt-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.trading-terminal .tt-sync-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--tt-muted);
}

.trading-terminal .tt-sync-status.ok { color: #34d399; }
.trading-terminal .tt-sync-status.syncing { color: #fbbf24; }
.trading-terminal .tt-sync-status.err { color: #f87171; }

.trading-terminal .tt-market-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.2);
  color: var(--tt-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trading-terminal .tt-market-pill.open {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.trading-terminal .tt-market-pill.closed {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.trading-terminal .tt-order-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  flex-shrink: 0;
}

.trading-terminal .tt-mini-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 14px;
  background: var(--tt-input);
  border-radius: 8px;
  min-width: 90px;
}

.trading-terminal .tt-mini-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tt-muted);
}

.trading-terminal .tt-mini-val {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trading-terminal .tt-mini-val.complete { color: #60a5fa; }
.trading-terminal .tt-mini-val.pending { color: #fbbf24; }
.trading-terminal .tt-mini-val.cancel { color: #a78bfa; }
.trading-terminal .tt-mini-val.reject { color: #f87171; }

.trading-terminal .tt-chip-count {
  display: inline-flex;
  min-width: 18px;
  justify-content: center;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 700;
}

.trading-terminal .tt-chip.active .tt-chip-count {
  background: rgba(255, 255, 255, 0.15);
}

.trading-terminal .tt-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.trading-terminal .tt-badge-complete,
.trading-terminal .tt-badge-open {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.trading-terminal .tt-badge-pending {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.trading-terminal .tt-badge-cancel {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.trading-terminal .tt-badge-reject {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.trading-terminal .tt-side {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}

.trading-terminal .tt-side-buy {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.trading-terminal .tt-side-sell {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.trading-terminal .tt-mode-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
}

.trading-terminal .tt-mode-live {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.trading-terminal .tt-mode-paper {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

.trading-terminal .tt-mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 11px;
}

.trading-terminal .tt-time {
  font-size: 11px;
  color: var(--tt-muted);
  white-space: nowrap;
}

.trading-terminal .tt-empty {
  text-align: center;
  padding: 28px 12px !important;
  color: var(--tt-muted);
  font-size: 13px;
}

.trading-terminal .tt-stat-value.pnl-pos { color: #34d399; }
.trading-terminal .tt-stat-value.pnl-neg { color: #f87171; }
.trading-terminal .tt-stat-value.tt-stat-flat { color: var(--tt-text); }

.trading-terminal .tt-stat {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.trading-terminal .tt-stat-value {
  letter-spacing: -0.02em;
}

.trading-terminal .tt-action-grid button {
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 42px;
}

.trading-terminal .tt-refresh-btn {
  border: 1px solid var(--tt-border);
  color: var(--tt-text);
}

.trading-terminal .tt-filter-chips {
  background: var(--tt-input);
  border: 1px solid var(--tt-border);
}

.trading-terminal .tt-chip.active {
  background: rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}

.trading-terminal .tt-chip[data-order-filter="reject"].active {
  background: rgba(239, 68, 68, 0.25);
  color: #fecaca;
}

.trading-terminal .pnl-pos { color: #34d399; font-weight: 700; }
.trading-terminal .pnl-neg { color: #f87171; font-weight: 700; }

.trading-terminal .tt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--gradient-hero);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  flex-shrink: 0;
}

.trading-terminal .tt-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trading-terminal .tt-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #10b981);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.trading-terminal .tt-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.trading-terminal .tt-tagline {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.trading-terminal .tt-header-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  min-width: 220px;
}

.trading-terminal .tt-clock-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.trading-terminal .tt-clock {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-accent);
}

.trading-terminal .tt-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trading-terminal .tt-mode-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.trading-terminal .tt-broker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.trading-terminal .tt-broker-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.trading-terminal .tt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.trading-terminal .tt-view-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.trading-terminal .tt-view-tab {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.trading-terminal .tt-view-tab:hover {
  background: var(--btn-sidebar-hover);
  color: var(--text-main);
}

.trading-terminal .tt-view-tab.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.trading-terminal .tt-view-tab-live.active {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.trading-terminal .tt-toolbar-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.trading-terminal .tt-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  flex-shrink: 0;
}

.trading-terminal .tt-stat {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trading-terminal .tt-stat.accent-blue { border-left: 3px solid var(--accent-blue); }
.trading-terminal .tt-stat.accent-green { border-left: 3px solid var(--accent-green); }
.trading-terminal .tt-stat.accent-purple { border-left: 3px solid var(--accent-purple); }
.trading-terminal .tt-stat.accent-amber { border-left: 3px solid var(--accent-amber); }
.trading-terminal .tt-stat.accent-danger { border-left: 3px solid #ef4444; }

.trading-terminal .tt-order-filters {
  padding: 8px 12px;
  border-bottom: 1px solid var(--tt-border);
  background: var(--tt-input);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trading-terminal .tt-symbol-search {
  width: 100%;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--tt-border);
  background: var(--tt-panel);
  color: var(--tt-text);
  font-size: 13px;
}

.trading-terminal .tt-desk-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.trading-terminal .tt-desk-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--tt-border);
  background: var(--tt-input);
  color: var(--tt-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.trading-terminal .tt-desk-tab.active {
  background: rgba(59, 130, 246, 0.25);
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.45);
}

.trading-terminal .tt-mode-hint {
  font-size: 10px;
  color: var(--tt-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trading-terminal .tt-cancel-btn {
  padding: 4px 8px;
  font-size: 11px;
  min-width: 56px;
}

.trading-terminal .tt-desk-panel.hidden {
  display: none !important;
}

.trading-terminal .tt-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trading-terminal .tt-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trading-terminal .tt-stat-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.trading-terminal .tt-layout:not(.tt-layout-full) {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.trading-terminal .tt-layout.tt-layout-full {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100% !important;
  overflow: hidden;
}

.trading-terminal .tt-sidebar,
.trading-terminal .tt-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.trading-terminal .tt-panel {
  background: var(--tt-panel);
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

.trading-terminal .tt-order-entry {
  flex-shrink: 0;
}

.trading-terminal .tt-positions-panel {
  flex: 1;
  min-height: 120px;
}

.trading-terminal .tt-orderbook-panel {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

.trading-terminal .trade-ledger-table,
.trading-terminal .tt-table {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
}

.trading-terminal .tt-toolbar,
.trading-terminal .tt-order-stats,
.trading-terminal .tt-summary-grid,
.trading-terminal .tt-header {
  flex-shrink: 0;
  width: 100%;
}

.trading-terminal .tt-summary-grid {
  width: 100%;
}

.trading-terminal .tt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.trading-terminal .tt-panel-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--tt-head);
}

.trading-terminal .tt-panel-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trading-terminal .tt-filter-chips {
  display: flex;
  gap: 4px;
  padding: 2px;
  background: var(--bg-input);
  border-radius: 8px;
}

.trading-terminal .tt-chip {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.trading-terminal .tt-chip:hover {
  color: var(--text-main);
}

.trading-terminal .tt-chip.active {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.trading-terminal .tt-export-btn {
  font-size: 11px;
  padding: 4px 10px;
}

.trading-terminal .tt-scroll-body:not(.tt-scroll-15) {
  flex: 1;
  min-height: 0;
}

.trading-terminal .tt-scroll-body-lg {
  max-height: none;
}

.trading-terminal .tt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.trading-terminal .tt-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0a1220;
}

.trading-terminal .tt-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tt-head);
  border-bottom: 1px solid var(--tt-border);
  white-space: nowrap;
}

.trading-terminal .tt-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.trading-terminal .tt-table-compact td,
.trading-terminal .tt-table-compact th {
  padding: 6px 8px;
}

.trading-terminal .tt-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.trading-terminal .tt-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

.trading-terminal .tt-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
}

.trading-terminal .tt-form select,
.trading-terminal .tt-form input {
  width: 100%;
}

.trading-terminal .tt-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 14px 14px;
}

.trading-terminal .tt-action-grid button {
  padding: 10px;
  font-weight: 700;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .trading-terminal .tt-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .trading-terminal .tt-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #trading.section.active,
  #netposition.section.active {
    overflow: visible;
  }

  .trading-terminal .tt-scroll-body.tt-scroll-15,
  .trading-terminal .tt-scroll-body.tt-scroll-fill {
    height: 52vh !important;
    min-height: 280px !important;
    max-height: 52vh !important;
  }
}

@media (max-width: 600px) {
  .trading-terminal .tt-summary-grid {
    grid-template-columns: 1fr;
  }

  .trading-terminal .tt-header-clock {
    min-width: auto;
    width: 100%;
  }

  .trading-terminal .tt-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Force dark terminal even in light theme */
[data-mode="light"] .trading-terminal,
.trading-terminal {
  --tt-bg: #070d1a;
  --tt-panel: #0c1528;
  --tt-text: #e8eef7;
  --tt-head: #eef3fb;
  --tt-muted: #94a3b8;
  --tt-border: #1e3354;
  background: var(--tt-bg) !important;
  color: var(--tt-text) !important;
}

[data-mode="light"] .trading-terminal .tt-panel,
[data-mode="light"] .trading-terminal .tt-stat,
[data-mode="light"] .trading-terminal .tt-mini-stat,
[data-mode="light"] .trading-terminal .tt-order-stats,
[data-mode="light"] .trading-terminal .tt-header,
[data-mode="light"] .trading-terminal .tt-header-clock,
[data-mode="light"] .trading-terminal .tt-view-tabs {
  background: var(--tt-panel) !important;
  border-color: var(--tt-border) !important;
  color: var(--tt-text) !important;
}

.trading-terminal .tt-panel-head h3,
.trading-terminal .tt-table th,
.trading-terminal .trade-ledger-table th {
  color: var(--tt-head) !important;
}

.trading-terminal .tt-stat-label,
.trading-terminal .tt-mini-label {
  color: #8fa3c0 !important;
}

.trading-terminal .tt-stat-value {
  color: #f8fafc !important;
}

.trading-terminal .tt-title {
  color: #f8fafc !important;
}

.trading-terminal .trade-ledger-table td,
.trading-terminal .tt-table td {
  color: #dbe4f0 !important;
}

.trading-terminal .tt-table thead,
.trading-terminal .trade-ledger-table thead {
  background: #081018 !important;
}

.trading-terminal .tt-export-btn,
.trading-terminal .tt-refresh-btn {
  color: #cbd5e1 !important;
  border-color: var(--tt-border) !important;
}

/* Final layout overrides — full width + split height */
.trading-terminal .tt-layout.tt-layout-full,
.trading-terminal .tt-main.tt-main-full {
  width: 100% !important;
  max-width: 100% !important;
}

.trading-terminal .tt-layout.tt-layout-full {
  display: flex !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  grid-template-columns: none !important;
}

.trading-terminal .tt-orderbook-panel .tt-scroll-body.tt-scroll-15 {
  flex: 0 0 auto !important;
  height: 504px !important;
  min-height: 504px !important;
  max-height: 504px !important;
  overflow-y: auto !important;
}

.trading-terminal .tt-table td {
  padding: 8px 10px;
  vertical-align: middle;
  box-sizing: border-box;
}

.trading-terminal .tt-table th {
  padding: 0 10px;
  vertical-align: middle;
  box-sizing: border-box;
}

