/* ==========================================================================
   AI Document Intelligence -- stylesheet
   --------------------------------------------------------------------------
   Layout: a single-column stack of cards on small screens, widening to a
   two-column document/results split at 1080px.

   Theming: every colour is a token on :root. Light is the default (documents
   are read on white); dark is applied for prefers-color-scheme and for an
   explicit [data-theme] override from the toggle, so the toggle wins in both
   directions.
   ========================================================================== */

:root {
  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef1f7;
  --bg-inset: #f8fafc;

  --border: #dfe4ed;
  --border-strong: #c9d1de;

  --text: #141922;
  --text-secondary: #4d5768;
  --text-muted: #7a8497;

  --accent: #1c64f2;
  --accent-hover: #1a56db;
  --accent-soft: rgba(28, 100, 242, 0.09);
  --accent-contrast: #ffffff;

  --success: #067647;
  --success-soft: rgba(6, 118, 71, 0.1);
  --warning: #b54708;
  --warning-soft: rgba(181, 71, 8, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);

  /* Confidence bands. Also used for the bounding-box overlay, so these must
     stay legible against arbitrary document pixels. */
  --conf-high: #067647;
  --conf-medium: #b54708;
  --conf-low: #b42318;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 16px 40px -8px rgba(16, 24, 40, 0.16);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, "SF Mono", Consolas, monospace;

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-elevated: #161b24;
    --bg-subtle: #1c222d;
    --bg-inset: #11161e;

    --border: #262d3a;
    --border-strong: #37404f;

    --text: #e8ecf3;
    --text-secondary: #a3adbf;
    --text-muted: #6f7a8d;

    --accent: #4d84f7;
    --accent-hover: #6b99f9;
    --accent-soft: rgba(77, 132, 247, 0.14);

    --success: #3dd68c;
    --success-soft: rgba(61, 214, 140, 0.14);
    --warning: #f9a03c;
    --warning-soft: rgba(249, 160, 60, 0.15);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);

    --conf-high: #3dd68c;
    --conf-medium: #f9a03c;
    --conf-low: #f87171;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-elevated: #161b24;
  --bg-subtle: #1c222d;
  --bg-inset: #11161e;

  --border: #262d3a;
  --border-strong: #37404f;

  --text: #e8ecf3;
  --text-secondary: #a3adbf;
  --text-muted: #6f7a8d;

  --accent: #4d84f7;
  --accent-hover: #6b99f9;
  --accent-soft: rgba(77, 132, 247, 0.14);

  --success: #3dd68c;
  --success-soft: rgba(61, 214, 140, 0.14);
  --warning: #f9a03c;
  --warning-soft: rgba(249, 160, 60, 0.15);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --conf-high: #3dd68c;
  --conf-medium: #f9a03c;
  --conf-low: #f87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

/* The `hidden` attribute must beat any author `display` rule. Components below
   set display:flex/grid, which would otherwise override the user-agent
   [hidden]{display:none} and leave hidden panels visible. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.012em;
  line-height: 1.25;
}

button {
  font: inherit;
  cursor: pointer;
}

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

/* Respect a user's reduced-motion preference: animation here is decorative. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  margin-bottom: 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), #7c3aed);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand__mark svg {
  width: 22px;
  height: 22px;
}

.brand__title {
  font-size: 19px;
}

.brand__subtitle {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.masthead__aside {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Badges and pills
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge--accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--gpu[data-state="active"] {
  border-color: transparent;
  background: var(--success-soft);
  color: var(--success);
}

.badge--gpu[data-state="cpu"] {
  border-color: transparent;
  background: var(--warning-soft);
  color: var(--warning);
}

.badge--gpu[data-state="error"] {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.badge--gpu[data-state="active"] .dot {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition);
}

.btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: transparent;
  color: var(--text);
}

.btn--sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn--icon {
  padding: 8px;
  border-color: var(--border);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}

.card__title {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 14px;
  font-weight: 650;
}

.card__title svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex: none;
}

.card__hint {
  font-size: 12px;
  font-weight: 450;
  color: var(--text-muted);
}

.card__body {
  padding: 20px;
}

.card__body--flush {
  padding: 0;
}

/* --------------------------------------------------------------------------
   Upload
   -------------------------------------------------------------------------- */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 44px 24px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-inset);
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
}

.dropzone:hover {
  border-color: var(--accent);
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone__icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.dropzone__icon svg {
  width: 26px;
  height: 26px;
}

.dropzone__title {
  font-size: 16px;
  font-weight: 650;
}

.dropzone__or {
  margin: 6px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.dropzone__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.dropzone__meta {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}

input[type="file"] {
  display: none;
}

/* File summary strip shown once a document is selected. */
.filecard {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
}

.filecard__thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.filecard__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.filecard__info {
  flex: 1 1 200px;
  min-width: 0;
}

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

.filecard__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.filecard__status {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.filecard__status[data-state="processing"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.filecard__status[data-state="done"] {
  background: var(--success-soft);
  color: var(--success);
}

.filecard__status[data-state="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------------- */

.progress {
  margin-top: 16px;
}

.progress__track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.progress__bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transition: width 320ms ease;
}

/* Indeterminate: OCR duration is unknown until it finishes, so the bar
   reports "working", never a fabricated percentage. */
.progress__bar.is-indeterminate {
  width: 40% !important;
  animation: slide 1.15s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.progress__steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
}

.progress__step {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.progress__step .dot {
  background: var(--border-strong);
  transition: background var(--transition);
}

.progress__step[data-state="active"] {
  color: var(--accent);
  font-weight: 600;
}

.progress__step[data-state="active"] .dot {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.progress__step[data-state="done"] {
  color: var(--success);
}

.progress__step[data-state="done"] .dot {
  background: var(--success);
}

/* --------------------------------------------------------------------------
   Spinner
   -------------------------------------------------------------------------- */

.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --------------------------------------------------------------------------
   Results layout
   -------------------------------------------------------------------------- */

.results {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.results__split {
  display: grid;
  gap: 20px;
}

@media (min-width: 1080px) {
  .results__split {
    /* Document slightly wider than the results panel: the overlay is the
       centrepiece of the demo. */
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: start;
  }
}

.stack {
  display: grid;
  gap: 20px;
}

/* --------------------------------------------------------------------------
   Document preview + bounding-box overlay
   -------------------------------------------------------------------------- */

.viewer {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
  max-height: 78vh;
  overflow: auto;
  background:
    linear-gradient(45deg, var(--bg-subtle) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(-45deg, var(--bg-subtle) 25%, transparent 25%) 0 9px / 18px 18px,
    var(--bg-inset);
}

.viewer__stage {
  position: relative;
  display: block;
  line-height: 0;
  /* The stage sizes to the image; the SVG then stretches to match exactly, so
     box coordinates line up at any zoom level. */
  transform-origin: top left;
}

.viewer__image {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow);
}

.viewer__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.region {
  fill: transparent;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 120ms ease, stroke-width 120ms ease;
}

.region--high { stroke: var(--conf-high); }
.region--medium { stroke: var(--conf-medium); }
.region--low { stroke: var(--conf-low); }

.region--high:hover, .region--high.is-active { fill: color-mix(in srgb, var(--conf-high) 24%, transparent); }
.region--medium:hover, .region--medium.is-active { fill: color-mix(in srgb, var(--conf-medium) 26%, transparent); }
.region--low:hover, .region--low.is-active { fill: color-mix(in srgb, var(--conf-low) 26%, transparent); }

.region.is-active {
  stroke-width: 3.5;
}

.viewer.hide-boxes .viewer__overlay {
  display: none;
}

/* Floating label near a hovered/selected box. */
.viewer__tooltip {
  position: absolute;
  z-index: 5;
  max-width: 320px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: #10131a;
  color: #f5f7fa;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.viewer__tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.viewer__tooltip strong {
  display: block;
  font-weight: 600;
  word-break: break-word;
}

.viewer__tooltip span {
  color: #9aa4b6;
  font-family: var(--font-mono);
  font-size: 11px;
}

.viewer__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 11px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend__item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.legend__swatch {
  width: 11px;
  height: 11px;
  border: 2px solid;
  border-radius: 2px;
}

.legend__swatch--high { border-color: var(--conf-high); }
.legend__swatch--medium { border-color: var(--conf-medium); }
.legend__swatch--low { border-color: var(--conf-low); }

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.tab {
  padding: 6px 13px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
  transition: background var(--transition), color var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tabpanel[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Extracted text
   -------------------------------------------------------------------------- */

.textout {
  max-height: 460px;
  margin: 0;
  padding: 16px 20px;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--bg-inset);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

/* Region list -------------------------------------------------------------- */

.regionlist {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.regionrow {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 9px 13px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background var(--transition);
}

.regionrow:last-child {
  border-bottom: none;
}

.regionrow:hover {
  background: var(--bg-subtle);
}

.regionrow.is-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.regionrow__index {
  flex: none;
  min-width: 26px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 2px;
}

.regionrow__text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  word-break: break-word;
}

.regionrow__score {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.regionrow__score[data-band="high"] { background: var(--success-soft); color: var(--conf-high); }
.regionrow__score[data-band="medium"] { background: var(--warning-soft); color: var(--conf-medium); }
.regionrow__score[data-band="low"] { background: var(--danger-soft); color: var(--conf-low); }

/* --------------------------------------------------------------------------
   Field extraction
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.notice svg {
  width: 15px;
  height: 15px;
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

.notice--warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
  color: var(--text);
}

.notice--warning svg {
  color: var(--warning);
}

.fieldgrid {
  display: grid;
  gap: 10px;
}

@media (min-width: 640px) {
  .fieldgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}

.field--empty {
  opacity: 0.62;
}

.field__label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field__value {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.field--empty .field__value {
  font-weight: 450;
  font-style: italic;
  color: var(--text-muted);
}

.field__source {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field__method {
  flex: none;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Statistics
   -------------------------------------------------------------------------- */

.statgrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

.stat {
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
}

.stat__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat__value {
  margin-top: 4px;
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat__value--high { color: var(--conf-high); }
.stat__value--medium { color: var(--conf-medium); }
.stat__value--low { color: var(--conf-low); }

.stat__note {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Stacked confidence distribution bar. */
.distbar {
  display: flex;
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.distbar__seg {
  transition: width 400ms ease;
}

.distbar__seg--high { background: var(--conf-high); }
.distbar__seg--medium { background: var(--conf-medium); }
.distbar__seg--low { background: var(--conf-low); }

/* --------------------------------------------------------------------------
   Performance dashboard
   -------------------------------------------------------------------------- */

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pipeline__row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 84px;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
}

.pipeline__label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.pipeline__step {
  display: grid;
  place-items: center;
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Track and fill are <span> elements inside a grid row; they must be blocks or
   the height and the fill's percentage width collapse to nothing. */
.pipeline__track {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.pipeline__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pipeline__fill--detect { background: #7c3aed; }
.pipeline__fill--recognise { background: #db2777; }
.pipeline__fill--muted { background: var(--border-strong); }

.pipeline__value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pipeline__value--muted {
  color: var(--text-muted);
}

.pipeline__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 650;
}

.pipeline__total span:last-child {
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .pipeline__row {
    grid-template-columns: 1fr 72px;
  }
  .pipeline__track {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Spec / key-value lists (GPU card, system info)
   -------------------------------------------------------------------------- */

.speclist {
  display: grid;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.specrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
}

.specrow__key {
  font-size: 12px;
  color: var(--text-secondary);
}

.specrow__value {
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.specrow__value--mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
}

.gpucard {
  padding: 15px 17px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.gpucard__name {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 15px;
  font-weight: 650;
}

.gpucard__name svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--accent);
}

.gpucard__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-secondary);
}

.vrambar {
  height: 6px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.vrambar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 400ms ease;
}

/* --------------------------------------------------------------------------
   Empty / error states
   -------------------------------------------------------------------------- */

.state {
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 52px 24px;
  text-align: center;
}

.state__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.state__icon svg {
  width: 22px;
  height: 22px;
}

.state__title {
  font-size: 14.5px;
  font-weight: 650;
}

.state__text {
  max-width: 46ch;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.state--error .state__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.toast.is-leaving {
  animation: toast-out 180ms ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px) scale(0.97); }
}

.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }

.toast__icon {
  flex: none;
  margin-top: 1px;
}

.toast__icon svg {
  width: 16px;
  height: 16px;
}

.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info .toast__icon { color: var(--accent); }

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: 13px;
  font-weight: 650;
}

.toast__text {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-secondary);
  word-break: break-word;
}

.toast__close {
  flex: none;
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  line-height: 0;
}

.toast__close:hover {
  color: var(--text);
}

.toast__close svg {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

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

.mono {
  font-family: var(--font-mono);
}

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

.footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

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