:root {
  --bg: #0b0e14;
  --bg-panel: #12161f;
  --bg-panel-2: #171c27;
  --border: #232938;
  --text: #e6e9f0;
  --muted: #8891a7;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --success: #33c17a;
  --success-soft: rgba(51, 193, 122, 0.14);
  --danger: #ef5a6f;
  --danger-soft: rgba(239, 90, 111, 0.14);
  --warning: #e8b34c;
  --radius: 5px;
  --radius-sm: 2px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

* {
  scrollbar-color: #30384a #0b0e14;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0b0e14;
}

*::-webkit-scrollbar-thumb {
  background: #30384a;
  border: 2px solid #0b0e14;
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #475169;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

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

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  padding: 6px 10px 20px 10px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--bg-panel-2); color: var(--text); }

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-section-label {
  padding: 8px 10px 4px;
  color: #69738b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.nav-section-label.quiddich { color: #9b7cff; }

.nav-section-divider {
  height: 1px;
  margin: 12px 6px 7px;
  background: linear-gradient(90deg, transparent, #3b4255 18%, #3b4255 82%, transparent);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.topbar .meta {
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 22px 24px 44px 24px;
  max-width: 1280px;
  width: 100%;
}

.content-wide {
  max-width: none;
}

.content-dashboard {
  width: 1580px;
  min-width: 1580px;
  max-width: none;
}

.content-screener {
  height: calc(100vh - 57px);
  overflow: hidden;
  padding-bottom: 12px;
}

.content-screener #screener-table {
  width: 1260px;
  max-width: 100%;
}

.content-stats {
  max-width: none;
  min-height: calc(100vh - 57px);
  padding: 12px;
  background: var(--bg);
  overflow-x: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.card .value {
  font-size: 26px;
  font-weight: 700;
}

.value.positive { color: var(--success); }
.value.negative { color: var(--danger); }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 16px 0;
  font-weight: 600;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  transition: background 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

th a { color: inherit; text-decoration: none; cursor: pointer; }
th a:hover { color: var(--text); }

tr:last-child td { border-bottom: none; }

.connections-summary-table {
  table-layout: fixed;
  min-width: 1040px;
}

.connections-summary-table th,
.connections-summary-table td {
  padding: 8px 9px;
  vertical-align: middle;
  white-space: nowrap;
}

.connections-summary-table .compact {
  overflow: hidden;
  text-overflow: ellipsis;
}

.connections-summary-table .col-label { width: 118px; }
.connections-summary-table .col-exchange { width: 66px; }
.connections-summary-table .col-status { width: 64px; }
.connections-summary-table .col-us { width: 64px; }
.connections-summary-table .col-param { width: 54px; }
.connections-summary-table .col-money { width: 82px; }
.connections-summary-table .col-count { width: 76px; }
.connections-summary-table .col-actions { width: 96px; }

.connections-summary-table .param-cell {
  font-weight: 700;
  color: var(--text);
}

.connections-summary-table .action-cell {
  text-align: right;
}

.dashboard-positions-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dashboard-position-settings {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dashboard-table-scroll {
  width: auto;
  max-width: none;
  overflow-x: visible;
  overscroll-behavior-inline: auto;
  -webkit-overflow-scrolling: touch;
}

.dashboard-positions-table {
  min-width: 1500px;
}

.dashboard-positions-table .position-actions-cell {
  min-width: 610px;
  white-space: nowrap;
}

.dashboard-positions-table .position-actions-cell .btn {
  margin: 2px 1px;
}

.stats-shell {
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: calc(100vh - 81px);
  width: 2000px;
  min-width: 2000px;
  max-width: 2000px;
}

.stats-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: none;
}

.stats-panel h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
  line-height: 1.2;
}

.stats-panel h3 {
  margin: 10px 0 8px 0;
  font-size: 14px;
}

.stats-panel p,
.stats-note,
.stats-rendered {
  color: var(--muted);
  margin: 0;
  font-size: 12px;
}

.stats-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stats-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.stats-metric-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 8px 0 10px 0;
}

.stats-metric {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--bg-panel-2);
}

.stats-metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
}

.stats-metric strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
}

.stats-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}

.stats-stack.nested {
  margin-top: 8px;
}

.stats-accordion,
.stats-day {
  border: 1px solid #cbd9ef;
  border-color: var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  overflow: hidden;
}

.stats-accordion > summary,
.stats-day > summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  min-height: 46px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.stats-day > summary {
  background: var(--bg-panel-2);
}

.stats-accordion > summary::-webkit-details-marker,
.stats-day > summary::-webkit-details-marker {
  display: none;
}

.stats-accordion > summary::before,
.stats-day > summary::before {
  content: ">";
  color: var(--accent);
  font-weight: 700;
}

.stats-accordion[open] > summary::before,
.stats-day[open] > summary::before {
  content: "v";
}

.stats-summary-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  min-width: 150px;
}

.stats-connection-body {
  padding: 8px 10px 12px 10px;
  border-top: 1px solid var(--border);
}

.stats-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
}

.ticker-scroll {
  max-height: 520px;
  margin-top: 10px;
}

.ticker-stats {
  padding: 0;
}

.ticker-stats > summary {
  background: var(--bg-panel);
  border-radius: 6px;
  min-height: 58px;
  padding: 12px 16px;
}

.ticker-stats[open] > summary {
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}

.stats-table {
  min-width: 1120px;
  border-collapse: collapse;
}

.stats-trades-table {
  width: 2000px;
  min-width: 2000px;
  max-width: 2000px;
}

.stats-table th,
.stats-table td {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.stats-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-panel-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.stats-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

.stats-shell .empty {
  color: var(--muted);
  padding: 10px;
}

.stats-shell .badge.on {
  background: var(--success-soft);
  color: var(--success);
}

.stats-shell .badge.mode {
  background: var(--accent-soft);
  color: var(--accent);
}

.stats-table .clickable-row {
  cursor: pointer;
}

.stats-table .clickable-row:hover td {
  background: var(--accent-soft);
}

.trade-card-page {
  width: 2000px;
  min-width: 2000px;
  max-width: 2000px;
}

.trade-card-toolbar,
.trade-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.trade-card-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.trade-chart-panel {
  padding: 0;
  overflow: hidden;
}

.trade-chart-panel .stats-panel-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.trade-tv-chart {
  height: 460px;
  width: 100%;
}

@media (max-width: 1100px) {
  .stats-metric-grid,
  .stats-metric-grid.compact {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge.on { background: var(--success-soft); color: var(--success); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.mode { background: var(--accent-soft); color: var(--accent); }

.group-tickers {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.group-tickers-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ticker-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 92px;
  overflow: auto;
}

.ticker-chip {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-panel-2);
  color: var(--text);
  font-size: 12px;
}

.empty.compact {
  padding: 8px 0 0;
}

form.inline { display: inline; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13.5px;
  width: 100%;
}

textarea { resize: vertical; font-family: inherit; }

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
  margin-top: 12px;
  min-height: 15px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 20px;
}

.form-grid label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-suffix {
  position: relative;
}

.field-suffix input {
  padding-right: 28px;
}

.field-suffix .suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 13px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.88; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.position-actions-cell .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.actions { margin-top: 16px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: auto; }

.muted { color: var(--muted); }
.mono { font-family: "SF Mono", Consolas, monospace; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 34px;
  width: 320px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 22px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--success-soft); color: var(--success); }

.quiddich-workspace {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.quiddich-ticker-rail {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.quiddich-ticker-rail form { margin: 0; }

.quiddich-ticker-button {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.025em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.quiddich-ticker-button:hover,
.quiddich-ticker-button.active {
  border-color: rgba(155, 124, 255, 0.85);
  background: rgba(155, 124, 255, 0.10);
}

.quiddich-ticker-button.enabled {
  border-color: var(--success);
  box-shadow: inset 0 0 0 1px rgba(58, 207, 134, 0.18);
}

.quiddich-ticker-button.enabled.active {
  box-shadow: inset 0 0 0 1px rgba(58, 207, 134, 0.24), 0 0 0 1px rgba(58, 207, 134, 0.14);
}

.quiddich-ticker-button.add {
  justify-content: center;
  min-height: 42px;
  border-style: dashed;
  color: #b7a4ff;
  font-size: 22px;
  line-height: 1;
}

.quiddich-ticker-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(58, 207, 134, 0.72);
}

.quiddich-profile-pane { min-width: 0; }
.hedger-workspace { align-items: start; }

.hedger-exchange-card {
  border-color: rgba(155, 124, 255, 0.22);
}

.hedger-exchange-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.hedger-exchange-heading h2 { margin: 4px 0 0; }
.hedger-exchange-toggle { margin: 0; }

.hedger-checkbox-field {
  display: flex;
  align-items: end;
  padding-bottom: 9px;
}

.hedger-live-grid,
.hedger-connection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.hedger-weekend-arb {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.hedger-weekend-arb > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(155, 124, 255, 0.30);
  border-radius: 3px;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.10), rgba(155, 124, 255, 0.05));
}

.hedger-weekend-arb span,
.hedger-weekend-arb small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.hedger-weekend-arb strong {
  display: block;
  margin: 7px 0 4px;
  color: var(--text);
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.hedger-live-grid > div,
.hedger-connection-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-panel-2);
}

.hedger-live-grid span,
.hedger-live-grid small,
.hedger-connection-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.hedger-live-grid strong {
  display: block;
  margin: 6px 0 3px;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hedger-connection-card .switch { margin-bottom: 12px; }
.hedger-connection-card label:not(.switch) { margin-top: 8px; }

@media (max-width: 900px) {
  .hedger-exchange-heading { align-items: flex-start; flex-direction: column; }
  .hedger-live-grid,
  .hedger-connection-grid,
  .hedger-weekend-arb { grid-template-columns: 1fr; }
}
.quiddich-stats-title h2 { margin-bottom: 5px; }
.quiddich-stats-title p { margin: 0; }

.quiddich-stats-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiddich-stats-pane > .panel { margin-bottom: 0; }

.quiddich-stats-toolbar {
  padding: 16px;
  border-color: rgba(155, 124, 255, 0.28);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.07), rgba(155, 124, 255, 0.035));
}

.quiddich-stats-heading,
.quiddich-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.quiddich-stats-heading h2,
.quiddich-section-title h2 {
  margin: 2px 0 0;
  font-size: 19px;
}

.quiddich-stats-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quiddich-stats-heading p span { color: #b7a4ff; padding: 0 5px; }

.quiddich-kicker {
  color: #9f8bff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.quiddich-period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(155, 124, 255, 0.16);
}

.quiddich-period-tab {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.quiddich-period-tab:hover {
  color: var(--text);
  border-color: rgba(155, 124, 255, 0.55);
}

.quiddich-period-tab.active {
  color: #e8e2ff;
  border-color: #8f74ef;
  background: rgba(143, 116, 239, 0.17);
}

.quiddich-custom-period {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quiddich-custom-period label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.quiddich-custom-period input[type="date"] {
  width: 142px;
  padding: 6px 8px;
  border-radius: 3px;
}

.quiddich-custom-period .btn { min-height: 31px; padding: 6px 12px; }

.quiddich-reset-period {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
}

.quiddich-view-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
  position: relative;
  z-index: 2;
  margin-bottom: -14px;
  padding: 0 0 0 12px;
  border: 0;
  background: transparent;
}

.quiddich-view-tab {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  flex: 0 0 180px;
  width: 180px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.quiddich-view-tab:hover {
  color: var(--text);
  border-color: rgba(155, 124, 255, 0.55);
  background: rgba(155, 124, 255, 0.07);
}
.quiddich-view-tab.active {
  color: #e8e2ff;
  border-color: #8f74ef;
  background: rgba(143, 116, 239, 0.17);
}

.quiddich-view-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiddich-view-panel[hidden] { display: none; }

.quiddich-sigma-panel { padding: 16px; }
.quiddich-sigma-intro {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.quiddich-sigma-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid rgba(155, 124, 255, 0.16);
}

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

.quiddich-sigma-form input {
  width: 170px;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 3px;
}

.quiddich-sigma-form .btn { min-height: 34px; }
.quiddich-sigma-state {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
}

.quiddich-sigma-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.quiddich-sigma-card {
  min-width: 0;
  margin: 0;
  padding: 15px;
  border-top: 2px solid rgba(126, 137, 164, 0.25);
}

.quiddich-sigma-card.ready { border-top-color: #8f74ef; }
.quiddich-sigma-card.error { border-top-color: var(--danger); }
.quiddich-sigma-card.loading { border-top-color: #5b8cff; }
.quiddich-sigma-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.quiddich-sigma-card h3 { margin: 3px 0 0; font-size: 15px; }
.quiddich-sigma-message { min-height: 88px; display: flex; align-items: center; color: var(--muted); font-size: 11px; line-height: 1.5; }

.quiddich-sigma-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--border);
}

.quiddich-sigma-metrics > div {
  min-width: 0;
  padding: 10px;
  background: var(--bg-panel-2);
}

.quiddich-sigma-metrics span,
.quiddich-sigma-levels span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.quiddich-sigma-metrics strong,
.quiddich-sigma-levels strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiddich-sigma-metrics small { display: block; margin-top: 3px; color: #65708a; font-size: 9px; }
.quiddich-sigma-levels { display: grid; grid-template-columns: repeat(7, minmax(64px, 1fr)); gap: 1px; margin-top: 10px; overflow-x: auto; border: 1px solid var(--border); border-radius: 3px; background: var(--border); }
.quiddich-sigma-levels > div { min-width: 64px; padding: 8px; background: var(--bg-panel-2); }
.quiddich-sigma-levels .upper strong { color: #f0a96a; }
.quiddich-sigma-levels .zero strong { color: #b7a4ff; }
.quiddich-sigma-levels .lower strong { color: #62b7ff; }
.quiddich-sigma-meta { margin: 10px 0 0; color: #65708a; font-size: 9px; line-height: 1.45; }

.quiddich-summary-panel { padding: 16px; }

.quiddich-route-meta {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 65%;
}

.quiddich-route-meta span,
.quiddich-table-count {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: var(--bg-panel-2);
  font-size: 10px;
}

.quiddich-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--border);
}

.quiddich-metric {
  min-width: 0;
  padding: 14px 13px;
  background: var(--bg-panel-2);
}

.quiddich-metric.primary { background: linear-gradient(135deg, rgba(58, 207, 134, 0.09), var(--bg-panel-2)); }
.quiddich-metric > span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.055em; }
.quiddich-metric strong { display: block; margin-top: 7px; overflow: hidden; font-size: 18px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.quiddich-metric small { display: block; margin-top: 5px; color: #65708a; font-size: 10px; }

.quiddich-data-note {
  margin: 11px 0 0;
  color: #76819b;
  font-size: 10px;
  line-height: 1.5;
}

.quiddich-equity-panel { padding: 16px; }

.quiddich-chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.quiddich-chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.quiddich-chart-legend i { width: 18px; height: 2px; background: currentColor; }
.quiddich-chart-legend i.gross { color: #3acf86; }
.quiddich-chart-legend i.mexc { color: #ad91ff; }
.quiddich-chart-legend i.binance { color: #5b8cff; }

.quiddich-chart-wrap {
  position: relative;
  width: 100%;
  margin-top: 13px;
  overflow-x: auto;
  border: 1px solid rgba(126, 137, 164, 0.12);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.012), rgba(0, 0, 0, 0.05));
}

.quiddich-chart-wrap canvas { display: block; }

.quiddich-chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 160px;
  padding: 9px 10px;
  border: 1px solid rgba(155, 124, 255, 0.35);
  border-radius: 3px;
  background: rgba(12, 15, 24, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  font-size: 10px;
}

.quiddich-chart-tooltip strong { display: block; margin-bottom: 6px; }
.quiddich-chart-tooltip span { display: flex; justify-content: space-between; gap: 18px; margin-top: 3px; color: var(--muted); }
.quiddich-chart-tooltip b { color: var(--text); }

.quiddich-chart-empty {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 13px;
  border: 1px dashed rgba(126, 137, 164, 0.25);
  border-radius: 3px;
  color: var(--muted);
  text-align: center;
}

.quiddich-chart-empty strong { color: var(--text); }
.quiddich-chart-empty span { max-width: 520px; font-size: 11px; }

.quiddich-live-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.quiddich-live-grid .panel { margin-bottom: 0; }
.quiddich-live-card { padding: 15px; }
.quiddich-live-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.quiddich-live-head > strong { font-size: 18px; }
.quiddich-live-card > p { margin: 10px 0 0; color: var(--muted); font-size: 11px; }

.quiddich-leg-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quiddich-leg-grid > div {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-panel-2);
}

.quiddich-leg-grid span { display: block; color: var(--muted); font-size: 9px; letter-spacing: 0.05em; }
.quiddich-leg-grid strong { display: block; margin-top: 4px; font-size: 12px; }

.quiddich-flat-state {
  min-height: 110px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  column-gap: 8px;
  margin-top: 8px;
}

.quiddich-flat-state small { grid-column: 2; margin-top: 4px; color: var(--muted); }
.quiddich-flat-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px rgba(58, 207, 134, 0.6); }

.quiddich-table-panel { padding: 15px; }
.quiddich-table-scroll { margin-top: 12px; overflow-x: auto; }
.quiddich-stats-table { min-width: 1180px; margin: 0; }
.quiddich-stats-table.compact { min-width: 900px; }
.quiddich-stats-table th { position: sticky; top: 0; background: var(--bg-panel); color: #7f8aa5; font-size: 9px; letter-spacing: 0.055em; text-transform: uppercase; white-space: nowrap; }
.quiddich-stats-table td { font-size: 10px; white-space: nowrap; }
.quiddich-error-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

.quiddich-side {
  display: inline-block;
  min-width: 37px;
  padding: 3px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  text-align: center;
}

.quiddich-side.buy { color: var(--success); background: var(--success-soft); }
.quiddich-side.sell { color: var(--danger); background: var(--danger-soft); }

.quiddich-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-color: rgba(155, 124, 255, 0.34);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.08), rgba(155, 124, 255, 0.05));
}

.quiddich-hero p { margin: 0; max-width: 780px; line-height: 1.55; }

.quiddich-status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  min-width: 220px;
}

.quiddich-config-heading {
  margin: 24px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(155, 124, 255, 0.24);
  color: #b7a4ff;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiddich-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.quiddich-rule-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
}

.quiddich-rule-grid span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.quiddich-rule-grid strong { font-size: 13px; font-weight: 600; }

@media (max-width: 900px) {
  .quiddich-workspace { grid-template-columns: 1fr; }
  .quiddich-ticker-rail {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 3px;
  }
  .quiddich-ticker-rail form { flex: 0 0 54px; }
  .quiddich-ticker-button { width: auto; min-width: 138px; }
  .quiddich-ticker-button.add { min-width: 54px; }
  .quiddich-hero { flex-direction: column; }
  .quiddich-status-stack { justify-content: flex-start; min-width: 0; }
  .quiddich-stats-heading,
  .quiddich-section-title { flex-direction: column; }
  .quiddich-route-meta { justify-content: flex-start; max-width: none; }
  .quiddich-metric-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .quiddich-live-grid { grid-template-columns: 1fr; }
  .quiddich-sigma-results { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .quiddich-metric-grid { grid-template-columns: 1fr; }
  .quiddich-custom-period label { width: 100%; justify-content: space-between; }
  .quiddich-custom-period input[type="date"] { flex: 1; width: auto; }
  .quiddich-view-tabs { overflow-x: auto; }
  .quiddich-view-tab { flex: 0 0 138px; width: 138px; }
  .quiddich-sigma-form label { width: 100%; }
  .quiddich-sigma-form input { width: 100%; }
}

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.dashboard-health-strip {
  padding-top: 10px;
  padding-bottom: 10px;
}

.dashboard-health-strip-row {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.dashboard-health-strip h2,
.dashboard-health-strip .pill-row {
  margin: 0;
}

.dashboard-health-summary {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-left: auto;
  font-size: 13px;
}

@media (max-width: 900px) {
  .dashboard-health-summary { margin-left: 0; }
}

@media (max-width: 760px) {
  .layout {
    display: block;
  }

  .sidebar {
    width: 100%;
    padding: 8px;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand,
  .nav-link,
  .sidebar-footer {
    flex: 0 0 auto;
  }

  .brand {
    padding: 6px 10px;
  }

  .nav-link {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .sidebar-footer {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .sidebar-footer .btn {
    width: auto !important;
    white-space: nowrap;
  }

  .main {
    width: 100%;
  }

  .topbar {
    padding: 12px 14px;
  }

  .content,
  .content-dashboard {
    max-width: 100%;
    padding: 12px 10px 28px;
  }

  .panel {
    padding: 14px 12px;
  }

  .dashboard-positions-head {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-position-settings {
    justify-content: flex-start;
  }

  .dashboard-body {
    overflow-x: auto;
  }

  .dashboard-body .layout,
  .dashboard-body .main {
    width: 1580px;
    min-width: 1580px;
    max-width: none;
  }

  .dashboard-body .sidebar {
    overflow-x: visible;
  }
}

.empty { color: var(--muted); font-style: italic; padding: 12px 0; }

.screener-panel {
  padding-top: 0;
  padding-left: 22px;
  padding-right: 22px;
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 210px);
  overflow-y: auto;
  overflow-x: hidden;
}

.screener-panel table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.screener-panel .col-ticker { width: 11%; }
.screener-panel .col-price { width: 8%; }
.screener-panel .col-alpaca { width: 15%; }
.screener-panel .col-raw { width: 9.2%; }
.screener-panel .col-arb { width: 11.05%; }
.screener-panel .col-dev { width: 10.1%; }
.screener-panel .col-book { width: 15.6%; }
.screener-panel .col-book-small { width: 17%; }

.screener-panel td.mono,
.screener-panel th {
  white-space: nowrap;
}

.screener-panel th,
.screener-panel td {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1200px) {
  .screener-panel { padding-left: 10px; padding-right: 10px; }
  .screener-panel th,
  .screener-panel td { padding-left: 5px; padding-right: 5px; font-size: 12px; }
}

.screener-panel thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-panel);
  box-shadow: 0 1px 0 var(--border);
}

#screener-table tr.screener-search-hit > td {
  background: rgba(51, 193, 122, 0.18) !important;
  box-shadow: inset 0 1px 0 rgba(51, 193, 122, 0.9), inset 0 -1px 0 rgba(51, 193, 122, 0.9) !important;
  animation: screener-hit-glow 0.35s ease-out;
}

#screener-table tr.screener-search-hit > td:first-child {
  box-shadow: inset 2px 0 0 var(--success), inset 0 1px 0 rgba(51, 193, 122, 0.9), inset 0 -1px 0 rgba(51, 193, 122, 0.9) !important;
}

#screener-table tr.screener-search-hit > td:last-child {
  box-shadow: inset -2px 0 0 var(--success), inset 0 1px 0 rgba(51, 193, 122, 0.9), inset 0 -1px 0 rgba(51, 193, 122, 0.9) !important;
}

@keyframes screener-hit-glow {
  from { background: rgba(51, 193, 122, 0.04); }
  to { background: rgba(51, 193, 122, 0.18); }
}
