/* ==========================================================================
   VPS0.cc · Swiss Instrument Design System
   Light: Paper & Cobalt (#F7F8FA / #FFFFFF / #1D4ED8)
   Dark:  Carbon Ink & Ice Cobalt (#09090B / #111114 / #60A5FA)
   Strict 3-radius scale: 6px (sm) · 10px (md) · 999px (pill)
   ========================================================================== */

:root {
  color-scheme: light;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Core Light Tokens — Paper & Cobalt */
  --palette-page: #f7f8fa;
  --palette-surface: #ffffff;
  --palette-header: rgba(255, 255, 255, 0.86);
  --palette-raised: #f1f3f6;
  --palette-ink: #0f172a;
  --palette-muted: #5b667a;
  --palette-subtle: #8892a4;
  --palette-border: rgba(15, 23, 42, 0.09);
  --palette-border-strong: rgba(15, 23, 42, 0.16);
  --palette-accent: #1d4ed8;
  --palette-accent-hover: #1e40af;
  --palette-on-accent: #ffffff;
  --palette-selected: rgba(29, 78, 216, 0.08);
  --palette-hover: rgba(15, 23, 42, 0.032);
  --palette-brand: #0f172a;
  --palette-shadow: rgba(15, 23, 42, 0.08);
  --palette-shadow-lg: rgba(15, 23, 42, 0.16);

  /* Semantic Status (restrained 8-10% tints) */
  --status-in: #047857;
  --status-in-bg: rgba(5, 150, 105, 0.10);
  --status-out: #be123c;
  --status-out-bg: rgba(225, 29, 72, 0.09);
  --status-warn: #b45309;
  --status-warn-bg: rgba(217, 119, 6, 0.11);
  --status-good-dot: #10b981;

  /* Brand mark */
  --brand-mark-top: #dbeafe;
  --brand-mark-line: #60a5fa;

  /* Radii & Spacing */
  --r-sm: 6px;
  --r-md: 10px;
  --r-pill: 999px;

  /* Legacy alias bindings so every existing sub-stylesheet stays unified */
  --bg: var(--palette-page);
  --surface: var(--palette-surface);
  --raised: var(--palette-raised);
  --ink: var(--palette-ink);
  --muted: var(--palette-muted);
  --line: var(--palette-border);
  --green: var(--palette-accent);
  --selected: var(--palette-selected);
  --hover: var(--palette-hover);
  --control: var(--palette-surface);
  --control-border: var(--palette-border-strong);
  --accent-border: rgba(29, 78, 216, 0.34);
  --palette-stock-text: var(--status-in);
  --palette-hero-start: #0f172a;
  --palette-hero-end: #1e293b;
  --palette-hero-caption: #94a3b8;
  --palette-hero-stock: #34d399;

  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --palette-page: #09090b;
  --palette-surface: #111114;
  --palette-header: rgba(9, 9, 11, 0.88);
  --palette-raised: #18181c;
  --palette-ink: #f4f4f5;
  --palette-muted: #a1a1aa;
  --palette-subtle: #71717a;
  --palette-border: rgba(255, 255, 255, 0.09);
  --palette-border-strong: rgba(255, 255, 255, 0.16);
  --palette-accent: #60a5fa;
  --palette-accent-hover: #93c5fd;
  --palette-on-accent: #09090b;
  --palette-selected: rgba(96, 165, 250, 0.16);
  --palette-hover: rgba(255, 255, 255, 0.06);
  --palette-brand: #18181c;
  --palette-shadow: rgba(0, 0, 0, 0.42);
  --palette-shadow-lg: rgba(0, 0, 0, 0.72);

  --status-in: #34d399;
  --status-in-bg: rgba(16, 185, 129, 0.15);
  --status-out: #fda4af;
  --status-out-bg: rgba(244, 63, 94, 0.16);
  --status-warn: #fbbf24;
  --status-warn-bg: rgba(245, 158, 11, 0.15);
  --status-good-dot: #34d399;

  /* Explicit dark re-bindings for all alias tokens */
  --bg: #09090b;
  --surface: #111114;
  --raised: #18181c;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: rgba(255, 255, 255, 0.09);
  --green: #60a5fa;
  --selected: rgba(96, 165, 250, 0.16);
  --hover: rgba(255, 255, 255, 0.06);
  --control: #18181c;
  --control-border: rgba(255, 255, 255, 0.15);
  --accent-border: rgba(96, 165, 250, 0.42);
  --palette-stock-text: #34d399;
  --palette-hero-start: #111114;
  --palette-hero-end: #18181c;
}

/* Explicit dark-mode control surface guard against UA light backgrounds */
:root[data-theme="dark"] :is(.input-shell, .select-shell, .cmdk-trigger, .theme-toggle, .language-toggle, .nav-toggle, .preset-chip, .compare-pick, .star, .vendor-picker-trigger, .list-footer button, .secondary-button) {
  background-color: #18181c;
  color: #e4e4e7;
  border-color: rgba(255, 255, 255, 0.14);
}
:root[data-theme="dark"] :is(.facet-bar .select-shell, .range-bar .select-shell) {
  background-color: #18181c;
  border-color: rgba(255, 255, 255, 0.13);
}
:root[data-theme="dark"] :is(.facet-bar .select-shell.active, .range-bar .select-shell.active, .preset-chip[aria-pressed="true"], .compare-pick[aria-pressed="true"]) {
  background-color: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
  color: #93c5fd;
}
:root[data-theme="dark"] .segmented {
  background-color: #18181c;
  border-color: rgba(255, 255, 255, 0.11);
}
:root[data-theme="dark"] .segmented button[aria-pressed="true"] {
  background-color: #27272e;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
:root[data-theme="dark"] :is(select, input, button) {
  color-scheme: dark;
}
:root[data-theme="dark"] .select-shell select,
:root[data-theme="dark"] .input-shell input {
  background-color: transparent;
  color: #f4f4f5;
}
:root[data-theme="dark"] .select-shell option {
  background-color: #18181c;
  color: #f4f4f5;
}

html { scrollbar-gutter: stable; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { border: 0; background: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--palette-accent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}
svg.icon { width: 1.08em; height: 1.08em; display: block; flex-shrink: 0; }
i[data-icon] { display: inline-flex; align-items: center; font-style: normal; }
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Sticky Precision Header
   ========================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--palette-header);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.header-inner, .main {
  max-width: 1320px;
  width: 100%;
  padding-inline: clamp(16px, 3.2vw, 40px);
  margin-inline: auto;
}
.header-inner {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.8vw, 36px);
}
.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  font-size: 1.12rem;
  letter-spacing: -0.04em;
  font-weight: 720;
  color: var(--ink);
  flex-shrink: 0;
}
.brand-icon {
  display: grid;
  place-items: center;
  background: var(--palette-brand);
  height: 28px;
  width: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
}
.brand-icon svg { width: 19px; height: 19px; }

#header-tools { display: contents; }
.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 520;
  color: var(--muted);
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease;
}
.nav a:hover {
  color: var(--ink);
  background: var(--hover);
}
.nav a[aria-current] {
  color: var(--palette-accent);
  background: var(--selected);
  font-weight: 620;
}
#favorite-count:not(:empty),
#compare-count:not(:empty) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--selected);
  color: var(--palette-accent);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
  margin-inline-start: auto;
}
.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--control-border);
  border-radius: var(--r-sm);
  background: var(--control);
  color: var(--muted);
  font-size: 0.8rem;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.cmdk-trigger:hover {
  border-color: var(--accent-border);
  color: var(--ink);
  background: var(--hover);
}
.cmdk-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--muted);
}

.theme-toggle, .language-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--r-sm);
  color: var(--muted);
  background: var(--control);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease, transform 90ms ease;
}
.theme-toggle:hover, .language-toggle:hover {
  color: var(--palette-accent);
  border-color: var(--accent-border);
  background: var(--hover);
}
.theme-toggle:active, .language-toggle:active { transform: scale(0.96); }
.theme-toggle svg, .language-toggle svg { width: 16px; height: 16px; }
.language-toggle i { display: inline-flex; }
.theme-toggle .theme-sun, html[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
.nav-toggle { display: none; }

/* ==========================================================================
   Main Layout & Sections
   ========================================================================== */
.main {
  flex: 1 0 auto;
  padding-top: 16px;
}
.section { margin-top: 16px; }
.catalog { margin-top: 14px; scroll-margin-top: 68px; }
.catalog.standalone { margin-top: 8px; }
.section-heading, .page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.section-heading h2 {
  font-size: 1.05rem;
  letter-spacing: -0.025em;
  font-weight: 660;
}
.page-heading { justify-content: flex-start; margin-bottom: 14px; }
.page-heading h1, .standalone h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  letter-spacing: -0.035em;
  font-weight: 700;
}
.title-count { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-count > span, .page-heading > span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  padding: 2px 9px;
}
#result-count { display: inline-grid; }
#result-count > span, #result-count::after { grid-area: 1 / 1; }
#result-count::after { content: attr(data-full-count); visibility: hidden; }

.text-link {
  font-size: 0.82rem;
  color: var(--palette-accent);
  font-weight: 560;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.text-link:hover { background: var(--selected); color: var(--palette-accent-hover); }
.refresh { display: inline-flex; align-items: center; gap: 5px; }
.refresh:disabled { opacity: 0.55; cursor: wait; }

/* ==========================================================================
   Inventory Container & High-Density Toolbar
   ========================================================================== */
.inventory-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--palette-shadow);
}
.toolbar {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.toolbar-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.catalog-tools {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.input-shell, .select-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--control-border);
  background: var(--control);
  border-radius: var(--r-sm);
  height: 34px;
  color: var(--muted);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.input-shell {
  padding: 0 10px;
  gap: 7px;
  flex: 1 1 240px;
  max-width: 420px;
}
.input-shell:focus-within, .select-shell:focus-within {
  border-color: var(--palette-accent);
  box-shadow: 0 0 0 3px var(--selected);
}
.input-shell input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.85rem;
}
.input-shell input::placeholder { color: var(--palette-subtle); }

.select-shell { flex: none; }
.select-shell select {
  height: 100%;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0 8px 0 10px;
  font-size: 0.82rem;
  color: var(--ink);
  text-overflow: ellipsis;
}
.select-shell select:focus-visible { outline: 0; }
.select-shell option { color: var(--ink); background: var(--surface); }

.segmented {
  display: inline-flex;
  align-items: center;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
  white-space: nowrap;
}
.segmented button {
  color: var(--muted);
  border-radius: 4px;
  padding: 4px 10px;
  line-height: 1.35;
  font-size: 0.81rem;
  font-weight: 520;
  transition: color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--surface);
  font-weight: 640;
  box-shadow: 0 1px 2px var(--palette-shadow), inset 0 0 0 1px var(--line);
}

/* Faceted Filter Bar */
.facet-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.facet-bar .select-shell {
  width: clamp(114px, 12.2%, 158px);
  height: 32px;
  background: var(--raised);
  border-color: var(--line);
}
.facet-bar .select-shell:hover { border-color: var(--control-border); }
.facet-bar .select-shell.active {
  background: var(--selected);
  border-color: var(--accent-border);
}
.facet-bar .select-shell.active select {
  color: var(--palette-accent);
  font-weight: 600;
}
.facet-bar .text-link { font-size: 0.8rem; margin-inline-start: 2px; }

/* Scenario Presets & Quick Sort / Range Controls */
.preset-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.preset-strip::-webkit-scrollbar { display: none; }
.preset-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 540;
  white-space: nowrap;
  transition: all 120ms ease;
}
.preset-chip:hover {
  border-color: var(--accent-border);
  color: var(--ink);
  background: var(--hover);
}
.preset-chip[aria-pressed="true"] {
  background: var(--selected);
  border-color: var(--accent-border);
  color: var(--palette-accent);
  font-weight: 640;
}
.preset-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.preset-chip[data-preset="in"] .preset-dot { background: var(--status-good-dot); opacity: 1; }

.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.range-bar .select-shell {
  height: 30px;
  width: auto;
  min-width: 112px;
  max-width: 170px;
  background: var(--surface);
  border-color: var(--line);
}
.range-bar .select-shell.active {
  background: var(--selected);
  border-color: var(--accent-border);
}
.range-bar .select-shell.active select {
  color: var(--palette-accent);
  font-weight: 600;
}
.range-bar-spacer { margin-inline-start: auto; }
.page-size-select { min-width: 92px !important; }

/* Active Filter Chips */
.active-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}
.active-chips:empty { display: none; }
.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--selected);
  border: 1px solid var(--accent-border);
  color: var(--palette-accent);
  font-size: 0.76rem;
  font-weight: 580;
}
.active-chip:hover { filter: brightness(0.95); }
.active-chip b { font-size: 0.92rem; line-height: 1; opacity: 0.8; }

/* ==========================================================================
   High-Density Precision Plan Table
   ========================================================================== */
.plans {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.plans th {
  background: var(--raised);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.plans td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.87rem;
  vertical-align: middle;
}
.plans tbody tr:last-child td { border-bottom: 0; }
.plans th:first-child, .plans td:first-child { padding-left: 16px; }
.plans th:last-child, .plans td:last-child { padding-right: 16px; text-align: right; }
.plans tbody tr {
  cursor: pointer;
  transition: background 90ms ease;
}
.plans tbody tr:hover { background: var(--hover); }

.model-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.emblem {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--emblem-bg, var(--raised));
  color: var(--emblem-ink, var(--palette-accent));
  border: 1px solid var(--line);
}
.emblem svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .emblem {
  color: color-mix(in srgb, var(--emblem-ink, #60a5fa) 55%, #ffffff);
  background: color-mix(in srgb, var(--emblem-ink, #60a5fa) 18%, var(--raised));
}
.model-btn {
  text-align: left;
  padding: 0;
  line-height: 1.32;
  font-weight: 630;
  font-size: 0.9rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.model-btn:hover { color: var(--palette-accent); text-decoration: underline; text-underline-offset: 3px; }
.secondary {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.inline-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.micro-tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 600;
  line-height: 1;
  background: var(--raised);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.micro-tag.tag-route {
  color: var(--palette-accent);
  background: var(--selected);
  border-color: var(--accent-border);
}
.micro-tag.tag-value {
  color: var(--status-in);
  background: var(--status-in-bg);
  border-color: transparent;
}
.micro-tag.tag-rtt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.micro-tag.rtt-fast { color: var(--status-in); background: var(--status-in-bg); border-color: transparent; }
.micro-tag.rtt-mid { color: var(--status-warn); background: var(--status-warn-bg); border-color: transparent; }
.micro-tag.rtt-slow { color: var(--status-out); background: var(--status-out-bg); border-color: transparent; }

.where { display: flex; align-items: center; gap: 7px; }
.iso {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 680;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  flex: none;
}
.spec-primary {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.spec-secondary {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.price {
  font-family: var(--font-mono);
  font-weight: 680;
  font-size: 0.9rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.period {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 2px;
}
.price-equivalent {
  display: block;
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.73rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.status {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1.3;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.status::before {
  content: "";
  border-radius: 50%;
  height: 6px;
  width: 6px;
  background: currentColor;
  flex: none;
}
.s-in { color: var(--status-in); background: var(--status-in-bg); }
.s-out { color: var(--status-out); background: var(--status-out-bg); }
.s-unknown { color: var(--status-warn); background: var(--status-warn-bg); }

/* Row Actions */
.plan-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.compare-pick, .row-alert-btn, .star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 580;
  transition: all 110ms ease;
}
.compare-pick { padding: 0 8px; white-space: nowrap; }
.compare-pick:hover, .star:hover {
  border-color: var(--accent-border);
  color: var(--palette-accent);
  background: var(--hover);
}
.compare-pick[aria-pressed="true"] {
  background: var(--selected);
  border-color: var(--accent-border);
  color: var(--palette-accent);
}
.row-alert-btn {
  padding: 0 7px;
  gap: 3px;
  font-size: 0.73rem;
  color: var(--status-warn);
  border-color: rgba(217, 119, 6, 0.28);
  background: var(--status-warn-bg);
  white-space: nowrap;
}
.row-alert-btn:hover {
  filter: brightness(0.95);
  border-color: var(--status-warn);
}
.star { width: 30px; padding: 0; }
.star[aria-pressed="true"] {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(245, 158, 11, 0.10);
}
.star[aria-pressed="true"] svg { fill: currentColor; }
:root[data-theme="dark"] .star[aria-pressed="true"] { color: #fbbf24; }

/* Compare Tray */
.compare-tray {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
}
.compare-tray-items {
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 0;
  gap: 6px;
  flex-wrap: wrap;
}
.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 28px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--accent-border);
  color: var(--palette-accent);
  font-size: 0.78rem;
  font-weight: 580;
}
.compare-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-chip b { font-size: 0.95rem; line-height: 1; }
.compare-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--palette-accent);
  color: var(--palette-on-accent);
  font-size: 0.8rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.compare-go:hover { background: var(--palette-accent-hover); }

/* Pagination & Table Footer */
.list-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--line);
  background: var(--raised);
}
.list-footer > div { display: flex; flex-shrink: 0; gap: 5px; }
.list-footer button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--control-border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 540;
  transition: background 110ms ease, border-color 110ms ease;
}
.list-footer button:enabled:hover {
  background: var(--hover);
  border-color: var(--accent-border);
  color: var(--palette-accent);
}
.list-footer button:disabled { color: var(--palette-subtle); border-color: var(--line); opacity: 0.55; cursor: default; }

.sort-note {
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}
.sort-note a { color: var(--palette-accent); text-underline-offset: 2px; text-decoration: underline; }
.stock-reasons {
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
  border-top: 1px solid var(--line);
}
.stock-reasons strong { color: var(--ink); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); font-size: 0.9rem; }
.empty p { margin-bottom: 12px; }

/* Buttons */
.secondary-button, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 120ms ease;
}
.secondary-button {
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink);
}
.secondary-button:hover {
  border-color: var(--accent-border);
  color: var(--palette-accent);
  background: var(--hover);
}
.primary {
  color: var(--palette-on-accent);
  background: var(--palette-accent);
}
.primary:hover { background: var(--palette-accent-hover); }
.primary:active, .secondary-button:active { transform: scale(0.98); }

/* Provider Directory */
.directory { min-height: 52vh; }
.directory-search { max-width: 340px; margin: 0 0 14px; }
.directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.provider-card {
  background: var(--surface);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.provider-card:hover {
  border-color: var(--accent-border);
  background: var(--hover);
  box-shadow: 0 2px 8px var(--palette-shadow);
}
.provider-card.selected {
  background: var(--selected);
  border-color: var(--accent-border);
}
.provider-card > span:last-child { min-width: 0; }
.provider-name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 640;
  line-height: 1.3;
  font-size: 0.93rem;
}
.provider-caption {
  display: block;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.provider-caption b { font-weight: 640; color: var(--palette-stock-text); }
.provider-caption b[data-count="0"] { color: var(--muted); }

/* ==========================================================================
   Plan Details Modal (Desktop Dialog -> Mobile Bottom Sheet)
   ========================================================================== */
dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  background: var(--surface);
  width: min(500px, calc(100vw - 24px));
  max-height: 86dvh;
  overflow: auto;
  box-shadow: 0 20px 60px var(--palette-shadow-lg);
}
dialog::backdrop {
  background: rgba(9, 9, 11, 0.56);
  backdrop-filter: blur(4px);
}
#details[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(86dvh, 56rem);
}
#details .dialog-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.dialog-provider {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}
.dialog-top .close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}
.dialog-top .close:hover { background: var(--hover); color: var(--ink); }
.dialog-content { padding: 18px 20px 20px; }
#detail-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-top: 14px; }
.dialog-content h2 {
  margin: 0 0 8px;
  line-height: 1.3;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}
.detail-tco {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--raised);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.detail-tco strong { color: var(--ink); font-weight: 650; }
.detail-tco span { color: var(--muted); }
.detail-spec {
  margin: 14px 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  border-block: 1px solid var(--line);
  padding: 12px 0;
}
.detail-spec dt { color: var(--muted); font-size: 0.74rem; font-weight: 540; }
.detail-spec dd { margin: 2px 0 0; font-size: 0.86rem; font-weight: 560; overflow-wrap: anywhere; }
.detail-note, .detail-date { font-size: 0.78rem; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.detail-date { margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.detail-date a, .model-sources a { color: var(--palette-accent); text-decoration: underline; text-underline-offset: 2px; }
.model-specs summary { cursor: pointer; color: var(--palette-accent); font-size: 0.84rem; font-weight: 600; }
.model-specs .detail-spec { margin-top: 8px; }
.model-sources { margin: 6px 0 14px; font-size: 0.8rem; }
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.referral-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stock-reason-note { color: var(--muted); font-size: 0.82rem; line-height: 1.5; margin: 8px 0; }
.location-stock h3 { font-size: 0.88rem; margin: 12px 0 6px; }
.location-stock .detail-spec { margin: 0 0 10px; }

/* Smart In-Stock Alternatives inside Out-of-Stock Detail Sheet */
.detail-alts {
  margin: 14px 0;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent-border);
  background: var(--selected);
}
.detail-alts h3 {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--palette-accent);
  margin: 0 0 8px;
}
.detail-alt-list { display: grid; gap: 6px; }
.detail-alt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 110ms ease;
}
.detail-alt-item:hover { border-color: var(--accent-border); }
.detail-alt-item strong { display: block; font-size: 0.82rem; font-weight: 630; color: var(--ink); }
.detail-alt-item small { display: block; font-size: 0.73rem; color: var(--muted); }
.detail-alt-price {
  flex: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 660;
  color: var(--status-in);
  font-variant-numeric: tabular-nums;
}

/* Command Palette (Cmd+K) */
dialog.cmdk-dialog {
  width: min(560px, calc(100vw - 24px));
  margin-top: min(14vh, 110px);
  overflow: hidden;
  border-radius: var(--r-md);
}
.cmdk-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.cmdk-head input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.94rem;
}
.cmdk-head kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--muted);
}
.cmdk-list {
  max-height: min(56vh, 400px);
  overflow-y: auto;
  padding: 6px;
}
.cmdk-group {
  padding: 6px 8px 4px;
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--palette-subtle);
}
.cmdk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  font-size: 0.85rem;
  color: var(--ink);
}
.cmdk-item:hover, .cmdk-item.is-active {
  background: var(--selected);
  color: var(--palette-accent);
}
.cmdk-item small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  white-space: nowrap;
}
.cmdk-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 15px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px var(--palette-shadow-lg);
  z-index: 60;
  max-width: 90%;
  width: max-content;
  font-size: 0.82rem;
  font-weight: 560;
}

/* Sponsor Slots (Clean Native Integration) */
.sponsor-banners, .sponsor-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.sponsor-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  aspect-ratio: 5.4;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  padding: 6px;
  font-size: 0.8rem;
  text-align: center;
}
.sponsor-rail .sponsor-slot { aspect-ratio: 3.3; }

@media (min-width: 75em) {
  .with-sponsor-slots {
    --rail-width: clamp(210px, 16vw, 280px);
    --rail-gap: 16px;
    --layout-width: calc(1320px + var(--rail-width) + var(--rail-gap));
  }
  .with-sponsor-slots :is(.header-inner, .main) {
    max-width: var(--layout-width);
  }
  .with-sponsor-slots .catalog {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--rail-width);
    column-gap: var(--rail-gap);
    align-items: start;
  }
  .with-sponsor-slots .catalog > .section-heading { grid-column: 1; }
  .with-sponsor-slots .inventory-box { grid-column: 1; min-width: 0; }
  .sponsor-rail { grid-column: 2; grid-row: 2; grid-template-columns: minmax(0, 1fr); margin: 0; }
}

/* ==========================================================================
   Footer (Restrained Architectural Footer)
   ========================================================================== */
.site-footer {
  margin-block-start: clamp(32px, 4.5vw, 56px);
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.site-footer-inner {
  max-width: 1320px;
  margin-inline: auto;
  padding: clamp(26px, 3.2vw, 40px) clamp(16px, 3.2vw, 40px) 0;
}
.site-footer-groups {
  display: grid;
  grid-template-columns: minmax(190px, 1.6fr) repeat(2, minmax(0, 0.85fr)) minmax(180px, 1fr);
  gap: 24px;
  padding-bottom: 24px;
}
.site-footer .brand { width: fit-content; }
.site-footer-group { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.site-footer-group h2 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 660;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.site-footer-group a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  font-size: 0.84rem;
  color: var(--muted);
}
.site-footer-group a:hover { color: var(--palette-accent); }
.site-footer .telegram-contact { gap: 7px; color: var(--palette-accent); font-weight: 560; }
.telegram-contact svg { flex: none; width: 15px; height: 15px; }
.site-footer-copyright {
  border-top: 1px solid var(--line);
  color: var(--palette-subtle);
  font-size: 0.76rem;
  padding-block: 14px 18px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (min-width: 901px) {
  .plans { table-layout: fixed; }
  .plans th:nth-child(1) { width: 28%; }
  .plans th:nth-child(2) { width: 13%; }
  .plans th:nth-child(3) { width: 16%; }
  .plans th:nth-child(4) { width: 13.5%; }
  .plans th:nth-child(5) { width: 11.5%; }
  .plans th:last-child { width: 18%; }
  .plans td, .plans .model-cell > div, .plans .where > div { overflow-wrap: anywhere; }
  .plans .model-cell > div, .plans .where > div { min-width: 0; }
}

@media (max-width: 72em) {
  .header-inner { position: relative; justify-content: space-between; min-height: 54px; gap: 10px; }
  .cmdk-trigger span { display: none; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--control-border);
    border-radius: var(--r-sm);
    background: var(--control);
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 580;
  }
  .nav-toggle svg { width: 16px; height: 16px; }
  .nav-toggle[aria-expanded="true"] {
    color: var(--palette-accent);
    background: var(--selected);
    border-color: var(--accent-border);
  }
  .nav-toggle .menu-cross, .nav-toggle[aria-expanded="true"] .menu-bars { display: none; }
  .nav-toggle[aria-expanded="true"] .menu-cross { display: block; }
  #header-tools {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: clamp(16px, 3.2vw, 40px);
    width: min(16.5rem, calc(100% - 32px));
    max-height: calc(100dvh - 76px);
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: 0 14px 36px var(--palette-shadow-lg);
  }
  #header-tools.is-open { display: block; }
  #header-tools .nav { flex-direction: column; align-items: stretch; gap: 2px; }
  #header-tools .nav a { height: 40px; padding: 0 10px; font-size: 0.9rem; }
  #header-tools #favorite-count, #header-tools #compare-count { margin-inline-start: auto; }
}

@media (max-width: 900px) {
  .directory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plans, .plans tbody { display: block; }
  .plans thead { display: none; }
  .plans tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }
  .plans td, .plans td:first-child, .plans td:last-child {
    display: block;
    border: 0;
    padding: 0;
    text-align: left;
    width: auto;
  }
  .plans td:nth-child(1) { grid-area: 1 / 1; }
  .plans td:nth-child(4) { grid-area: 1 / 2; text-align: right; align-self: start; }
  .plans td:nth-child(2) { grid-area: 2 / 1; }
  .plans td:nth-child(5) { grid-area: 2 / 2; text-align: right; align-self: center; }
  .plans td:nth-child(3) { grid-area: 3 / 1; }
  .plans td:nth-child(6) { grid-area: 3 / 2; text-align: right; align-self: end; }
  .plans .model-cell .emblem { width: 28px; height: 28px; }
  .plans .where > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 6px; }
  .plans .where .secondary { margin: 0; }
}

@media (max-width: 780px) {
  .facet-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .facet-bar .select-shell { width: 100%; }
  .range-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .range-bar .select-shell { width: 100%; max-width: none; }
  .range-bar-spacer { display: none; }
}

@media (max-width: 650px) {
  .header-inner, .main { padding-inline: 12px; }
  .main { padding-top: 10px; }
  .section-heading { gap: 6px; }
  .section-heading h2 { font-size: 0.94rem; white-space: nowrap; }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar-primary { flex-direction: column; align-items: stretch; gap: 7px; }
  .toolbar-primary .input-shell { flex: 0 0 auto; width: 100%; max-width: none; height: 36px; }
  .toolbar-primary .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .toolbar-primary .segmented button { padding: 5px 2px; text-align: center; font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .preset-strip { padding-inline-end: 8px; }
  .directory-grid { grid-template-columns: 1fr; }
  .list-footer { flex-wrap: wrap; padding: 10px 12px; }

  /* Mobile Native Bottom Sheet for #details */
  #details[open] {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    border-radius: 16px 16px 0 0;
    border-inline: 0;
    border-bottom: 0;
    animation: sheet-up 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  #details .dialog-top {
    position: relative;
    padding: 16px 14px 10px;
  }
  #details .dialog-top::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--palette-border-strong);
  }
  #details .dialog-top .close { width: 36px; height: 36px; }
  #detail-body { padding: 12px 14px max(16px, env(safe-area-inset-bottom)); }
  .site-footer-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .site-footer-about, .site-footer-group:last-child { grid-column: 1 / -1; }
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}
