/* theme.css */
:root {
  color-scheme: dark;
  --bg: #071014;
  --bg-elevated: #091820;
  --panel: #0d171d;
  --panel-2: #12212a;
  --panel-3: #172b34;
  --text: #e6edf3;
  --muted: #8fa3ad;
  --subtle: #607782;
  --line: #243744;
  --line-strong: #365160;
  --accent: #2dd4bf;
  --profit: var(--accent); /* profit metrics intentionally share the accent hue */
  --success: #4ade80;
  --warning: #f59e0b;
  --danger: #ef4444;
  --focus: #67e8f9;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.35);
}

/* shared/base.css */
/* Shared base styles for the lp and missions front-ends.
   Loaded after theme.css (design tokens) and before each app's local stylesheet,
   so app-specific rules still win. Served at /shared/base.css for the missions app
   and concatenated into lp.css (after theme.css) for the lp app. */

.diagnostic-chips {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-width: 0;
}

.diagnostic-chip {
  display: inline-flex;
  min-height: 24px;
  max-width: 230px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: color-mix(in srgb, var(--panel-2) 68%, transparent);
  color: var(--subtle);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* style.css */
* {
  box-sizing: border-box;
}

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

:root {
  --space-highsec: #3b82f6;
  --space-nullsec: #ef4444;
  --detail-cols: 1.25fr 1fr 1fr 1.45fr 1fr;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(45, 212, 191, 0.1), transparent 34rem),
    var(--bg);
  color: var(--text);
  font: 13px/1.45 "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
}

button,
.button,
input,
select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover,
input:hover,
select:hover {
  border-color: var(--line-strong);
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.ghost {
  background: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}

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

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

#statusLine {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#statusLine::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px color-mix(in srgb, var(--success) 72%, transparent);
}

#statusLine.bad::before {
  background: var(--danger);
  box-shadow: 0 0 12px color-mix(in srgb, var(--danger) 72%, transparent);
}

.staleness-chips {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  min-width: 0;
}

.staleness-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: color-mix(in srgb, var(--panel-3) 72%, transparent);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.staleness-chip[data-tone="good"] {
  border-color: color-mix(in srgb, var(--success) 42%, var(--line));
  color: var(--success);
}

.staleness-chip[data-tone="bad"] {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
}

.staleness-chip[data-tone="muted"] {
  color: var(--subtle);
}

/* .diagnostic-chips / .diagnostic-chip base rules now live in web/shared/base.css. */

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  gap: 8px;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-only {
  width: 34px;
  padding: 0;
}

.workstation {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 64px);
}

.workstation.filters-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.workstation.filters-collapsed .filters-anchor {
  display: contents;
}

.workstation.filters-collapsed .filters {
  display: none;
}

.workstation.filters-collapsed .filter-edge-toggle {
  position: fixed;
  top: 84px;
  right: auto;
  left: 0;
  border-radius: 0 6px 6px 0;
  border-color: color-mix(in srgb, var(--profit) 48%, var(--line));
  background: color-mix(in srgb, var(--profit) 14%, var(--panel-2));
  color: var(--text);
}

.filters,
.table-wrap,
.summary-strip,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.filters-anchor {
  position: sticky;
  top: 78px;
  align-self: start;
  z-index: 4;
}

.filters {
  max-height: calc(100vh - 82px);
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.filter-edge-toggle {
  position: absolute;
  top: 50px;
  right: -16px;
  z-index: 6;
  width: 34px;
  min-height: 44px;
  padding: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel-3) 88%, var(--panel));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.filter-edge-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filter-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filters-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filters-head button {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.filters-head button:hover {
  color: var(--text);
}

.filter-group {
  display: grid;
  gap: 7px;
}

.filter-group + .filter-group {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.filter-group h2 {
  margin: 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

label,
.field-label {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 4px;
}

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

input,
select {
  width: 100%;
  padding: 0 9px;
}

.risk-tier-filter,
.level5-missions-filter,
.basis-filter,
.bpc-filter {
  display: grid;
  width: 100%;
  gap: 4px;
}

.risk-tier-filter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.level5-missions-filter,
.basis-filter {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bpc-filter {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.risk-tier-filter button,
.level5-missions-filter button,
.basis-filter button,
.bpc-filter button {
  gap: 6px;
  min-height: 30px;
  padding: 0 5px;
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--panel-3) 68%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.risk-tier-filter button[data-risk-filter="HIGHSEC"] {
  --tier-color: var(--space-highsec);
}

.risk-tier-filter button[data-risk-filter="NULLSEC"] {
  --tier-color: var(--space-nullsec);
}

.tier-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.risk-tier-filter .tier-icon {
  color: var(--tier-color);
}

/* Four-up ribbon: tighter gaps and icons so all labels fit the 240px sidebar. */
.bpc-filter button {
  gap: 4px;
  padding: 0 3px;
}

.bpc-filter .tier-icon {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
}

.risk-tier-filter button[aria-pressed="true"],
.level5-missions-filter button[aria-pressed="true"],
.basis-filter button[aria-pressed="true"],
.bpc-filter button[aria-pressed="true"] {
  border-color: var(--profit);
  background: color-mix(in srgb, var(--profit) 18%, var(--panel-2));
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--profit) 35%, transparent);
}

.risk-tier-filter button[aria-pressed="true"] {
  border-color: var(--tier-color);
  background: color-mix(in srgb, var(--tier-color) 17%, var(--panel-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tier-color) 38%, transparent);
}

.level5-missions-filter button[data-level5-filter="hide"][aria-pressed="true"] {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, var(--panel-2));
}

.level5-missions-filter button[data-level5-filter="show"][aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
}

.quality-filters {
  gap: 6px;
}

.quality-state-inputs {
  display: none;
}

.quality-toggle-grid {
  display: grid;
  /* 8 toggles in two rows of four */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
}

.quality-toggle-grid button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 38px;
  padding: 2px 1px;
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--panel-3) 68%, transparent);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.quality-toggle-grid button[aria-pressed="true"] {
  border-color: var(--profit);
  background: color-mix(in srgb, var(--profit) 16%, var(--panel-2));
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--profit) 35%, transparent);
}

.quality-toggle-grid button[data-quality-toggle="hideSuspicious"][aria-pressed="true"] {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 15%, var(--panel-2));
}

.quality-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.ranking-limits {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ranking-limits input {
  padding: 0 6px;
}

.skill-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.results {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.metric-card {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  min-width: 0;
  padding: 14px 18px;
  background: transparent;
  box-shadow: none;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-label,
.metric-note {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-label {
  color: var(--subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--text);
  font-size: 21px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metric-card[data-value-tone="profit"] strong {
  color: var(--profit);
}

.metric-card[data-value-tone="success"] strong {
  color: var(--success);
}

.metric-card[data-value-tone="info"] strong {
  color: var(--focus);
}

.metric-card[data-value-tone="cost"] strong {
  color: var(--warning);
}

.metric-card[data-tone="good"] strong {
  color: var(--success);
}

.metric-card[data-tone="warn"] strong {
  color: var(--warning);
}

.metric-card[data-tone="bad"] strong {
  color: var(--danger);
}

.summary-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  color: var(--muted);
}

.loading-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
}

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

.loading-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 10px color-mix(in srgb, currentColor 70%, transparent);
}

.table-wrap {
  position: relative;
  overflow: auto;
}

.floating-hscroll {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-top: 1px solid var(--line);
  z-index: 50;
  display: none;
}

.floating-hscroll.is-active {
  display: block;
}

.floating-hscroll-inner {
  height: 1px;
}

.floating-table-header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  overflow: hidden;
  z-index: 45;
  display: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.floating-table-header.is-active {
  display: block;
}

.floating-table-header table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

.floating-table-header th {
  top: 0;
  box-shadow: 0 1px 0 var(--line);
}

.floating-table-header th:nth-child(1),
.floating-table-header th:nth-child(2) {
  position: sticky;
}

.results.is-refreshing .table-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loadingPulse 900ms ease-in-out infinite;
}

.results.is-refreshing tbody .data-row {
  opacity: 0.68;
}

@keyframes loadingPulse {
  0%,
  100% {
    opacity: 0.35;
  }

  50% {
    opacity: 1;
  }
}

table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid color-mix(in srgb, var(--line) 64%, transparent);
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 44px;
  padding-inline: 4px;
  text-align: center;
  background: var(--panel-2);
}

th:nth-child(2),
td:nth-child(2) {
  position: sticky;
  left: 44px;
  z-index: 3;
  width: 300px;
  background: var(--panel-2);
}

thead th:nth-child(1),
thead th:nth-child(2) {
  z-index: 4;
  background: var(--panel-3);
}

/* Scroll shadow on the frozen 2nd column. Uses ::before so polish.css's
   hover/expand chevron (::after on .data-row td:nth-child(2)) no longer
   suppresses it — both pseudo-elements now coexist on data rows. */
td:nth-child(2)::before,
th:nth-child(2)::before {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 6px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), transparent);
  opacity: 0;
  transition: opacity 120ms ease;
}

.table-wrap.is-scrolled td:nth-child(2)::before,
.table-wrap.is-scrolled th:nth-child(2)::before {
  opacity: 1;
}

th:nth-child(3),
td:nth-child(3) {
  width: 220px;
}

th:nth-child(n + 4):nth-child(-n + 12),
td:nth-child(n + 4):nth-child(-n + 12) {
  width: 1%;
  padding-inline: 6px;
  text-align: right;
  white-space: nowrap;
}

th:nth-child(13),
td:nth-child(13) {
  width: 164px;
}

td:nth-child(13) {
  white-space: normal;
  overflow: visible;
}

/* anchor targets must clear the sticky topbar (~88px tall on the about page) */
.summary-strip h2[id] {
  scroll-margin-top: 104px;
}

.methodology-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.methodology-toc a {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.methodology-toc a:hover {
  color: var(--text);
  border-color: var(--accent);
}

.methodology-table {
  table-layout: auto;
  /* the base leaderboard table is width: max-content — unwrapped prose here
     would push the table past the 980px methodology column */
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.methodology-table .chip.flag {
  margin: 0 6px 0 0;
  cursor: default;
  vertical-align: middle;
}

.methodology-table th,
.methodology-table td {
  width: auto;
  min-width: 0;
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: top;
}

.methodology-table th {
  position: static;
  z-index: auto;
}

.methodology-table td:nth-child(1),
.methodology-table th:nth-child(1) {
  width: 190px;
}

.methodology-table td:nth-child(3),
.methodology-table th:nth-child(3) {
  width: 160px;
}

.methodology-table code {
  white-space: normal;
  word-break: break-word;
}

/* formula blocks on the methodology page are wider than a phone — scroll, don't bleed */
pre {
  overflow-x: auto;
}

@media (max-width: 700px) {
  .methodology-table {
    display: block;
    border: 0;
    background: transparent;
  }

  .methodology-table thead {
    display: none;
  }

  .methodology-table tbody,
  .methodology-table tr,
  .methodology-table td {
    display: block;
    width: 100%;
  }

  .methodology-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    overflow: hidden;
  }

  .methodology-table th,
  .methodology-table td,
  .methodology-table td:nth-child(1),
  .methodology-table td:nth-child(3) {
    width: 100%;
  }

  .methodology-table td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    padding: 8px 10px;
    border-right: 0;
    text-align: left;
  }

  .methodology-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }
}

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

.sort-header {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  width: 100%;
  min-height: 22px;
  cursor: pointer;
}

.sort-header:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sort-indicator {
  display: inline-block;
  width: 10px;
  color: var(--profit);
  text-align: center;
}

th[aria-sort="descending"] .sort-indicator::before {
  content: "v";
}

td:nth-child(2),
td:nth-child(3),
th:nth-child(2),
th:nth-child(3) {
  text-align: left;
}

td:nth-child(2) {
  white-space: normal;
  overflow: hidden;
  line-height: 1.3;
  word-break: break-word;
}

td:nth-child(3) {
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.3;
  text-overflow: ellipsis;
}

td:nth-child(2) .cell-text {
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

td:nth-child(3) .cell-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th:nth-child(2) .sort-header,
th:nth-child(3) .sort-header {
  justify-content: flex-start;
}

.value-isk-lp {
  color: var(--accent);
  font-weight: 700;
}

.value-instant {
  color: var(--profit);
  font-weight: 700;
}

.value-patient {
  color: var(--success);
  font-weight: 650;
}

.value-roi {
  color: var(--success);
  font-weight: 650;
}

.value-cost {
  color: var(--warning);
}

.value-lp {
  color: var(--focus);
}

.value-volume {
  color: var(--text);
}

.value-supply {
  color: var(--muted);
}

.data-row {
  cursor: pointer;
}

.data-row:hover td,
.data-row.expanded td {
  background: color-mix(in srgb, var(--profit) 12%, transparent);
}

.data-row:hover td:nth-child(1),
.data-row:hover td:nth-child(2),
.data-row.expanded td:nth-child(1),
.data-row.expanded td:nth-child(2) {
  background: color-mix(in srgb, var(--profit) 12%, var(--panel-2));
}

.data-row.expanded {
  box-shadow: inset 3px 0 0 var(--profit);
}

.detail-row td {
  padding: 0;
  overflow: visible;
  white-space: normal;
  text-align: left;
  vertical-align: top;
  background: color-mix(in srgb, var(--panel-3) 72%, var(--panel));
}

.detail-grid {
  display: grid;
  grid-template-columns: var(--detail-cols);
  min-height: 238px;
  max-height: 286px;
  overflow: hidden;
}

.detail-grid section {
  min-width: 0;
  padding: 14px 15px;
  border-right: 1px solid var(--line);
}

.detail-grid section:last-child {
  border-right: 0;
}

h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h3 span {
  box-sizing: border-box;
  flex: 0 0 auto;
  overflow: visible;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.35;
  padding-inline: 1px 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin-bottom: 5px;
}

.detail-primary {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 700;
}

.mini-dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.mini-dl div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.detail-list li {
  display: grid;
  gap: 2px;
}

.mini-dl dt {
  color: var(--subtle);
  font-size: 11px;
}

.mini-dl dd {
  margin: 0;
  color: var(--text);
  min-width: 0;
  white-space: normal;
}

.detail-list {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.detail-list li {
  margin: 0;
  min-width: 0;
}

.detail-list strong,
.detail-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-list strong {
  color: var(--accent);
  font-weight: 600;
}

.detail-list span,
.more-line {
  color: var(--muted);
  font-size: 12px;
}

.material-summary {
  margin: 0;
  color: var(--accent);
  line-height: 1.55;
  white-space: normal;
}

.material-summary-cost {
  margin: 10px 0 0;
  color: var(--warning);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.fill-estimate {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 20px;
  margin: 0 4px 4px 0;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
}

.chip.flag {
  width: 28px;
  min-width: 28px;
  padding: 0;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.chip.flag .flag-label {
  display: none;
}

.chip.flag.open {
  width: auto;
  max-width: 100%;
  min-height: 20px;
  height: auto;
  padding: 2px 8px;
}

.chip.flag.open .flag-label {
  display: inline;
  color: var(--text);
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
}

.flag-doc-link {
  margin-left: 5px;
  color: var(--subtle);
  font-weight: 700;
  text-decoration: none;
}

.flag-doc-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.chip-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flag.warn {
  border-color: var(--warning);
  color: var(--warning);
}

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

.flag-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  max-width: 100%;
  overflow: visible;
}

.flag-wrap .chip {
  flex: 0 0 auto;
  margin: 0;
}

.skeleton-row td {
  height: 42px;
}

.skeleton-bar {
  display: inline-block;
  width: 100%;
  max-width: 88px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--panel-3) 72%, transparent),
    color-mix(in srgb, var(--line-strong) 58%, transparent),
    color-mix(in srgb, var(--panel-3) 72%, transparent)
  );
}

.skeleton-bar-2,
.skeleton-bar-3 {
  max-width: 100%;
}

.muted-state,
.error {
  padding: 22px;
  text-align: left;
}

.muted-state {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

@media (prefers-reduced-motion: no-preference) {
  button,
  .button,
  .data-row,
  input,
  select {
    transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
  }
}

/* mobile.css */
@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .workstation {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .filters-anchor {
    position: static;
    display: flex;
    flex-direction: column;
  }

  .filters {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .filter-edge-toggle {
    position: static;
    order: -1;
    width: auto;
    min-height: 32px;
    margin: 0 0 10px;
    padding: 0 11px;
    border-radius: 6px;
    gap: 8px;
    box-shadow: none;
    align-self: flex-start;
  }

  .filter-toggle-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .staleness-chips,
  .diagnostic-chips {
    justify-content: flex-start;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .workstation {
    display: block;
    padding: 10px;
  }

  /* the metric strip keeps the 900px two-up layout — six stacked cards
     cost 1.5 phone screens before the table */
  .grid-two {
    grid-template-columns: 1fr;
  }

  /* collapsed-filters toggle: a bottom-left pill — fixed at top: 84px it floats
     over card titles once the static phone topbar scrolls away */
  .workstation.filters-collapsed .filter-edge-toggle {
    top: auto;
    bottom: 12px;
    left: 10px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }

  .ranking-limits {
    grid-template-columns: 1fr 1fr;
  }

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

  .filters,
  .results {
    margin-bottom: 12px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .floating-hscroll {
    display: none !important;
  }

  .floating-table-header {
    display: none !important;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  th:nth-child(1),
  td:nth-child(1),
  th:nth-child(2),
  td:nth-child(2) {
    position: static;
    left: auto;
  }

  thead {
    display: none;
  }

  /* Offer card: name + corp, a 2x2 labeled metric grid, flags. The five hidden
     numeric columns stay desktop-only — a phone card can't carry all thirteen. */
  tbody .data-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "offer offer"
      "corp corp"
      "ratio roi"
      "rate supply"
      "flags flags";
    gap: 8px 12px;
    margin-bottom: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: var(--panel);
  }

  /* :nth-child(n) lifts specificity to tie the desktop 1%-width column rule
     (td:nth-child(n+4):nth-child(-n+12)) so this later rule wins the cascade */
  .data-row td:nth-child(n) {
    display: grid;
    width: auto;
    gap: 2px;
    align-content: start;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .data-row td::before {
    content: attr(data-label);
    color: var(--subtle);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .data-row td[data-cell="rank"],
  .data-row td[data-cell="lp"],
  .data-row td[data-cell="isk"],
  .data-row td[data-cell="instant"],
  .data-row td[data-cell="patient"],
  .data-row td[data-cell="cargo"] {
    display: none;
  }

  .data-row td[data-cell="offer"] {
    grid-area: offer;
    font-size: 15px;
    font-weight: 700;
  }

  .data-row td[data-cell="corp"] {
    grid-area: corp;
    margin-top: -4px;
    color: var(--muted);
    font-size: 12px;
  }

  .data-row td[data-cell="offer"]::before,
  .data-row td[data-cell="corp"]::before,
  .data-row td[data-cell="flags"]::before {
    content: none;
  }

  .data-row td[data-cell="iskPerLp"] {
    grid-area: ratio;
    font-size: 15px;
    font-weight: 700;
  }

  .data-row td[data-cell="roi"] { grid-area: roi; }
  .data-row td[data-cell="iskHour"] { grid-area: rate; }
  .data-row td[data-cell="supply"] { grid-area: supply; }
  .data-row td[data-cell="flags"] { grid-area: flags; }

  /* the desktop expand chevron is keyed to the offer cell — meaningless in card form */
  .data-row td:nth-child(2)::after {
    content: none;
  }

  .detail-row {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: var(--panel-2);
  }

  .detail-row td {
    display: block;
    width: 100%;
    padding: 12px;
    border: 0;
    white-space: normal;
  }

  .detail-row td::before {
    content: none;
  }

  /* The polish layer keeps .detail-row at display: table-row (for the expand
     animation) and animates .detail-grid with the desktop five-column template and
     a 286px height cap; all three break the stacked card. :not([hidden]) outranks
     polish while leaving the collapsed state animatable at max-height 0. */
  .detail-row:not([hidden]) {
    display: block;
  }

  .detail-row:not([hidden]) .detail-grid {
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: none;
  }

  .detail-grid section {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
  }

  .detail-grid section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .flag-wrap {
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow: visible;
  }

  .flag-wrap .chip {
    margin: 0 4px 4px 0;
  }
}

/* polish.css */
/* Polish layer -- subtle enhancements layered over source style.css.
   Goals: smoother interactions, better affordances, refined glyphs.
   Non-goals: changing the layout, colors, spacing, or visual character. */

/* ---------- 2. Smoother detail-row expand ----------
   Source toggles [hidden] instantly. Replace with a grid-rows animation
   that opens the detail strip in 220ms. */
.detail-row {
  display: table-row;
}
.detail-row[hidden] {
  display: table-row;
}
.detail-row > td {
  padding: 0;
  border-bottom: 0;
}
.detail-row .detail-grid {
  display: grid;
  grid-template-columns: var(--detail-cols);
  overflow: hidden;
  max-height: 286px;
  opacity: 1;
  transition: max-height 240ms cubic-bezier(.2,.7,.3,1), opacity 180ms ease;
}
.detail-row[hidden] .detail-grid {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  min-height: 0;
}
.detail-row[hidden] > td {
  border-bottom: 0;
}

/* ---------- 3. Refined sort indicator ----------
   Replace the ASCII marker with a clean chevron and a gentle rotate
   between ascending and descending. */
.sort-indicator {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 180ms ease, color 160ms ease;
}
.sort-indicator::before { content: "" !important; }
.sort-indicator::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}
th[aria-sort="descending"] .sort-indicator {
  color: var(--profit);
}
th[aria-sort="ascending"] .sort-indicator {
  color: var(--profit);
  transform: rotate(180deg);
}
th:not([aria-sort]) .sort-indicator {
  color: var(--subtle);
  opacity: 0;
  transition: opacity 160ms ease;
}
.sort-header:hover .sort-indicator {
  opacity: 0.7;
}

/* ---------- 4. Subtle row affordance ----------
   Add a faint chevron at the right of the Offer cell on hover to hint
   the row is expandable. */
.data-row td:nth-child(2)::after {
  content: "";
  position: absolute;
  right: 8px; top: 50%;
  width: 6px; height: 6px;
  margin-top: -4px;
  border-right: 1.5px solid var(--subtle);
  border-bottom: 1.5px solid var(--subtle);
  transform: rotate(-45deg);
  opacity: 0;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,.7,.3,1);
}
.data-row:hover td:nth-child(2)::after {
  opacity: 0.6;
}
.data-row.expanded td:nth-child(2)::after {
  opacity: 0.8;
  transform: rotate(45deg);
}

/* ---------- 5. Filter section eyebrow color ----------
   Source filter-group h2 uses --text; nudge to a more deliberate
   accent-leaning subtle. Same weight, no shift in rhythm. */
.filter-group > h2 {
  color: color-mix(in srgb, var(--accent) 35%, var(--muted));
}

/* ---------- 6. Metric strip number, slight weight bump ---------- */
.metric-card strong {
  font-weight: 650;
  letter-spacing: -0.005em;
}

/* ---------- 7. Reduced-motion respect ---------- */
@media (prefers-reduced-motion: reduce) {
  .data-row td:nth-child(2)::after,
  .sort-indicator,
  .detail-row .detail-grid {
    transition: none !important;
    animation: none !important;
  }
}
