:root {
  color-scheme: dark;
  font: 16px system-ui, sans-serif;
  color: #e7eeeb;
  background: #181c1a;
  --panel: #202624;
  --line: #3d4a45;
  --muted: #acbdb6;
  --accent: #9ce2d0;
  --selected: #30443d;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.15rem; border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.topbar-actions button { margin: 0; }
h1, h2 { margin: 0; }
h1 { color: var(--accent); font-size: 1.35rem; }
h2 { font-size: 1rem; }
#connection { color: var(--accent); font-size: .875rem; }
.workspace { display: grid; grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr); align-items: start; gap: .9rem; padding: .9rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: .4rem; min-width: 0; }
.sidebar-section { padding: .85rem; margin-bottom: .75rem; }
.sidebar-section p { margin: .55rem 0 0; font-size: .875rem; overflow-wrap: anywhere; }
.account-list { display: grid; gap: .3rem; margin-top: .65rem; }
.sidebar-actions { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .65rem; }
.sidebar-actions button { flex: 1 0 auto; }
.account-list button, #open-predictions { text-align: left; width: 100%; }
#sidebar-toggle { display: none; }
#open-predictions { margin-top: .7rem; }
.signal-banner { padding: .7rem .9rem; color: var(--accent); border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.prediction-favorites {
  --line: #6f5835;
  margin: .65rem .85rem;
  overflow: hidden;
  background: #332a1d;
  border: 1px solid var(--line);
  border-radius: .4rem;
}
.favorites-header { justify-content: space-between; background: #40321f; }
.favorites-header h2, #add-favorite { color: #ffda91; }
#add-favorite { background: #503c23; border-color: #927348; }
#add-favorite:hover:enabled { background: #624a2b; }
.prediction-favorites th { background: #3b301f; }
#favorites-table td:nth-child(7) { white-space: normal; overflow-wrap: anywhere; }
.cooldown-status { display: block; color: var(--muted); }
.favorite-actions { white-space: normal; }
.favorite-actions button { color: #ffda91; white-space: nowrap; margin: .15rem .25rem .15rem 0; }
.logs { border-bottom: 1px solid var(--line); }
.logs summary, .manual-order summary { padding: .55rem .85rem; cursor: pointer; }
.manual-order { border-top: 1px solid var(--line); }
.manual-order p { margin: 0 .85rem .65rem; color: var(--muted); }
.manual-order form { padding: 0 .85rem .85rem; }
.manual-order button + button { margin-left: .35rem; }
#manual-order-availability { margin-left: .5rem; font-size: .8rem; }
.manual-order[data-unavailable] { background: #1b1e1d; }
.manual-order[data-unavailable] summary, .manual-order[data-unavailable] form { color: var(--muted); }
.manual-order[data-unavailable] form { opacity: .65; }
.log-table { max-height: 15rem; overflow: auto; }
.log-table th:first-child { width: calc(100% / 3 - 12%); }
.log-table th:nth-child(2) { width: 12%; }
.log-table th, .log-table td { white-space: normal; overflow-wrap: anywhere; }
.tabs, .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; padding: .65rem .85rem; border-bottom: 1px solid var(--line); }
.tabs { padding-block: .4rem 0; }
.tabs button { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.account-financials { display: flex; flex-wrap: wrap; gap: .45rem 1rem; margin-right: auto; }
.toolbar label { display: flex; align-items: center; gap: .4rem; }
.action-bar { border-top: 1px solid var(--line); border-bottom: 0; }
.settings-health { margin: 0; padding: .7rem .85rem; border-top: 1px solid var(--line); }
.sidebar-section p, #prediction-summary, .settings-health, th { color: var(--muted); }
#prediction-summary, .settings-health { font-size: .875rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; white-space: nowrap; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
th, td { font-size: .875rem; }
td, .symbol-button { overflow: hidden; text-overflow: ellipsis; }
#positions-table { min-width: 58rem; }
#positions-table th:nth-child(1) { width: 4.75rem; }
#positions-table th:nth-child(3), #positions-table th:nth-child(4) { width: 7rem; }
#positions-table th:nth-child(5) { width: 3.5rem; }
#positions-table th:nth-child(6) { width: 4.25rem; }
#positions-table th:nth-child(7) { width: 5.75rem; }
#positions-table th:nth-child(n+8):nth-child(-n+10) { width: 3.75rem; }
#positions-table th:nth-child(11) { width: 5.25rem; }
#positions-table th:nth-child(12) { width: 3rem; }
#positions-table :is(th, td):is(:first-child, :nth-child(5), :nth-child(6), :nth-child(n+8)) {
  padding-inline: .35rem;
}
#positions-table .symbol-button { max-width: 100%; vertical-align: middle; }
@media (width > 46rem) {
  .topbar, .workspace {
    max-width: 82rem;
    margin-inline: auto;
    padding-inline: .9rem;
  }
  #positions-table {
    /* Fixed columns total 51.75rem. Leave room for the symbol and its padding. */
    width: min(100%, calc(54rem + 15ch));
    margin-inline: auto;
  }
  #positions-table .symbol-button {
    max-width: min(100%, calc(15ch + .9rem + 2px));
  }
}
.mobile-position-side { display: none; text-decoration: none; }
#favorites-table { min-width: 55rem; }
#forecasts-table { min-width: 46rem; }
#favorites-table th:nth-child(-n+3), #forecasts-table th:nth-child(-n+3) { width: 15%; }
#favorites-table th:nth-child(n+4):nth-child(-n+6),
#forecasts-table th:nth-child(n+4):nth-child(-n+6) { width: 9%; }
#favorites-table th:last-child { width: 17%; }
.sort-heading { border: 0; background: none; padding: .15rem 0; color: inherit; font-weight: inherit; touch-action: manipulation; }
th[aria-sort] { color: var(--accent); }
.sort-indicator { margin-left: .3rem; }
.mobile-sort { display: none; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #232b28; }
tbody tr[aria-selected="true"], button[aria-pressed="true"], button[aria-selected="true"] { background: var(--selected); color: #e9fff8; }
.symbol-button { padding: .25rem .45rem; }
.long { color: var(--accent); }
.short, [data-stale] #connection { color: #ffa6a1; }
.positive-metric { color: #8cbeff; }
.negative-metric { color: #ff8e89; }
button.danger { color: #ffa6a1; }
input, select, button { font: inherit; color: inherit; background: #171d1b; border: 1px solid var(--line); border-radius: .35rem; padding: .42rem .65rem; }
button { cursor: pointer; color: var(--accent); font-size: .875rem; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
dialog { width: min(42rem, calc(100vw - 1.5rem)); max-height: 86vh; padding: 0; border: 1px solid var(--line); border-radius: .5rem; background: var(--panel); color: inherit; }
dialog::backdrop { background: #101613c9; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
#editor-body { padding: 1rem; }
#editor-body p { margin-top: 0; }
#editor-body form + form { margin-top: .75rem; }
fieldset { margin: 0; padding: .8rem; border: 1px solid var(--line); border-radius: .4rem; min-width: 0; }
#editor-body fieldset { border: 0; }
legend { color: var(--accent); padding: 0 .4rem; }
.rule-group { background: #1a201e; margin-block: .65rem .85rem; }
.rule-group legend { font-weight: 650; }
.rule-group[data-inactive] { background: #1b1e1d; }
.rule-group[data-inactive] legend, .rule-group label:has(input:disabled) { color: var(--muted); }
.rule-group input:disabled { opacity: .65; cursor: default; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .8rem; }
.fields label { display: grid; align-content: start; gap: .4rem; font-size: .9rem; }
.parameter-help { color: var(--muted); font-size: .875rem; }
.parameter-help summary { cursor: pointer; padding: .35rem 0; color: var(--accent); }
#editor-body .parameter-help p { margin: 0 0 .45rem; }
input:not([type="checkbox"]) { width: 100%; }
input[type="checkbox"] { justify-self: start; }
form button { margin-top: .75rem; }
.save-result { display: block; padding-top: .65rem; color: var(--muted); }
.save-result:empty { display: none; }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-panel { width: min(100%, 24rem); padding: 1.35rem; }
.login-panel h2 { margin: .4rem 0 1rem; }
.login-panel label { display: grid; gap: .35rem; margin-bottom: .85rem; }
.login-panel button { width: 100%; min-height: 44px; }
.login-error { color: #ffa6a1; }
@media (max-width: 46rem) {
  .position-side > span { display: none; }
  .mobile-position-side { display: inline; }
  .workspace { grid-template-columns: minmax(0, 1fr); padding: .65rem; gap: .65rem; }
  .topbar { padding: .6rem .75rem; }
  .topbar-actions { gap: .4rem; }
  #connection { font-size: .75rem; }
  #sidebar-toggle { display: block; width: 100%; text-align: left; }
  #sidebar-toggle[aria-expanded="false"] + #sidebar-tools { display: none; }
  #sidebar-tools { margin-top: .55rem; }
  .tabs button { flex: 1; }
  button, .symbol-button, select, input:not([type="checkbox"]) { min-height: 44px; }
  input, select { font-size: 16px; }
  .mobile-sort { display: flex; }
  th, td { padding-inline: .4rem; }
  #favorites-table { min-width: 46rem; }
  #forecasts-table { min-width: 38rem; }
  dialog { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: .65rem .65rem 0 0; }
  .dialog-header { position: sticky; top: 0; background: var(--panel); z-index: 1; }
}
