/* Desktop shell (≥1024px): deep-indigo sidebar, light top bar, labeled filter panel.
   Phones and tablets keep the gradient header and tab bar from app.css untouched. */
.sidebar { display:none; }

@media (min-width:1024px) {
  :root {
    --sidebar-w:232px; --maxw:1360px;
    --sidebar-bg:#1d2150; --sidebar-fg:#c5c9ee; --sidebar-muted:#8a90c4;
    --sidebar-hover:#ffffff0f; --sidebar-active:#ffffff1a; --sidebar-accent:#ffda49;
  }
  :root[data-theme='dark'] { --sidebar-bg:#11142a; --sidebar-hover:#ffffff0b; --sidebar-active:#ffffff14; }

  body { padding-left:var(--sidebar-w); }
  .tabbar { display:none; }
  .scroll-top { bottom:28px; right:28px; }
  #toast-host { bottom:32px; }

  /* ---------- sidebar ---------- */
  .sidebar { position:fixed; inset:0 auto 0 0; z-index:30; width:var(--sidebar-w); display:flex; flex-direction:column;
    background:var(--sidebar-bg); color:var(--sidebar-fg); }
  .sidebar-brand { display:flex; align-items:center; gap:11px; padding:22px 20px 18px; color:#fff; text-decoration:none; }
  .sidebar-brand svg { flex-shrink:0; color:#fff; }
  .sidebar-brand strong { display:block; font-size:17px; font-weight:650; letter-spacing:.06em; line-height:1.3; }
  .sidebar-brand small { display:block; margin-top:2px; font-size:11px; color:var(--sidebar-muted); line-height:1.4; }
  .sidebar-scroll { flex:1; min-height:0; overflow-y:auto; padding:4px 12px 16px; scrollbar-width:thin;
    scrollbar-color:#ffffff26 transparent; }
  .sidebar-primary { display:flex; flex-direction:column; gap:2px; padding-bottom:12px; margin-bottom:6px;
    border-bottom:1px solid #ffffff14; }
  .sidebar-link { position:relative; display:flex; align-items:center; gap:10px; min-height:34px; padding:0 10px;
    border-radius:8px; color:var(--sidebar-fg); font-size:13px; text-decoration:none; }
  .sidebar-link .icon { width:16px; height:16px; opacity:.8; }
  .sidebar-link:hover { background:var(--sidebar-hover); color:#fff; }
  .sidebar-link.is-active { background:var(--sidebar-active); color:#fff; font-weight:600; }
  .sidebar-link.is-active .icon { opacity:1; color:var(--sidebar-accent); }
  .sidebar-link.is-active::before { content:''; position:absolute; left:-12px; top:8px; bottom:8px; width:3px;
    border-radius:0 3px 3px 0; background:var(--sidebar-accent); }
  .sidebar-primary .sidebar-link { min-height:38px; font-size:14px; }
  .sidebar-group { margin-top:6px; }
  .sidebar-group summary { display:flex; align-items:center; justify-content:space-between; padding:8px 10px 6px;
    color:var(--sidebar-muted); font-size:12px; cursor:pointer; list-style:none; border-radius:6px; }
  .sidebar-group summary::-webkit-details-marker { display:none; }
  .sidebar-group summary:hover { color:var(--sidebar-fg); }
  .sidebar-group summary .icon { width:14px; height:14px; transition:transform .15s; }
  .sidebar-group:not([open]) summary .icon { transform:rotate(-90deg); }
  .sidebar-group .sidebar-link { min-height:32px; font-size:13px; }
  .sidebar :focus-visible { outline-color:var(--sidebar-accent); outline-offset:-2px; }
  .sidebar-foot { padding:12px 16px 18px; border-top:1px solid #ffffff14; }
  .sidebar-theme { display:flex; align-items:center; gap:8px; width:100%; min-height:34px; padding:0 10px;
    border:0; border-radius:8px; background:var(--sidebar-hover); color:var(--sidebar-fg); font-size:12px; }
  .sidebar-theme:hover { background:var(--sidebar-active); color:#fff; }
  .sidebar-foot p { margin:10px 2px 0; font-size:11px; color:var(--sidebar-muted); }

  /* ---------- top bar: same controls, light surface ---------- */
  .app-header {
    --header-fg:var(--color-text); --header-muted:var(--color-text-tertiary); --header-shadow:none;
    --glass-bg:var(--color-surface-sunken); --glass-bg-hover:var(--color-primary-1); --glass-bg-active:var(--color-primary-2);
    --glass-edge:transparent; --glass-ring:var(--color-primary-3); --glass-outline:var(--color-border);
    --glass-focus:var(--color-primary-5);
    position:static; padding:22px 32px 0; background:var(--color-bg);
  }
  .app-header>* { max-width:calc(var(--maxw) - 64px); margin-left:auto; margin-right:auto; }
  .header-heading { flex-direction:row; align-items:baseline; font-size:22px; font-weight:650; line-height:1.3;
    border-left:0; padding-left:0; }
  .header-heading small { display:none; }
  .header-back { width:32px; height:32px; background:var(--color-surface); color:var(--color-text-secondary);
    box-shadow:0 0 0 1px var(--color-border); }
  .header-back:hover { background:var(--color-primary-1); color:var(--color-primary); }
  .header-controls,#header-actions { gap:6px; }
  .app-header .icon-button { width:34px; height:34px; background:var(--color-surface); color:var(--color-text-secondary);
    box-shadow:0 0 0 1px var(--color-border); }
  .app-header .icon-button:hover { background:var(--color-primary-1); color:var(--color-primary); }
  .header-login { padding:6px 16px; font-size:13px; color:var(--color-surface); background:var(--color-primary); border-color:var(--color-primary); }
  .header-login:hover { filter:brightness(.92); }
  .header-avatar { width:34px; height:34px; background:var(--color-primary); color:var(--color-surface); }

  /* Filters become a labeled panel instead of stacked pills on a gradient. */
  #header-filters { margin-top:16px; padding:14px 18px; background:var(--color-surface); border-radius:var(--radius-12);
    box-shadow:var(--shadow-card); }
  #header-filters:not(:has(>:not([hidden]))) { display:none; }
  #header-filters>* { margin-top:0; }
  #header-filters>*+* { margin-top:10px; }
  .ranking-filters { gap:8px; }
  .ranking-toolbar { padding-bottom:4px; }
  .ranking-search { min-height:38px; border-radius:10px; box-shadow:inset 0 0 0 1px var(--color-border);
    background:var(--color-surface-alt); color:var(--color-text-tertiary); }
  .ranking-search input { font-size:13px; }
  .ranking-search:focus-within { background:var(--color-surface); }
  .glass-label { min-height:30px; }
  .glass-tabs { flex-wrap:wrap; gap:2px 4px; overflow:visible; padding:0; border-radius:0; background:none; box-shadow:none; }
  .glass-tabs button { min-height:28px; padding:0 11px; color:var(--color-text-secondary); }
  .glass-tabs button:hover { background:var(--color-surface-sunken); color:var(--color-text); }
  .glass-tabs button.active,.glass-tabs button[aria-pressed='true'] { background:var(--color-primary-1);
    box-shadow:none; color:var(--color-primary); font-weight:600; }
  /* A labeled group names what the row filters; wrapped options stay aligned under the first one. */
  .ranking-filters>.glass-tabs[aria-label] { position:relative; width:100%; padding-left:84px; }
  .ranking-filters>.glass-tabs[aria-label]::before { content:attr(aria-label); position:absolute; left:0; top:0;
    line-height:28px; font-size:12px; color:var(--color-text-tertiary); }
  .glass-tabs.is-clamped { max-height:60px; overflow:hidden; padding-right:84px; }
  .glass-tabs .chips-more { display:inline-flex; align-items:center; color:var(--color-primary); }
  .glass-tabs.is-clamped .chips-more { position:absolute; right:0; top:30px; background:var(--color-surface); }
  .glass-tabs.is-clamped .chips-more:hover { background:var(--color-primary-1); }
  #header-filters .chip-row { flex-wrap:wrap; gap:4px; padding:0; background:none; overflow:visible; }
  #header-filters .chip { color:var(--color-text-secondary); }
  #header-filters .chip:hover { background:var(--color-surface-sunken); }
  #header-filters .chip.is-active { background:var(--color-primary-1); box-shadow:none; color:var(--color-primary); font-weight:600; }
  #header-filters :is(.auth-input,.range-input,select),.mb-select { border-radius:8px; border:1px solid var(--color-border);
    background:var(--color-surface-alt); }
  #header-filters .text-link { color:var(--color-primary); }

  #app-outlet { padding:16px 32px 40px; max-width:var(--maxw); }
  .notice-bar { background:var(--color-surface-alt); box-shadow:none; border:1px solid var(--color-border-light); }
  .more-grid { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); }
}

/* Ranking rows: name, every period and the headline number share one line when there is room. */
@media (min-width:1280px) {
  .fund-ranking-list { padding:0 18px; }
  .fund-result { display:grid; grid-template-columns:26px minmax(220px,1fr) minmax(0,2.3fr) 96px;
    column-gap:18px; align-items:center; padding:14px 0; }
  .fund-result-head { display:contents; }
  .fund-result .rank-badge { grid-column:1; grid-row:1; }
  .fund-result-main { grid-column:2; grid-row:1; }
  .fund-result-value { grid-column:4; grid-row:1; align-self:center; }
  .fund-result-value strong { font-size:17px; font-weight:650; font-variant-numeric:tabular-nums; }
  .fund-periods { grid-column:3; grid-row:1; display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); gap:0 6px;
    margin:0; padding:0; border:0; font-size:12px; text-align:right; }
  .fund-periods>span { display:flex; flex-direction:column; align-items:flex-end; gap:2px; min-width:0; }
  .fund-periods>span>.muted { font-size:11px; }
  .fund-result>div:last-child:not(.fund-periods) { grid-column:1/-1; }
  .fund-result>div:last-child:not(:empty) { margin-top:4px; }
  .fund-title-button { font-size:14px; }
}
