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

/* Lovable Strategy Panel visual system, mapped to the live Ashu dashboard. */
:root {
  --radius: 14px;
  --background: oklch(0.16 0.012 30);
  --foreground: oklch(0.86 0.025 65);
  --card: oklch(0.19 0.013 35);
  --surface: oklch(0.21 0.012 35);
  --surface-raised: oklch(0.25 0.014 35);
  --muted-foreground: oklch(0.73 0.015 50);
  --primary: oklch(0.68 0.21 35);
  --primary-foreground: oklch(0.20 0.025 35);
  --ember: oklch(0.66 0.23 32);
  --ember-glow: oklch(0.78 0.18 60);
  --success: oklch(0.72 0.17 155);
  --destructive: oklch(0.62 0.22 25);
  --border: oklch(1 0 0 / 9%);
  --gradient-ember: linear-gradient(135deg, oklch(0.72 0.24 28), oklch(0.68 0.23 40) 45%, oklch(0.62 0.2 22));
  --ink: var(--foreground);
  --muted: var(--muted-foreground);
  --line: var(--border);
  --bg: var(--background);
  --navy: oklch(0.13 0.012 30);
  --navy2: var(--surface);
  --blue: var(--primary);
  --blue-strong: var(--ember-glow);
  --cyan: var(--ember-glow);
  --green: var(--success);
  --red: var(--destructive);
  --amber: var(--ember-glow);
  --shadow: 0 12px 32px -18px oklch(0 0 0 / 80%);
}

body.app-body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% -15%, oklch(0.66 0.23 32 / 15%), transparent 35%), var(--background);
  color: var(--foreground);
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
}

/* Login uses the same ember visual language as the strategy dashboard. */
body.auth-body {
  min-height: 100vh;
  color: var(--foreground);
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 85%, oklch(0.66 0.23 32 / 18%), transparent 32%),
    radial-gradient(circle at 58% -10%, oklch(0.78 0.18 60 / 10%), transparent 28%),
    var(--background);
}

.auth-body .auth-orb { filter: blur(70px); opacity: .18; }
.auth-body .orb-one { background: var(--ember); }
.auth-body .orb-two { background: var(--ember-glow); }

.auth-body .auth-brand { color: var(--foreground); }
.auth-body .auth-brand .eyebrow { color: var(--ember-glow); }
.auth-body .auth-brand h1 {
  max-width: 760px;
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
}
.auth-body .auth-brand h1 span { color: var(--ember-glow); }
.auth-body .auth-copy { color: var(--muted-foreground); }
.auth-body .auth-points i { color: var(--ember-glow); border-color: oklch(0.78 0.18 60 / 38%); }
.auth-body .auth-points b { color: var(--foreground); }
.auth-body .auth-points small { color: var(--muted-foreground); }

.auth-body .logo-mark {
  color: var(--primary-foreground);
  background: var(--gradient-ember);
  box-shadow: 0 14px 34px oklch(0.62 0.22 30 / 30%);
}

.auth-body .login-card {
  position: relative;
  overflow: hidden;
  color: var(--foreground);
  background: color-mix(in oklab, var(--card) 96%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 30px 90px -30px oklch(0 0 0 / 90%);
}
.auth-body .login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--gradient-ember);
}
.auth-body .login-card h2 {
  color: var(--foreground);
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
}
.auth-body .login-card .muted { color: var(--muted-foreground); }
.auth-body .login-form label { color: var(--foreground); }
.auth-body .login-form input {
  color: var(--foreground);
  background: var(--surface-raised);
  border-color: oklch(1 0 0 / 12%);
  border-radius: 12px;
}
.auth-body .login-form input:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px oklch(0.66 0.23 32 / 14%);
}
.auth-body .login-form .btn-primary {
  color: var(--primary-foreground);
  background: var(--gradient-ember);
  box-shadow: 0 12px 28px oklch(0.62 0.22 30 / 22%);
}
.auth-body .login-form .btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.auth-body .alert.error {
  color: oklch(0.76 0.16 25);
  background: oklch(0.62 0.22 25 / 12%);
  border-color: oklch(0.62 0.22 25 / 24%);
}
.auth-body .alert.success {
  color: var(--success);
  background: oklch(0.72 0.17 155 / 10%);
  border-color: oklch(0.72 0.17 155 / 22%);
}

.app-body code {
  color: var(--ember-glow);
  overflow-wrap: anywhere;
}

.app-content { margin-left: 0; }
.topbar {
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1152px) / 2));
  gap: 24px;
  background: oklch(0.16 0.012 30 / 88%);
  border-color: var(--border);
  backdrop-filter: blur(18px);
}
.market-clock b, .page-title h1, .control-copy h3, .section-head h2, .section-head h3 { color: var(--foreground); }
.market-clock b { font-size: 14px; }
.market-clock small { font-size: 11px; }
.market-clock small, .page-title p, .control-copy p, .section-head p, .meta { color: var(--muted-foreground); }
.pulse-dot { background: var(--success); box-shadow: 0 0 0 5px oklch(0.72 0.17 155 / 12%); }
.navbar-ltp, .connection-pill { background: var(--surface-raised); border: 1px solid var(--border); color: var(--foreground); }

/* Keep every navbar action on the same visual rhythm regardless of label length. */
.top-actions {
  flex: 0 1 760px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.top-actions > .btn,
.top-actions > .broker-menu > .btn,
.top-actions > .connection-pill {
  width: 100%;
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
}
.nav-label-compact { display: none; }
.broker-menu {
  position: relative;
  width: 100%;
  min-width: 0;
}
.dropdown-chevron {
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .16s ease;
}
#openBrokerFormButton[aria-expanded="true"] .dropdown-chevron {
  transform: translateY(2px) rotate(225deg);
}
.broker-dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 40;
  display: none;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: 0 18px 40px -18px oklch(0 0 0 / 85%);
}
.broker-dropdown.open { display: grid; gap: 3px; }
.broker-dropdown button {
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  color: var(--foreground);
  background: transparent;
  text-align: left;
}
.broker-dropdown button:hover,
.broker-dropdown button:focus-visible {
  outline: none;
  background: oklch(1 0 0 / 6%);
}
.broker-dropdown span,
.broker-dropdown small { display: block; }
.broker-dropdown span { font-size: 12px; font-weight: 600; }
.broker-dropdown small { margin-top: 3px; color: var(--muted-foreground); font-size: 9px; }
.broker-specific .broker-modal {
  width: min(620px, 100%);
  border: 1px solid var(--border);
}
.broker-specific .modal-copy {
  display: none;
}
.broker-specific #brokerModalEyebrow {
  display: none;
}
.broker-specific .broker-choice-list {
  display: none;
}
.broker-modal .modal-form-card[hidden] {
  display: none !important;
}
#brokerModal .broker-modal {
  padding: 22px;
}
#brokerModal .modal-head {
  align-items: flex-start;
  margin: 0 0 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
#brokerModal .modal-head .eyebrow {
  margin-bottom: 5px;
}
#brokerModal .modal-head h3 {
  margin: 0;
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.2;
}
#brokerModal .modal-copy {
  max-width: 520px;
  line-height: 1.6;
}
#brokerModal .modal-close {
  width: 34px;
  height: 34px;
  font-size: 20px;
}
#brokerModal .modal-form-card:not([hidden]) {
  display: grid;
  gap: 12px;
}
#brokerModal .modal-form-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#brokerModal .modal-form-card .card-topline {
  align-items: flex-start;
  margin: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
#brokerModal .modal-form-card .card-topline strong {
  display: block;
  margin-bottom: 5px;
  font-size: 15px;
  line-height: 1.35;
}
#brokerModal .modal-form-card .broker-status-row {
  align-items: center;
  padding: 0 1px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
#brokerModal .broker-status-row .meta {
  margin-top: 2px;
  line-height: 1.55;
}
#brokerModal .broker-section-kicker {
  display: block;
  color: var(--ember-glow);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1.3;
  text-transform: uppercase;
}
#brokerModal .broker-redirect-note {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in oklab, var(--surface-raised) 68%, transparent);
}
#brokerModal .broker-redirect-note code {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: oklch(0.14 0.012 30 / 65%);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
#brokerModal :is(.upstox-fields, .icici-fields) {
  padding: 0;
  border: 0;
  background: transparent;
}
#brokerModal .upstox-fields .field label > span {
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 500;
}
#brokerModal .modal-form-card .field-grid {
  gap: 11px 12px;
}
#brokerModal .modal-form-card .field {
  gap: 5px;
}
#brokerModal .modal-form-card .field label {
  line-height: 1.35;
}
#brokerModal .modal-form-card input {
  height: 38px;
  padding-inline: 11px;
  border-radius: 9px;
  font-size: 12px;
}
#brokerModal .modal-form-card > .meta {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  line-height: 1.65;
}
#brokerModal .actions {
  align-items: center;
  margin: 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in oklab, var(--surface-raised) 72%, transparent);
}
#brokerModal .actions .meta {
  line-height: 1.55;
}
#brokerModal .broker-action-footer {
  padding: 11px 12px;
}
#brokerModal .broker-action-footer .action-row {
  flex: 0 0 auto;
}
#brokerModal .broker-action-footer :is(.save-button, .secondary-button) {
  min-width: 92px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}
#brokerModal .broker-action-footer .secondary-button {
  border: 1px solid var(--border);
  color: var(--foreground);
  background: var(--surface-raised);
}
#brokerModal .broker-action-footer .secondary-button:hover {
  border-color: oklch(0.68 0.21 35 / 40%);
  background: oklch(1 0 0 / 6%);
}
#brokerModal .save-feedback {
  min-height: 0;
  margin: 0;
  line-height: 1.5;
}
#brokerModal .save-feedback:empty {
  display: none;
}
#brokerModal .save-feedback:not(:empty) {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-raised);
}
.top-actions > .broker-init-button {
  height: 38px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
}

@media (max-width: 1000px) and (min-width: 761px) {
  .market-clock { display: none; }
  .top-actions {
    flex: 1 1 auto;
    width: 100%;
  }
}

.workspace {
  position: relative;
  width: min(1152px, calc(100% - 32px));
  max-width: none;
  margin: 34px auto 64px;
  padding: 32px;
  border: 6px solid transparent;
  border-radius: 36px;
  background: linear-gradient(oklch(0.16 0.012 30 / 96%), oklch(0.16 0.012 30 / 96%)) padding-box, var(--gradient-ember) border-box;
  box-shadow: 0 30px 80px -30px oklch(0.62 0.22 30 / 55%);
}

.page-title { margin-bottom: 26px; }
.page-title .eyebrow { color: var(--ember-glow); font-size: 11px; letter-spacing: .32em; }
.page-title h1 { margin-top: 10px; font-size: clamp(30px, 4vw, 40px); font-weight: 600; letter-spacing: -.035em; }

.index-grid { gap: 12px; margin-bottom: 16px; }
.index-card, .content-card, .control-card, .setting-card, .runtime-card {
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.index-card, .content-card, .control-card { border-radius: 22px; }
.index-card { min-height: 132px; padding: 18px; }
.index-card small { color: var(--muted-foreground); font-size: 10px; letter-spacing: .12em; }
.index-card strong { color: var(--foreground); font-size: 24px; font-weight: 600; }
.index-card span { color: var(--muted-foreground); }
.index-card .card-icon, .summary-icon { background: var(--surface-raised); color: var(--ember-glow); border-radius: 50%; }

/* Balanced summary tiles: labels and icons share a header while metric content
   uses the full width below, keeping both card edges equally padded. */
#summaryGrid > .index-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 164px;
  padding: 18px;
  gap: 0;
}
#summaryGrid .summary-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
#summaryGrid .summary-card-head small {
  min-width: 0;
  padding-top: 3px;
}
#summaryGrid .card-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  font-size: 15px;
}
#summaryGrid .summary-card-copy,
#summaryGrid .market-card-quote {
  width: 100%;
  min-width: 0;
  margin-top: 14px;
}
#summaryGrid .index-card strong {
  margin: 0 0 5px;
  font-size: clamp(20px, 1.55vw, 25px);
}
#summaryGrid .market-card-atm {
  width: 100%;
  margin-top: auto;
}

.control-card {
  margin-top: 16px;
  padding: 0;
  background: var(--surface);
}
.control-head {
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border-color: var(--border);
}
.control-head .control-copy {
  flex: 0 1 auto;
  margin-right: 32px;
}
.control-head .operation-selectors {
  flex: 0 0 min(420px, 46%);
  margin-left: auto;
}
.control-footer, .strategy-save-bar {
  background: var(--surface);
  border-color: var(--border);
}
.control-footer p, .strategy-save-bar span { color: var(--muted-foreground); }
.control-footer p > span { background: var(--surface-raised); color: var(--ember-glow); }
.control-icon { background: oklch(0.66 0.23 32 / 15%); color: var(--ember-glow); border-radius: 50%; }
.control-eyebrow, .field label, .eyebrow { color: var(--ember-glow); }
.mode-select {
  height: 38px;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
}
.mode-select button {
  height: 100%;
  color: var(--muted-foreground);
  border-radius: 10px;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.mode-select button:hover:not(.active) {
  color: var(--foreground);
  background: oklch(1 0 0 / 4%);
}
.mode-select button.active {
  color: var(--primary-foreground);
  background: var(--gradient-ember);
  box-shadow: 0 5px 14px oklch(0.62 0.22 30 / 22%);
}

.content-card { margin-top: 16px; overflow: hidden; }
.strategy-status, .session-card { background: var(--surface); border-color: var(--border); color: var(--foreground); }
.shared-strategy-panel {
  background: var(--surface-raised);
  border-color: var(--border);
}
.shared-strategy-head h4 { color: var(--foreground); }
.shared-strategy-head p { color: var(--muted-foreground); }
.shared-strategy-head > span, .count-badge {
  background: oklch(0.66 0.23 32 / 15%);
  color: var(--ember-glow);
}
.section-head { padding: 20px 22px; border-color: var(--border); }
.setting-card, .runtime-card { border-radius: 16px; background: var(--surface); }
.card-topline { border-color: var(--border); }

.btn { border-radius: 999px; font-weight: 600; }
.btn-primary, .start-button { background: var(--primary); color: var(--primary-foreground); box-shadow: none; }
.save-button { background: var(--primary); color: var(--primary-foreground); box-shadow: none; }
.btn-primary:hover, .start-button:hover { background: var(--ember-glow); }
.btn-ghost, .btn-dark { background: var(--surface-raised); border-color: var(--border); color: var(--foreground); }
.btn-danger { background: oklch(0.62 0.22 25 / 15%); border-color: oklch(0.62 0.22 25 / 22%); color: oklch(0.75 0.16 25); }
.status-chip, .side-chip { border-radius: 7px; }
.side-chip.buy, .status-chip.open, .pnl-positive { background: oklch(0.72 0.17 155 / 15%); color: var(--success); }
.side-chip.sell, .status-chip.error, .pnl-negative { background: oklch(0.62 0.22 25 / 15%); color: oklch(0.72 0.18 25); }
.status-chip.complete, .connection-pill.good { background: oklch(0.72 0.17 155 / 15%); color: var(--success); }
.connection-pill.bad { background: oklch(0.62 0.22 25 / 15%); color: oklch(0.72 0.18 25); }

/* Trading-book selector. The base stylesheet gives .tabs a fixed 55px height,
   so define the container and its buttons together to keep the active segment
   evenly inset on every side. */
.trading-books-card {
  min-height: 420px;
  border-color: oklch(1 0 0 / 11%);
}
.trading-books-head {
  min-height: 88px;
  padding: 20px 24px;
  background: color-mix(in oklab, var(--surface) 92%, var(--surface-raised));
}
.trade-book-tools label {
  color: var(--muted-foreground);
  letter-spacing: .04em;
}
.trade-book-tools input {
  width: 158px;
  min-width: 158px;
  height: 40px;
  padding: 0 8px 0 12px;
  color-scheme: dark;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
  line-height: 40px;
}
.trade-book-tools input[type="date"]::-webkit-datetime-edit {
  min-width: 0;
  padding: 0 5px 0 0;
  color: var(--foreground);
}
.trade-book-tools input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}
.trade-book-tools input[type="date"]::-webkit-calendar-picker-indicator {
  box-sizing: border-box;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 5px;
  border-radius: 7px;
  background-color: transparent;
  filter: grayscale(1) brightness(0) invert(1);
  cursor: pointer;
  opacity: .95;
}
.trade-book-tools input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
#bookTabs.tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(144px, 1fr));
  align-items: stretch;
  gap: 4px;
  width: auto;
  height: 48px;
  margin: 16px 22px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
}
#bookTabs.tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 100%;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
#bookTabs.tabs button:hover:not(.active) {
  color: var(--foreground);
  background: oklch(1 0 0 / 4%);
}
#bookTabs.tabs button.active {
  color: var(--primary-foreground);
  background: var(--gradient-ember);
  box-shadow: 0 5px 14px oklch(0.62 0.22 30 / 22%);
}
#bookTabs.tabs em {
  display: inline-grid;
  min-width: 21px;
  height: 21px;
  place-items: center;
  margin: 0;
  padding: 0 6px;
  border-radius: 7px;
  background: oklch(0.16 0.012 30 / 32%);
  color: inherit;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
#bookTabs.tabs button:not(.active) em {
  background: oklch(1 0 0 / 7%);
}

.trading-books-card .tab-panel {
  border-top: 1px solid var(--border);
}
.trading-books-card .table-wrap {
  min-height: 260px;
}
.trading-books-card th {
  height: 44px;
  color: oklch(0.76 0.014 50);
  background: oklch(1 0 0 / 2.5%);
  font-weight: 600;
}
.trading-books-card td {
  color: oklch(0.79 0.016 55);
  line-height: 1.5;
  vertical-align: middle;
}
.trading-books-card tbody tr:last-child td {
  border-bottom: 0;
}
.trading-books-card .empty-row td {
  height: 170px;
  color: var(--muted-foreground);
  text-align: center;
}

.table-wrap, table, th, td { border-color: var(--border); }
th { padding: 11px 13px; background: transparent; color: var(--muted-foreground); font-size: 10px; letter-spacing: .12em; }
td { padding: 13px; color: var(--muted-foreground); }
td b { color: var(--foreground); font-weight: 500; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: color-mix(in oklab, var(--surface-raised) 60%, transparent); }

input, select, textarea, .field input, .field select, .field textarea {
  background: var(--surface-raised);
  border-color: oklch(1 0 0 / 12%);
  color: var(--foreground);
  border-radius: 12px;
}
input:focus, select:focus, textarea:focus { border-color: var(--ember); box-shadow: 0 0 0 3px oklch(0.66 0.23 32 / 14%); }
option { background: var(--surface); color: var(--foreground); }
.reference-strike-control select,
.mobile-reference-strike select {
  color-scheme: dark;
  background-color: var(--surface-raised);
  border-color: oklch(1 0 0 / 12%);
  color: var(--foreground);
}
.reference-strike-control select:focus,
.mobile-reference-strike select:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px oklch(0.66 0.23 32 / 14%);
  outline: none;
}
.operation-grid .field :is(input, select),
.operation-grid .field :is(input, select):focus,
.shared-strategy-grid :is(input, select) {
  background: var(--surface-raised);
  border-color: oklch(1 0 0 / 12%);
  color: var(--foreground);
}

.modal-backdrop { background: oklch(0.1 0.01 30 / 82%); }
.modal-card { background: var(--card); border-color: var(--border); color: var(--foreground); border-radius: 24px; }
.modal-head, .modal-actions { border-color: var(--border); }
.modal-close { background: var(--surface-raised); color: var(--muted-foreground); }
.tsl-toggle-field { justify-content: center; }
.tsl-toggle-field input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  box-shadow: none;
}
.tsl-live-state {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
}
.tsl-live-state { color: var(--muted-foreground); font-size: 12px; line-height: 1.6; }

/* Compact settings dialog: remove page-level nesting and use modal-sized rhythm. */
#tslSettingsModal .settings-modal {
  width: min(860px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 32px));
  padding: 20px;
}
#tslSettingsModal .modal-head {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
#tslSettingsModal .modal-head h3 {
  font-family: "Sora", ui-sans-serif, system-ui, sans-serif;
  font-size: 22px;
  font-weight: 600;
}
#tslSettingsModal .modal-copy {
  font-size: 11px;
  line-height: 1.5;
}
#tslSettingsModal #strategy-settings {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#tslSettingsModal #strategy-settings > .section-head {
  display: none;
}
#tslSettingsModal .shared-strategy-panel {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
}
#tslSettingsModal .shared-strategy-head {
  margin-bottom: 11px;
}
#tslSettingsModal .shared-strategy-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}
#tslSettingsModal :is(input:not([type="checkbox"]), select) {
  height: 38px;
  padding-inline: 11px;
  border-radius: 9px;
  font-size: 12px;
}
#tslSettingsModal .field {
  gap: 5px;
}
#tslSettingsModal .field label {
  font-size: 11px;
  line-height: 1.35;
}
#tslSettingsModal #strategySettings {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 0;
}
#tslSettingsModal .tsl-settings-slot {
  grid-column: 1 / -1;
}
#tslSettingsModal .tsl-settings-block {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}
#tslSettingsModal .strategy-form {
  padding: 12px;
  border-radius: 12px;
}
#tslSettingsModal .strategy-form .card-topline {
  margin-bottom: 10px;
}
#tslSettingsModal .strategy-save-bar {
  padding: 11px 0 0;
  border-top: 1px solid var(--border);
  background: transparent;
}
#tslSettingsModal .strategy-save-bar .btn,
#tslSettingsModal .actions .save-button {
  height: 38px;
  padding-inline: 15px;
  font-size: 11px;
}
#tslSettingsModal .settings-divider {
  margin: 18px 0;
}
#tslSettingsModal .settings-subhead {
  margin-bottom: 12px;
}
#tslSettingsModal .settings-subhead h3 {
  margin-bottom: 4px;
  font-size: 17px;
}
#tslSettingsModal .modal-form-card {
  display: grid;
  gap: 11px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#tslSettingsModal .modal-form-card .field-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
#tslSettingsModal .tsl-live-state {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.5;
}
#tslSettingsModal .actions {
  justify-content: flex-end;
  margin: 0;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}
.log-item { background: var(--surface); border-color: var(--border); border-radius: 14px; }
.toast { background: var(--surface-raised); border-color: var(--border); color: var(--foreground); }
.status-line { background: var(--surface-raised); color: var(--foreground); }

/* Keep the strategy interface warm and low-glare; no pure-white surfaces or text. */
.app-body :is(.btn-primary, .save-button, .start-button) { color: var(--primary-foreground); }
.app-body :is(.modal-card, .setting-card, .runtime-card, .index-card, .content-card, .control-card) { color: var(--foreground); }

@media (max-width: 760px) {
  .topbar {
    height: 58px;
    min-height: 58px;
    padding: 8px 10px;
  }
  .top-actions {
    flex-basis: auto;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    gap: 4px;
  }
  .top-actions > .btn,
  .top-actions > .broker-menu > .btn,
  .top-actions > .broker-init-button,
  .top-actions > .connection-pill {
    height: 38px !important;
    padding: 0 5px !important;
    border-radius: 9px;
    font-size: 9.5px !important;
    line-height: 1;
    white-space: nowrap;
  }
  .top-actions > .btn,
  .top-actions > .broker-menu > .btn { gap: 3px; }
  .top-actions > .connection-pill {
    display: inline-flex;
    overflow: hidden;
  }
  .top-actions > .connection-pill i {
    flex: 0 0 auto;
    margin-right: 3px;
  }
  .top-actions .nav-label-full { display: none; }
  .top-actions .nav-label-compact { display: inline; }
  .top-actions .broker-init-button i { margin-right: 3px; }
  .top-actions .dropdown-chevron {
    width: 5px;
    height: 5px;
    margin-left: 5px;
  }
  .broker-dropdown {
    top: calc(100% + 6px);
    z-index: 100;
    width: min(190px, calc(100vw - 20px));
  }
  #brokerModal .broker-modal {
    padding: 18px;
  }
  #brokerModal .modal-head {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
  #brokerModal .modal-form-card:not([hidden]) {
    gap: 12px;
  }
  #brokerModal .modal-form-card .field-grid {
    grid-template-columns: 1fr;
  }
  #brokerModal .actions {
    align-items: stretch;
    flex-direction: column;
  }
  #brokerModal .action-row,
  #brokerModal .actions :is(.save-button, .secondary-button) {
    width: 100%;
  }
  #tslSettingsModal .settings-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 18px;
  }
  #tslSettingsModal .shared-strategy-grid,
  #tslSettingsModal #strategySettings,
  #tslSettingsModal .modal-form-card .field-grid {
    grid-template-columns: 1fr;
  }
  .workspace { width: min(100% - 16px, 1152px); margin: 16px auto 44px; padding: 18px 12px; border-width: 3px; border-radius: 24px; }
  .page-title { padding: 0 6px; }
  #bookTabs.tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: calc(100% - 24px);
    max-width: none;
    height: 48px;
    margin: 12px;
    overflow: visible;
  }
  #bookTabs.tabs button {
    min-width: 0;
    padding-inline: 6px;
    font-size: 11px;
    white-space: nowrap;
  }
  .trading-books-head { min-height: 0; padding: 18px; }
  .trade-book-tools input {
    flex: 1 1 158px;
    width: 100%;
    min-width: 158px;
  }
  .trading-books-card .table-wrap { min-height: 220px; }
  .mobile-action-bar {
    width: 100%;
    min-width: 0;
    gap: 9px;
    padding: 10px;
    overflow: visible;
    background: oklch(0.16 0.012 30 / 96%);
    border-color: var(--border);
  }
  .mobile-operation-head,
  .mobile-operation-selectors,
  .mobile-operation-buttons {
    width: 100%;
    min-width: 0;
    margin: 0;
  }
  .mobile-operation-head {
    display: grid;
    justify-content: stretch;
    padding: 0 2px;
  }
  .mobile-operation-head > strong {
    line-height: 1.2;
    text-align: left;
  }
  .mobile-operation-selectors {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }
  .mobile-operation-selectors > * {
    grid-template-rows: 14px 38px;
    min-width: 0;
    gap: 4px;
  }
  .mobile-operation-selectors > * > span {
    display: block;
    min-width: 0;
    padding: 0 2px;
    overflow: hidden;
    line-height: 14px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-operation-buttons {
    align-items: stretch;
    gap: 8px;
  }
  .mobile-operation-buttons .btn {
    min-width: 0;
    padding-inline: 6px;
    overflow: hidden;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-reference-strike {
    position: relative;
    color: var(--muted-foreground);
  }
  .mobile-reference-strike::after {
    position: absolute;
    right: 13px;
    bottom: 13px;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--ember-glow);
    border-bottom: 1.5px solid var(--ember-glow);
    content: "";
    pointer-events: none;
    transform: rotate(45deg);
  }
  .mobile-reference-strike select {
    height: 38px;
    padding: 0 32px 0 12px;
    appearance: none;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 600;
  }
  .mobile-reference-strike select:hover {
    border-color: oklch(1 0 0 / 18%);
  }
  .mobile-mode-control { color: var(--muted-foreground); }
  .mobile-mode-select { height: 38px; }
  .mobile-mode-select button { height: 100%; }
#positionsPanel tbody tr { background: var(--surface); border-color: var(--border); }
.position-action-button { height: 30px; min-width: 72px; padding: 0 10px; font-size: 11px; }
}
