

/* ---------------------------------------------------------------- coupling */

.band-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }

.band-row {
  display: grid;
  grid-template-columns: 116px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.band-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.band-bar {
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  /* The gap between segments is drawn in the surface colour so stacked bands
     read as distinct quantities rather than one continuous smear. */
  gap: 2px;
  background: var(--surface-raised);
}

.band-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  transition: filter .12s ease;
}
.band-seg:first-child { border-radius: 4px 0 0 4px; }
.band-seg:last-child { border-radius: 0 4px 4px 0; }
.band-seg:hover { filter: brightness(1.06); }

/* The printed share is what carries identity where the fill's contrast is
   below 3:1 — required relief, not decoration. Ink is chosen for legibility on
   the fill, which is why it is not a text token here. */
.band-seg span {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.band-gap {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0 2px;
  font-size: 12px;
  color: var(--text-secondary);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i {
  width: 12px; height: 12px; border-radius: 3px; display: inline-block;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.data-table th,
.data-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th:first-child,
.data-table td:first-child { text-align: left; }
.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom-width: 2px;
}
.data-table td { color: var(--text-primary); }
.data-table td.warn { color: #b45309; white-space: normal; font-size: 11px; }

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .data-table td.warn { color: #fbbf24; }
}
:root[data-theme="dark"] .data-table td.warn { color: #fbbf24; }

@media (max-width: 640px) {
  .band-row { grid-template-columns: 92px 1fr 44px; gap: 8px; }
  .band-name { font-size: 11px; }
}

/* An empty filter bar still carries its card padding and border, leaving a
   blank strip above pages that take no filters. :empty removes the frame
   rather than the element, so the layout closes up without a second rule
   having to know which pages those are. */
.filters:empty { display: none; }

/* Sequential ramp legend: contiguous cells, because a ramp is one continuous
   quantity rather than a set of separate categories. Labels sit under the
   boundaries they mark. */
.ramp-legend { display: flex; gap: 0; margin: 10px 0 2px; flex-wrap: wrap; }
.ramp-cell { display: flex; flex-direction: column; gap: 3px; min-width: 54px; }
.ramp-cell i { height: 10px; display: block; }
.ramp-cell:first-child i { border-radius: 3px 0 0 3px; }
.ramp-cell:last-child i { border-radius: 0 3px 3px 0; }
.ramp-cell small {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- data panel */

/* Sits in the card header opposite the title. Recessive until hovered: the
   chart is the content, this is a way in to what is behind it. */
.data-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.data-icon:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.data-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.data-icon.is-open {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface-1);
}

.data-panel { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.data-panel-bar { display: flex; justify-content: flex-end; margin-bottom: 8px; }

.csv-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.csv-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* Sortable headers are real buttons so the keyboard reaches them; they inherit
   the header cell's type rather than looking like page buttons. */
.th-sort {
  background: none; border: 0; padding: 0;
  font: inherit; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.th-sort:hover { color: var(--text-primary); }
.sort-mark { color: var(--accent); }
.data-table td.col-left, .data-table th.col-left { text-align: left; }

/* A long table scrolls inside the card instead of stretching the page. */
.data-panel .table-wrap { max-height: 460px; overflow: auto; }
.data-panel .data-table thead th {
  position: sticky; top: 0;
  background: var(--surface-raised);
  z-index: 1;
}

/* ----------------------------------------------------------- year scrubber */

.scrubber {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 12px;
}
.scrub-play {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px; line-height: 1;
  cursor: pointer;
}
.scrub-play:hover { color: var(--text-primary); border-color: var(--text-muted); }
.scrub-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scrub-range { flex: 1 1 auto; accent-color: var(--accent); }
.scrub-year {
  flex: 0 0 auto;
  min-width: 3.5em;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
/* A provisional year is marked on the control itself, not only in a note
   further down: the reader changing the year is looking here. */
.scrub-year.partial { color: #b45309; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme=light])) .scrub-year.partial { color: #fbbf24; }
}
:root[data-theme=dark] .scrub-year.partial { color: #fbbf24; }
.note.warn { color: #b45309; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme=light])) .note.warn { color: #fbbf24; }
}
:root[data-theme=dark] .note.warn { color: #fbbf24; }

/* ------------------------------------------------------------- pivot table */

.data-panel-bar { align-items: center; gap: 10px; }
.panel-spacer { flex: 1 1 auto; }

.panel-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius, 6px); overflow: hidden; }
.seg-btn {
  font-size: 12px; padding: 4px 10px;
  border: 0; background: transparent;
  color: var(--text-secondary); cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn[aria-pressed=true] { background: var(--surface-1); color: var(--text-primary); font-weight: 600; }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.panel-select {
  font-size: 12px; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: var(--radius, 6px);
  background: transparent; color: var(--text-secondary);
}

/* 36 year columns will not fit, so the table scrolls sideways with the entity
   column pinned — scrolling a name out of view makes every number anonymous. */
.pivot-wrap { max-height: 520px; overflow: auto; }
.pivot-table { font-size: 11px; }
.pivot-table th, .pivot-table td { padding: 4px 8px; white-space: nowrap; }
.pivot-table td.pivot-head, .pivot-table th.pivot-head {
  position: sticky; left: 0;
  background: var(--surface-raised);
  font-weight: 600;
  min-width: 120px;
  z-index: 1;
}
/* The corner cell sits above both sticky axes, so it needs the higher stack
   order or the scrolled header slides over it. */
.pivot-table thead th.pivot-head { z-index: 3; }
.pivot-table thead th { z-index: 2; }

/* Legend entries double as toggles on the history chart. */
.legend-toggle {
  border: 0; background: none; padding: 2px 0;
  font: inherit; color: var(--text-secondary); cursor: pointer;
}
.legend-toggle[aria-pressed="true"] { color: var(--text-primary); font-weight: 600; }
.legend-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.event-seg { margin-bottom: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------ theme toggle */

.head-controls { display: inline-flex; align-items: center; gap: 8px; }
/* portal.css positions .lang absolutely at the corner of its containing block,
 * which on the portal is the header itself. Here the containing block is
 * header.page-head, whose top-right corner is where #agent-fab lives — so the
 * language button rendered underneath the assistant icon and every click on
 * "EN" opened the drawer instead. Keep it in the flex row it was written into. */
.head-controls .lang { position: static; }

.theme-toggle {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px; line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--text-muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------ supply chain rows */

.cmd-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.cmd-row {
  display: grid;
  grid-template-columns: 190px 1fr 46px;
  align-items: center;
  gap: 12px;
}
.cmd-label { font-size: 12px; color: var(--text-secondary); display: flex; gap: 7px; align-items: baseline; }
.cmd-code {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
}
.cmd-bar {
  display: flex; height: 24px; border-radius: 4px; overflow: hidden;
  gap: 2px; background: var(--surface-raised);
}
.cmd-seg { display: flex; align-items: center; justify-content: center; min-width: 0; }
.cmd-seg:first-child { border-radius: 4px 0 0 4px; }
.cmd-seg:last-child { border-radius: 0 4px 4px 0; }
.cmd-seg span {
  font-size: 10px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  white-space: nowrap; overflow: hidden; pointer-events: none;
}
.cmd-rest { background: var(--ghost, #e0e0dc); }
.cmd-eff {
  font-size: 12px; text-align: right; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 680px) {
  .cmd-row { grid-template-columns: 120px 1fr 38px; gap: 8px; }
  .cmd-label { font-size: 11px; }
}


/* --------------------------------------------- AI assistant
   Ported from the trade bloc so both panels look and behave the
   same; the difference between them is the toolset, not the UI. */
.chat-log {
  min-height: 320px; max-height: 60vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 6px 2px;
}
.chat-welcome { color: var(--text-muted); padding: 40px 20px; text-align: center; }
.chat-row { display: flex; flex-direction: column; }
.chat-user { align-items: flex-end; }
.chat-assistant { align-items: flex-start; }
.chat-bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.55; overflow-wrap: break-word;
}
.chat-user .chat-bubble {
  background: var(--accent, #3987e5); color: #fff;
  border-bottom-right-radius: 4px; white-space: pre-wrap;
}
.chat-assistant .chat-bubble {
  background: var(--ghost); color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul { margin: 4px 0 8px; padding-left: 20px; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble h3, .chat-bubble h4, .chat-bubble h5 { margin: 10px 0 6px; }
.chat-bubble code {
  background: var(--surface-1); padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px;
}
.chat-bubble .table-wrap { margin: 8px 0; }
.chat-tools { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.chat-status { font-size: 12px; color: var(--text-muted); font-style: italic; }
.chat-input-row {
  display: flex; gap: 10px; margin-top: 14px; align-items: flex-end;
}
.chat-input-row textarea {
  flex: 1; resize: vertical; min-height: 44px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font: inherit; font-size: 13.5px;
}
.chat-input-row textarea:focus { outline: 2px solid var(--accent, #3987e5); }
.chat-send {
  background: var(--accent, #3987e5); color: #fff; border: 0;
  border-radius: var(--radius); padding: 11px 22px; font: inherit;
  font-size: 13.5px; cursor: pointer;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }
#agent-banner {
  background: color-mix(in srgb, var(--accent, #3987e5) 8%, var(--surface-1));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: 13px;
  color: var(--text-secondary);
}
#agent-banner code {
  background: var(--surface-1); padding: 1px 5px; border-radius: 4px;
}
#agent-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 70;
  width: 54px; height: 54px; border-radius: 50%; border: 0;
  background: var(--accent, #3987e5); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22), 0 2px 5px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease;
}
#agent-fab:hover { transform: scale(1.07); }
#agent-fab[aria-expanded="true"] { transform: scale(0.94); }
#agent-panel {
  position: fixed; right: 26px; bottom: 92px; z-index: 70;
  width: min(460px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 130px));
  display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 16px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24), 0 3px 9px rgba(0, 0, 0, 0.12);
}
#agent-panel[hidden] { display: none; }
.agent-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px; gap: 8px;
}
.agent-panel-head h2 { margin: 0; font-size: 15px; }
.agent-panel-head .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.agent-panel-actions { display: flex; gap: 6px; flex-shrink: 0; }
#agent-panel .chat-log { flex: 1; min-height: 0; max-height: none; }
#agent-panel .note { margin: 8px 0 0; font-size: 10.5px; }


/* ------------------------------------------------- assistant drawer -------
   Replaces the corner bubble. A grounded answer is often a wide table plus
   several paragraphs; 460x640 floating above a button could not hold one
   without scrolling in small steps.

   The trigger sits top-left with the page title — where a reader looks to
   begin something — and the panel is a full-height drawer on the right.
*/

#agent-fab {
  position: static;
  width: auto; height: 34px;
  padding: 0 14px 0 11px;
  border-radius: 9px;
  gap: 7px;
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 600;
  box-shadow: none;
  transform: none;
}
#agent-fab::after {
  content: attr(data-label);
  white-space: nowrap;
}
#agent-fab svg { width: 17px; height: 17px; }
#agent-fab:hover { transform: none; filter: brightness(1.06); }
#agent-fab[aria-expanded="true"] { transform: none; }

/* The drawer. Fixed to the viewport edge so it is full height regardless of
   how far the page has scrolled. */
#agent-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  left: auto;
  z-index: 70;
  width: clamp(480px, 34vw, 620px);
  height: 100vh;
  max-height: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .10);
  padding: 18px 20px 16px;
}

/* Give the drawer its room instead of covering the charts, so an answer can
   be read against the figure that prompted it. */
@media (min-width: 1100px) {
  body.agent-open .app { padding-right: clamp(480px, 34vw, 620px); }
  .app { transition: padding-right .2s ease; }
}

#agent-panel .chat-log {
  flex: 1;
  min-height: 0;
  max-height: none;
  /* Wider than the bubble allowed, so a table of a dozen rows fits without
     wrapping every cell. */
  font-size: 13.5px;
}
#agent-panel .chat-log table { width: 100%; font-size: 12px; }
#agent-panel #agent-input { min-height: 54px; }

.agent-panel-head { margin-bottom: 12px; }

@media (max-width: 1099px) {
  /* Not enough width for both; the drawer overlays and the page stays put. */
  #agent-panel { width: min(520px, 100vw); }
}


/* The trigger sits in the existing control row beside the
   theme and language buttons. */
#agent-slot { display: inline-flex; margin-right: 8px; }


/* The trigger is a bolt and nothing else. A bubble with the words "AI 问答"
   described a chat assistant; this queries the platform's own data, and the
   tooltip says so for anyone who needs it spelled out. */
#agent-fab {
  width: 34px;
  padding: 0;
  gap: 0;
  justify-content: center;
}
#agent-fab::after { content: none; }
#agent-fab svg { width: 17px; height: 17px; }

/* The header carries the trigger opposite its title. Without this the slot is
   the header's first child in source order and pushes the h1 down, which reads
   as a bar above the page rather than as one of its controls. Placed with
   explicit grid coordinates rather than flex  so the reading order a
   screen reader follows still matches the source. */
.page-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 4px 16px;
}
#agent-slot { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
.page-head h1 { grid-column: 1; grid-row: 1; }
.page-head > .sub, .page-head p { grid-column: 1; grid-row: 2; }


/* ---- market: quotes + headlines ------------------------------------- */
/* The board needs width to keep ten labelled rows legible; the sparkline is a
 * glance. Below 900px they stack rather than both shrinking. */
.market-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .market-grid { grid-template-columns: 1fr; } }

.news-list { list-style: none; margin: 0; padding: 0; }
.news-item { padding: 11px 0; border-bottom: 1px solid var(--grid); }
.news-item:last-child { border-bottom: 0; }
.news-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 3px; }
.news-src {
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  color: var(--text-secondary);
}
/* A government statistical agency and a trade blog are not the same kind of
 * source. The page marks the difference rather than flattening it. */
.news-src.is-official {
  color: var(--rail-accent-ink, #141a22);
  background: var(--rail-accent, #f5b800);
  padding: 1px 7px; border-radius: 3px;
}
.news-time { font-size: 11.5px; color: var(--text-muted); }
.news-title {
  display: block; font-size: 14px; line-height: 1.45;
  color: var(--text-primary); text-decoration: none;
}
.news-title:hover { text-decoration: underline; }
.news-sum { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }


/* ---- chat history ---------------------------------------------------- */
/* Occupies the same box as the chat log, so opening the list swaps the view
 * instead of floating over a half-visible conversation. */
.chat-history { flex: 1 1 auto; overflow-y: auto; padding: 6px 0; }
.chat-history-empty {
  padding: 24px 16px; color: var(--text-muted);
  font-size: 13px; text-align: center; line-height: 1.6;
}
.chat-session {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  padding: 10px 14px; border: 0; border-bottom: 1px solid var(--grid);
  background: transparent; text-align: left; cursor: pointer;
  font: inherit; color: var(--text-primary);
}
.chat-session:hover { background: var(--surface-raised); }
/* The open conversation is marked with an accent edge rather than a fill, so
 * the row stays readable in both themes. */
.chat-session[aria-current="true"] {
  box-shadow: inset 3px 0 0 var(--rail-accent, #f5b800);
}
.chat-session-title {
  flex: 1 1 auto; font-size: 13px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-session-meta {
  flex: 0 0 auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap;
}
.chat-session-del {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 5px;
  border-radius: 3px;
}
.chat-session-del:hover { color: #d03b3b; background: var(--grid); }
.chat-history-foot {
  padding: 10px 14px; font-size: 11.5px; color: var(--text-muted);
}


/* ---- energy trade ---------------------------------------------------- */
.market-grid.two-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .market-grid.two-even { grid-template-columns: 1fr; } }
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; padding: 4px 0 2px;
}
.kpi { padding: 10px 12px; border-radius: 6px; background: var(--surface-raised); }
.kpi .kpi-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; }
/* Hero figures use the body sans and proportional digits — tabular-nums
 * makes a large standalone number look loose. */
.kpi .kpi-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.15; }
.kpi .kpi-note { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.chart-tip {
  position: absolute; pointer-events: none; padding: 4px 8px; border-radius: 4px;
  background: var(--surface-raised); border: 1px solid var(--grid);
  color: var(--text-primary); font-size: 12px; white-space: nowrap;
}
#et-series { position: relative; }


/* ---- consolidated views ---------------------------------------------- */
/* A view stacks several blocks. The jump bar names them in order and the
 * numbered heads make that order visible while scrolling. */
.view-subnav {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px;
}
.view-subnav button {
  font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--grid); background: var(--surface-raised);
  color: var(--text-secondary); cursor: pointer;
}
.view-subnav button:hover { color: var(--text-primary); border-color: var(--text-muted); }
.view-subnav button b { color: var(--rail-accent, #f5b800); font-weight: 700; margin-right: 4px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--grid);
  font-size: 17px; font-weight: 700; color: var(--text-primary);
}
.section-head:first-child { border-top: 0; padding-top: 0; margin-top: 8px; }
.section-head .n {
  font-size: 12px; font-weight: 700; color: var(--rail-accent-ink, #141a22);
  background: var(--rail-accent, #f5b800); border-radius: 4px; padding: 1px 7px;
}
.section-head .lead { font-size: 12.5px; font-weight: 400; color: var(--text-muted); }


/* ---- research shelf --------------------------------------------------- */
.rs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.rs-card { padding: 14px 16px; border-radius: 8px; background: var(--surface-raised); border: 1px solid var(--grid); }
.rs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rs-head h3 { margin: 0; font-size: 15px; }
.rs-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.st-scoping { background: var(--grid); color: var(--text-secondary); }
.st-active { background: var(--rail-accent, #f5b800); color: var(--rail-accent-ink, #141a22); }
.st-revision { background: #d9c8ff; color: #2b1a5e; }
.st-done { background: #cfe9d6; color: #144d2a; }
.rs-meta { font-size: 11.5px; color: var(--text-muted); margin: 4px 0 8px; }
.rs-summary { font-size: 13px; line-height: 1.55; margin: 0 0 8px; }
.rs-tags span { display: inline-block; font-size: 11px; padding: 1px 7px; margin: 0 4px 4px 0; border-radius: 3px; background: var(--grid); color: var(--text-secondary); }
.rs-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rs-doc, .rs-link { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--grid); background: transparent; color: var(--text-primary); cursor: pointer; }
.rs-doc:hover, .rs-link:hover { border-color: var(--text-muted); }
.rs-doc:disabled { opacity: .45; cursor: not-allowed; }
.rs-docview { margin: 0 0 16px; padding: 12px 16px; border-radius: 8px; background: var(--surface-raised); border: 1px solid var(--grid); }
.rs-docbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.rs-docbody { max-height: 70vh; overflow: auto; font-size: 13.5px; line-height: 1.6; }
.rs-explainer { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); margin-top: 8px; }
.rs-explainer b { color: var(--text-primary); }


/* ---- data-source attribution (shared design with the trade platform) --- */
.src-foot {
  margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--grid);
  font-size: 11px; line-height: 1.5; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline;
}
.src-foot .src-label { font-weight: 700; letter-spacing: .02em; }
.src-foot a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px dotted var(--text-muted); }
.src-foot a:hover { color: var(--text-primary); }
.src-foot .src-lic { padding: 0 5px; border-radius: 3px; background: var(--grid); }
.src-foot .src-all { margin-left: auto; font: inherit; font-size: 11px; background: none; border: 0; color: var(--text-secondary); cursor: pointer; text-decoration: underline dotted; }
.src-foot .src-all:hover { color: var(--text-primary); }
#sources-panel {
  position: fixed; top: 0; right: 0; width: min(560px, 100vw); height: 100vh; overflow: auto; z-index: 60;
  background: var(--surface-raised); border-left: 1px solid var(--grid); box-shadow: -8px 0 24px rgba(0,0,0,.18);
  padding: 16px 20px 32px; font-size: 13px; line-height: 1.55; color: var(--text-primary);
}
.src-panel-head { display: flex; justify-content: space-between; align-items: center; }
.src-panel-head h2 { margin: 0; font-size: 17px; }
.src-panel-intro { color: var(--text-secondary); }
#sources-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 6px; }
.src-rec { padding: 10px 0; border-top: 1px solid var(--grid); }
.src-rec h4 { margin: 0 0 6px; font-size: 14px; }
.src-rec h4 a { color: var(--text-primary); text-decoration: none; }
.src-rec dl { display: grid; grid-template-columns: 7em 1fr; gap: 3px 10px; margin: 0; }
.src-rec dt { color: var(--text-muted); }
.src-rec dd { margin: 0; }
.src-panel-foot { color: var(--text-muted); font-size: 11px; margin-top: 16px; }
