:root {
  --bg: #eef2f8;
  --bg-mesh-1: rgba(99, 102, 241, 0.09);
  --bg-mesh-2: rgba(14, 165, 233, 0.07);
  --bg-mesh-3: rgba(16, 185, 129, 0.05);
  --panel: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.88);
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --soft: #f8fafc;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.1);
  --radius-lg: 16px;
  --radius-xl: 20px;
  /* Unified UI type scale (13px base for controls & values) */
  --fs-label: 0.6875rem;
  --fs-ui: 0.8125rem;
  --fs-body: 0.8125rem;
  --fs-value: 0.8125rem;
  --fs-quote: 0.9375rem;
}

* { box-sizing: border-box; }
.app-body,
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--bg-mesh-1), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, var(--bg-mesh-2), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, var(--bg-mesh-3), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea {
  font: inherit;
  font-size: var(--fs-ui);
}
.app-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 0 20px 32px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  background: var(--panel-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.stack-col { display: flex; flex-direction: column; gap: 0.85rem; }
.brand span, .quote span, .market-status span, label, .muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 0.65rem; flex: 0 0 auto; }
.brand-icon { height: 48px; width: 48px; border-radius: 10px; display: block; }
.brand-title { font-size: 1rem; font-weight: 700; line-height: 1.2; color: var(--text); white-space: nowrap; }
.brand-logo { height: 56px; width: auto; object-fit: contain; display: block; max-width: 100%; }
.brand span { display: block; font-size: 0.88rem; font-weight: 700; line-height: 1.2; }
.brand strong { display: none; }
.market-strip, .actions, .topbar-end, .modal-actions, .report-actions, .panel-actions { display: flex; align-items: center; gap: 10px; }
.topbar-end {
  flex: 0 0 auto;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.market-strip {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}
.market-strip::-webkit-scrollbar { height: 6px; }
.market-strip::-webkit-scrollbar-thumb { background: rgba(103, 117, 134, 0.35); border-radius: 99px; }
.market-status, .quote {
  min-height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border-radius: var(--radius-lg);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.quote:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.quote {
  border-left: none;
  min-width: 240px;
  max-width: 320px;
  justify-content: space-between;
  padding: 12px 20px;
  position: relative;
  overflow: hidden;
}
.quote::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--blue) 0%, #6366f1 100%);
  border-radius: 3px 0 0 3px;
  opacity: 0.85;
}
.market-status {
  min-height: 40px;
  min-width: 0;
  border-radius: 12px;
  padding: 6px 12px;
}
.market-status > div { display: flex; flex-direction: column; line-height: 1.15; gap: 1px; }
.market-status strong { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; }
.market-status .muted { font-size: 0.68rem; color: var(--muted); }
.quote-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
}
.quote-values {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}
.quote-main-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quote-value-main { font-size: var(--fs-quote); font-weight: 800; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.quote.positive .quote-change {
  color: var(--green);
}
.quote.negative .quote-change {
  color: var(--red);
}
.quote-change, .quote-pts {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.market-status i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.market-status i.open { background: var(--green); animation: pulseDot 2.2s ease-in-out infinite; }
.market-status.open strong { color: var(--green); }
.market-status.closed strong { color: var(--red); }
.quote-label { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; margin-bottom: 2px; text-align: center; }
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

button, a {
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid #cfd8e3;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
button:hover, a:hover { border-color: var(--blue); background: var(--blue-soft); }
button:disabled, input:disabled { opacity: 0.55; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover { background: #0f5dbc; border-color: #0f5dbc; }
.danger { color: var(--red); border-color: #f0b79e; }
.secondary { background: #fff; }
.small { min-height: 28px; }
.actions { flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.actions button,
.btn-toolbar {
  white-space: nowrap;
  min-width: 0;
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn-toolbar:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-toolbar-muted {
  background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
  border-color: var(--line-strong);
  color: #334155;
}
.btn-toolbar-muted:hover:not(:disabled) {
  background: #fff;
  border-color: var(--blue);
  color: var(--blue);
}
.btn-toolbar-start {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  border-color: #15803d;
  color: #fff;
}
.btn-toolbar-start:hover:not(:disabled):not(.btn-start-locked) {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  color: #fff;
}
.btn-toolbar-start:disabled,
.btn-toolbar-start.btn-start-locked {
  background: linear-gradient(180deg, #d1d5db 0%, #9ca3af 100%);
  border-color: #9ca3af;
  color: #f9fafb;
  opacity: 1;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-toolbar-stop {
  background: linear-gradient(180deg, #fff 0%, #fef2f2 100%);
  border-color: #fecaca;
  color: var(--red);
}
.btn-toolbar-stop:hover:not(:disabled) {
  background: #fef2f2;
  border-color: var(--red);
  color: #b91c1c;
}
.btn-toolbar-warn {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  color: #b45309;
}
.btn-toolbar-install {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border: 1px solid #4338ca;
  color: #fff;
  font-weight: 700;
  min-height: 36px;
  padding: 0 14px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
.btn-toolbar-install:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
}
.btn-toolbar-install[hidden] { display: none !important; }
.actions button {
  min-width: 80px;
}
.panel-actions button:not(.btn-settings) {
  white-space: nowrap;
  min-width: 52px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.88rem;
}

/* Capital panel: Defaults | Save | Reset */
.settings-actions {
  gap: 5px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
.settings-actions .btn-settings {
  min-height: 26px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.settings-actions .btn-settings:hover:not(:disabled) {
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.1);
}
.settings-actions .btn-settings-defaults {
  background: linear-gradient(180deg, #5b6fd6 0%, #4a5fc9 100%);
  border-color: #3f52b8;
  color: #fff;
}
.settings-actions .btn-settings-defaults:hover:not(:disabled) {
  background: linear-gradient(180deg, #4f63cb 0%, #3f4fba 100%);
  border-color: #3a4da8;
  color: #fff;
}
.settings-actions .btn-settings-save {
  background: linear-gradient(180deg, #1a7ae8 0%, #1769d4 100%);
  border-color: #145ebf;
  color: #fff;
}
.settings-actions .btn-settings-save:hover:not(:disabled) {
  background: linear-gradient(180deg, #156dcc 0%, #0f5dbc 100%);
  border-color: #0d52a8;
  color: #fff;
}
.settings-actions .btn-settings-reset {
  background: linear-gradient(180deg, #e8893a 0%, #d97706 100%);
  border-color: #c56a05;
  color: #fff;
}
.settings-actions .btn-settings-reset:hover:not(:disabled) {
  background: linear-gradient(180deg, #db7c2f 0%, #c56a05 100%);
  border-color: #b35f04;
  color: #fff;
}
.settings-actions .btn-settings:disabled {
  opacity: 0.5;
  filter: grayscale(0.35);
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}
.grid { display: grid; gap: 12px; }
@media (max-width: 1040px) {
  .topbar { justify-content: flex-start; }
  .market-strip { flex: 1 1 100%; }
  .actions { flex: 1 1 100%; justify-content: flex-start; }
}
@media (max-width: 720px) {
  .market-status, .quote { min-width: 140px; padding: 10px 12px; }
  .actions { gap: 8px; }
}
.hero-grid { grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.85fr); gap: 18px; align-items: start; }
.main-grid { grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr); margin-bottom: 12px; }
.panel {
  background: linear-gradient(165deg, #ffffff 0%, #fafbfd 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  box-shadow: var(--shadow-md);
  border-top: 4px solid #94a3b8;
  position: relative;
  overflow: hidden;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.5) 0%, transparent 42%);
  pointer-events: none;
}
.panel > * { position: relative; z-index: 1; }
.panel-elevated { box-shadow: var(--shadow-lg); }
.panel-accent-capital { border-top-color: #3b82f6; }
.panel-accent-slate { border-top-color: #64748b; }
.panel-accent-paytm { border-top-color: #0ea5e9; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.panel-head > h2 {
  flex: 0 0 auto;
  white-space: nowrap;
}
.panel-head .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.panel-head .panel-actions {
  margin-left: auto;
  gap: 8px;
  flex: 0 0 auto;
}
h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--blue) 0%, #6366f1 100%);
  flex-shrink: 0;
}
.muted { font-size: var(--fs-body); line-height: 1.4; color: var(--muted); }

/* Compact export links — not full-size toolbar buttons */
.report-actions { gap: 6px; flex-wrap: wrap; }
.report-actions a {
  min-height: 26px;
  min-width: 0;
  padding: 0 10px;
  font-size: var(--fs-ui);
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  color: #475569;
  box-shadow: none;
}
.report-actions a:hover {
  background: var(--blue-soft);
  border-color: #93c5fd;
  color: var(--blue);
}

.strategy-card {
  border-top-width: 4px;
  min-height: 100px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(226, 232, 240, 0.9);
}
.strategy-card strong,
.strategy-card span,
.strategy-card div {
  color: #1f2933;
}
.strategy-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.strategy-card-title {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}
.strategy-signal-main {
  font-size: var(--fs-quote);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.strategy-signal-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.strategy-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.strategy-gate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.strategy-gate {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  line-height: 1.3;
}

.strategy-gate.gate-ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.strategy-gate.gate-fail {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.strategy-gate.gate-neutral {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.strategy-card-description {
  font-size: 0.79rem;
  color: #475569;
  line-height: 1.3;
  min-height: 1.2rem;
}

.strategy-block-hint {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.35rem;
}

.strategy-block-hint.block-hint-dte {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.strategy-block-hint.block-hint-mqi {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.strategy-block-hint.block-hint-other {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
}

.strategy-card-detail {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.25;
}
.strategy-rejection {
  color: #b91c1c;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  margin-top: 0;
}
.strategy-card-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
}
.strategy-card-meta div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.strategy-card-meta label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}
.strategy-card-meta strong {
  font-size: var(--fs-value);
  font-weight: 700;
  color: #0f172a;
}
.strategy-card-meta span {
  font-size: 0.76rem;
  color: #475569;
}
.strategy-card.active-buy { border-top-color: #10b981; }
.strategy-card.active-sell { border-top-color: #ef4444; }
.strategy-card.active-hold { border-top-color: #f59e0b; }
.strategy-card.active-idle { border-top-color: #64748b; }
.strategy-card.active-buy .strategy-signal-badge { background: rgba(16, 185, 129, 0.15); color: #065f46; }
.strategy-card.active-sell .strategy-signal-badge { background: rgba(239, 68, 68, 0.12); color: #991b1b; }
.strategy-card.active-hold .strategy-signal-badge { background: rgba(245, 158, 11, 0.12); color: #92400e; }
.strategy-card.active-idle .strategy-signal-badge { background: rgba(100, 116, 139, 0.14); color: #334155; }
.chip {
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}
.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.small-note { font-size: 0.7rem; color: var(--muted); margin-left: 8px; }
.halt-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid #fdba74;
  background: linear-gradient(90deg, #fff7ed 0%, #ffedd5 100%);
  color: #9a3412;
  font-size: 0.84rem;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}
.halt-banner[hidden] { display: none !important; }
.halt-banner strong { font-weight: 800; white-space: nowrap; }

.api-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: var(--fs-body);
  line-height: 1.4;
}
.api-banner-wait {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  color: #92400e;
}
.api-banner-error {
  background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #fecaca;
  color: #991b1b;
}
.api-banner[hidden] { display: none !important; }
.api-banner strong { font-weight: 800; white-space: nowrap; }
.strategy-health-panel { border-top-color: #6366f1; }
.strategy-health-body { font-size: 0.82rem; line-height: 1.45; display: flex; flex-direction: column; gap: 8px; }
.strategy-health-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.strategy-health-row strong { font-size: 0.84rem; }
.strategy-health-empty {
  margin: 0;
  padding: 4px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}
.health-pill { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
.health-pill.ok { background: #dcfce7; color: #166534; }
.health-pill.watch { background: #fef9c3; color: #854d0e; }
.health-pill.decay { background: #fee2e2; color: #991b1b; }
.promotion-pass { color: var(--green); font-weight: 700; }
.promotion-fail { color: var(--red); font-weight: 700; }
button.primary {
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-deep) 100%);
  border-color: var(--blue-deep);
  color: #fff;
  font-weight: 700;
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  color: #fff;
}
.checkbox-row input[type="checkbox"] {
  min-height: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}
.modal .modal-actions { flex-wrap: wrap; gap: 8px; }
.neutral { background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%); color: #475569; border-color: #cbd5e1; }
.info { background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%); color: #1d4ed8; border-color: #93c5fd; }
.good { background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%); color: #047857; border-color: #6ee7b7; }
.bad { background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%); color: #b91c1c; border-color: #fca5a5; }
.warn { background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%); color: #b45309; border-color: #fcd34d; }
.health-badge {
  min-height: 25px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}
.health-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(160deg, #fff 0%, #f8fafc 100%);
  padding: 9px 10px;
  min-height: 50px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.health-grid label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  white-space: normal;
}
.health-grid strong {
  display: block;
  margin-top: 3px;
  font-size: var(--fs-value);
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
.health-grid strong.good { color: #047857; }
.health-grid strong.bad { color: #b91c1c; }
.health-grid strong.warn { color: #b45309; }
.health-grid strong.neutral { color: var(--text); }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.mini-grid > div {
  background: linear-gradient(160deg, #ffffff 0%, var(--soft) 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  align-self: start;
  width: 100%;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mini-grid > div:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.mini-grid .highlight {
  background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #93c5fd;
}
.mini-grid .highlight strong { color: var(--blue-deep); font-size: var(--fs-value); font-weight: 700; }
.mini-grid .pnl-positive-bg { background: var(--green-soft); border-color: #d1eadd; }
.mini-grid .pnl-negative-bg { background: var(--red-soft); border-color: #f8d7d7; }

.mini-grid label {
  display: block;
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}
.mini-grid strong,
.mini-grid .stat-value {
  font-size: var(--fs-value);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.mini-grid .stat-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}
.mini-grid .stat-sep {
  color: var(--muted);
  font-size: var(--fs-value);
  font-weight: 600;
  line-height: 1.25;
}
.mini-grid .stat-input {
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 0;
  height: auto;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--fs-value);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.mini-grid .stat-input-compact {
  width: 2.5rem;
  flex: 0 0 auto;
}
.mini-grid .stat-input:focus {
  outline: none;
  box-shadow: none;
  border-bottom: 1px dashed var(--blue);
}

.capital-form { display: grid; grid-template-columns: minmax(150px, 1.2fr) repeat(2, minmax(120px, 0.95fr)); gap: 10px; align-items: end; }
label { display: grid; gap: 4px; font-size: var(--fs-label); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
.capital-form label { white-space: normal; }
.capital-form input[type="number"] {
  font-size: var(--fs-ui);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
input {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  outline: 0;
  background: #fff;
}
.risk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.table-like {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.table-like.empty {
  padding: 22px;
  color: var(--muted);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.5;
}
.row { min-width: 0; display: grid; grid-template-columns: minmax(70px, 0.9fr) minmax(140px, 1.6fr) minmax(70px, 1fr) minmax(70px, 1fr) minmax(70px, 1fr) minmax(70px, 1fr) minmax(80px, 1fr) minmax(80px, 1fr) minmax(95px, 1fr); border-top: 1px solid rgba(226, 232, 240, 0.95); }
.row:first-child { border-top: 0; }
.row span { padding: 9px 11px; color: var(--text); font-size: var(--fs-ui); white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.row.head {
  background: linear-gradient(180deg, #f1f5f9 0%, #e8eef5 100%);
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.row.head span { color: var(--muted); }
.row:not(.head):hover { background: rgba(37, 99, 235, 0.04); }
.row:not(.head):nth-child(even) { background: rgba(248, 250, 252, 0.65); }
.row .pnl-positive { color: var(--green); }
.row .pnl-negative { color: var(--red); }
.row .btn-small { padding: 6px 10px; }
.position-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-edit {
  border: 1px solid #b7c6d8;
  background: #ffffff;
  color: var(--blue);
  border-radius: 10px;
  font-weight: 700;
}
.btn-edit:hover:not(:disabled) {
  background: var(--blue-soft);
  border-color: var(--blue);
}
.btn-exit {
  border: 1px solid var(--red);
  background: transparent;
  color: var(--red);
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease, opacity 120ms ease;
}
.btn-exit:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.18);
  transform: translateY(-1px);
}
.btn-exit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.manual-control-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-top: 4px;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.62rem;
  font-weight: 800;
  white-space: nowrap;
}
.pnl-positive { color: var(--green); font-weight: 600; }
.pnl-negative { color: var(--red); font-weight: 600; }
.pnl-neutral { color: var(--muted); }
.snapshot-list { display: grid; gap: 10px; }
.snapshot {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(160deg, #fff 0%, #f8fafc 100%);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-sm);
}
.snapshot strong { color: #0f172a; }
.error-text { color: var(--red); font-size: 0.88rem; line-height: 1.5; }
dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: var(--radius-xl);
  padding: 0;
  box-shadow: var(--shadow-lg);
  overflow: visible;
  max-height: none;
  background: #fff;
  color: var(--text);
}
#paytmDialog {
  overflow-y: auto;
  max-height: min(90vh, 720px);
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}
.modal {
  padding: 18px;
  display: grid;
  gap: 12px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
/* Paytm connect dialog — isolated from global label { display:grid; nowrap } rules */
#paytmDialog form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  margin: 0;
  background: #fff;
  box-sizing: border-box;
}
#paytmDialog .paytm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}
#paytmDialog .paytm-modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  color: #0f172a;
  line-height: 1.3;
}
#paytmDialog .paytm-modal-close {
  width: 32px;
  min-height: 32px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #64748b;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
#paytmDialog .paytm-modal-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
}
#paytmDialog .paytm-modal-hint[hidden] {
  display: none !important;
}
#paytmDialog .paytm-dialog-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  border: 1px solid transparent;
}
#paytmDialog .paytm-dialog-message[hidden] {
  display: none !important;
}
#paytmDialog .paytm-dialog-message.info {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}
#paytmDialog .paytm-dialog-message.success {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}
#paytmDialog .paytm-dialog-message.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}
#paytmDialog .paytm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#paytmDialog .paytm-field > label {
  display: block !important;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  white-space: normal !important;
}
#paytmDialog .paytm-field input {
  display: block;
  width: 100%;
  min-height: 38px;
  box-sizing: border-box;
}
#paytmDialog a.paytm-inline-link {
  display: inline;
  min-height: 0 !important;
  height: auto;
  padding: 0 !important;
  margin: 0;
  border: none !important;
  border-radius: 0;
  background: none !important;
  box-shadow: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #2563eb !important;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
#paytmDialog a.paytm-inline-link:hover {
  color: #1d4ed8 !important;
  background: none !important;
  border: none !important;
}
#paytmDialog .paytm-inline-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
#paytmDialog .paytm-inline-links .paytm-inline-link[hidden] {
  display: none !important;
}
#paytmDialog .paytm-btn-secondary,
#paytmDialog .paytm-btn-primary {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 0.8125rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  width: auto;
}
#paytmDialog .paytm-btn-primary {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #fff;
}
#paytmDialog .paytm-btn-secondary {
  background: #fff;
  color: #0f172a;
}
#paytmDialog .paytm-remember {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}
#paytmDialog .paytm-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin-top: 2px;
  flex-shrink: 0;
}
#paytmDialog .paytm-remember > label {
  display: block !important;
  flex: 1;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  color: #64748b;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal !important;
}
#paytmDialog .paytm-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.modal-context {
  color: var(--text);
  font-size: var(--fs-value);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.control-current-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.control-current-values div {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}
.control-current-values label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.control-current-values strong {
  margin-top: 4px;
  display: block;
  font-size: var(--fs-value);
  font-weight: 600;
}
.icon-button { width: 32px; min-height: 32px; border-radius: 50%; padding: 0; }
.login-link { display: none; }
.login-link.show,
.paytm-login-row .login-link.show { display: inline-flex; align-items: center; font-weight: 700; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 9999;
}
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1060px) {
  .topbar, .hero-grid, .main-grid { grid-template-columns: 1fr; }
  .market-strip { overflow-x: auto; flex-wrap: nowrap; }
  .table-like.positions-table {
    overflow-x: auto;
  }
}
.table-like.positions-table,
.table-like.history-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* Open positions + trade history: real tables so numeric columns size to content (no ellipsis) */
.trade-data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.72rem;
  line-height: 1.35;
}
.trade-data-table .num-cell {
  display: block;
  width: 100%;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.trade-data-table th.col-qty,
.trade-data-table td.col-qty,
.trade-data-table th.col-num,
.trade-data-table td.col-num,
.trade-data-table th.col-pnl,
.trade-data-table td.col-pnl {
  text-align: left;
}
/* Column widths as % so the table always fills the card (no dead space on the right) */
.trade-positions-table col:nth-child(1) { width: 32%; }
.trade-positions-table col:nth-child(2) { width: 7%; }
.trade-positions-table col:nth-child(3) { width: 9%; }
.trade-positions-table col:nth-child(4) { width: 9%; }
.trade-positions-table col:nth-child(5) { width: 9%; }
.trade-positions-table col:nth-child(6) { width: 9%; }
.trade-positions-table col:nth-child(7) { width: 14%; }
.trade-positions-table col:nth-child(8) { width: 11%; }
.trade-history-table col:nth-child(1) { width: 28%; }
.trade-history-table col:nth-child(2) { width: 7%; }
.trade-history-table col:nth-child(3) { width: 12%; }
.trade-history-table col:nth-child(4) { width: 12%; }
.trade-history-table col:nth-child(5) { width: 14%; }
.trade-history-table col:nth-child(6) { width: 27%; }
.trade-data-table th,
.trade-data-table td {
  padding: 7px 8px;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
  vertical-align: middle;
}
.trade-data-table thead tr:first-child th {
  border-top: 0;
}
.trade-data-table thead th {
  background: linear-gradient(180deg, #f1f5f9 0%, #e8eef5 100%);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.trade-data-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}
.trade-data-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.65);
}
.trade-data-table tbody tr:nth-child(even):hover {
  background: rgba(37, 99, 235, 0.04);
}
.trade-data-table .col-qty,
.trade-data-table .col-num,
.trade-data-table .col-pnl {
  white-space: nowrap;
}
.trade-data-table .col-pnl,
.trade-data-table .col-pnl .num-cell {
  font-weight: 700;
}
.trade-data-table .col-reason,
.trade-data-table th.col-reason {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trade-data-table .col-contract {
  text-align: left;
  min-width: 7.5rem;
}
.trade-data-table th.col-action,
.trade-data-table td.col-action {
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}
.trade-data-table .contract-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.trade-data-table .contract-primary {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
}
.trade-data-table .contract-primary strong {
  font-weight: 700;
  white-space: nowrap;
}
.trade-data-table .contract-primary .manual-control-badge {
  flex-shrink: 0;
  margin: 0;
}
.trade-data-table .col-action .btn-small {
  display: inline-block;
  padding: 4px 8px;
  font-size: 0.62rem;
  line-height: 1.2;
  margin: 0;
}
.pos-edit-link {
  border: 0;
  background: none;
  padding: 0;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pos-edit-link:hover:not(:disabled) {
  color: var(--blue-deep);
}
.pos-edit-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#pnlBox .stat-value {
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
}
#pnlBox .pnl-sub {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}
#pnlBox .pnl-positive,
.trade-data-table .col-pnl.pnl-positive {
  color: var(--green);
  font-weight: 700;
}
#pnlBox .pnl-negative,
.trade-data-table .col-pnl.pnl-negative {
  color: var(--red);
  font-weight: 700;
}
#pnlBox .pnl-neutral {
  color: var(--muted);
}
.trade-data-table .hist-contract {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
}
.trade-data-table .hist-contract-text {
  font-weight: 600;
  white-space: nowrap;
}
.trade-data-table .hist-mode {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  min-height: 15px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.15;
}
.trade-data-table .col-pnl.pnl-neutral {
  color: var(--muted);
}
.fill-meta { font-size: 0.72rem; color: var(--muted); }
.fill-good { color: var(--green); font-weight: 700; }
.fill-ok { color: var(--amber); font-weight: 700; }
.fill-bad { color: var(--red); font-weight: 700; }
.fill-neutral { color: var(--muted); }
.portfolio-greeks-body { display: grid; gap: 10px; font-size: 0.84rem; }
.greeks-summary { display: flex; flex-wrap: wrap; gap: 12px; }
.greeks-summary span { background: #f8fbff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.greeks-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.greeks-table th, .greeks-table td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; }
@media (max-width: 720px) {
  .app-shell { padding: 0 10px calc(22px + env(safe-area-inset-bottom)); }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 12px;
  }
  .brand { justify-content: center; }
  .market-strip { width: 100%; }
  .topbar-end {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .btn-toolbar-install {
    width: 100%;
    min-height: 44px;
    order: -1;
  }
  .actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .actions button {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    min-width: 0;
    touch-action: manipulation;
  }
  .panel-head {
    flex-wrap: wrap;
    gap: 10px;
  }
  .settings-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .settings-actions .btn-settings {
    flex: 1 1 calc(33.333% - 6px);
    min-height: 44px;
    min-width: 0;
    padding: 10px 8px;
    font-size: 0.8rem;
    touch-action: manipulation;
  }
  .mini-grid, .risk-grid, .capital-form, .health-grid, .control-current-values { grid-template-columns: 1fr; }
  .capital-form input[type="number"],
  .risk-grid input[type="number"],
  .stat-input {
    font-size: 16px;
    min-height: 44px;
    touch-action: manipulation;
  }
  .report-actions a { flex: 0 1 auto; }
  .trade-data-table {
    font-size: 0.68rem;
  }
  .trade-data-table th,
  .trade-data-table td {
    padding: 6px 6px;
  }
  .chip-row {
    flex-wrap: wrap;
    gap: 6px;
  }
}
