:root {
  color-scheme: light;
  --color-bg: oklch(1 0 0);
  --color-surface: oklch(0.965 0.008 210);
  --color-surface-raised: oklch(0.985 0.004 210);
  --color-ink: oklch(0.22 0.02 230);
  --color-ink-soft: oklch(0.34 0.025 228);
  --color-muted: oklch(0.46 0.02 225);
  --color-border: oklch(0.89 0.012 215);
  --color-border-strong: oklch(0.79 0.02 215);
  --color-primary: oklch(0.47 0.10 185);
  --color-primary-hover: oklch(0.41 0.10 185);
  --color-primary-active: oklch(0.36 0.085 185);
  --color-primary-soft: oklch(0.94 0.025 185);
  --color-primary-softer: oklch(0.975 0.012 185);
  --color-success: oklch(0.46 0.12 155);
  --color-success-soft: oklch(0.95 0.035 155);
  --color-warning: oklch(0.57 0.14 75);
  --color-warning-soft: oklch(0.965 0.04 75);
  --color-danger: oklch(0.52 0.18 25);
  --color-danger-hover: oklch(0.46 0.17 25);
  --color-danger-soft: oklch(0.96 0.025 25);
  --color-info: oklch(0.49 0.12 245);
  --color-info-soft: oklch(0.955 0.028 245);
  --focus-ring: oklch(0.58 0.14 190);
  --radius-control: 8px;
  --radius-panel: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --text-caption: 0.75rem;
  --text-data: 0.8125rem;
  --text-secondary: 0.875rem;
  --text-body: 1rem;
  --text-section: 1.125rem;
  --text-page: 1.375rem;
  --topbar-height: 64px;
  --z-table-header: 10;
  --z-sticky: 20;
  --z-popover: 40;
  --z-backdrop: 60;
  --z-modal: 70;
  --z-toast: 80;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--color-bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--color-ink);
  background: var(--color-bg);
  font-size: var(--text-body);
  line-height: 1.5;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select,
summary,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--color-primary-hover);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-block-start: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

[hidden] {
  display: none !important;
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: var(--z-toast);
  inset: 8px auto auto 8px;
  padding: var(--space-2) var(--space-3);
  color: white;
  background: var(--color-primary-hover);
  border-radius: var(--radius-control);
  transform: translateY(-160%);
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: var(--z-sticky);
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: var(--space-2) var(--space-5);
  background: color-mix(in oklch, var(--color-bg) 96%, transparent);
  border-bottom: 1px solid var(--color-border);
}

.brand,
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: var(--color-ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  color: white;
  background: var(--color-primary-hover);
  border-radius: 9px;
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-copy,
.login-brand > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand-copy strong,
.login-brand strong {
  font-size: var(--text-secondary);
  font-weight: 700;
  line-height: 1.25;
}

.brand-copy span,
.login-brand span {
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.4;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding-inline: var(--space-3);
  color: var(--color-ink-soft);
  background: var(--color-surface);
  border-radius: 999px;
  font-size: var(--text-caption);
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--color-muted);
}

.status-dot-success {
  background: var(--color-success);
}

.status-dot-warning {
  background: var(--color-warning);
}

.status-dot-danger {
  background: var(--color-danger);
}

.account-menu {
  position: relative;
}

.account-menu > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-control);
  list-style: none;
}

.account-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: var(--space-1);
  border-right: 1.5px solid var(--color-muted);
  border-bottom: 1.5px solid var(--color-muted);
  transform: rotate(45deg) translateY(-2px);
}

.account-menu > summary:hover,
.account-menu[open] > summary {
  background: var(--color-surface);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--color-primary-hover);
  background: var(--color-primary-soft);
  border-radius: 999px;
  font-size: var(--text-caption);
  font-weight: 700;
}

.account-name {
  max-width: 130px;
  overflow: hidden;
  font-size: var(--text-secondary);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-popover {
  position: absolute;
  z-index: var(--z-popover);
  top: calc(100% + 8px);
  right: 0;
  width: 196px;
  padding: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  box-shadow: 0 4px 8px oklch(0.2 0.02 230 / 0.12);
}

.account-role {
  margin: 4px 8px 8px;
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.account-popover button {
  width: 100%;
  min-height: 38px;
  padding: 8px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: var(--text-secondary);
}

.account-popover button:hover {
  background: var(--color-surface);
}

.mobile-account-action {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-height));
  min-height: 540px;
}

.filter-rail {
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-surface-raised);
  border-right: 1px solid var(--color-border);
  scrollbar-gutter: stable;
}

#discovery-form {
  min-height: 100%;
  padding: var(--space-5) var(--space-5) 96px;
}

.filter-intro {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.workspace-header h2 {
  margin-bottom: 4px;
  font-size: var(--text-page);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.filter-intro h1 {
  margin-bottom: var(--space-1);
  font-size: var(--text-section);
  font-weight: 700;
  line-height: 1.35;
}

.filter-intro p {
  max-width: 30ch;
  margin-bottom: 0;
  color: var(--color-muted);
  font-size: var(--text-data);
  line-height: 1.4;
}

.filter-group {
  min-width: 0;
  margin: 0;
  padding: var(--space-4) 0 var(--space-5);
  border: 0;
  border-top: 1px solid var(--color-border);
}

.filter-group > summary {
  display: block;
  width: 100%;
  margin-bottom: var(--space-3);
  padding: 0;
  cursor: default;
  font-size: var(--text-secondary);
  font-weight: 700;
  list-style: none;
  pointer-events: none;
}

.filter-group > summary::-webkit-details-marker {
  display: none;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field-label {
  color: var(--color-ink-soft);
  font-size: var(--text-data);
  font-weight: 600;
}

.unit-label {
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  color: var(--color-ink);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  line-height: 1.35;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, background-color 150ms ease-out;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: oklch(0.47 0.018 225);
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: oklch(0.69 0.035 210);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  outline: 0;
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}

.field-help {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.4;
}

.field-error {
  margin: 0;
  color: var(--color-danger-hover);
  font-size: var(--text-caption);
  font-weight: 600;
}

.two-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.range-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.range-inputs > span {
  color: var(--color-muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: var(--space-1);
  background: var(--color-surface);
  border-radius: 9px;
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 34px;
  place-items: center;
  padding: var(--space-2);
  color: var(--color-muted);
  border-radius: 6px;
  font-size: var(--text-caption);
  font-weight: 600;
  text-align: center;
}

.segmented input:checked + span {
  color: var(--color-primary-hover);
  background: var(--color-bg);
  box-shadow: 0 1px 4px oklch(0.25 0.02 225 / 0.12);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-control);
}

.check-row input {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: var(--space-1) 0 0;
  accent-color: var(--color-primary);
}

.check-row span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-1);
}

.check-row strong {
  font-size: var(--text-data);
  font-weight: 600;
}

.check-row small {
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.4;
}

.check-row-warning {
  background: var(--color-warning-soft);
}

.advanced-settings {
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.advanced-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  color: var(--color-ink-soft);
  font-size: var(--text-data);
  font-weight: 700;
  list-style: none;
}

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

.advanced-settings > summary::after {
  content: "+";
  color: var(--color-primary-hover);
  font-size: var(--text-section);
  font-weight: 500;
}

.advanced-settings[open] > summary::after {
  content: "−";
}

.advanced-body {
  padding: var(--space-1) 0 var(--space-4);
}

.filter-actions {
  position: fixed;
  z-index: var(--z-sticky);
  bottom: 0;
  left: 0;
  display: flex;
  width: 340px;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-5) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: color-mix(in oklch, var(--color-surface-raised) 96%, transparent);
  border-top: 1px solid var(--color-border);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control);
  font-size: var(--text-data);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, transform 120ms ease-out;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button-primary {
  color: white;
  background: var(--color-primary-hover);
  border: 1px solid var(--color-primary-hover);
}

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

.button-secondary {
  color: var(--color-ink-soft);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  color: var(--color-primary-hover);
  background: var(--color-primary-soft);
  border-color: color-mix(in oklch, var(--color-primary) 45%, var(--color-border));
}

.button-quiet {
  color: var(--color-ink-soft);
  background: transparent;
  border: 1px solid transparent;
}

.button-danger-quiet {
  color: var(--color-danger-hover);
  background: var(--color-bg);
  border: 1px solid color-mix(in oklch, var(--color-danger) 28%, var(--color-border));
}

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

.button-full {
  width: 100%;
}

.filter-actions .button-primary {
  flex: 1 1 auto;
}

.text-button {
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
  color: var(--color-primary-hover);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: var(--text-caption);
  font-weight: 600;
}

.text-button:hover {
  background: var(--color-primary-soft);
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  font-size: var(--text-page);
  font-weight: 400;
  line-height: 1;
}

.icon-button:hover {
  color: var(--color-ink);
  background: var(--color-surface);
}

.form-alert {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  color: var(--color-danger-hover);
  background: var(--color-danger-soft);
  border: 1px solid color-mix(in oklch, var(--color-danger) 30%, var(--color-border));
  border-radius: var(--radius-control);
  font-size: var(--text-data);
  font-weight: 600;
}

.workspace {
  min-width: 0;
  overflow: auto;
  padding: var(--space-5) var(--space-6) 64px;
  scrollbar-gutter: stable;
}

.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--space-5);
}

.workspace-context {
  margin-bottom: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.run-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: var(--color-info-soft);
  border-radius: var(--radius-control);
}

.run-status strong {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-secondary);
  font-weight: 600;
}

.run-status p {
  margin: 0;
  color: var(--color-ink-soft);
  font-size: var(--text-caption);
  font-weight: 500;
}

.status-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in oklch, var(--color-info) 22%, transparent);
  border-top-color: var(--color-info);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(112px, 1fr));
  margin-bottom: var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.summary-strip > div {
  min-width: 0;
  padding: var(--space-3);
  border-right: 1px solid var(--color-border);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.summary-strip span,
.summary-strip strong {
  display: block;
}

.summary-strip span {
  margin-bottom: 4px;
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.summary-strip strong {
  overflow: hidden;
  font-size: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warning-summary {
  margin-bottom: var(--space-5);
  padding: var(--space-3);
  background: var(--color-warning-soft);
  border-radius: var(--radius-control);
}

.warning-summary > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.warning-summary h3 {
  margin: 0;
  font-size: var(--text-data);
  font-weight: 700;
}

.warning-summary ul {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  color: var(--color-ink-soft);
  font-size: var(--text-caption);
  font-weight: 500;
}

.warning-summary li + li {
  margin-top: var(--space-1);
}

.summary-strip:has(+ .warning-summary[hidden]) {
  margin-bottom: var(--space-5);
}

.empty-state {
  display: grid;
  min-height: min(420px, 50vh);
  align-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: var(--space-4);
  place-items: center;
  color: var(--color-primary-hover);
  background: var(--color-primary-soft);
  border-radius: 13px;
  font-size: var(--text-page);
}

.empty-state h3 {
  max-width: 28ch;
  margin-bottom: var(--space-2);
  font-size: var(--text-body);
  font-weight: 700;
}

.empty-state p {
  max-width: 56ch;
  margin-bottom: var(--space-4);
  color: var(--color-muted);
  font-size: var(--text-secondary);
}

.loading-skeleton {
  padding-top: var(--space-2);
}

.skeleton-row {
  height: 72px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-raised) 42%, var(--color-surface) 60%);
  background-size: 300% 100%;
  border-radius: 8px;
  animation: skeleton 1.4s ease-in-out infinite;
}

.skeleton-row-wide {
  height: 46px;
}

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

.results-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
}

.results-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  background: var(--color-bg);
  font-size: var(--text-data);
  font-variant-numeric: tabular-nums;
}

.results-table th,
.results-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

.results-table th {
  position: sticky;
  z-index: var(--z-table-header);
  top: 0;
  color: var(--color-muted);
  background: var(--color-surface);
  font-size: var(--text-caption);
  font-weight: 700;
  white-space: nowrap;
}

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

.results-table tbody tr:hover {
  background: var(--color-primary-softer);
}

.rank-cell {
  width: 46px;
  color: var(--color-muted);
  font-weight: 700;
  text-align: center !important;
}

.product-cell {
  display: flex;
  min-width: 260px;
  align-items: center;
  gap: var(--space-3);
}

.product-thumb,
.product-thumb-placeholder {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
  background: var(--color-surface);
  border-radius: 6px;
}

.product-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--color-muted);
  font-size: var(--text-caption);
}

.product-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.product-title-button {
  display: -webkit-box;
  max-width: 32ch;
  padding: 0;
  overflow: hidden;
  color: var(--color-ink);
  background: transparent;
  border: 0;
  border-radius: 3px;
  font-size: var(--text-data);
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-title-button:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.asin-text,
.secondary-text {
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.score-badge,
.confidence-badge,
.status-badge,
.risk-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  font-size: var(--text-caption);
  font-weight: 700;
  white-space: nowrap;
}

.score-high,
.confidence-high,
.status-completed {
  color: oklch(0.35 0.10 155);
  background: var(--color-success-soft);
}

.score-medium,
.confidence-medium,
.status-running,
.status-queued {
  color: oklch(0.43 0.12 75);
  background: var(--color-warning-soft);
}

.score-low,
.confidence-low,
.status-failed,
.status-cancelled {
  color: var(--color-danger-hover);
  background: var(--color-danger-soft);
}

.data-stack {
  display: flex;
  min-width: 110px;
  flex-direction: column;
  gap: var(--space-1);
}

.data-stack strong {
  font-weight: 600;
}

.metric-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  color: var(--color-primary-hover);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: var(--text-caption);
  font-weight: 700;
}

.metric-link:hover {
  background: var(--color-primary-soft);
}

.result-cards {
  display: none;
}

.result-card {
  padding: var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
}

.result-card + .result-card {
  margin-top: var(--space-3);
}

.result-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.result-card-main {
  min-width: 0;
  flex: 1 1 auto;
}

.result-card-rank {
  margin: 0 0 var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 700;
}

.result-card-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: var(--text-secondary);
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-card-scores {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.result-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  padding: 12px 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.result-card-metrics span,
.result-card-metrics strong {
  display: block;
}

.result-card-metrics span {
  margin-bottom: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.result-card-metrics strong {
  font-size: var(--text-data);
  font-variant-numeric: tabular-nums;
}

.result-card .button {
  width: 100%;
}

dialog {
  color: var(--color-ink);
}

dialog::backdrop {
  background: oklch(0.15 0.025 230 / 0.42);
}

.evidence-drawer {
  width: min(440px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  overflow: hidden;
  background: var(--color-bg);
  border: 0;
  transform: translateX(100%);
}

.evidence-drawer[open] {
  transform: translateX(0);
  animation: drawer-in 190ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-shell {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.drawer-product-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

#drawer-image {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--color-surface);
  border-radius: 7px;
}

.drawer-product-heading > div {
  min-width: 0;
}

.drawer-header p {
  margin-bottom: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.drawer-header h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: var(--text-section);
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.drawer-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3) 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
}

.drawer-tabs button {
  position: relative;
  min-height: 40px;
  padding: var(--space-2) var(--space-3) var(--space-3);
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: 6px 6px 0 0;
  font-size: var(--text-caption);
  font-weight: 600;
  white-space: nowrap;
}

.drawer-tabs button:hover {
  color: var(--color-ink);
  background: var(--color-surface);
}

.drawer-tabs button[aria-selected="true"] {
  color: var(--color-primary-hover);
}

.drawer-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 0;
  left: 8px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px 2px 0 0;
}

.drawer-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-4);
}

.tab-panel h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-secondary);
  font-weight: 700;
  line-height: 1.35;
}

.tab-panel h3:first-child {
  margin-top: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.metric-grid > div {
  min-width: 0;
  padding: var(--space-3);
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
}

.metric-grid > div:nth-child(odd) {
  border-right: 1px solid var(--color-border);
}

.metric-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.metric-grid > div:nth-last-child(1):nth-child(odd) {
  border-right: 0;
}

.metric-grid dt,
.metric-grid dd {
  margin: 0;
}

.metric-grid dt {
  margin-bottom: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.metric-grid dd {
  overflow-wrap: anywhere;
  font-size: var(--text-data);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.evidence-list,
.risk-list,
.asin-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.evidence-list li,
.risk-list li {
  margin-bottom: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--color-ink-soft);
  background: var(--color-surface);
  border-radius: 6px;
  font-size: var(--text-data);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.risk-list li {
  background: var(--color-warning-soft);
}

.asin-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.asin-list li {
  padding: 4px 8px;
  color: var(--color-primary-hover);
  background: var(--color-primary-soft);
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-caption);
}

.keyword-item {
  margin-bottom: var(--space-3);
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 9px;
}

.keyword-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.keyword-item-header h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-secondary);
  font-weight: 700;
  line-height: 1.35;
}

.keyword-item-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bar-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: var(--color-ink-soft);
  font-size: var(--text-caption);
  font-weight: 500;
}

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

.bar-fill {
  height: 100%;
  max-width: 100%;
  background: var(--color-primary);
  border-radius: inherit;
}

.methodology-note {
  padding: var(--space-3);
  color: var(--color-ink-soft);
  background: var(--color-info-soft);
  border-radius: var(--radius-control);
  max-width: 65ch;
  font-size: var(--text-secondary);
  line-height: 1.5;
}

.modal {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: min(82vh, 760px);
  padding: 0;
  overflow: auto;
  background: transparent;
  border: 0;
}

.modal-wide {
  width: min(820px, calc(100vw - 32px));
}

.modal-card {
  padding: var(--space-5);
  background: var(--color-bg);
  border-radius: var(--radius-panel);
  box-shadow: 0 8px 8px oklch(0.15 0.02 230 / 0.18);
}

.modal-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-4);
}

.modal-card > header h2 {
  margin-bottom: var(--space-1);
  font-size: var(--text-section);
  font-weight: 700;
  line-height: 1.35;
}

.modal-card > header p,
.modal-card > p {
  max-width: 65ch;
  margin-bottom: 0;
  color: var(--color-muted);
  font-size: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--space-5);
}

.dialog-status {
  min-height: 22px;
  margin-bottom: 8px;
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.job-list,
.user-list {
  display: flex;
  max-height: 440px;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.job-item,
.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--space-3);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.job-item-main,
.user-item-main {
  min-width: 0;
  flex: 1 1 auto;
}

.job-item strong,
.job-item span,
.user-item strong,
.user-item span {
  display: block;
}

.job-item strong,
.user-item strong {
  overflow: hidden;
  font-size: var(--text-data);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-item-meta,
.user-item-meta {
  margin-top: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-caption);
  font-weight: 500;
}

.job-item-actions,
.user-item-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
}

.job-item-actions .button,
.user-item-actions .button {
  min-height: 34px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-caption);
}

.user-item select {
  width: auto;
  min-height: 34px;
  padding: var(--space-2) 28px var(--space-2) var(--space-2);
  font-size: var(--text-caption);
}

.user-active-control {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-ink-soft);
  font-size: var(--text-caption);
  font-weight: 500;
  white-space: nowrap;
}

.create-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 130px auto;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.create-user-form .field {
  margin: 0;
}

.password-input {
  position: relative;
}

.password-input input {
  padding-right: 64px;
}

.password-input button {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 50px;
  height: 32px;
  padding: var(--space-1) var(--space-2);
  color: var(--color-primary-hover);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: var(--text-caption);
  font-weight: 600;
}

.password-input button:hover {
  background: var(--color-primary-soft);
}

.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  right: 16px;
  bottom: 16px;
  display: flex;
  width: min(380px, calc(100vw - 32px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: var(--space-3);
  color: white;
  background: var(--color-ink);
  border-radius: var(--radius-control);
  box-shadow: 0 4px 8px oklch(0.15 0.02 230 / 0.2);
  font-size: var(--text-data);
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background: var(--color-surface);
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  padding: var(--space-6);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-panel);
}

.login-brand {
  margin-bottom: var(--space-6);
}

.login-heading {
  margin-bottom: var(--space-5);
}

.login-heading h1 {
  margin-bottom: var(--space-1);
  font-size: var(--text-page);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.login-heading p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-secondary);
}

.login-panel .field {
  margin-bottom: 16px;
}

.login-security {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.55;
}

@media (max-width: 1399px) {
  .results-table-wrap {
    display: none !important;
  }

  .result-cards:not([hidden]) {
    display: block;
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  #discovery-form {
    padding-inline: 16px;
  }

  .filter-actions {
    width: 310px;
    padding-inline: 16px;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-strip > div:nth-child(3) {
    border-right: 0;
  }

  .summary-strip > div:nth-child(-n+3) {
    border-bottom: 1px solid var(--color-border);
  }
}

@media (max-width: 860px) {
  :root {
    --topbar-height: 58px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .brand-copy span,
  .provider-status,
  .topbar .button-quiet,
  .account-name {
    display: none;
  }

  .mobile-account-action {
    display: block;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: calc(100dvh - var(--topbar-height));
  }

  .filter-rail {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  #discovery-form {
    padding: var(--space-4) var(--space-4) 80px;
  }

  .filter-group {
    padding: 0;
  }

  .filter-group[open] {
    padding-bottom: var(--space-4);
  }

  .filter-group > summary {
    position: relative;
    min-height: 48px;
    margin: 0;
    padding: var(--space-3) var(--space-5) var(--space-3) 0;
    cursor: pointer;
    pointer-events: auto;
  }

  .filter-group > summary::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: var(--space-1);
    color: var(--color-primary-hover);
    transform: translateY(-50%);
  }

  .filter-group[open] > summary::after {
    content: "−";
  }

  .filter-actions {
    position: fixed;
    z-index: var(--z-sticky);
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
    background: var(--color-bg);
  }

  .workspace {
    overflow: visible;
    padding: var(--space-5) var(--space-4) calc(96px + env(safe-area-inset-bottom));
  }

  .workspace-header {
    align-items: flex-start;
  }

  .results-table-wrap {
    display: none !important;
  }

  .result-cards:not([hidden]) {
    display: block;
  }

  .evidence-drawer {
    width: 100vw;
  }

  .create-user-form {
    grid-template-columns: 1fr 1fr;
  }

  .create-user-form .button {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .brand-copy strong {
    max-width: 136px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .account-menu > summary {
    padding-right: 4px;
  }

  .account-menu > summary::after {
    display: none;
  }

  .two-fields {
    grid-template-columns: 1fr 1fr;
  }

  .workspace-header h2 {
    font-size: var(--text-page);
  }

  .workspace-header {
    flex-direction: column;
  }

  .workspace-actions {
    width: 100%;
  }

  .workspace-actions .button {
    flex: 1 1 0;
  }

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

  .summary-strip > div,
  .summary-strip > div:nth-child(3) {
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }

  .summary-strip > div:nth-child(2n) {
    border-right: 0;
  }

  .summary-strip > div:nth-last-child(-n+2) {
    border-bottom: 0;
  }

  .empty-state {
    min-height: 360px;
    padding-inline: var(--space-4);
  }

  .drawer-header {
    padding: var(--space-4);
  }

  .drawer-content {
    padding: var(--space-4);
  }

  .drawer-tabs {
    padding-inline: var(--space-2);
  }

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

  .modal-card {
    padding: 16px;
  }

  .create-user-form {
    grid-template-columns: 1fr;
  }

  .user-item,
  .job-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .user-item-actions,
  .job-item-actions {
    width: 100%;
  }

  .login-page {
    padding: 0;
    background: var(--color-bg);
  }

  .login-shell {
    width: 100%;
  }

  .login-panel {
    min-height: 100dvh;
    padding: var(--space-5) var(--space-4);
    border: 0;
    border-radius: 0;
  }
}

@media (pointer: coarse) {
  button,
  .button,
  input,
  select,
  summary {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .status-spinner {
    animation: none;
    border-color: var(--color-info);
  }

  .evidence-drawer,
  .evidence-drawer[open] {
    transform: none;
  }
}

@media print {
  .topbar,
  .filter-rail,
  .workspace-actions,
  .run-status,
  .warning-summary button,
  .metric-link,
  .filter-actions {
    display: none !important;
  }

  .app-shell {
    display: block;
    height: auto;
  }

  .workspace {
    overflow: visible;
    padding: 0;
  }

  .results-table-wrap {
    overflow: visible;
  }
}
