/* Layout option 2b — dashboard LEFT, tender list RIGHT (index.html only, via body.layout-split-left).
 * ≥1200px: dashboard column (hero, stat tiles, filters, 7 charts) + list column, both on the normal page scroll.
 * <1200px: compact hero + "Dashboard & filters | Tenders" tabs, Tenders by default. */
body.layout-split-left { --max: 2400px; --gutter: clamp(12px, 2vw, 36px); }
body.layout-split-left .header-inner { padding-left: var(--gutter); padding-right: var(--gutter); }

.split-shell { max-width: var(--max); margin: 0 auto; padding: 16px var(--gutter) 32px; min-width: 0; }
.split-shell main.page { max-width: none; margin: 0; padding: 0; min-width: 0; container-type: inline-size; }
.split-shell .market { max-width: none; margin: 0; padding: 0; }
.split-shell #market[hidden] { display: none !important; }
.dash { min-width: 0; }
.filters-panel { padding: 12px 14px; }
.filters-panel .filters > summary { cursor: pointer; }
.dash-see { display: none; }

/* Tabs */
.split-tabs { display: none; }
.split-tab {
  flex: 1 1 0; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent;
  font: inherit; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.split-tab[aria-selected="true"] { background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(7,44,67,.25); }
.split-tab:focus-visible { outline: 3px solid rgba(13,122,95,.45); outline-offset: 2px; }
.tab-badge { display: inline-block; min-width: 1.4em; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: #ffd27a; color: #1b2a12; font-size: .74rem; font-weight: 750; line-height: 1.5; }
.tab-badge[hidden] { display: none; }

/* ---------- Wide: dashboard left, list right ---------- */
@media (min-width: 1200px) {
  .split-shell {
    display: grid; align-items: start; gap: 20px;
    grid-template-columns: clamp(400px, 32vw, 780px) minmax(0, 1fr);
    grid-template-areas: "dash main";
  }
  .split-shell main.page { grid-area: main; }
  /* flows with the normal page scroll (no sticky panel, no inner scrollbar) */
  .dash {
    grid-area: dash;
    display: flex; flex-direction: column; gap: 12px;
    container-type: inline-size;
  }
  .dash #market { display: contents; }
  .dash .market-hero { order: 1; padding: 16px 16px 14px; border-radius: 14px; }
  .dash .filters-panel { order: 2; }
  .dash .market-charts { order: 3; margin-top: 0; }
  .dash .market-hero h1 { font-size: 1.3rem; }
  .dash .hero-sub { display: none; }
  .dash .scope-bar { margin: 10px 0 0; }
  .dash .stat-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
  .dash .stat { grid-column: span 2; padding: 9px 10px 8px; }
  .dash .stat:nth-child(n+4) { grid-column: span 3; }
  .dash .stat-k { font-size: 1.25rem; }
  .dash .stat-s { display: none; }
  .dash .chart-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .dash .lanes-card { grid-column: auto; }
  /* the filter panel opens in a narrow column: one field group per row */
  .dash .filter-grid { grid-template-columns: minmax(0, 1fr); }
}
@container (min-width: 600px) {
  .dash .stat-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dash .stat, .dash .stat:nth-child(n+4) { grid-column: auto; }
}
@container (min-width: 700px) { .dash .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 560px) { .dash .map-wrap { grid-template-columns: minmax(0, 1fr); } .dash .uk-map { max-height: 280px; } }
@container (min-width: 700px) { .dash .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash .lanes-card { grid-column: 1 / -1; } }

/* Tender list: 2 columns when the list column is wide enough */
@container (min-width: 1150px) {
  .split-main #list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .split-main #list > li { margin: 0; }
  .split-main #list > li.loading, .split-main #list > li.empty { grid-column: 1 / -1; }
}

/* ---------- Narrow: compact hero, then tabs ---------- */
@media (max-width: 1199.98px) {
  .split-shell { display: flex; flex-direction: column; padding-top: 12px; }
  .split-shell .dash, .split-shell #market { display: contents; }
  .split-shell .market-hero { order: 1; padding: 14px 16px 12px; }
  .split-shell .market-hero h1 { font-size: 1.25rem; }
  .split-shell .hero-sub, .split-shell .scope-hint { display: none; }
  .split-shell .scope-bar { margin: 8px 0 0; }
  .split-shell .scope-all { display: none; }
  .split-shell .stat-strip { margin-top: 10px; gap: 8px; }
  .split-shell .stat { padding: 8px 10px 7px; }
  .split-shell .stat-k { font-size: 1.2rem; }
  .split-shell .stat-s { display: none; }
  .split-tabs {
    order: 2; display: flex; gap: 4px; padding: 4px; margin: 12px 0;
    position: sticky; top: 0; z-index: 20;
    background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  }
  .split-shell .filters-panel { order: 3; margin-bottom: 12px; }
  .split-shell .market-charts { order: 4; margin-top: 0; }
  .split-shell .dash-see { order: 5; }
  .split-shell .split-main { order: 3; }
  .split-shell[data-view="tenders"] :is(.filters-panel, .market-charts, .dash-see) { display: none; }
  .split-shell[data-view="dash"] .split-main { display: none; }
  .split-shell[data-view="dash"] .dash-see {
    display: block; position: sticky; bottom: 12px; z-index: 15; margin: 14px auto 0; width: min(100%, 420px);
    padding: 12px 18px; border-radius: 999px; box-shadow: 0 6px 20px rgba(7,44,67,.3);
  }
  /* dashboard tab: charts as a vertical page, not the swipe carousel */
  .split-shell .chart-grid { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; scroll-snap-type: none; }
  .split-shell .market-charts > summary small::after { content: none; }
}
@media (min-width: 761px) and (max-width: 1199.98px) {
  .split-shell .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .split-shell .chart-grid { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .split-shell .stat-strip { grid-auto-columns: 31%; }
  .split-shell .stat-l { font-size: .78rem; line-height: 1.25; }
  .split-tab { padding: 8px 6px; font-size: .92rem; }
}

/* dashboard blocks never squash inside the scrolling panel */
.dash > *, .dash #market > * { flex-shrink: 0; }
.filters-panel .filters { margin-top: 0; border-top: 0; padding-top: 0; }
/* keep Clear / Apply in reach while the long filter panel is open (sticks to the viewport bottom) */
.filters-panel .filters[open] .filter-actions { position: sticky; bottom: 0; z-index: 3; background: var(--surface); padding: 10px 0 8px; border-top: 1px solid var(--line); }
.split-shell:has(.filters[open]) .dash-see { display: none !important; }

/* Notice detail uses the same right-hand column as the tender list. */
.split-shell.showing-notice .split-main > :not(#notice-view) { display: none; }
.split-shell.showing-notice #notice-view { display: block; min-width: 0; }
#notice-view[hidden] { display: none !important; }
.split-shell #notice-view .crumb {
  max-width: none;
  margin: 0 0 12px;
  padding: 0;
}
