/* Dashboard presentation. The shared scheme lives in tokens.css. */
.dashboard-context { display: none; }

:root[data-workspace="dashboard"] {
  --gs-target: var(--gs-control-compact);
  --gs-gutter: var(--gs-space-6);

  & :is(.logo .eye, .tab[aria-selected="true"], .frame-btn[aria-pressed="true"] .frame-weight) { color: var(--gs-accent); }
  & .brand { min-inline-size: 0; flex-wrap: wrap; column-gap: .5rem; row-gap: 0; line-height: 1.3; }
  & .brand strong { font-size: 1.125rem; white-space: nowrap; }
  & .brand span { color: var(--gs-muted); font-size: .8125rem; }
  & .dashboard-context { display: block; flex-basis: 100%; color: var(--gs-muted); font-size: .75rem; }
  & .topbar { height: auto; min-height: 3.5rem; padding-block: .375rem; border-color: var(--gs-border); }
  & .topbar > .top-actions { flex: none; flex-wrap: wrap; justify-content: flex-end; }
  & #dashboard-palette { min-block-size: var(--gs-target); padding-block: var(--gs-space-1); }
  & :is(.topbar, .tabsbar, .controls, .statusbar) { padding-inline: var(--gs-gutter); }
  & .workspace-nav { background: var(--gs-surface); }
  & :is(.statusbar, .system-row) { background: var(--gs-raised); }
  & :is(.tab, .style-pill, .frame-btn, .modes button, .reset, .small-button, .columns-menu summary,
          .theme-switch, .capital-groups button, #capital-markets, .drawer-head .icon-button, .modal-close) { min-block-size: var(--gs-target); }
  & :is(.style-pill, .frame-btn, .reset, .theme-switch, .searchbox, .drawer .search, .tf-select) {
    border-color: var(--gs-border-strong);
    border-radius: var(--gs-radius);
    background: var(--gs-raised);
  }
  & :is(.style-pill, .frame-btn, .modes button):is([aria-pressed="true"], :hover:not(:disabled)),
  & .tab[aria-selected="true"] .badge {
    color: var(--gs-accent);
    background: var(--gs-selected-bg);
    border-color: var(--gs-accent);
    box-shadow: none;
  }
  & :is(.ctl-label, .styles-docked .ctl-label, .frames-line) { color: var(--gs-subdued); }
  & .theme-switch { border-radius: 999px; }
  & .theme-knob { inset-block-start: 50%; margin-block-start: -12px; background: var(--gs-surface); color: var(--gs-accent); }
  & :is(.theme-track, .mode-suffix) { opacity: 1; }
  & :is(.small-button.primary, .capital-filter button.primary) { background: var(--gs-accent); color: var(--gs-action-ink); }
  & .small-button.primary:is(:hover, :focus-visible) { color: var(--gs-action-ink); }
  & :is(.searchbox, .drawer .search):focus-within { outline: var(--gs-focus); outline-offset: 2px; }
  & :is(.nav-item, .tab, .col-help, .col-gear, .col-eye, .scores th button, .grid-row-toggle,
          .grid-column-toggle, .studio-nav-item, .weight-option):focus-visible { outline: var(--gs-focus); outline-offset: -2px; }
  & .small-button.primary:focus-visible { outline: var(--gs-focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--gs-surface); }
  & :is(#dashboard-results, #capital-results) { scroll-padding-block-start: 2.5rem; }
  & .scores { font-family: var(--gs-font-table); font-size: .8125rem; }
  & .scores.adaptive-grid td[data-col] { height: 2.25rem; }
  & .scores tbody tr:focus-within td { background: var(--gs-selected-bg); }
  & :is(.tone-zero, .col-change .tone-zero, .sub.is-missing) { color: var(--gs-subdued); }
  & .trend:not(.tone-up, .tone-down) polyline { stroke: var(--gs-subdued); }
  & .bn-link { color: var(--gs-warm); }
  & .scores .symbol-links { gap: .125rem; margin-inline-start: 0; }
  & .scores .symbol-links a {
    display: inline-grid; place-items: center; min-inline-size: 1.5rem; min-block-size: 1.5rem;
  }
  & #table .col-symbol .symbol-name { max-inline-size: calc(100% - 3.25rem); }
  /* The EA fill colors carry established signal meaning. Adjust text contrast on those fills. */
  & .scores .value.is-strong:is(.tone-up, .tone-warn, .tone-grey) { color: var(--gs-signal-ink); }
  & .scores .sub.is-rank-up { color: var(--gs-rank-up); }
  & .scores .sub.is-rank-down { color: var(--gs-rank-down); }
  & .scores tr:is(:hover, :focus-within) .sub.is-rank-down { background: var(--gs-grid); }
  & .pf-tag { background: var(--gs-subdued); color: var(--gs-action-ink); }
  & .pf-tag.pf-green { background: var(--gs-positive); }
  & .pf-tag.pf-amber { background: var(--gs-warm); }
  & .pf-tag.pf-red { background: var(--gs-negative); }
  & .status-reasons, & .banner { color: var(--gs-warm); }
  & .banner { border-color: var(--gs-border-strong); background: var(--gs-warn-bg); }
  & .status[data-state="live"] :is(.code, .status-word) { color: var(--gs-status-live, var(--gs-positive)); }
  & .status:is([data-state="partial"], [data-state="stale"]) :is(.code, .status-word) { color: var(--gs-status-wait, var(--gs-warm)); }
  & .status[data-state="starting"] :is(.code, .status-word) { color: var(--gs-status-start, var(--gs-accent)); }
  & .status[data-state="fault"] :is(.code, .status-word) { color: var(--gs-status-fault, var(--gs-negative)); }
}

@media (max-width: 1023px) {
  :root[data-workspace="dashboard"] { --gs-gutter: var(--gs-space-4); }
}
@media (max-width: 900px) {
  :root[data-workspace="dashboard"] {
    & .capital-owner .topbar { flex-wrap: wrap; }
    & .capital-owner .topbar #tabs { order: 3; flex: 1 1 100%; }
    & .capital-owner .topbar .owner-search { order: 4; flex: 1 1 100%; }
  }
}
@media (max-width: 760px), (max-height: 590px) {
  :root[data-workspace="dashboard"] {
    & .shell .main { height: auto; }
    & .workspace-nav, & .disclaimer { position: relative; inset-block: auto; }
    & .shell .main > #dashboard-results, & .shell #capital-results {
      flex: none; block-size: clamp(15rem, 55dvh, 30rem);
    }
    & .shell #capital-view:not([hidden]) { flex: none; }
  }
}
@media (max-width: 600px) {
  :root[data-workspace="dashboard"] {
    --gs-gutter: var(--gs-space-3);
    --gs-target: var(--gs-control-touch);
    & .topbar { flex-wrap: wrap; column-gap: .375rem; }
    & .topbar > .brand { min-inline-size: 0; max-inline-size: 100%; }
    & .topbar > .top-actions { flex: 1 0 100%; }
    & .brand strong { font-size: 1rem; }
    & .frames { gap: .25rem; }
    & .frame-btn { min-inline-size: 0; padding-inline: .375rem; }
    & .searchbox { min-block-size: var(--gs-target); }
    & .searchbox .search-clear { min-inline-size: 2.75rem; min-block-size: var(--gs-target); justify-content: center; align-items: center; }
    & .workspace-nav #tabs { flex-wrap: nowrap; }
    & .workspace-nav #tabs .tab { min-block-size: var(--gs-target); padding-inline: .5rem; }
    & .shell .sidebar .logo { flex-basis: var(--gs-target); min-inline-size: var(--gs-target); }
    & .scores.adaptive-grid td[data-col] { height: 2.75rem; }
    & .drawer .search { min-block-size: var(--gs-target); }
    & :is(.reset.icon-only, .drawer-head .icon-button, .modal-close) { min-inline-size: var(--gs-target); justify-content: center; }
  }
}
@media (max-width: 350px) {
  :root[data-workspace="dashboard"] { --gs-gutter: var(--gs-space-2); }
}
