/*!
 * @fileoverview App shell styling (2026 refresh): the design-token system
 *   (type scale, 4-px spacing scale, radii, elevation, one accent, severity
 *   hues), page layout, the query builder, workspace tabs, side panels, the
 *   detail drawer, and small components (chips, buttons, sliders, funnels).
 *   Owns everything in index.html outside the `.tt-tl` subtree, which
 *   css/timeline.css owns on its own. The app bar, view switcher, Ask rail,
 *   command palette and the Home/Events/Ledger views live in css/views.css.
 * @module css/app
 */

/* ---------------------------------------------------------------------
   Tokens layered on top of css/timeline.css's --tt-* chart/surface set.
   Type scale 12/13/14/16/20/28, spacing scale 4-px, radius 10, soft
   elevation on overlays only. One accent (indigo) for interactive UI; it
   never encodes chart data (charts use the validated blue ramp). Severity
   hues are the dataviz status palette and always ship with an icon + label.
   --------------------------------------------------------------------- */
:root {
  --tt-font: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --tt-font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --tt-fs-12: 12px;
  --tt-fs-13: 13px;
  --tt-fs-14: 14px;
  --tt-fs-16: 16px;
  --tt-fs-20: 20px;
  --tt-fs-28: 28px;

  --tt-sp-1: 4px;
  --tt-sp-2: 8px;
  --tt-sp-3: 12px;
  --tt-sp-4: 16px;
  --tt-sp-5: 20px;
  --tt-sp-6: 24px;
  --tt-sp-8: 32px;
  --tt-sp-10: 40px;

  --tt-accent: #4338ca;
  --tt-accent-ink: #ffffff;
  --tt-accent-soft: #eceafc;
  --tt-accent-line: rgba(67, 56, 202, 0.35);
  --tt-danger: #b42f1c;
  --tt-danger-soft: #fbe9e5;
  --tt-success: #1f6b3a;
  --tt-success-soft: #e4f3e8;
  --tt-warn-soft: #fdf1d6;
  --tt-sev-high: #d03b3b;
  --tt-sev-medium: #fab219;
  --tt-sev-low: #898781;
  --tt-surface-2: #f4f4f1;
  --tt-border-strong: rgba(11, 11, 11, 0.18);

  --tt-radius: 10px;
  --tt-radius-sm: 7px;
  --tt-shadow: 0 12px 40px rgba(11, 11, 11, 0.16), 0 2px 8px rgba(11, 11, 11, 0.08);
  --tt-max-width: 1440px;
  --tt-appbar-h: 56px;
  --tt-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --tt-accent: #a5b0ff;
    --tt-accent-ink: #0b0b16;
    --tt-accent-soft: #23264f;
    --tt-accent-line: rgba(165, 176, 255, 0.4);
    --tt-danger: #f0a091;
    --tt-danger-soft: #3a2420;
    --tt-success: #8fce97;
    --tt-success-soft: #1d3324;
    --tt-warn-soft: #3a2f14;
    --tt-surface-2: #222221;
    --tt-border-strong: rgba(255, 255, 255, 0.2);
    --tt-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme='dark'] {
  --tt-accent: #a5b0ff;
  --tt-accent-ink: #0b0b16;
  --tt-accent-soft: #23264f;
  --tt-accent-line: rgba(165, 176, 255, 0.4);
  --tt-danger: #f0a091;
  --tt-danger-soft: #3a2420;
  --tt-success: #8fce97;
  --tt-success-soft: #1d3324;
  --tt-warn-soft: #3a2f14;
  --tt-surface-2: #222221;
  --tt-border-strong: rgba(255, 255, 255, 0.2);
  --tt-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------------
   Base / reset
   --------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--tt-page);
  color: var(--tt-ink);
}
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font: var(--tt-fs-14)/1.5 var(--tt-font);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'cv11', 'ss03', 'tnum';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
button { font-family: inherit; }
a { color: var(--tt-accent); }
code, kbd, pre { font-family: var(--tt-font-mono); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.tt-skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 2000;
  background: var(--tt-accent);
  color: var(--tt-accent-ink);
  padding: 8px 14px;
  border-radius: var(--tt-radius-sm);
  text-decoration: none;
  transition: top 0.15s ease;
}
.tt-skip-link:focus {
  top: 8px;
}

:focus-visible {
  outline: 2px solid var(--tt-accent);
  outline-offset: 2px;
}

.tt-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------------
   Buttons, inputs (shared across the app shell)
   --------------------------------------------------------------------- */
.tt-btn {
  font: inherit;
  font-size: var(--tt-fs-13);
  font-weight: 500;
  color: var(--tt-ink);
  background: var(--tt-surface);
  border: 1px solid var(--tt-border-strong);
  border-radius: var(--tt-radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.12s var(--tt-ease), border-color 0.12s var(--tt-ease), transform 0.12s var(--tt-ease);
}
.tt-btn:hover { background: var(--tt-surface-2); }
.tt-btn:active { transform: translateY(0.5px); }
.tt-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tt-btn-primary {
  background: var(--tt-accent);
  color: var(--tt-accent-ink);
  border-color: var(--tt-accent);
  font-weight: 600;
}
.tt-btn-primary:hover { background: var(--tt-accent); filter: brightness(1.1); }
.tt-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--tt-ink-secondary);
}
.tt-btn-ghost:hover { background: var(--tt-surface-2); color: var(--tt-ink); }
.tt-btn-danger {
  color: var(--tt-danger);
  border-color: var(--tt-danger);
  background: transparent;
}
.tt-btn-danger:hover { background: var(--tt-danger-soft); }
.tt-btn-small { padding: 4px 9px; font-size: var(--tt-fs-12); }
.tt-btn-icon { padding: 6px 8px; line-height: 1; }
.tt-btn[aria-pressed='true'] {
  background: var(--tt-accent-soft);
  border-color: var(--tt-accent-line);
  color: var(--tt-ink);
}

label {
  font-size: var(--tt-fs-12);
  font-weight: 600;
  color: var(--tt-ink-secondary);
}
input[type='text'],
input[type='search'],
input[type='number'],
input[type='date'],
select {
  font: inherit;
  font-size: var(--tt-fs-13);
  color: var(--tt-ink);
  background: var(--tt-surface);
  border: 1px solid var(--tt-border-strong);
  border-radius: var(--tt-radius-sm);
  padding: 7px 10px;
  min-width: 0;
  width: 100%;
  transition: border-color 0.12s var(--tt-ease), box-shadow 0.12s var(--tt-ease);
}
input::placeholder { color: var(--tt-ink-muted); }
select[multiple] {
  min-height: 84px;
}
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--tt-accent);
  box-shadow: 0 0 0 3px var(--tt-accent-soft);
}

/* ---------------------------------------------------------------------
   Top bar: brand + workspace tabs + query builder
   --------------------------------------------------------------------- */
.tt-topbar {
  /* The Timeline view's own header: workspace tabs + query builder. The
     global app bar (brand, views, palette, theme, Ask) is css/views.css. */
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  padding: var(--tt-sp-3) var(--tt-sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--tt-sp-3);
  margin-bottom: var(--tt-sp-4);
}
.tt-topbar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.tt-workspace-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.tt-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  background: var(--tt-surface);
  color: var(--tt-ink-secondary);
  border: 1px solid var(--tt-border-strong);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  cursor: pointer;
  transition: background-color 0.12s var(--tt-ease), border-color 0.12s var(--tt-ease);
}
.tt-tab:hover { background: var(--tt-surface-2); }
.tt-tab[aria-selected='true'] {
  background: var(--tt-accent-soft);
  color: var(--tt-ink);
  border-color: var(--tt-accent-line);
  font-weight: 600;
}
.tt-tab-close {
  border: none;
  background: none;
  color: inherit;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 1;
  cursor: pointer;
  font-size: 12px;
}
.tt-tab-close:hover { background: var(--tt-grid); }
.tt-tab-compare-check {
  margin-right: 2px;
}
.tt-workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* ---------------------------------------------------------------------
   Keyboard shortcuts help popover
   --------------------------------------------------------------------- */
.tt-shortcuts-anchor {
  position: relative;
  display: inline-flex;
}
.tt-shortcuts-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1100;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  box-shadow: var(--tt-shadow);
  padding: 14px 16px;
  width: 300px;
}
.tt-shortcuts-popover h2 {
  margin: 0 0 8px;
  font-size: 13px;
}
.tt-shortcuts-popover dl {
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tt-shortcuts-popover dl > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.tt-shortcuts-popover dt { color: var(--tt-ink-secondary); white-space: nowrap; }
.tt-shortcuts-popover dd { margin: 0; text-align: right; color: var(--tt-ink-muted); }
.tt-shortcuts-popover kbd {
  font: inherit;
  font-size: 11px;
  background: var(--tt-surface-2);
  border: 1px solid var(--tt-border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

/* ---------------------------------------------------------------------
   Query builder
   --------------------------------------------------------------------- */
.tt-query-builder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tt-qb-row {
  display: flex;
  gap: var(--tt-sp-3);
  flex-wrap: wrap;
  align-items: flex-end;
}
.tt-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  /* flex-shrink must stay enabled (not `0 0 auto`) so a chip-group fieldset
     can shrink to the row's available width and let its own `.tt-chips`
     wrap onto multiple lines — otherwise the fieldset sizes to its full
     unwrapped content width and chips run off the right edge at narrow
     viewports (caught in integration screenshot review at 400px). */
  flex: 1 1 auto;
}
.tt-field-grow { flex: 1 1 200px; }
.tt-field-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
}
.tt-field-inline label { white-space: nowrap; }
.tt-field-inline select { width: auto; min-width: 140px; }
.tt-field-checkbox { justify-content: flex-end; }
.tt-field-checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.tt-field-checkbox label.tt-disabled { opacity: 0.55; }
fieldset.tt-field {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 220px;
}
fieldset.tt-field legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--tt-ink-secondary);
  padding: 0;
  margin-bottom: 4px;
}

.tt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tt-chip {
  font: inherit;
  font-size: 12px;
  background: var(--tt-surface);
  color: var(--tt-ink-secondary);
  border: 1px solid var(--tt-border-strong);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background-color 0.12s var(--tt-ease), border-color 0.12s var(--tt-ease), color 0.12s var(--tt-ease);
}
.tt-chip:hover { background: var(--tt-surface-2); color: var(--tt-ink); }
.tt-chip[aria-pressed='true'] {
  background: var(--tt-accent);
  color: var(--tt-accent-ink);
  border-color: var(--tt-accent);
  font-weight: 600;
}
.tt-chip.is-highlighted {
  border-color: var(--tt-accent);
  box-shadow: 0 0 0 2px var(--tt-accent-soft);
}
.tt-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  margin-left: 4px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

/* ---------------------------------------------------------------------
   Collapsible query builder: one-line summary + "Edit query"
   --------------------------------------------------------------------- */
.tt-qb-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.tt-qb-summary-text {
  font-size: 13px;
  color: var(--tt-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.tt-qb-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tt-qb-actions {
  align-items: center;
  position: sticky;
  top: var(--tt-appbar-h);
  z-index: 60;
  background: var(--tt-surface);
  padding-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
}
.tt-qb-actions.is-stuck {
  border-bottom-color: var(--tt-border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.tt-qb-status {
  font-size: 12px;
  color: var(--tt-ink-secondary);
}
.tt-qb-status.is-error { color: var(--tt-danger); }

/* ---------------------------------------------------------------------
   Company multi-select popover
   --------------------------------------------------------------------- */
.tt-company-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tt-company-popover-anchor {
  position: relative;
  align-self: flex-start;
}
.tt-company-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1100;
  width: min(340px, 82vw);
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  box-shadow: var(--tt-shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tt-company-popover-actions {
  display: flex;
  gap: 6px;
}
.tt-company-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid var(--tt-border);
}
.tt-company-option {
  border-bottom: 1px solid var(--tt-border);
}
.tt-company-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--tt-ink);
  cursor: pointer;
}
.tt-company-option input[type='checkbox'] { flex: none; }
.tt-company-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-company-type-tag {
  flex: none;
  font-size: 10px;
  color: var(--tt-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tt-company-empty {
  font-size: 12px;
  color: var(--tt-ink-muted);
  padding: 6px 4px;
}

/* ---------------------------------------------------------------------
   Results summary strip (counts by phase / status, click to filter)
   --------------------------------------------------------------------- */
.tt-results-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  padding: 6px 0;
}
.tt-results-strip-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tt-strip-bar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--tt-page);
  border: 1px solid var(--tt-border);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  font: inherit;
  color: var(--tt-ink-secondary);
}
.tt-strip-bar:hover { filter: brightness(1.05); }
.tt-strip-bar[aria-pressed='true'] {
  background: var(--tt-accent-soft);
  border-color: var(--tt-accent);
  color: var(--tt-ink);
  font-weight: 600;
}
.tt-strip-bar-fill {
  display: inline-block;
  width: var(--tt-strip-fill, 4px);
  min-width: 4px;
  height: 6px;
  border-radius: 3px;
  background: var(--tt-ink-secondary);
}

/* ---------------------------------------------------------------------
   Main layout
   --------------------------------------------------------------------- */
.tt-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: var(--tt-sp-4);
  padding: 0;
  width: 100%;
  align-items: start;
}
@media (max-width: 1023px) {
  .tt-main {
    grid-template-columns: 1fr;
  }
}
/* The content column is a size container: with the Ask rail docked the Timeline
   view is narrower than the viewport, so stack the side panels under the chart
   by the column's own width rather than the window's. */
.tt-content { container-type: inline-size; container-name: tt-content; }
@container tt-content (max-width: 1060px) {
  .tt-tl-layout { grid-template-columns: minmax(0, 1fr); }
  .tt-tl-layout > .tt-side-panels { position: static; max-height: none; overflow: visible; }
}

.tt-timeline-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tt-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.tt-highlight-label {
  font-size: 12px;
  background: var(--tt-accent-soft);
  color: var(--tt-ink);
  border: 1px solid var(--tt-accent);
  border-radius: 999px;
  padding: 4px 10px;
}

.tt-side-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
/* Panels keep their natural height; the column scrolls instead of flex
   squeezing (and clipping, via .tt-panel's overflow: hidden) the first panels
   when the sticky column is capped at the viewport height. */
.tt-side-panels > .tt-panel {
  flex-shrink: 0;
}
@media (min-width: 1024px) {
  .tt-side-panels {
    position: sticky;
    top: calc(var(--tt-appbar-h) + 12px);
    max-height: calc(100vh - var(--tt-appbar-h) - 24px);
    overflow-y: auto;
    padding-bottom: 4px;
  }
}

/* ---------------------------------------------------------------------
   Panels (indication / company / uniqueness / valuation)
   --------------------------------------------------------------------- */
.tt-panel {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  padding: 0;
  overflow: hidden;
}
.tt-panel.is-highlighted {
  border-color: var(--tt-accent);
  box-shadow: 0 0 0 2px var(--tt-accent-soft);
}
.tt-panel > summary {
  cursor: pointer;
  padding: 10px 14px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tt-panel > summary::-webkit-details-marker { display: none; }
.tt-panel > summary::after {
  content: '\2212';
  color: var(--tt-ink-muted);
  font-size: 13px;
}
.tt-panel:not([open]) > summary::after {
  content: '+';
}
.tt-panel > summary h2 {
  margin: 0;
  font-size: var(--tt-fs-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tt-ink-secondary);
}
.tt-panel-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  text-transform: none;
  letter-spacing: normal;
}
.tt-panel-nav button {
  font-size: 11px;
  padding: 2px 7px;
}
.tt-panel-nav-position {
  font-size: 10px;
  color: var(--tt-ink-muted);
  white-space: nowrap;
}
.tt-panel-body {
  padding: 2px 14px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tt-panel-empty {
  color: var(--tt-ink-muted);
  font-size: 12px;
}
.tt-panel-note {
  color: var(--tt-ink-muted);
  font-size: 11px;
  line-height: 1.5;
}
.tt-field-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.tt-field-row dt { color: var(--tt-ink-secondary); }
.tt-field-row dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.tt-field-row--prose { flex-direction: column; gap: 2px; }
.tt-field-row--prose dd { text-align: left; font-variant-numeric: normal; line-height: 1.5; }
dl.tt-deflist { margin: 0; display: flex; flex-direction: column; gap: 4px; }

.tt-source-note {
  font-size: 11px;
  color: var(--tt-ink-muted);
}
.tt-source-note a { color: inherit; }

/* Population funnel */
.tt-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tt-funnel-step {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.tt-funnel-bar-track {
  background: var(--tt-page);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}
.tt-funnel-bar-fill {
  height: 100%;
  background: var(--tt-accent);
  border-radius: 4px;
}
.tt-funnel-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.tt-funnel-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.tt-funnel-slider-row input[type='range'] { flex: 1 1 auto; }

/* Company assets table */
.tt-asset-table, .tt-competitor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tt-asset-table th, .tt-asset-table td,
.tt-competitor-table th, .tt-competitor-table td {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--tt-border);
}
.tt-size-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--tt-grid);
  color: var(--tt-ink-secondary);
  font-size: 10px;
  font-weight: 700;
}

/* Uniqueness score */
.tt-score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 700;
  color: var(--tt-ink);
}
.tt-score-badge small { font-size: 12px; font-weight: 500; color: var(--tt-ink-muted); }
.tt-score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tt-score-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 34px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--tt-ink-secondary);
}
.tt-score-bar-track {
  background: var(--tt-page);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.tt-score-bar-fill {
  height: 100%;
  background: var(--tt-ink-secondary);
  border-radius: 4px;
}
details.tt-disclosure summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--tt-accent);
  list-style: none;
}
details.tt-disclosure summary::-webkit-details-marker { display: none; }
details.tt-disclosure summary::before { content: '\25B8 '; }
details.tt-disclosure[open] summary::before { content: '\25BE '; }
details.tt-disclosure p { font-size: 11px; color: var(--tt-ink-secondary); margin: 6px 0 0; }

/* ---------------------------------------------------------------------
   Valuation panel
   --------------------------------------------------------------------- */
.tt-val-tabs {
  display: flex;
  gap: 4px;
}
.tt-val-tabs button {
  flex: 1 1 0;
}
.tt-val-sliders {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tt-val-slider {
  display: grid;
  grid-template-columns: 108px 1fr 64px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.tt-val-slider label { font-size: 11px; white-space: nowrap; }
.tt-val-slider input[type='range'] { width: 100%; }
.tt-val-slider input[type='number'] { font-size: 11px; padding: 3px 5px; }
.tt-val-slider.is-derived label { color: var(--tt-ink-muted); }

.tt-val-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tt-val-metric {
  background: var(--tt-page);
  border-radius: var(--tt-radius-sm);
  padding: 8px 10px;
}
.tt-val-metric .tt-val-metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tt-ink-muted);
}
.tt-val-metric .tt-val-metric-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tt-val-metric .tt-val-metric-pct {
  font-size: 11px;
  color: var(--tt-ink-secondary);
  font-variant-numeric: tabular-nums;
}

.tt-cashflow-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 64px;
  padding: 4px 0;
  border-bottom: 1px solid var(--tt-border);
}
.tt-cashflow-bar {
  flex: 1 1 0;
  background: var(--tt-accent);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}
.tt-cashflow-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--tt-ink-muted);
}

.tt-scenario-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tt-scenario-table th, .tt-scenario-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--tt-border);
  text-align: right;
}
.tt-scenario-table th:first-child, .tt-scenario-table td:first-child { text-align: left; }
.tt-scenario-table input[type='number'] {
  width: 56px;
  font-size: 11px;
  padding: 2px 4px;
}
.tt-heuristic-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tt-ink-muted);
  border: 1px solid var(--tt-border);
  border-radius: 999px;
  padding: 2px 8px;
  width: fit-content;
}

/* ---------------------------------------------------------------------
   Compare mode: small multiples + summary table
   --------------------------------------------------------------------- */
.tt-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}
.tt-compare-card {
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  background: var(--tt-surface);
  padding: 10px;
  min-width: 0;
}
.tt-compare-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
}
.tt-compare-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 14px;
}
.tt-compare-summary-table th, .tt-compare-summary-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tt-border);
  text-align: right;
  white-space: nowrap;
}
.tt-compare-summary-table th:first-child, .tt-compare-summary-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--tt-surface);
}
.tt-compare-summary-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------------
   Empty / loading / error states
   --------------------------------------------------------------------- */
.tt-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 28px 18px;
  border: 1px dashed var(--tt-border);
  border-radius: var(--tt-radius);
  color: var(--tt-ink-secondary);
  background: var(--tt-surface);
}
.tt-state-title { font-weight: 600; color: var(--tt-ink); }
.tt-state.is-error { border-color: var(--tt-danger); }
.tt-state.is-error .tt-state-title { color: var(--tt-danger); }
.tt-progress-line {
  font-size: 12px;
  color: var(--tt-ink-secondary);
  font-variant-numeric: tabular-nums;
}
.tt-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--tt-border);
  border-top-color: var(--tt-accent);
  animation: tt-spin 0.8s linear infinite;
}
@keyframes tt-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Toast (share-link copy confirmation, etc.)
   --------------------------------------------------------------------- */
.tt-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1200;
  background: var(--tt-ink);
  color: var(--tt-page);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: var(--tt-shadow);
}

/* ---------------------------------------------------------------------
   Detail drawer
   --------------------------------------------------------------------- */
.tt-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 900;
}
.tt-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--tt-surface);
  color: var(--tt-ink);
  box-shadow: var(--tt-shadow);
  z-index: 901;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tt-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--tt-border);
}
.tt-drawer-head h2 { margin: 0; font-size: 15px; }
.tt-drawer-body {
  padding: 14px 16px 28px;
  overflow-y: auto;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tt-drawer-body a { color: var(--tt-accent); }

/* ---------------------------------------------------------------------
   Company comparison section (js/company-compare.js mount) — a full-width
   collapsible panel under the timeline, off by default. Reuses the query
   builder's chip/popover classes (.tt-chip, .tt-company-popover, etc.) for
   the add-company control so the two multi-selects look and behave the
   same way; css/company-compare.css owns everything inside `.cc-root`.
   --------------------------------------------------------------------- */
.tt-cc-panel {
  margin-top: 4px;
}
.tt-cc-panel > summary h2 {
  display: inline;
}
.tt-cc-count {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--tt-ink-muted);
}
.tt-cc-panel-body {
  gap: 12px;
}
.tt-cc-mode-row {
  display: flex;
  align-items: center;
}
.tt-cc-controls {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}
.tt-cc-controls .tt-company-popover-anchor {
  align-self: center;
}
.tt-cc-host {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.tt-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: var(--tt-sp-4) 0 var(--tt-sp-6);
  font-size: 11px;
  color: var(--tt-ink-muted);
  border-top: 1px solid var(--tt-border);
  width: 100%;
  margin-top: var(--tt-sp-8);
  box-sizing: border-box;
}
.tt-footer-note { flex: 1 1 320px; }

/* ---------------------------------------------------------------------
   Responsive — usable at ~400px (SPEC.md §2)
   --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .tt-topbar { padding: 10px 12px; }
  .tt-qb-row { gap: 8px; }
  .tt-field { min-width: 120px; }
  /* Stack query-builder fields one per row at narrow widths instead of
     squeezing several onto one row: at ~400px, letting "Free-text
     condition" and "Query name" share a row with the indication <select>
     shrinks their text inputs down toward the 120px floor above, which
     visually truncates long placeholder/value text (caught in screenshot
     review — not a page-level overflow, just a cramped input). Full width
     per field matches the "panels stack" responsive rule in SPEC.md §2. */
  .tt-field { flex-basis: 100%; }
  .tt-val-results { grid-template-columns: 1fr; }
  .tt-drawer { width: 100vw; }
  .tt-company-popover { width: min(300px, 88vw); }
  .tt-shortcuts-popover { width: min(280px, 88vw); right: -8px; }
  .tt-qb-summary-text { white-space: normal; }
  .tt-results-strip { gap: 8px; }
}
