@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-grad-1: #0e1116;
  --surface: #141920;
  --surface-raised: #1a2029;
  --surface-soft: #1d242e;
  --sidebar-bg: #0b0e13;
  --border: #242b35;
  --border-strong: #333d4c;
  --text: #e8ebf0;
  --muted: #8b94a3;
  --muted-strong: #c3cad4;
  --accent: #4f7cff;
  --accent-strong: #7897f5;
  --accent-ink: #f3f6ff;
  --accent-soft: rgba(79, 124, 255, 0.12);
  --accent-line: rgba(79, 124, 255, 0.45);
  --danger: #f2576e;
  --danger-soft: rgba(242, 87, 110, 0.12);
  --good: #21b885;
  --good-soft: rgba(33, 184, 133, 0.13);
  --warning: #e0a93b;
  --violet: #8b7cf6;
  --up: #21b885;
  --down: #f2576e;
  --panel: #141920;
  --hover-fill: rgba(255, 255, 255, 0.05);
  --track: rgba(255, 255, 255, 0.08);
  --chip-fill: rgba(255, 255, 255, 0.06);
  --well: rgba(0, 0, 0, 0.24);
  --scrim: rgba(0, 0, 0, 0.6);
  --warning-soft: rgba(224, 169, 59, 0.14);
  --danger-strong: #ff99a7;
  --warning-ink: #21160a;
  --header-bg: rgba(14, 17, 22, 0.88);
  --good-dim: #2aa578;
  --chart-grid: #1c2433;
  --chart-axis: #33405a;
  --chart-neutral: #8a94a8;
  --chart-amber: #f5b94b;
  --chart-1: var(--accent);
  --chart-2: var(--good);
  --chart-3: var(--danger);
  --chart-4: #e0a93b;
  --chart-5: var(--violet);
  --chart-6: #22b8cf;
  --chart-7: #f06595;
  --chart-8: #82c91e;
  --chart-9: #fd7e14;
  --chart-10: #15aabf;
  --chart-11: #e64980;
  --chart-fan-1: rgba(33, 184, 133, 0.15);
  --chart-fan-2: rgba(33, 184, 133, 0.35);
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: none;
  --sidebar-w: 232px;
  --sidebar-rail: 64px;
  --topbar-h: 52px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* Light theme — stamped as data-theme="light" on <html> by the boot script
   in index.html (explicit localStorage choice, else OS preference). */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-grad-1: #f3f4f6;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #eef1f5;
  --sidebar-bg: #eceff3;
  --border: #dde2e8;
  --border-strong: #c4ccd6;
  --text: #1a1f27;
  --muted: #5b6472;
  --muted-strong: #3c4450;
  --accent: #3560e0;
  --accent-strong: #2749b8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(53, 96, 224, 0.1);
  --accent-line: rgba(53, 96, 224, 0.42);
  --danger: #cf3a52;
  --danger-soft: rgba(207, 58, 82, 0.1);
  --good: #157f5f;
  --good-soft: rgba(21, 127, 95, 0.1);
  --warning: #9a6a10;
  --violet: #6d5ae0;
  --up: #157f5f;
  --down: #cf3a52;
  --panel: #ffffff;
  --hover-fill: rgba(26, 31, 39, 0.05);
  --track: rgba(26, 31, 39, 0.08);
  --chip-fill: rgba(26, 31, 39, 0.06);
  --well: rgba(26, 31, 39, 0.05);
  --scrim: rgba(15, 19, 26, 0.45);
  --warning-soft: rgba(154, 106, 16, 0.12);
  --danger-strong: #a82740;
  --header-bg: rgba(243, 244, 246, 0.88);
  --good-dim: #3d9578;
  --chart-grid: #e7eaef;
  --chart-axis: #c4ccd6;
  --chart-neutral: #667082;
  --chart-amber: #a8770f;
  --chart-4: #a8770f;
  --chart-6: #0f8fa3;
  --chart-7: #d0356f;
  --chart-8: #5c8f10;
  --chart-9: #c45a08;
  --chart-10: #0779b8;
  --chart-11: #c22a63;
  --chart-fan-1: rgba(21, 127, 95, 0.12);
  --chart-fan-2: rgba(21, 127, 95, 0.26);
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p {
  margin: 0;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 12px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: 20;
  overflow: hidden;
  transition: flex-basis 0.22s ease, width 0.22s ease, padding 0.22s ease, opacity 0.16s ease;
}

/* Keep nav labels on one line (clean rail animation) without forcing the
   footer's wrapping text (mode note) to overflow. */
.sidebar .nav-item span,
.sidebar .brand-copy strong,
.sidebar .sidebar-rail-toggle span {
  white-space: nowrap;
}

/* Collapsed — shrink to an icon rail (labels hidden, icons centered). */
.app.sidebar-collapsed .sidebar {
  flex-basis: var(--sidebar-rail);
  width: var(--sidebar-rail);
  padding-left: 10px;
  padding-right: 10px;
}

.app.sidebar-collapsed .brand-copy,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .mode-note,
.app.sidebar-collapsed .user-meta,
.app.sidebar-collapsed .logout-btn,
.app.sidebar-collapsed #statusText {
  display: none;
}

.app.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 4px 0 16px;
}

.app.sidebar-collapsed .nav-item {
  justify-content: center;
  gap: 0;
  padding: 0;
}

.app.sidebar-collapsed .user-chip,
.app.sidebar-collapsed .status-band {
  justify-content: center;
}

.app.sidebar-collapsed .user-chip {
  padding-left: 0;
  padding-right: 0;
}

/* Bottom rail toggle (> to open, < to close) */
.sidebar-rail-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.sidebar-rail-toggle:hover {
  background: var(--hover-fill);
  color: var(--text);
}

.sidebar-rail-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.22s ease;
}

.app.sidebar-collapsed .sidebar-rail-toggle span {
  display: none;
}

.app.sidebar-collapsed .sidebar-rail-toggle svg {
  transform: rotate(180deg);
}

.sidebar-toggle {
  flex: 0 0 auto;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 13px;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  font-size: 14px;
  letter-spacing: -0.01em;
}

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* Keep the footer (sign-in, status, collapse) from shrinking/clipping. */
.sidebar-foot {
  flex: 0 0 auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--hover-fill);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mode-note {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
}

.mode-note strong {
  font-size: 12px;
  color: var(--accent-strong);
}

.mode-note span {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------------- Main column ---------------- */
.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

/* Title and subtitle share one row so the bar keeps a fixed height (the
   research toolbar sticks directly beneath it at --topbar-h). */
.topbar-lead {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.topbar-lead h1 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 650;
  white-space: nowrap;
}

.topbar-lead p {
  color: var(--muted);
  margin-top: 0;
  font-size: 12px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Symbol search */
.symbol-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  transition: border-color 0.14s ease;
}

.symbol-search:focus-within {
  border-color: var(--accent-line);
}

.symbol-search svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.symbol-search input {
  width: 130px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  text-transform: uppercase;
}

.symbol-search input::placeholder {
  color: var(--muted);
  text-transform: none;
}

/* Security search + autocomplete (inside the Security view header) */
.security-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  /* doubled so the dropdown can show symbol + full name + tags + sector */
  min-width: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  transition: border-color 0.14s ease;
}

.search-inactive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.search-inactive-toggle input {
  accent-color: var(--accent, #4f7cff);
  cursor: pointer;
}

.security-search:focus-within {
  border-color: var(--accent-line);
}

.security-search svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.security-search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.security-search input::placeholder {
  color: var(--muted);
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.autocomplete-list li[role="option"] {
  display: grid;
  /* Symbol column sizes to its content — a fixed 64px track let long symbols
     (SAGILITY.NS) overflow into the company name. Fourth track: ETF/inactive tags. */
  grid-template-columns: minmax(64px, max-content) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.autocomplete-list li[role="option"]:hover,
.autocomplete-list li[role="option"].is-active {
  background: var(--accent-soft, rgba(79, 124, 255, 0.14));
}

.autocomplete-list .ac-symbol {
  font-weight: 700;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.autocomplete-list .ac-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.autocomplete-list .ac-tag-etf {
  color: var(--accent-strong);
  border-color: var(--accent-line);
}

.autocomplete-list .ac-tag-inactive {
  color: var(--warning);
  border-color: var(--warning);
  opacity: 0.85;
}

.autocomplete-list .ac-name {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-list .ac-sector {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.autocomplete-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

/* Research-only header controls (strategy + run snapshot/backtest) */
.research-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Full-width controls row directly below the topbar: refresh + research pickers
   + run actions. Shown on research views; on other views it carries just the
   refresh button. */
.research-toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
}

/* Let the pickers group fill the row so the run actions can sit at the far right. */
.research-toolbar .research-tools {
  flex: 1 1 auto;
}

/* Push the run actions to the right edge of the toolbar. */
.research-toolbar #runReviewBtn {
  margin-left: auto;
}

/* Strategy picker */
.earnings-scan-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.strategy-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.strategy-picker > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.strategy-picker select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 6px 6px;
  cursor: pointer;
  outline: none;
  max-width: 200px;
}

.strategy-picker select option {
  background: var(--surface-raised);
  color: var(--text);
}

/* ---------------- Buttons ---------------- */
button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

button.ghost {
  background: var(--surface);
  color: var(--muted-strong);
  border-color: var(--border);
}

button.ghost:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-icon {
  width: 32px;
  padding: 0;
  display: grid;
  place-items: center;
}

.btn-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- Product note ---------------- */
.product-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 24px 24px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
}

.product-note-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------------- Content ---------------- */
.content {
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

/* In-panel loading skeleton: a shimmer overlay shown over the active view while
   its data loads (so the panel itself shows progress, not just the top spinner). */
.content-skeleton {
  position: absolute;
  inset: 0;
  z-index: 50;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg, #0b0e14);
}

.content-skeleton[hidden] {
  display: none;
}

.content-skeleton .skeleton-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.content-skeleton .skeleton-bar,
.content-skeleton .skeleton-card {
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    var(--hover-fill) 25%,
    var(--track) 37%,
    var(--hover-fill) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
}

.content-skeleton .skeleton-bar {
  height: 18px;
  width: 100%;
}

.content-skeleton .skeleton-bar-lg {
  height: 30px;
  width: 45%;
}

.content-skeleton .skeleton-bar-sm {
  width: 60%;
}

.content-skeleton .skeleton-card {
  height: 96px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.view-block {
  display: grid;
  gap: 16px;
}

[data-view].is-hidden {
  display: none;
}

/* Security-analysis tab panels toggle visibility via .is-hidden. Without this rule
   the panels never hide, so all tabs render stacked and clicking a tab does nothing. */
[data-security-panel].is-hidden {
  display: none;
}

/* Global loading indicator — a non-blocking pill shown while any API call runs.
   Anchored bottom-center so it never reads as part of the header. */
.global-loading {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel, rgba(20, 24, 33, 0.95));
  color: var(--muted-strong, #c8d0e0);
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.global-loading[hidden] {
  display: none;
}

.security-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 4px;
  color: var(--muted);
}

.security-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent, #6c8cff);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   STATUS
   ============================================================ */
.status-band {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted-strong);
  font-size: 12.5px;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

.status-band.busy .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.status-band.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ============================================================
   PANELS & CARDS
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

h2 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-header p,
.topbar p {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 5px;
}

/* ---------------- Live heading ---------------- */
.live-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.live-heading h2 {
  font-size: 17px;
  margin-top: 2px;
}

.live-heading p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 12.5px;
}

.mc-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.snapshot-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted-strong);
  font-size: 12px;
  background: transparent;
}

/* ============================================================
   METRICS
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

/* Overview hero row: 10 tiles → two clean rows of five. */
.hero-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric small {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.secondary-metrics .metric strong,
.compact-metrics .metric strong {
  font-size: 17px;
}

/* ---------------- Insight widgets ---------------- */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.insight-widget {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
}

.insight-widget span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.insight-widget strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.insight-widget p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* ============================================================
   LAYOUTS
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  gap: 16px;
  align-items: start;
}

.side-column {
  display: grid;
  gap: 16px;
}

.paper-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.mandate-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.portfolio-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.portfolio-toolbar label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.portfolio-toolbar label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.portfolio-toolbar input,
.portfolio-toolbar select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
  outline: none;
}

.mandate-form label,
.profile-defaults label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.mandate-form label > span,
.profile-defaults label > span,
.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mandate-form input,
.mandate-form select,
.mandate-form textarea,
.profile-defaults input,
.profile-defaults select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
  outline: none;
}

/* Dark dropdown options (some browsers inherit the OS palette otherwise) */
.profile-defaults select option {
  background: var(--surface, #12161f);
  color: var(--text);
}

.mandate-form textarea {
  resize: vertical;
  min-height: 86px;
  font-family: var(--mono);
  font-size: 12px;
}

.mandate-wide {
  grid-column: 1 / -1;
}

.sector-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.universe-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 7px;
}

/* Investible universe grouped by market */
.universe-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 7px;
}

.universe-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.universe-group .universe-check-grid {
  margin-top: 6px;
}

/* Allowed-sector row: checkbox + target-weight input */
.sector-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sector-row .sector-check {
  flex: 1 1 auto;
  min-width: 0;
}

/* High-specificity selector so it beats `.mandate-form input { width: 100% }`. */
.sector-row .sector-weight {
  flex: 0 0 66px;
  width: 66px;
  text-align: right;
}

/* Keep sector labels on one line with an ellipsis instead of breaking per-char. */
.sector-check strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapsible advanced sections in the mandate form */
details.mandate-advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: transparent;
}

details.mandate-advanced > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

details.mandate-advanced > summary::-webkit-details-marker {
  display: none;
}

details.mandate-advanced > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
}

details.mandate-advanced[open] > summary::before {
  content: "▾";
}

details.mandate-advanced[open] > summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

details.mandate-advanced > *:last-child {
  margin-bottom: 14px;
}

.advanced-hint {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.advanced-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Mode params: per-mandate override grid + global preset cards.
   auto-fill with a max track keeps the numeric inputs at a sane width
   instead of stretching each across a third of the page. */
.mode-param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 220px));
  gap: 10px;
}

/* Keep the save action visually attached to the inputs it saves. */
.research-mode-params .mandate-actions {
  justify-content: flex-start;
}
.mode-param {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mode-param > span {
  font-size: 12px;
  color: var(--muted);
}
.mode-param input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s ease;
}
.mode-param input::placeholder {
  color: var(--muted);
}
.mode-param input:focus {
  border-color: var(--accent, #6c8cff);
}
.mode-presets-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mode-preset-card {
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  padding: 12px;
}
.mode-preset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.mode-preset-head button {
  height: auto;
  padding: 4px 12px;
}

.stop-loss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 7px;
  align-items: end;
}

.stop-toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  min-height: 38px;
}

.stop-toggle input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* ---- Risk profiling questionnaire ---- */
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.questionnaire {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-category {
  margin: 14px 0 2px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.question {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0;
  background: transparent;
}

.question legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 0 8px;
}

.question .options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.question .opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
}

.question .opt:hover {
  border-color: var(--accent);
}

.question .opt input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.panel-subhead {
  margin-top: 6px;
}

.panel-subhead h3 {
  font-size: 13px;
  margin: 0;
}

.panel-subhead p {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

.profile-defaults {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.profile-result {
  text-align: right;
  min-width: 180px;
}

.profile-result-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.profile-result strong {
  font-size: 16px;
  color: var(--accent-strong);
}

.profile-score-track {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
  margin: 6px 0 4px;
}

.profile-score-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ---- Mandate list ---- */
.mandate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- Strategy Lab (mandate x strategy sweep) ---- */
#strategyLabPanel {
  margin-top: 16px;
}

.sweep-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.sweep-logic-set {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 560px;
}

.sweep-logic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.sweep-progress {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
}

.sweep-best {
  margin: 4px 0 10px;
  font-size: 14px;
}

.sweep-row-best td {
  background: var(--accent-soft);
  font-weight: 600;
}

.sweep-failures {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.mandate-list-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  width: 100%;
  height: auto; /* override the global fixed button height so 2-line cards don't clip */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  white-space: normal;
}

.mandate-list-item:hover {
  border-color: var(--accent);
  background: var(--hover-fill); /* override the global accent button:hover */
}

.mandate-list-item.active,
.mandate-list-item.active:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mandate-list-item.active strong {
  color: var(--accent-strong);
}

.mandate-list-item strong {
  font-size: 13px;
}

.mandate-list-item small {
  color: var(--muted);
  font-size: 11px;
}

/* ---- Read-only mandate summary in the portfolio view ---- */
.mandate-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mandate-summary-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.mandate-summary-head small {
  color: var(--muted);
  font-size: 11px;
}

.mandate-link {
  background: none;
  border: none;
  border-radius: 0;
  height: auto;
  padding: 2px 0 0;
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.mandate-link:hover,
.mandate-link:focus-visible {
  background: none;
  border-color: transparent;
  color: var(--accent-strong);
  text-decoration: underline;
}

.mandate-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.mandate-summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
}

.mandate-summary-item span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mandate-summary-item strong {
  font-size: 13px;
}

/* ---- Unified Portfolios topbar ---- */
.portfolio-topbar-section {
  margin-bottom: 0;
}

.portfolio-topbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.portfolio-topbar label {
  display: grid;
  gap: 7px;
}

.portfolio-topbar label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.portfolio-topbar select {
  min-width: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

/* Dark native dropdown options across the app (the popup list ignores CSS vars,
   so use literal values). */
:root[data-theme="dark"] select option,
:root[data-theme="dark"] select optgroup {
  background-color: #11151d;
  color: #e6e9f2;
}

:root[data-theme="light"] select option,
:root[data-theme="light"] select optgroup {
  background-color: #ffffff;
  color: #1a1f27;
}

.paper-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.table-footer {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.positions-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-mandate {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.topbar-mandate .mandate-link {
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
}

.portfolio-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portfolio-details-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portfolio-details-row .field-label {
  margin: 0;
}

.portfolio-details-row small {
  color: var(--muted);
  font-size: 11px;
}

.kind-badge {
  align-self: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}

.kind-badge[data-kind="live"] {
  color: var(--up, #22c55e);
  border-color: var(--good);
}

.portfolio-topbar button {
  margin-left: auto;
}

.portfolio-topbar #deletePortfolioBtn {
  margin-left: 0;
}

/* ---- Rebalance strategy modal ---- */
.rebalance-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px 2px;
}

.rebalance-mandate-line {
  color: var(--text);
  font-size: 13px;
}

.rebalance-universes {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.rebalance-universes legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.universe-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.universe-default-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

/* ---- Portfolio detail tabs ---- */
.portfolio-tabs,
.research-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.ptab {
  height: auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ptab:hover:not(:disabled) {
  background: none;
  border-color: transparent;
  border-bottom-color: var(--border);
  color: var(--text);
}

.ptab.is-active,
.ptab.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}

.ptab-pane {
  display: grid;
  gap: 16px;
}

.whatif-chart-block {
  margin-top: 16px;
}

.whatif-chart-block:first-of-type {
  margin-top: 8px;
}

.whatif-chart-block h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---- Rebalance actions + diff legend ---- */
.rebalance-actions {
  display: inline-flex;
  gap: 8px;
}

.rebalance-pending-note {
  color: var(--warning, #e0a93b);
  font-size: 12px;
  font-weight: 600;
}

.diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.diff-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.diff-key::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface, #11151d);
}

.diff-key.diff-add::before { background: var(--good-soft); border-color: var(--good); }
.diff-key.diff-remove::before { background: var(--danger-soft); border-color: var(--danger); }
.diff-key.diff-reweight::before { background: var(--warning-soft); border-color: var(--warning); }

/* Color-coded rebalance diff rows (subtle tint + left accent bar) */
.rebalance-diff-table tbody tr.diff-row td:first-child {
  border-left: 3px solid transparent;
}
.diff-row.diff-add { background: var(--good-soft); }
.diff-row.diff-add td:first-child { border-left-color: var(--good, #21b885); }
.diff-row.diff-remove { background: var(--danger-soft); }
.diff-row.diff-remove td:first-child { border-left-color: var(--danger, #f2576e); }
.diff-row.diff-reweight { background: var(--warning-soft); }
.diff-row.diff-reweight td:first-child { border-left-color: var(--warning, #e0a93b); }
.diff-row.diff-hold { color: var(--muted); }

/* ---- Overview tab ---- */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* ---- Suggested changes / rebalance audit ---- */
.suggested-actions {
  display: flex;
  gap: 8px;
}

.badge-unsaved {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warning, #e0a93b);
  border: 1px solid var(--warning);
  border-radius: 4px;
  padding: 2px 7px;
  vertical-align: middle;
  margin-left: 8px;
}

.diff-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
}

.diff-tag-add { color: var(--good, #21b885); border-color: rgba(33, 184, 133, 0.5); }
.diff-tag-remove { color: var(--danger, #f2576e); border-color: rgba(242, 87, 110, 0.5); }
.diff-tag-reweight { color: var(--warning, #e0a93b); border-color: rgba(224, 169, 59, 0.5); }
.diff-tag-hold { color: var(--muted); }

.status-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.status-accepted { color: var(--good, #21b885); border-color: rgba(33, 184, 133, 0.5); }
.status-rejected { color: var(--danger, #f2576e); border-color: rgba(242, 87, 110, 0.5); }
.status-proposed { color: var(--warning, #e0a93b); border-color: rgba(224, 169, 59, 0.5); }

.danger-button {
  border-color: var(--danger);
  color: var(--danger-strong);
}

.danger-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.danger-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- New Portfolio wizard (modal) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface, #12161f);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.wizard-kinds {
  display: grid;
  gap: 8px;
  margin-top: 7px;
}

.wizard-upload {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.wizard-hint {
  color: var(--down, #ef4444);
  font-size: 12px;
}

/* ---- Inline buy/sell trade form ---- */
.trade-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.trade-form input {
  width: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

.trade-form input#tradeSymbol {
  width: 110px;
  text-transform: uppercase;
}

.sector-check {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px !important;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
}

.sector-check input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.sector-check span {
  min-width: 0;
}

.sector-check strong,
.sector-check small {
  display: block;
}

.sector-check strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sector-check small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.mandate-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.security-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
  gap: 16px;
}

.security-content {
  display: grid;
  gap: 16px;
}

/* Consistent vertical rhythm inside each analysis tab panel. */
[data-security-panel] {
  display: grid;
  gap: 12px;
  align-content: start;
}

[data-security-panel] > h3 {
  margin-bottom: 0;
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-panel {
  display: flex;
  flex-direction: column;
}

.chart-box {
  flex: 1 1 auto;
  min-height: 230px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.compact-chart {
  min-height: 180px;
  margin-bottom: 10px;
}

/* Price-chart indicator / range toggles (security page price panel). */
.pc-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.pc-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.pc-btn[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--chart-1);
  background: color-mix(in srgb, var(--chart-1) 12%, transparent);
}

.chart-box svg {
  display: block;
  width: 100%;
  height: auto;
  /* Charts are fixed-aspect SVGs: in a full-width well they would upscale
     to cinema size. Capping height keeps the drawing sane (centered by the
     SVG's default preserveAspectRatio) while the well spans the panel. */
  max-height: 400px;
}

.chart-axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}

.chart-value {
  fill: var(--muted-strong);
  font-weight: 600;
}

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.empty-chart {
  min-height: 180px;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-chart svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

.empty-chart p {
  color: var(--muted-strong);
}

.empty-chart small {
  font-size: 12px;
  color: var(--muted);
}

/* ---------------- Return bars ---------------- */
.return-bars {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.return-row {
  display: grid;
  grid-template-columns: 96px minmax(120px, 1fr) 76px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.return-row strong {
  text-align: right;
}

.return-track {
  height: 10px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.return-track div {
  height: 100%;
  border-radius: inherit;
}

.return-track.gain div {
  background: var(--good);
}

.return-track.loss div {
  background: var(--danger);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  /* Scroll horizontally for wide tables only; let height grow so the page
     provides a single vertical scrollbar (no nested scroll areas). */
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
}

table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 12.5px;
}

th, td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--hover-fill);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: var(--muted-strong);
}

td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.selected-row {
  background: var(--accent-soft) !important;
}

.table-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

/* Live positions panel: edge-to-edge table */
.live-positions-panel {
  padding: 0;
  overflow: hidden;
}

.live-positions-panel .panel-header {
  padding: 18px 18px 14px;
  margin-bottom: 0;
}

.live-positions-panel .table-wrap {
  border-width: 1px 0 0;
  border-radius: 0;
}

/* ============================================================
   BAR LISTS
   ============================================================ */
.bar-list {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted-strong);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 8px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.bar-fill.bar-danger {
  background: var(--danger);
}

/* ============================================================
   FILE LISTS / LINKS
   ============================================================ */
.file-list {
  display: grid;
  gap: 8px;
}

.file-list a {
  display: block;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 12.5px;
  overflow-wrap: anywhere;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.file-list a:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  height: auto;
  padding: 0;
  font-weight: 700;
  font-size: inherit;
}

.link-button:hover {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================================
   PILLS / EXPOSURE
   ============================================================ */
.exposure {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   SETUP TAGS
   ============================================================ */
.setup {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  justify-content: center;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--chip-fill);
  color: var(--muted);
}

.setup-strong {
  background: var(--good-soft);
  color: var(--good);
}

.setup-neutral {
  background: var(--chip-fill);
  color: var(--muted-strong);
}

.setup-weak {
  background: var(--danger-soft);
  color: var(--danger-strong);
}

/* ============================================================
   SECURITY DETAIL
   ============================================================ */
.reason-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.55;
  max-width: 90ch;
}

.reason-list li {
  margin-bottom: 6px;
}

/* Underline tabs, matching .ptab / .research-subnav elsewhere in the app. */
.security-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.security-tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  min-height: 36px;
  height: auto;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.security-tabs button:hover:not(.active) {
  background: none;
  border-color: transparent;
  border-bottom-color: var(--border-strong);
  color: var(--text);
}

.security-tabs button.active {
  background: none;
  border-color: transparent;
  border-bottom-color: var(--accent-strong);
  color: var(--accent-strong);
}

.inline-panel-header {
  align-items: flex-start;
  margin-bottom: 12px;
}

.ai-panel {
  margin-bottom: 18px;
}

.ai-content {
  display: grid;
  gap: 12px;
}

.ai-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.ai-summary {
  color: var(--text);
  font-weight: 700;
}

.ai-flags {
  display: grid;
  gap: 10px;
}

.ai-flag {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: transparent;
}

.ai-flag span {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.ai-json pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: transparent;
}

.mini-metrics,
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

/* Security overview: indicator chart and its metric tiles share the row on
   wide screens instead of leaving half the panel empty. */
.indicator-flow {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.indicator-flow .chart-box {
  min-height: 0;
}

.indicator-flow .indicator-grid {
  align-content: start;
}

@media (max-width: 1200px) {
  .indicator-flow {
    grid-template-columns: 1fr;
  }
}

.mini-metric,
.indicator {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  min-width: 0;
}

.mini-metric span,
.indicator span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.mini-metric strong,
.indicator strong {
  display: block;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.earnings-summary,
.earnings-overlay-summary {
  margin-bottom: 12px;
}

/* ---------------- News ---------------- */
.news-list {
  display: grid;
  gap: 8px;
}

.news-list a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  transition: border-color 0.14s ease;
}

.news-list a:hover {
  border-color: var(--accent-line);
}

.news-list strong {
  font-size: 13px;
  line-height: 1.35;
}

.news-list span,
.news-list p {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.4;
}

/* ---------------- LSEG Reuters news ---------------- */
.lseg-news-list {
  margin-bottom: 20px;
}

.lseg-news-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: transparent;
}

.lseg-news-item + .lseg-news-item {
  margin-top: 6px;
}

.lseg-news-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.lseg-news-meta .provider {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-line);
}

.lseg-news-meta .ts {
  font-size: 11px;
}

.lseg-news-item strong {
  font-size: 13px;
  line-height: 1.35;
  display: block;
}

.news-headline-link {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: block;
  color: inherit;
  text-decoration: none;
}
.news-headline-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.story-link {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: inherit;
}
.story-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* Story modal */
.story-modal-card {
  width: min(820px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.story-modal-body {
  overflow-y: auto;
  flex: 1;
  padding-top: 4px;
}
.story-loading {
  padding: 24px 0;
  text-align: center;
}
.story-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.story-body p {
  margin: 0 0 10px;
}
.story-body h1, .story-body h2, .story-body h3 {
  margin: 16px 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.badge-hot {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: #d9534f;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-med {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-line);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pos {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: #16a34a;
  color: #fff;
  letter-spacing: 0.02em;
}

.badge-neg {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: #dc2626;
  color: #fff;
  letter-spacing: 0.02em;
}

.badge-neu {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--muted, #7a8194);
  color: #fff;
  letter-spacing: 0.02em;
}

/* ---------------- LSEG live price bar ---------------- */
.lseg-price-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--accent-line) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-line) 25%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: live-pulse 1.8s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.45; transform: scale(0.85); }
}

/* ============================================================
   DISCLOSURE
   ============================================================ */
.disclosure-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.disclosure-grid div {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 14px;
}

.disclosure-grid p {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 6px;
}

/* ============================================================
   SEMANTIC COLORS
   ============================================================ */
.negative {
  color: var(--danger);
}

.positive {
  color: var(--good);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .layout,
  .paper-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-w: 100%;
  }

  .app {
    flex-direction: column;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    overflow-x: auto;
  }

  .sidebar-brand {
    border-bottom: 0;
    border-right: 1px solid var(--border);
    padding: 0 16px 0 0;
    margin-bottom: 0;
    flex: 0 0 auto;
  }

  .sidebar-nav {
    flex-direction: row;
    flex: 1 1 auto;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .sidebar-foot {
    display: none;
  }
}

@media (max-width: 960px) {
  .metrics-grid,
  .widget-grid,
  .chart-grid,
  .disclosure-grid,
  .mandate-form,
  .portfolio-toolbar,
  .sector-check-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .security-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .topbar-lead {
    flex-wrap: wrap;
    row-gap: 2px;
  }

  .topbar-lead p {
    white-space: normal;
  }

  /* Header height is fluid here, so pinning the toolbar under it can't work. */
  .research-toolbar {
    position: static;
  }

  .topbar-tools {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 16px 14px 32px;
  }

  .topbar,
  .product-note,
  .research-toolbar {
    padding-left: 14px;
    padding-right: 14px;
    margin-left: 0;
    margin-right: 0;
  }

  .product-note {
    margin: 4px 14px 20px;
  }

  .metrics-grid,
  .widget-grid,
  .chart-grid,
  .disclosure-grid,
  .mandate-form,
  .portfolio-toolbar,
  .sector-check-grid,
  .mini-metrics,
  .indicator-grid {
    grid-template-columns: 1fr;
  }

  .nav-item span {
    display: none;
  }

  .nav-item {
    width: 42px;
    justify-content: center;
    padding: 0;
  }

  .symbol-search input {
    width: 100px;
  }
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* ============================================================
   USER CHIP / LOGOUT
   ============================================================ */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
}

.user-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 12px;
}

.user-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
  margin-right: auto;
}

.user-meta strong {
  font-size: 13px;
  letter-spacing: -0.01em;
}

.user-meta span {
  font-size: 11px;
  color: var(--muted);
}

.logout-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.logout-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.logout-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 28px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.login-brand-copy {
  display: grid;
  gap: 2px;
}

.login-brand-copy strong {
  font-size: 14px;
}

.login-brand-copy span {
  font-size: 12px;
  color: var(--muted);
}

.login-card h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.login-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.login-field input {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.14s ease;
}

.login-field input:focus {
  border-color: var(--accent-line);
}

.login-error {
  margin: -2px 0 0;
  color: var(--danger);
  font-size: 12.5px;
}

.login-submit {
  height: 38px;
  margin-top: 4px;
  font-size: 13.5px;
}

.login-switch {
  height: 34px;
  justify-content: center;
}

.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-hint code {
  font-family: var(--mono);
  color: var(--muted-strong);
  background: var(--chip-fill);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Market picker onboarding modal */
.market-picker-card {
  width: min(420px, 100%);
}

.market-picker-card .modal-header h2 {
  font-size: 1.15rem;
}

.market-picker-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.market-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}

.market-option:hover {
  border-color: var(--accent);
}

.market-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.market-option span {
  font-weight: 500;
}

.modal-hint {
  font-size: 0.82rem;
  color: var(--danger, #e55);
  margin: 0 0 10px;
}

/* ============ Connect broker modal ============ */
.broker-fields {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}

.broker-field {
  display: grid;
  gap: 4px;
}

.broker-field span {
  font-size: 0.82rem;
  color: var(--muted, #667);
}

.broker-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #ccd);
  border-radius: 6px;
  font: inherit;
}

/* ============ Toast notifications ============ */
/* Broker re-auth prompt. Bottom-right so it never covers the toast stack or the
   header controls, and non-modal so an expired broker token does not block
   research work — only live trading needs the token. */
.reauth-prompt {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  width: min(360px, calc(100vw - 40px));
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--warning, #d08700);
  box-shadow: var(--shadow);
}
.reauth-prompt[hidden] {
  display: none;
}
.reauth-prompt strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 6px;
}
.reauth-prompt p {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}
.reauth-actions {
  display: flex;
  gap: 8px;
}
.reauth-actions button {
  font-size: 12.5px;
  padding: 7px 12px;
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  cursor: pointer;
  word-break: break-word;
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}
.toast-success {
  border-left: 3px solid var(--good);
}
.toast-success::before { content: "\2713  "; color: var(--good); font-weight: 700; }
.toast-error {
  border-left: 3px solid var(--danger);
}
.toast-error::before { content: "\26A0  "; color: var(--danger); font-weight: 700; }
.toast-info { border-left: 3px solid var(--accent); }


/* ===== Monte Carlo diversification study ===== */
.mc-callout {
  margin-bottom: 18px;
  border-left: 3px solid var(--accent);
}

.mc-callout-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.mc-callout-head strong {
  font-size: 17px;
  color: var(--text);
}

.mc-callout-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
}

.mc-callout-text {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13.5px;
  line-height: 1.6;
}

.mc-callout-text code {
  font-family: var(--mono);
  color: var(--muted-strong);
  background: var(--chip-fill);
  padding: 2px 6px;
  border-radius: 6px;
}

tr.mc-row-highlight {
  background: var(--accent-soft);
}

tr.mc-bench-row {
  border-top: 1px solid var(--border-strong);
  color: var(--muted-strong);
  font-style: italic;
}

.mc-pos {
  color: var(--good);
  font-weight: 600;
}

.mc-neg {
  color: var(--danger);
  font-weight: 600;
}

tr.mc-row-highlight td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
  font-weight: 600;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 18px 0;
}

.mc-sector-panel.is-hidden,
.mc-breadth-panel.is-hidden {
  display: none;
}

.mc-metric-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.mc-metric-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
}

.mc-metric-btn:hover {
  color: var(--text);
}

.mc-metric-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.mc-heatmap-wrap {
  overflow-x: auto;
  margin-top: 6px;
}

.mc-heatmap {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
}

.mc-heatmap th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.mc-heatmap .mc-hm-corner {
  text-align: right;
  white-space: nowrap;
  color: var(--muted-strong);
  padding-right: 8px;
}

.mc-heatmap .mc-hm-row {
  text-align: right;
  color: var(--muted-strong);
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.mc-heatmap .mc-hm-col {
  text-align: center;
}

.mc-hm-cell {
  text-align: center;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 8px 6px;
  border-radius: 6px;
  min-width: 46px;
}

.mc-hm-empty {
  color: var(--muted);
  background: var(--surface-soft);
}

.mc-heatmap-caption {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.mc-sector-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.mc-sector-bar-row {
  display: grid;
  grid-template-columns: 170px 1fr 96px;
  align-items: center;
  gap: 12px;
}

.mc-sector-bar-label {
  font-size: 13px;
  color: var(--muted-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-sector-bar-track {
  position: relative;
  height: 14px;
  background: var(--surface-soft);
  border-radius: 7px;
  overflow: hidden;
}

.mc-sector-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 7px;
}

.mc-sector-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.mc-sector-bar-value small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

/* ===== Security research committee ===== */
.committee-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 14px;
}

.committee-rating {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  background: var(--muted);
}

.committee-rating.rating-buy { background: var(--good); }
.committee-rating.rating-overweight { background: var(--good-dim); }
.committee-rating.rating-hold { background: var(--muted); }
.committee-rating.rating-underweight { background: var(--warning); color: var(--warning-ink); }
.committee-rating.rating-sell { background: var(--danger); }

.committee-head-meta {
  display: flex;
  flex-direction: column;
}

.committee-head-meta strong { font-size: 16px; }
.committee-head-meta span { font-size: 13px; color: var(--muted); }

/* Rating / conviction scales: every possible value shown, current highlighted */
.scale-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 10px 0;
}

.scale-block {
  margin: 6px 0;
}

.scale-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.scale-meter {
  display: inline-flex;
  gap: 4px;
}

.scale-step {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  opacity: 0.75;
}

.scale-step.is-active {
  opacity: 1;
  color: var(--accent-ink);
  border-color: transparent;
}

.scale-step.is-active.tone-buy,
.scale-step.is-active.tone-high { background: var(--good); }
.scale-step.is-active.tone-overweight { background: var(--good-dim); }
.scale-step.is-active.tone-hold,
.scale-step.is-active.tone-medium { background: var(--accent, #4f7cff); }
.scale-step.is-active.tone-underweight,
.scale-step.is-active.tone-low { background: var(--warning); color: var(--warning-ink); }
.scale-step.is-active.tone-sell { background: var(--danger); }

.scale-unknown {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
}

.committee-summary {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted-strong);
  margin: 0 0 16px;
  max-width: 110ch;
}

.committee-components {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  /* A 0-100 score bar stretched across a full-width panel is unreadable. */
  max-width: 940px;
}

.committee-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 28px;
  align-items: center;
  gap: 12px;
}

.committee-bar-label {
  font-size: 13px;
  color: var(--muted-strong);
}

.committee-bar-label small { color: var(--muted); font-size: 11px; }

.committee-bar-track {
  position: relative;
  height: 8px;
  background: var(--surface-soft);
  border-radius: 6px;
  overflow: hidden;
}

.committee-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 6px;
}

.committee-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted-strong);
}

.committee-manager {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0;
  font-size: 13.5px;
  color: var(--muted-strong);
  margin: 14px 0;
  max-width: 110ch;
}

.committee-stance {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
}

.committee-thesis {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted-strong);
  margin-top: 14px;
  max-width: 110ch;
}

.committee-gaps { font-size: 12px; }

.committee-disclaimer {
  font-size: 11.5px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.committee-agreement {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 3px;
}
.committee-agreement.is-agree { background: var(--good-soft); color: var(--good); }
.committee-agreement.is-partial { background: var(--warning-soft); color: var(--warning); }
.committee-agreement.is-disagree { background: var(--danger-soft); color: var(--danger); }

.committee-ai-header {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Outlook stances reuse the sell->buy tone ramp */
.scale-step.is-active.tone-bullish { background: var(--good); }
.scale-step.is-active.tone-constructive { background: var(--good-dim); }
.scale-step.is-active.tone-neutral { background: var(--accent, #4f7cff); }
.scale-step.is-active.tone-cautious { background: var(--warning); color: var(--warning-ink); }
.scale-step.is-active.tone-bearish { background: var(--danger); }

/* Short/long-term outlook cards */
.outlook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.outlook-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: transparent;
}

.outlook-card h3 { margin: 0; }
.outlook-card h3 small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.outlook-card h4 { margin: 12px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.outlook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.outlook-badges { display: flex; align-items: center; gap: 8px; }

.outlook-score { font-size: 15px; font-weight: 700; }

.confidence-chip {
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.confidence-chip.confidence-high { color: var(--accent-ink); background: var(--good); border-color: transparent; }
.confidence-chip.confidence-medium { color: var(--accent-ink); background: var(--accent, #4f7cff); border-color: transparent; }
.confidence-chip.confidence-low { color: var(--warning-ink); background: var(--warning); border-color: transparent; }

.outlook-detail {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin: -2px 0 8px 2px;
}

/* The projection basis sits under bordered metric boxes, not under a bar row —
   it needs real separation, not the bar-row pull-up above. */
.projection-basis {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 2px 14px;
}

/* Stacked metric-box blocks (3M target / analyst / structure rows) inside an
   outlook card were touching each other and the surrounding text. */
.outlook-card .mini-metrics {
  margin: 10px 0 12px;
}

.committee-bar-row.is-missing { opacity: 0.45; }

/* Price chip beside the security title: latest stored close + its as-of date */
.security-price-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  margin-left: 12px;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.security-price-chip small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ============================================================
   THEME SUPPORT (charts + toggle)
   ============================================================ */
/* SVG presentation attributes can't resolve var(); charts emit these
   classes (structural strokes) or style="…" (data series) instead. */
svg .chart-grid { stroke: var(--chart-grid); }
svg .chart-zero { stroke: var(--chart-axis); }
svg .chart-bench { stroke: var(--chart-neutral); }
svg .chart-bench-amber { stroke: var(--chart-amber); }

/* Cards ride on borders in dark (--shadow-sm: none) and get a soft
   ambient shadow in light. */
.panel,
.metric,
.insight-widget {
  box-shadow: var(--shadow-sm);
}

/* Sidebar theme toggle: icon previews the theme you'll switch TO. */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.app.sidebar-collapsed .theme-toggle svg { transform: none; }

/* ============================================================
   V2 REDESIGN (login split panel, nav groups, KPI tones)
   ============================================================ */
/* ---- Login: brand side panel + form card ---- */
.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  max-width: 880px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 36px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.login-side .login-brand {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.login-side-copy h2 {
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-weight: 650;
}

.login-side-copy p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 40ch;
}

.login-side-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.login-shell .login-card {
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-side {
    flex-direction: row;
    align-items: center;
    padding: 18px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .login-side-copy,
  .login-side-note {
    display: none;
  }
}

/* ---- Sidebar nav groups ---- */
.nav-section-label {
  display: block;
  padding: 14px 10px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-nav .nav-section-label:first-child {
  padding-top: 4px;
}

.app.sidebar-collapsed .nav-section-label {
  display: none;
}

.nav-item {
  position: relative;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---- KPI tile tones + tabular numerals ---- */
.metric strong.positive {
  color: var(--good);
}

.metric strong.negative {
  color: var(--danger);
}

.metric strong.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.metric strong,
.mini-metric strong,
.indicator strong,
td.numeric,
th.numeric {
  font-variant-numeric: tabular-nums;
}

/* Mini-metric tiles: semantic tones + dimmed empty values (Security tabs). */
.mini-metric strong.positive,
.indicator strong.positive {
  color: var(--good);
}

.mini-metric strong.negative,
.indicator strong.negative {
  color: var(--danger);
}

.mini-metric strong.is-empty,
.indicator strong.is-empty {
  color: var(--muted);
  font-weight: 500;
}

/* Security search with no results: a clear no-data state instead of the
   empty tab shell. */
.security-empty {
  min-height: 260px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ============================================================
   ANALYSIS CARDS (Committee / DeepSeek / AI validation tabs)
   ============================================================ */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.desks-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.insight-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
}

.insight-card > h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.insight-card h5 {
  margin: 10px 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.insight-card p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted-strong);
}

.insight-card p + p {
  margin-top: 8px;
}

.insight-card .reason-list {
  font-size: 12.5px;
}

.insight-card > h4 .committee-stance {
  margin-left: 0;
}

.insight-card.tone-good { border-left-color: var(--good); }
.insight-card.tone-bad { border-left-color: var(--danger); }
.insight-card.tone-warn { border-left-color: var(--warning); }
.insight-card.tone-accent { border-left-color: var(--accent); }

/* Annual-report link chips (Financials tab) */
.annual-report-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.annual-report-links a {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--accent-strong);
}

.annual-report-links a:hover {
  border-color: var(--accent-line);
}

/* Screener-style statement tables */
.statement-table table td:first-child {
  white-space: nowrap;
}

.statement-table .statement-total td {
  font-weight: 700;
  border-top: 1px solid var(--border);
}

.build-stamp {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* ---- Live Market (realtime engine) ---------------------------------------- */
.live-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.live-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted-text, #7a8194);
}

.live-controls .live-paper-toggle {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.live-delayed-banner {
  border-left: 3px solid #d97706;
  padding: 6px 10px;
  margin: 8px 0 0;
}

.live-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .live-columns { grid-template-columns: 1fr; }
}

.live-watchlist-wrap {
  max-height: 560px;
  overflow-y: auto;
}

.live-watchlist-wrap tbody tr { cursor: pointer; }

.live-signal-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 560px;
  overflow-y: auto;
}

.live-signal {
  border: 1px solid var(--border, #2a2f3d);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 8px 10px;
}

.live-signal-strong { border-left-color: #16a34a; }
.live-signal-notice { border-left-color: #2563eb; }
.live-signal-info { border-left-color: var(--border, #2a2f3d); }
.live-signal-acked { opacity: 0.55; }

.live-signal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-signal-head .live-signal-ack { margin-left: auto; }
.live-signal p { margin: 4px 0 0; }
.live-signal-direction { font-weight: 600; color: #16a34a; }
.live-signal-direction.negative { color: #dc2626; }

.live-candle-chart { width: 100%; height: auto; }
.candle-wick { stroke: var(--muted-text, #7a8194); stroke-width: 1; }
.candle-body.candle-up { fill: #16a34a; }
.candle-body.candle-down { fill: #dc2626; }
.chart-axis-label { font-size: 11px; fill: var(--muted-text, #7a8194); }

/* ---- Assisted trading (order ticket) --------------------------------------- */
.live-ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 10px 0;
}

.live-ticket-grid > div, .live-ticket-grid > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.live-ticket-grid input {
  max-width: 140px;
}

#liveTicketMode {
  border-left-color: #2563eb;
}

/* --- Data Operations ------------------------------------------------------ */
/* Status is encoded in form as well as text: a failed run must read at a glance
   in a list of forty, not require reading the word. */
.run-status {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.run-ok { color: var(--positive, #128a5f); }
.run-bad { color: var(--negative, #c0392b); }
.run-warn { color: #b45309; }
.run-info { color: var(--muted); }

.run-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}
.run-row > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.run-row > summary::-webkit-details-marker { display: none; }
.run-row > summary:hover { background: var(--surface-raised); }
.run-name { font-weight: 600; flex: 1; min-width: 160px; }
.run-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.run-detail {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 12.5px;
  color: var(--negative, #c0392b);
}
.run-children {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.run-children td {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.run-children td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rerun-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.rerun-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  background: var(--surface);
}
.rerun-card .muted { font-size: 12px; line-height: 1.4; }

.gap-days { display: flex; flex-wrap: wrap; gap: 6px; }
.gap-days code { font-size: 12px; }
