:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #0f1620;
  --border: rgba(255, 255, 255, 0.08);
  --muted: rgba(255, 255, 255, 0.7);
  --text: rgba(255, 255, 255, 0.9);
  --text-strong: rgba(255, 255, 255, 0.92);
  --control-bg: rgba(255, 255, 255, 0.03);
  --control-bg-hover: rgba(255, 255, 255, 0.06);
  --focus: rgba(120, 170, 255, 0.7);
  /* Shared action button accent (Add Strategy, Save, Add). */
  --primary: #2563eb;
  --primary-hover: #3b82f6;
}

* {
  box-sizing: border-box;
}

/* Ensure HTML hidden attribute always wins over component display styles. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 40px;
  overflow: hidden;
}

/* Minimal app shell: empty title bar + empty footer. */
.titlebar,
.footer {
  background: var(--panel);
  border-color: var(--border);
  border-style: solid;
  border-width: 0;
}

.titlebar {
  height: 48px;
  border-bottom-width: 1px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
}

.titlebar__left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.titlebar__project-title {
  color: #ffd84d;
  font-family: "Montserrat", "Segoe UI", "Inter", "Arial Black", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1;
  white-space: nowrap;
  text-transform: none;
}

.titlebar__actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.titlebar__auth-btn {
  min-height: 34px;
  width: 96px;
  min-width: 96px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #0b0f14;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.titlebar__backup-btn {
  min-height: 34px;
  width: 96px;
  min-width: 96px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.titlebar__backup-btn:hover {
  background: var(--control-bg-hover);
  color: var(--text-strong);
}

.titlebar__backup-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.titlebar__auth-btn--signed-out {
  background: #15803d;
  border-color: #22c55e;
}

.titlebar__auth-btn--signed-out:hover {
  background: #16a34a;
}

.titlebar__auth-btn--signed-in {
  background: #dc2626;
  border-color: #ef4444;
  color: #ffffff;
}

.titlebar__auth-btn--signed-in:hover {
  background: #ef4444;
}

.titlebar__auth-btn--busy {
  background: var(--control-bg);
  border-color: var(--border);
  color: var(--muted);
  cursor: wait;
}

.titlebar__auth-btn:disabled {
  opacity: 0.9;
}

.titlebar__auth-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.footer {
  min-height: 40px;
  height: 40px;
  border-top-width: 1px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
}

/* Left cluster: clock + exchange status (green = on, red = off). */
.footer__left {
  display: flex;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  /* Keep the top-movers boundary anchored around the middle. */
  flex: 0 1 50%;
  max-width: 50%;
}

.footer__clock {
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
  white-space: nowrap;
}

.footer__exchanges {
  display: block;
  min-width: 0;
  overflow: hidden;
}

/* Single-line moving segments strip (left -> right). */
.footer__segments-viewport {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.footer__segments-track {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: max-content;
  white-space: nowrap;
  will-change: transform;
}

.footer__segments-copy {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.footer__segments-divider {
  color: var(--muted);
  opacity: 0.82;
  margin: 0 6px;
}

.footer__ex {
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.footer__ex--on {
  color: #52c41a;
}

.footer__ex--off {
  color: #ff4d4f;
}

/* Inline: last market JSON latency (browser receive time − server locatimestamp). */
.footer__latency {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
  white-space: nowrap;
}

.footer__latency-label {
  color: var(--muted);
  font-weight: 500;
}

/* Fixed width so latency digits can change without moving the label. */
.footer__latency-value {
  display: inline-block;
  width: 7ch;
  min-width: 7ch;
  text-align: left;
  flex: 0 0 7ch;
  font-variant-numeric: tabular-nums;
}

.footer__ticker {
  min-width: 0;
  /* Reserve more horizontal room for the movers stream. */
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.footer__ticker-separator {
  color: var(--muted);
  flex-shrink: 0;
}

.footer__ticker-viewport {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
}

.footer__ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: max-content;
  white-space: nowrap;
  will-change: transform;
}

.footer__ticker-track[data-empty="true"] {
  transform: translate3d(0, 0, 0);
}

.footer__ticker-copy {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.footer__ticker-item {
  white-space: nowrap;
  font-weight: 600;
}

.footer__ticker-item--up {
  color: #52c41a;
}

.footer__ticker-item--down {
  color: #ff4d4f;
}

.footer__ticker-divider,
.footer__ticker-empty {
  color: var(--muted);
}

.footer__ticker-divider {
  margin: 0 6px;
}

.toastify.trigger-toastify {
  background: #ffd84d !important;
  color: #000000 !important;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  min-width: 260px;
  max-width: min(440px, calc(100vw - 42px));
  padding: 10px 12px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toastify.trigger-toastify .toast-close {
  color: #000000;
  opacity: 0.68;
}

.toastify.trigger-toastify .toast-close:hover {
  opacity: 1;
}

.toastify.trigger-toastify.on {
  transform: translateX(0);
  opacity: 1;
}

.toastify.disclaimer-toastify {
  position: fixed;
  left: 50% !important;
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  background: #ffd84d !important;
  color: #000000 !important;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  padding: 12px 14px;
  max-width: min(680px, calc(100vw - 40px));
  text-align: left;
  z-index: 12000;
}

.content {
  min-height: 0;
}

/* Floating panels (Panel 1 / Panel 2). */
.floating-panels {
  position: fixed;
  left: 14px;
  right: 14px;
  top: calc(48px + 14px);
  bottom: calc(40px + 14px);
  display: flex;
  flex-direction: row;
  gap: 14px;
  z-index: 1000;
  pointer-events: none; /* allow main page interactions unless panel itself is hovered */
}

.floating-panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  height: 100%;
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.floating-panel__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.floating-panel__title {
  flex: 1 1 auto;
  min-width: 0;
}

.floating-panel__tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.floating-panel__tab {
  appearance: none;
  border-radius: 999px;
  border: 0;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
}

.floating-panel__tab--active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-strong);
}

.floating-panel__btn {
  appearance: none;
  border: 1px solid #3b82f6;
  background: var(--primary);
  color: #f8fbff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.floating-panel__btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.floating-panel__btn--ghost:hover {
  background: var(--control-bg-hover);
}

.floating-panel__icon {
  width: 16px;
  height: 16px;
  display: block;
}

.floating-panel__btn:hover {
  background: var(--primary-hover);
  border-color: #60a5fa;
}

.floating-panel__btn:active {
  background: var(--primary-hover);
  border-color: #60a5fa;
}

.floating-panel__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.floating-panel__meta {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.floating-panel__field {
  width: 140px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.floating-panel__field select {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  outline: none;
  padding: 6px 10px;
  min-height: 34px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color-scheme: dark;
}

.floating-panel__field select:hover {
  background: var(--control-bg-hover);
}

.floating-panel__field select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.ts-wrapper {
  font: inherit;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
  color: var(--text-strong);
  min-height: 34px;
  padding: 6px 34px 6px 10px;
}

.ts-wrapper.single .ts-control:hover,
.ts-wrapper.single.input-active .ts-control:hover {
  background: var(--control-bg-hover);
}

.ts-wrapper.single.focus .ts-control {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 35%, transparent);
}

.ts-wrapper.single .ts-control > input {
  color: var(--text-strong);
}

.ts-wrapper.single .ts-control,
.ts-wrapper.single .ts-control .item {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
}

.ts-wrapper.single .ts-control:after {
  border-color: var(--muted) transparent transparent transparent;
  right: 12px;
}

.ts-wrapper.dropdown-active.single .ts-control:after {
  border-color: transparent transparent var(--muted) transparent;
}

.ts-dropdown {
  margin-top: 6px;
  background: #111821;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.38);
  color: var(--text-strong);
  overflow: hidden;
}

.ts-dropdown .option,
.ts-dropdown .optgroup-header,
.ts-dropdown .no-results,
.ts-dropdown .create {
  padding: 8px 10px;
  font-size: 12px;
}

.ts-dropdown .option {
  color: var(--text-strong);
}

.ts-dropdown .active,
.ts-dropdown .option:hover {
  background: rgba(47, 227, 140, 0.12);
  color: var(--text-strong);
}

.floating-panel__field .ts-wrapper {
  width: 100%;
}

.chart-panel__field .ts-wrapper {
  width: 100%;
}

.floating-panel__body {
  padding: 10px 12px;
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  /* Dark, minimal scrollbar for spreadmap container in all major engines. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.04);
}

.floating-panel__body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.floating-panel__body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.floating-panel__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
}

.floating-panel__body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tab-content--hidden {
  display: none;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 520px;
  gap: 10px;
  align-content: start;
}

.charts-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
}

.marketwatch-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
}

.marketwatch-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

/* Keep marketwatch table scrolling inside its own viewport for sticky headers. */
[data-tab-content="marketwatch"] {
  height: 100%;
}

.marketwatch-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.marketwatch-toolbar__status {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.marketwatch-toolbar__form {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

select.marketwatch-toolbar__exchange {
  width: 180px;
  flex: 0 0 180px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 34px 8px 10px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  min-height: 36px;
  font: inherit;
  line-height: 1.2;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 1px),
    calc(100% - 12px) calc(50% - 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color-scheme: dark;
}

select.marketwatch-toolbar__exchange option,
select.marketwatch-toolbar__exchange optgroup {
  background: var(--panel);
  color: var(--text-strong);
}

select.marketwatch-toolbar__exchange:hover {
  background: var(--control-bg-hover);
}

select.marketwatch-toolbar__exchange:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.marketwatch-toolbar__form .ts-wrapper {
  width: 180px;
  flex: 0 0 180px;
}

.marketwatch-toolbar__form .ts-wrapper.single .ts-control,
.marketwatch-toolbar__form .ts-wrapper.single.input-active .ts-control {
  min-height: 36px;
  box-sizing: border-box;
  font: inherit;
  line-height: 1.2;
}

.marketwatch-toolbar__form .ts-dropdown {
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  padding: 6px;
}

.marketwatch-toolbar__form .ts-dropdown-content {
  display: grid;
}

.marketwatch-toolbar__form .ts-dropdown .option,
.marketwatch-toolbar__form .ts-dropdown .optgroup-header,
.marketwatch-toolbar__form .ts-dropdown .no-results,
.marketwatch-toolbar__form .ts-dropdown .create {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.2;
}

.marketwatch-toolbar__form .ts-dropdown .option {
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.marketwatch-toolbar__form .ts-dropdown .active,
.marketwatch-toolbar__form .ts-dropdown .option:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-strong);
}

.marketwatch-toolbar__autocomplete {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 360px;
}

.marketwatch-toolbar__autocomplete input[type="text"] {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  box-sizing: border-box;
  min-height: 36px;
  font: inherit;
  line-height: 1.2;
}

.marketwatch-toolbar__autocomplete input[type="text"]:hover {
  background: var(--control-bg-hover);
}

.marketwatch-toolbar__autocomplete input[type="text"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

select.marketwatch-toolbar__exchange:disabled,
.marketwatch-toolbar__form .ts-wrapper.disabled,
.marketwatch-toolbar__autocomplete input[type="text"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.marketwatch-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.03);
}

.marketwatch-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1680px;
  font-size: 12px;
}

.marketwatch-table th,
.marketwatch-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.marketwatch-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  background: #111821;
  color: var(--muted);
  font-weight: 600;
}

.marketwatch-table__sort {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.marketwatch-table__sort:hover,
.marketwatch-table__sort--active {
  color: var(--text-strong);
}

.marketwatch-table__sort:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.marketwatch-table__sort-indicator {
  font-size: 10px;
  opacity: 0.65;
}

.marketwatch-table td {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.marketwatch-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.marketwatch-table__row--selected,
.marketwatch-table tbody tr.marketwatch-table__row--selected:hover {
  background: rgba(74, 163, 255, 0.16);
}

.marketwatch-table tbody tr:last-child td {
  border-bottom: 0;
}

.marketwatch-table__symbol {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.marketwatch-table__cell--up {
  color: #2fe38c !important;
}

.marketwatch-table__cell--down {
  color: #ff6b6b !important;
}

.marketwatch-table__cell-tooltip {
  position: relative;
  cursor: help;
}

/* Custom tooltip to control width (native title tooltip width is browser-controlled). */
.marketwatch-table__cell-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111821;
  color: var(--text-strong);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 40;
  transition: opacity 120ms ease;
}

.marketwatch-table__cell-tooltip:hover::after,
.marketwatch-table__cell-tooltip:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.marketwatch-table__value--flash-up {
  background: rgba(47, 227, 140, 0.18);
  color: #2fe38c !important;
}

.marketwatch-table__value--flash-down {
  background: rgba(255, 107, 107, 0.18);
  color: #ff6b6b !important;
}

.marketwatch-table__qty--flash-buy {
  background: rgba(47, 227, 140, 0.18);
  color: #2fe38c !important;
}

.marketwatch-table__qty--flash-sell {
  background: rgba(255, 107, 107, 0.18);
  color: #ff6b6b !important;
}

.marketwatch-table__actions {
  width: 1%;
  text-align: right;
}

.marketwatch-table__remove {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.marketwatch-table__remove:hover {
  opacity: 1;
}

.chart-panel {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  overflow: hidden;
  height: 520px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.chart-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.chart-panel__controls {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.chart-panel__field {
  max-width: 280px;
}

.chart-panel__strategy-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-panel__toggle {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}

.chart-panel__field--strategy {
  min-width: 280px;
  max-width: 420px;
  flex: 1 1 360px;
}

.chart-panel__toggle:hover {
  background: var(--control-bg-hover);
  color: var(--text-strong);
}

.chart-panel__toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chart-panel__toggle--on {
  border-color: rgba(47, 227, 140, 0.35);
  color: #2fe38c;
  background: rgba(47, 227, 140, 0.12);
}

.chart-panel__filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 120px));
  gap: 8px;
}

.chart-panel__field--range {
  max-width: 120px;
}

.chart-panel__field--range input[type="number"] {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.chart-panel__status {
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
}

.chart-panel__status-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-panel__status-meta {
  flex: 0 1 auto;
  margin-left: auto;
  text-align: right;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-panel__status-label,
.chart-panel__status-sep {
  color: var(--muted);
}

.chart-panel__status-symbol {
  font-weight: 600;
}

.chart-panel__status-symbol--l1 {
  color: #ff6b6b;
}

.chart-panel__status-symbol--l2 {
  color: #2fe38c;
}

.chart-panel__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.chart-panel__btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.75;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.chart-panel__btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.06);
}

.chart-panel__body {
  position: relative;
  min-height: 220px;
}

.chart-panel__canvas {
  position: absolute;
  inset: 0;
}

.chart-panel__axis-label {
  position: absolute;
  top: 50%;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1;
  white-space: nowrap;
  writing-mode: vertical-rl;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.chart-panel__axis-label--left {
  left: 4px;
  transform: translateY(-50%) rotate(180deg);
  color: #ffb020;
}

.chart-panel__axis-label--right {
  right: 4px;
  transform: translateY(-50%);
  color: #2fe38c;
}

.chart-panel__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  background: linear-gradient(180deg, rgba(6, 10, 14, 0.08), rgba(6, 10, 14, 0.22));
  pointer-events: none;
}

.chart-panel__empty[hidden] {
  display: none;
}

@media (max-width: 1180px) {
  .charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.field select {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  color-scheme: dark; /* ensures native popup/menu follows dark theme where supported */
}

.field select:hover {
  background: var(--control-bg-hover);
}

.field select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.field input[type="text"] {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}

.field input[type="tel"] {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}

.field input[type="password"] {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}

.field input[type="number"] {
  width: 100%;
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.field input[type="text"]:hover {
  background: var(--control-bg-hover);
}

.field input[type="tel"]:hover {
  background: var(--control-bg-hover);
}

.field input[type="password"]:hover {
  background: var(--control-bg-hover);
}

.field input[type="number"]:hover {
  background: var(--control-bg-hover);
}

.field input[type="text"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.field input[type="tel"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.field input[type="password"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.field input[type="number"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Hide native spin buttons (Chrome/Safari/Edge) to match theme */
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.autocomplete {
  position: relative;
}

.ac-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 2000;
  max-height: 240px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  padding: 6px;
}

.ac-menu__item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-menu__item:hover,
.ac-menu__item--active,
.ac-menu__item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid var(--border);
  margin-left: 8px;
}

.status-badge--online {
  color: #2fe38c;
  background: rgba(47, 227, 140, 0.08);
  border-color: rgba(47, 227, 140, 0.25);
}

.status-badge--offline {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.25);
}

.status-badge--error {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.25);
}

/* Native dropdown menu items (varies by browser/OS, but helps where supported). */
.field select option,
.field select optgroup {
  background: var(--panel);
  color: var(--text-strong);
}

/* Panel 1 strategy grid */
.strategy-grid {
  display: grid;
  --tile-size: 190px;
  grid-template-columns: repeat(auto-fill, var(--tile-size));
  grid-auto-rows: var(--tile-size);
  gap: 10px;
  align-content: start;
  justify-content: start;
}

.strategy-grid__empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
}

.strategy-tile {
  position: relative;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at top left, rgba(47, 227, 140, 0.1), transparent 42%),
    radial-gradient(circle at bottom right, rgba(74, 163, 255, 0.1), transparent 48%),
    rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  height: 100%;
  padding: 10px;
  display: flex;
  flex-direction: column;
  /* Distribute leftover tile height as vertical "line spacing"
     so we don't end up with an empty block at the bottom. */
  justify-content: space-between;
  gap: 0;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 0 24px rgba(47, 227, 140, 0.08);
  transition:
    transform 180ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease,
    background 220ms ease;
}

.strategy-tile-wrap {
  position: relative;
  height: 100%;
  overflow: visible;
}

.strategy-tile::before {
  content: "";
  position: absolute;
  inset: -35% auto auto -25%;
  width: 70%;
  height: 170%;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.02) 24%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(47, 227, 140, 0.08) 68%,
    transparent 100%
  );
  transform: rotate(8deg);
  opacity: 0.85;
  animation: strategyTileFlow 5.5s ease-in-out infinite;
}

.strategy-tile:hover {
  border-color: color-mix(in srgb, var(--focus) 45%, var(--border));
  transform: translateY(-2px);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 32px rgba(47, 227, 140, 0.14);
}

.strategy-tile__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.strategy-tile__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-strong);
}

.strategy-tile__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.strategy-tile__clone,
.strategy-tile__delete {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0.7;
  flex: 0 0 auto;
}

.strategy-tile__clone:hover,
.strategy-tile__delete:hover {
  opacity: 1;
}

.strategy-tile__clone:active,
.strategy-tile__delete:active {
  opacity: 1;
}

.strategy-tile__clone:focus-visible,
.strategy-tile__delete:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.strategy-tile:active {
  cursor: grabbing;
}

.strategy-tile__meta {
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.strategy-tile__leg {
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-strong);
  position: relative;
  z-index: 1;
}

.strategy-tile__leg--l2,
.strategy-tile__leg--l3,
.strategy-tile__leg--l4 {
  color: var(--muted);
}

.strategy-tile__basis,
.strategy-tile__spread,
.strategy-tile__high,
.strategy-tile__low,
.strategy-tile__funding-annualized,
.strategy-tile__basis-range,
.strategy-tile__md-timestamp {
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.strategy-tile__basis-range {
  gap: 6px;
}

.strategy-tile__range-track {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(74, 163, 255, 0.5), rgba(255, 255, 255, 0.22), rgba(255, 107, 107, 0.5));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.strategy-tile__range-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #d5dbe3;
  border: 1px solid rgba(11, 15, 20, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
  opacity: 0.35;
  transition:
    left 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease,
    opacity 140ms ease;
}

.strategy-tile--range-low .strategy-tile__range-marker {
  background: #4aa3ff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 10px rgba(74, 163, 255, 0.55);
}

.strategy-tile--range-high .strategy-tile__range-marker {
  background: #ff6b6b;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 10px rgba(255, 107, 107, 0.5);
}

.strategy-tile__range-badge {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.strategy-tile--range-low .strategy-tile__range-badge {
  color: #7cc3ff;
}

.strategy-tile--range-high .strategy-tile__range-badge {
  color: #ff8f8f;
}

.strategy-tile__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-tile__value {
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.strategy-tile__value--flash {
  background: #fadb14;
  color: #0b0f14 !important;
  border-radius: 4px;
}

.strategy-tile__values {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  flex: 0 0 auto;
}

.strategy-tile__sep {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.strategy-tile__value--red {
  color: #ff6b6b;
}

.strategy-tile__value--green {
  color: #2fe38c;
}

.strategy-tile__hover-lines {
  position: absolute;
  top: 44px;
  left: calc(100% + 8px);
  min-width: 220px;
  display: grid;
  gap: 6px;
  opacity: 0;
  transform: translateX(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 160ms ease;
  z-index: 20;
}

.strategy-tile-wrap--hover-left .strategy-tile__hover-lines {
  left: auto;
  right: calc(100% + 8px);
  transform: translateX(4px);
  justify-items: end;
}

.strategy-tile-wrap:hover .strategy-tile__hover-lines,
.strategy-tile-wrap:focus-within .strategy-tile__hover-lines {
  opacity: 1;
  transform: translateX(0);
}

.strategy-tile__hover-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #000000;
  font-size: 11px;
  line-height: 1.2;
  background: #fadb14;
  border-radius: 6px;
  padding: 3px 8px;
  width: fit-content;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.strategy-tile__hover-label {
  color: #000000;
  font-weight: 600;
}

.strategy-tile__hover-symbol {
  white-space: nowrap;
}

@keyframes strategyTileFlow {
  0% {
    transform: translate3d(-28%, -4%, 0) rotate(8deg);
    opacity: 0.55;
  }
  50% {
    transform: translate3d(115%, 5%, 0) rotate(8deg);
    opacity: 0.95;
  }
  100% {
    transform: translate3d(-28%, -4%, 0) rotate(8deg);
    opacity: 0.55;
  }
}

.app-dialog.app-dialog--strategy-details {
  width: min(1140px, calc(100vw - 24px));
}

.app-dialog__body--strategy-details {
  gap: 12px;
}

.app-dialog--strategy-details .app-dialog__footer {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.app-dialog--strategy-details [data-role="strategy-details-status"] {
  flex: 1 1 100%;
  text-align: left;
}

.app-dialog--strategy-details .app-dialog__footer .floating-panel__btn {
  white-space: nowrap;
}

.strategy-details-grid {
  display: grid;
  gap: 10px;
}

.strategy-details-grid__row {
  display: grid;
  gap: 10px;
}

.strategy-details-grid__row--meta {
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 1.6fr) minmax(230px, 1.1fr) minmax(230px, 1.1fr);
  align-items: end;
}

.strategy-details-grid__row--legs {
  grid-template-columns: minmax(0, 1.3fr) minmax(140px, 0.8fr) minmax(0, 1.3fr) minmax(140px, 0.8fr);
  align-items: end;
}

.strategy-details-grid__symbol {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 36px;
}

.strategy-details-grid__qty {
  min-width: 0;
}

.strategy-details-grid__symbol-k {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.strategy-details-grid__symbol-v {
  font-size: 12px;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dialog */
.app-dialog {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  overflow: visible;
}

.app-dialog.app-dialog--add-strategy {
  width: min(1280px, calc(100vw - 16px));
  max-height: none;
  overflow: visible;
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.app-dialog__form {
  display: grid;
  gap: 0;
  overflow: visible;
  position: relative;
}

.app-dialog__header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.app-dialog__title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-dialog__body {
  padding: 12px 14px;
  display: grid;
  gap: 12px;
  overflow: visible;
}

.app-dialog__body--add-strategy {
  gap: 12px;
  max-height: none;
  overflow: visible;
}

.add-strategy__row {
  display: grid;
  gap: 10px;
}

.add-strategy__row--meta {
  grid-template-columns: minmax(140px, 0.85fr) minmax(160px, 1fr) minmax(220px, 1.45fr) minmax(86px, 0.55fr) minmax(210px, 1.1fr) minmax(210px, 1.1fr);
  align-items: end;
}

.add-strategy__row--legs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.add-strategy__leg {
  display: grid;
  grid-template-columns: minmax(145px, 0.9fr) minmax(240px, 1.8fr) minmax(120px, 0.7fr);
  gap: 10px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.add-strategy__row .field {
  min-width: 0;
  align-content: start;
}

.add-strategy__row .field label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.threshold-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
}

.add-strategy__row--meta [data-role="contracts-status"] {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
}

.app-dialog__row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.app-dialog__status {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Keep auth feedback clearly visible during login/signup steps. */
[data-role="ws-auth-status"] {
  font-size: 13px;
  font-weight: 700;
}

.app-dialog__status--warning {
  color: #000000;
  background: #ffd84d;
  border-radius: 6px;
  padding: 3px 8px;
}

.ws-auth-mode-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ws-auth-mode-picker__btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.ws-auth-mode-picker__btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ws-auth-mode-picker__btn--active {
  background: #ffd84d;
  color: #000000;
  border-color: rgba(0, 0, 0, 0.24);
}

.ws-auth-mode-picker__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Login/signup credential fields: add breathing room and stable focus ring (no jump). */
[data-role="ws-auth-credentials"] {
  display: grid;
  gap: 12px;
  grid-auto-rows: 63px;
}

[data-role="ws-auth-credentials"] .field {
  display: grid;
  grid-template-rows: 15px 38px;
  gap: 8px;
  min-height: 63px;
  max-height: 63px;
  overflow: hidden;
}

[data-role="ws-auth-credentials"] .field label {
  display: block;
  min-height: 15px;
  max-height: 15px;
  line-height: 1.25;
  overflow: hidden;
}

[data-role="ws-auth-credentials"] .field input[type="tel"],
[data-role="ws-auth-credentials"] .field input[type="password"] {
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  padding-right: 44px; /* reserve space for browser/password-manager inline icons */
  line-height: 20px;
  transition: none !important;
}

[data-role="ws-auth-credentials"] .field input[type="tel"]:focus-visible,
[data-role="ws-auth-credentials"] .field input[type="password"]:focus-visible {
  outline: none;
  border-color: rgba(120, 170, 255, 0.78);
  box-shadow: none;
}

/* Keep login dialog dimensions stable while focusing/typing in inputs. */
dialog[data-role="ws-auth-dialog"] {
  width: min(620px, calc(100vw - 32px));
}

dialog[data-role="ws-auth-dialog"] .app-dialog__body {
  min-height: 300px;
}

dialog[data-role="ws-auth-dialog"] [data-role="ws-auth-status"] {
  min-height: 22px;
}

.ws-auth-qr {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.ws-auth-qr[hidden] {
  display: none !important;
}

.ws-auth-qr__img {
  width: 132px;
  height: 132px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.ws-auth-qr__meta {
  display: grid;
  gap: 8px;
}

.ws-auth-qr__secret {
  display: block;
  word-break: break-all;
  font-size: 12px;
  color: var(--text);
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.app-dialog__footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ws-auth-watch-demo-btn {
  margin-right: auto;
  /* Variant 2 breathing pattern: gently pulse fill + border to draw attention. */
  animation: wsAuthWatchDemoBreathing 3s ease-in-out infinite;
}

.ws-auth-watch-demo-btn:hover,
.ws-auth-watch-demo-btn:focus-visible {
  animation-play-state: paused;
  background: rgba(255, 216, 77, 0.24);
  border-color: rgba(255, 216, 77, 0.9);
  color: #f6f8fc;
}

@keyframes wsAuthWatchDemoBreathing {
  0%,
  100% {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
    box-shadow: 0 0 0 rgba(255, 216, 77, 0);
  }
  50% {
    background: rgba(255, 216, 77, 0.2);
    border-color: rgba(255, 216, 77, 0.85);
    color: #f6f8fc;
    box-shadow: 0 0 0 1px rgba(255, 216, 77, 0.16);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ws-auth-watch-demo-btn {
    /* Keep visibility cue while respecting reduced-motion preference. */
    animation-duration: 6s;
  }
}

@media (max-width: 1120px) {
  .add-strategy__row--meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-strategy__row--legs {
    grid-template-columns: minmax(0, 1fr);
  }

  .strategy-details-grid__row--meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .strategy-details-grid__row--legs {
    grid-template-columns: minmax(0, 1.3fr) minmax(140px, 0.8fr);
  }
}

/* Prevent cramped 6-column layout on medium-large screens. */
@media (max-width: 1400px) {
  .add-strategy__row--meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .add-strategy__row--meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .add-strategy__leg {
    grid-template-columns: minmax(0, 1fr);
  }

  .strategy-details-grid__row--meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .strategy-details-grid__row--legs {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Wider modal for copy-paste console snippets. */
.app-dialog--guide {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
}

.app-dialog__body--guide {
  max-height: min(70vh, 560px);
  overflow-y: auto;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
}

.guide-lead {
  margin: 0;
  color: var(--muted);
}

.guide-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.guide-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.guide-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.guide-h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

.guide-ol {
  margin: 0 0 12px;
  padding-left: 1.25em;
  color: var(--text);
}

.guide-label {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.guide-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.guide-actions input[type="file"] {
  font-size: 12px;
  color: var(--muted);
  max-width: 100%;
}

.storage-guide__toggle--on {
  border-color: rgba(47, 227, 140, 0.35);
  color: #2fe38c;
  background: rgba(47, 227, 140, 0.12);
}

.guide-code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #060a0e;
  font-size: 11px;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

.guide-code--tall {
  max-height: 200px;
  overflow-y: auto;
}

.guide-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-strong);
}

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