/* Undercut — "Counterweight" design system.
   DESIGN.md is the brief; this file is the source of truth for the tokens.
   Rules live on custom properties only — components never hardcode color. */

/* ---------- fonts (vendored, variable) ---------- */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/BricolageGrotesque-var.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

@font-face {
  font-family: "Spline Sans Mono";
  src: url("/static/fonts/SplineSansMono-var.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

/* ---------- tokens ---------- */

:root {
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-data: "Spline Sans Mono", ui-monospace, "Cascadia Mono", monospace;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* assay office at noon */
  --bg: #e9ecf0;
  --bg-raised: #f5f7fa;
  --bg-sunken: #dfe3e9;
  --ink: #1c2129;
  --ink-muted: #5a6473;
  --line: #c6ccd6;
  --brass: #8a6d1f;
  --brass-hover: #6f5817;
  --brass-ink: #ffffff;
  --profit: #1e7c4d;
  --loss: #b3323c;
  /* darker than --profit: the chip renders at 12px, needs 4.5:1 on --bg */
  --fresh: #186b41;
  --aging: #85590f;
  --stale: #a2453b;

  --radius: 4px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgb(18 21 27 / 0.08), 0 2px 8px rgb(18 21 27 / 0.06);
  color-scheme: light;
}

/* the vault */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --bg-raised: #1a1f27;
    --bg-sunken: #0c0e13;
    --ink: #dee3ea;
    --ink-muted: #8b95a5;
    --line: #2a313d;
    --brass: #d4b04a;
    --brass-hover: #e3c66e;
    --brass-ink: #12151b;
    --profit: #4cc38a;
    --loss: #e5646e;
    --fresh: #4cc38a;
    --aging: #d9a03f;
    --stale: #c96a5b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 8px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

/* explicit toggle wins over the OS preference, both directions */
:root[data-theme="light"] {
  --bg: #e9ecf0;
  --bg-raised: #f5f7fa;
  --bg-sunken: #dfe3e9;
  --ink: #1c2129;
  --ink-muted: #5a6473;
  --line: #c6ccd6;
  --brass: #8a6d1f;
  --brass-hover: #6f5817;
  --brass-ink: #ffffff;
  --profit: #1e7c4d;
  --loss: #b3323c;
  /* darker than --profit: the chip renders at 12px, needs 4.5:1 on --bg */
  --fresh: #186b41;
  --aging: #85590f;
  --stale: #a2453b;
  --shadow: 0 1px 2px rgb(18 21 27 / 0.08), 0 2px 8px rgb(18 21 27 / 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12151b;
  --bg-raised: #1a1f27;
  --bg-sunken: #0c0e13;
  --ink: #dee3ea;
  --ink-muted: #8b95a5;
  --line: #2a313d;
  --brass: #d4b04a;
  --brass-hover: #e3c66e;
  --brass-ink: #12151b;
  --profit: #4cc38a;
  --loss: #e5646e;
  --fresh: #4cc38a;
  --aging: #d9a03f;
  --stale: #c96a5b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 8px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* ---------- base ---------- */

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

/* markdown-rendered prose (patch notes): long code tokens and blocks must not
   push the page wider than the viewport on mobile. */
pre { overflow-x: auto; max-width: 100%; }
code { overflow-wrap: anywhere; }

h1 { font-size: 2.25rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; font-weight: 600; }

/* the undercut step: a price dropping one notch. Wordmark + h2 only. */
h2.u-step,
.c-wordmark {
  position: relative;
  display: inline-block;
  padding-bottom: 8px;
}

/* as a grid item the heading must shrink-wrap too, or the step's notch
   lands mid-page instead of under the words */
.page > h2.u-step { justify-self: start; }

h2.u-step::after,
.c-wordmark::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 6px;
  background:
    linear-gradient(to right, var(--brass) 0 55%, transparent 55%) top / 100% 2px no-repeat,
    linear-gradient(to right, transparent 0 55%, var(--brass) 55%) bottom / 100% 2px no-repeat,
    linear-gradient(var(--brass), var(--brass)) 55% 0 / 2px 100% no-repeat;
}

a {
  color: var(--brass);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { color: var(--brass-hover); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Smooth cross-document page changes (native MPA View Transitions). Plain
   server-rendered navigations cross-fade instead of hard-cutting; browsers
   without support just navigate normally. No JS, no framework. */
@view-transition { navigation: auto; }

/* One orchestrated page-load reveal: the main column's direct children rise in
   with a short stagger. Compositor-only (transform/opacity), capped so a long
   page doesn't cascade forever, and off entirely under reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  .page > * {
    animation: rise 0.4s cubic-bezier(0.2, 0.6, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
  }
  .page > *:nth-child(1) { --i: 0; }
  .page > *:nth-child(2) { --i: 1; }
  .page > *:nth-child(3) { --i: 2; }
  .page > *:nth-child(4) { --i: 3; }
  .page > *:nth-child(5) { --i: 4; }
  .page > *:nth-child(n + 6) { --i: 5; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- page grid: content / wide / full-bleed ---------- */
/* Kills the old centred 1200px column and its dead gutters. Three named
   columns: text and forms sit in `content` (a comfortable scanning measure),
   the wide multi-column data tables break out to `wide`, and hero/status
   bands can bleed edge-to-edge with `.u-bleed`. Collapses to a single gutter-
   padded column below ~1400px, so mobile is untouched. */
.page {
  --gutter: clamp(1rem, 4vw, 4rem);
  --content-w: min(1360px, 100% - var(--gutter) * 2);
  --wide-w: min(1760px, 100% - var(--gutter) * 2);
  --pop: calc((var(--wide-w) - var(--content-w)) / 2);
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, var(--pop))
    [content-start] var(--content-w) [content-end]
    minmax(0, var(--pop)) [wide-end]
    minmax(var(--gutter), 1fr) [full-end];
  padding-bottom: 64px;
}

.page > * { grid-column: content; }
.page > .u-wide { grid-column: wide; }
.page > .u-bleed { grid-column: full; }

/* A bleed band that keeps its own inner content on the content column, so a
   full-width coloured/sunken strip still aligns its text with everything else. */
.page > .u-bleed-band {
  grid-column: full;
  display: grid;
  grid-template-columns: inherit;
}
.page > .u-bleed-band > * { grid-column: content; }

.u-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.u-muted { color: var(--ink-muted); }
.u-num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.u-right { text-align: right; }

/* ---------- top nav: sticky, translucent, brass-edged ---------- */

.c-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px 22px;
  padding: 11px clamp(1rem, 4vw, 4rem);
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  /* the counter's brass edge, now horizontal */
  box-shadow: inset 0 -3px 0 -1px color-mix(in srgb, var(--brass) 55%, transparent);
}

.c-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  flex: none;
}

.c-nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: auto;
  min-width: 0;
}

.c-navlink {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-lg);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

.c-navlink:hover {
  background: color-mix(in srgb, var(--brass) 9%, transparent);
  color: var(--ink);
}

.c-navlink.is-active {
  color: var(--ink);
  font-weight: 600;
}

/* active tab wears the brand's undercut-step — a price dropping one notch */
.c-navlink.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 5px;
  background:
    linear-gradient(to right, var(--brass) 0 55%, transparent 55%) top / 100% 2px no-repeat,
    linear-gradient(to right, transparent 0 55%, var(--brass) 55%) bottom / 100% 2px no-repeat,
    linear-gradient(var(--brass), var(--brass)) 55% 0 / 2px 100% no-repeat;
}

/* a mini inventory-slot glyph in front of each tool */
.c-navlink__ico {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  line-height: 1;
  color: var(--ink-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.c-navlink.is-active .c-navlink__ico {
  color: var(--brass);
  border-color: color-mix(in srgb, var(--brass) 40%, var(--line));
}

.c-nav__side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Pro is the one brand-colored nav item — an invitation, not a tool */
.c-navlink--pro { color: var(--brass); font-weight: 600; }
.c-navlink--pro:hover { color: var(--brass); }

/* grouped nav: native <details> disclosures — click/tap/keyboard on every
   platform, no Popover-API or hover-on-touch risk; a tiny script in
   base.html adds outside-click dismiss */
.c-navgroup { position: relative; }

summary.c-navlink,
summary.c-btn {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary.c-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

summary::-webkit-details-marker { display: none; }

.c-navgroup[open] > summary.c-navlink {
  background: color-mix(in srgb, var(--brass) 9%, transparent);
  color: var(--ink);
}

.c-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.7;
}

.c-navgroup[open] .c-caret { transform: rotate(180deg); }

.c-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--ink) 45%, transparent);
}

.c-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  white-space: nowrap;
}

.c-menu a:hover,
.c-menu a:focus-visible { background: color-mix(in srgb, var(--brass) 9%, transparent); }

.c-menu a.is-active { color: var(--brass); font-weight: 600; }

.c-menu--end { left: auto; right: 0; }

/* exactly one nav rendering shows: strip below the breakpoint, groups above */
.c-nav__links--groups { display: none; }

@media (min-width: 921px) {
  .c-nav__links--groups { display: flex; }
  .c-nav__links--strip { display: none; }
}

/* ---------- the live ticker (signature): a market with a heartbeat ---------- */

.c-ticker {
  overflow: hidden;
  padding: 7px 0;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  font: 500 0.8125rem/1 var(--font-data);
  color: var(--ink-muted);
  /* fixed-px fade: 3% was ~12px on a phone (glyphs died abruptly) and 100px+
     on ultrawide (over-soft) */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}

.c-ticker__track {
  display: flex;
  width: max-content;
  animation: ticker 60s linear infinite;
}

/* Each set fills at least the viewport, so sparse content still spans the
   bar on ultrawide; two identical sets make the -50% loop seamless.
   space-around keeps the seam between sets the same rhythm as the gaps
   inside one. Links get block padding so a thumb can hit them. */
.c-ticker__set {
  display: flex;
  gap: 34px;
  justify-content: space-around;
  min-width: 100vw;
}

.c-ticker__item a { padding-block: 8px; }

.c-ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.c-ticker__region {
  color: var(--ink);
  font-weight: 700;
  text-transform: capitalize;
}

.c-ticker__gold::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--brass);
  vertical-align: middle;
}

@keyframes ticker { to { transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  /* still readable: the bar becomes a hand-scrollable strip instead of dead */
  .c-ticker { overflow-x: auto; }
  .c-ticker__track { animation: none; }
}

/* ---------- item frame: an Albion inventory slot ---------- */

.c-itemframe {
  --s: 56px;
  width: var(--s);
  height: var(--s);
  flex: none;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  position: relative;
  background:
    radial-gradient(115% 115% at 50% 0,
      color-mix(in srgb, var(--brass) 12%, var(--bg-sunken)), var(--bg-sunken));
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.05),
    inset 0 0 0 1px rgb(0 0 0 / 0.04),
    var(--shadow);
}

.c-itemframe::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 5px;
  border: 1px solid color-mix(in srgb, var(--brass) 24%, transparent);
  pointer-events: none;
}

.c-itemframe img {
  width: 84%;
  height: 84%;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35));
}

.c-itemframe--lg { --s: 76px; }

/* ---------- landing hero: the floor, live ---------- */

.c-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: center;
  width: 100%;
  max-width: 1640px;
  margin-inline: auto;
  padding: clamp(24px, 4vw, 56px) clamp(1rem, 4vw, 4rem) clamp(28px, 4vw, 48px);
}

.c-hero__title {
  font-size: clamp(2.4rem, 5vw, 4.25rem);
  line-height: 1.0;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}

.c-hero__lede {
  font-size: 1.125rem;
  color: var(--ink-muted);
  max-width: 48ch;
  margin: 0 0 26px;
}

.c-hero__cta { display: flex; flex-wrap: wrap; gap: 12px; }

.c-floor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.c-floor__head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font: 600 0.6875rem/1 var(--font-data);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  margin: 2px 2px 2px;
}

.c-tile {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.c-tile:hover {
  border-color: color-mix(in srgb, var(--brass) 40%, var(--line));
  transform: translateY(-1px);
}

.c-tile__body { min-width: 0; overflow: hidden; }

/* display:block is load-bearing: text-overflow:ellipsis is a no-op on an inline
   span, so without it a long item name expands the tile and scrolls the page. */
.c-tile__name {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-tile__price {
  display: block;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 1.0625rem;
  font-weight: 600;
  margin-top: 2px;
}

/* ---------- footer ---------- */

.c-footer {
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding: 22px clamp(1rem, 4vw, 4rem);
  color: var(--ink-muted);
  font-size: 0.875rem;
  display: flex;
  gap: 8px 20px;
  flex-wrap: wrap;
}

/* ---------- responsive: nav links become a scrollable pill strip ---------- */

/* Below the breakpoint the flat strip nav renders (see --groups/--strip
   switch above): full-width, swipeable, no wrap. */
@media (max-width: 920px) {
  .c-nav {
    flex-wrap: wrap;
    padding-inline: clamp(0.75rem, 3vw, 2rem);
  }

  .c-nav__side { margin-left: auto; }

  /* thumb-sized targets on the primary mobile nav */
  .c-nav__links--strip .c-navlink { padding-block: 11px; }

  /* full-width strip below the brand, swipeable, no wrap */
  .c-nav__links {
    order: 3;
    width: 100%;
    margin-right: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .c-nav__links::-webkit-scrollbar { display: none; }

  .c-hero { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- freshness pulse (THE signature) ---------- */

.c-fresh {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-data);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--ink-muted);
  white-space: nowrap;
}

.c-fresh::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.c-fresh--fresh { color: var(--fresh); }
.c-fresh--fresh::before {
  background: var(--fresh);
  animation: fresh-pulse 2.4s ease-in-out infinite;
}

.c-fresh--aging { color: var(--aging); }
.c-fresh--aging::before { background: var(--aging); }

.c-fresh--stale { color: var(--stale); }
.c-fresh--stale::before { background: var(--stale); }

@keyframes fresh-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fresh) 45%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* a price + its age, fused */
.c-price {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* rule 2: profit/loss numbers are colored — everywhere, not just tables */
.is-profit { color: var(--profit); }
.is-loss { color: var(--loss); }

/* ---------- cards / stats ---------- */

.c-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.c-card > h2:first-child,
.c-card > h3:first-child { margin-top: 0; }
/* Changelog prose quotes raw item ids — break the token, not the layout. */
.c-card li { overflow-wrap: anywhere; }

/* Option B pro gate (v0.16.0): the board's shape is public, the identity of
   its best rows is not. Redaction happens server-side; these just dress it. */
.c-lockedrow td { color: var(--ink-muted); }
.u-redact { color: var(--line); user-select: none; }

/* a card that is itself a link (landing tool grid) */
.c-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px; /* same breath as .c-card, so the next h2 doesn't touch */
}

@media (min-width: 680px) { .c-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .c-cards { grid-template-columns: repeat(3, 1fr); } }

.c-card--link {
  display: block;
  margin: 0;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.c-card--link:hover {
  border-color: color-mix(in srgb, var(--brass) 45%, var(--line));
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgb(18 21 27 / 0.1), 0 8px 26px rgb(18 21 27 / 0.08);
}

.c-card--link h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
}

.c-card--link .c-navlink__ico { width: 30px; height: 30px; font-size: 0.9375rem; }

.c-stat {
  display: inline-block;
  /* top, not the default baseline: cards whose label wraps (or carries a
     freshness chip) would otherwise push their big value upward */
  vertical-align: top;
  min-width: 130px;
  margin: 0 24px 12px 0;
}

.c-stat__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.c-stat__label {
  color: var(--ink-muted);
  font-size: 0.875rem;
}

/* ---------- tables ---------- */

.c-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--bg-raised);
}

.c-table th,
.c-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: baseline;
}

.c-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

.c-table .u-num,
.c-table td.u-right,
.c-table th.u-right { text-align: right; }

.c-table tbody tr:hover { background: color-mix(in srgb, var(--brass) 6%, var(--bg-raised)); }

.c-table .is-profit, .c-table .is-loss { font-weight: 600; }

/* ---------- forms / buttons ---------- */

.c-btn {
  display: inline-block;
  font: 600 0.9375rem var(--font-body);
  color: var(--brass-ink);
  background: var(--brass);
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
}

.c-btn:hover { background: var(--brass-hover); border-color: var(--brass-hover); color: var(--brass-ink); }

.c-btn--ghost {
  background: transparent;
  color: var(--brass);
}

.c-btn--ghost:hover {
  background: color-mix(in srgb, var(--brass) 10%, transparent);
  color: var(--brass);
}

.c-input,
.c-select {
  font: 400 0.9375rem var(--font-body);
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-width: 0;
  height: 36px; /* one height with .c-btn — filter rows align top AND bottom */
}

/* checkbox groups center on the control row instead of floating at its top
   (:has scopes this to the Bonuses-style spans, not the preset-link spans) */
.c-field > span:has(> label) {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-height: 36px;
}

.c-field > span > label { white-space: nowrap; }

.c-input[type="number"],
.c-input.u-num { font-family: var(--font-data); }

.c-field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 14px 14px 0;
  vertical-align: top;
}

.c-field > label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.c-toggle-group {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.c-toggle-group a,
.c-toggle-group button {
  font: 500 0.875rem var(--font-body);
  color: var(--ink-muted);
  background: var(--bg-raised);
  border: 0;
  border-right: 1px solid var(--line);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
}

.c-toggle-group > :last-child { border-right: 0; }

.c-toggle-group .is-active {
  background: var(--brass);
  color: var(--brass-ink);
  font-weight: 600;
}

/* ---------- misc components ---------- */

.c-badge {
  display: inline-block;
  font: 600 0.75rem var(--font-body);
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--bg-sunken);
}

/* trade-quality letter (S+ … D) — replaces the raw score number on boards.
   sp = S+ (the '+' can't live in a class name). */
.c-grade {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  font: 700 0.8125rem/1.4 var(--font-data);
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1px 7px;
  background: var(--bg-sunken);
}
.c-badge--yours { color: var(--brass); border-color: var(--brass); }

.c-input--px { width: 110px; }

.c-grade--sp { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.c-grade--s { color: var(--brass); border-color: var(--brass); }
.c-grade--a { color: var(--profit); border-color: var(--profit); }
.c-grade--b { color: var(--ink); }

/* A data-sanity warning on a scan row (outlier ask, dead market, no recipes). */
.c-badge--warn {
  color: var(--stale);
  border-color: color-mix(in srgb, var(--stale) 45%, var(--line));
  background: color-mix(in srgb, var(--stale) 10%, var(--bg-sunken));
}

/* ---------- pro tier: pricing cards, usage meters, the scan gate ---------- */

.c-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.c-plan {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}

/* the pro card wears the counter's brass edge (padding eats the extra 2px
   so both cards' content sits on one baseline) */
.c-plan--pro { border-top: 3px solid var(--brass); padding-top: 20px; }

.c-plan__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.c-plan__price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.c-plan__per {
  font: 500 0.875rem var(--font-body);
  color: var(--ink-muted);
  letter-spacing: 0;
  white-space: nowrap;
}

.c-plan__list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.c-plan__list li {
  position: relative;
  padding: 6px 0 6px 26px;
}

.c-plan__list li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  color: var(--profit);
  font-weight: 700;
}

/* cap usage on /account */
.c-meter {
  max-width: 420px;
  margin: 12px 0;
}

.c-meter__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.c-meter__track {
  height: 6px;
  border-radius: 999px;
  /* line-tinted so an empty meter still reads as a meter in the vault */
  background: color-mix(in srgb, var(--line) 35%, var(--bg-sunken));
  border: 1px solid var(--line);
  overflow: hidden;
}

.c-meter__fill {
  height: 100%;
  background: var(--ink-muted);
  border-radius: inherit;
}

/* the pro gate under a capped ranked scan */
.c-gate {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 14px 0;
  padding: 14px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius);
}

.c-gate__count {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.625rem;
  letter-spacing: -0.02em;
}

.c-gate__body { flex: 1 1 260px; }

.c-gate .c-btn { margin-left: auto; flex: none; }

/* ---------- tool-page headers: the best row, weighed up front ---------- */

.c-bestrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 28px;
}

.c-bestrow .c-stat { margin: 0; }

/* the stats travel as one unit, so a narrow screen wraps them cleanly
   below the item instead of orphaning the last one */
.c-bestrow__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  margin-left: auto;
}

.c-bestrow__what {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 240px;
}

.c-bestrow__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

a.c-bestrow__name:hover { color: var(--brass); }

/* the Black Market header sits in shadow */
.c-bestrow--bm { background: var(--bg-sunken); }

/* a route: buy leg, an arrow, sell leg */
.c-route {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.9375rem;
}

.c-route__arrow {
  flex: none;
  width: 26px;
  height: 2px;
  background: var(--ink-muted);
  position: relative;
}

.c-route__arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -3px;
  border-left: 6px solid var(--ink-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* what-to-craft podium: the top three, framed like inventory finds */
.c-podium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.c-podium__card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}

.c-podium__card:hover { border-color: color-mix(in srgb, var(--brass) 45%, var(--line)); }

.c-podium__rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.625rem;
  color: var(--ink-muted);
  flex: none;
}

.c-podium__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.c-podium__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-podium__profit {
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 1.25rem;
}

.c-flash {
  border: 1px solid var(--profit);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--profit) 8%, var(--bg-raised));
  padding: 10px 14px;
  margin-bottom: 20px;
}

.c-flash--error {
  border-color: var(--loss);
  background: color-mix(in srgb, var(--loss) 8%, var(--bg-raised));
}

.c-empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

/* the unfolded craft-profit math: a ledger */
.c-breakdown {
  max-width: 560px; /* a ledger reads down, not across the whole card */
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  margin: 0;
}

.c-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 5px 0;
  border-bottom: 1px dotted var(--line);
}

.c-breakdown dt { color: var(--ink-muted); font-family: var(--font-body); }
.c-breakdown dd { margin: 0; }

.c-breakdown > .c-breakdown__total {
  border-bottom: 0;
  border-top: 2px solid var(--ink);
  font-weight: 700;
  margin-top: 4px;
}

/* reserved sponsor slot — exists so ads never reflow a page later */
.c-adslot {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--ink-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 28px 0;
}

@media (max-width: 640px) {
  h1 { font-size: 1.625rem; }
  h2 { font-size: 1.25rem; }
  .c-stat__value { font-size: 1.625rem; }
  .c-adslot { height: 100px; }
  .c-nav { gap: 10px 16px; }
}
