:root {
  color-scheme: dark;
  --page: #090a0c;
  --rail: #050607;
  --panel: #17191d;
  --panel-2: #202329;
  --panel-3: #101216;
  --ink: #f3f6f8;
  --muted: #aeb7c1;
  --quiet: #76818d;
  --line: #343941;
  --line-soft: #272c33;
  --brand: #0077b5;
  --brand-bright: #4aa3ff;
  --green: #50c878;
  --amber: #d9a322;
  --red: #ef5a4d;
  --blue-soft: rgba(0, 119, 181, 0.22);
  --radius: 6px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --font:
    "Aptos",
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 78% 12%, rgba(0, 119, 181, 0.16), transparent 30%),
    var(--page);
  background-size: 34px 34px, 34px 34px, auto, auto;
  font-family: var(--font);
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand-bright);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 80;
  transform: translateY(-150%);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 800;
}

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

.hidden {
  display: none !important;
}

.nav-hidden {
  display: none !important;
}

.kicker {
  margin: 0 0 5px;
  color: var(--brand-bright);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 1.4rem;
  line-height: 1.18;
}

h3 {
  margin-bottom: 0;
  font-size: 0.96rem;
  line-height: 1.2;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 420px);
  border: 1px solid var(--line);
  background: rgba(12, 14, 17, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  min-height: 590px;
  display: grid;
  align-content: space-between;
  gap: 36px;
  padding: 34px;
  background:
    linear-gradient(90deg, rgba(0, 119, 181, 0.18), transparent 42%),
    repeating-linear-gradient(
      135deg,
      rgba(74, 163, 255, 0.08) 0,
      rgba(74, 163, 255, 0.08) 1px,
      transparent 1px,
      transparent 18px
    ),
    #101216;
}

.login-brand p:not(.kicker) {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.logo-plate {
  width: 160px;
  height: auto;
  border-radius: var(--radius);
  background: #11151a;
  box-shadow: inset 0 0 0 1px #2a3038;
  padding: 10px 12px;
}

.logo-plate.compact {
  width: 112px;
  padding: 7px 9px;
}

.login-signals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.login-signals div {
  min-width: 0;
  background: rgba(5, 6, 7, 0.72);
  padding: 14px;
}

.login-signals dt,
.definition-list dt {
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.login-signals dd,
.definition-list dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 800;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 34px;
  border-left: 1px solid var(--line);
  background: #f4f7fa;
  color: #101216;
}

.login-form .kicker {
  color: var(--brand);
}

.field,
.range-field {
  display: grid;
  gap: 7px;
}

.field span,
.range-field span {
  color: inherit;
  font-size: 0.82rem;
  font-weight: 850;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d0f12;
  color: var(--ink);
  padding: 9px 10px;
}

.login-form .field input,
.login-form .field select {
  border-color: #cdd6df;
  background: #fff;
  color: #101216;
}

.field input::placeholder {
  color: #8d98a3;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 0.9rem;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.btn,
.link-btn,
.status-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-weight: 850;
}

.btn {
  border: 1px solid var(--line);
  background: #232832;
  color: var(--ink);
  padding: 9px 13px;
}

.btn:hover,
.link-btn:hover,
.status-chip:hover {
  filter: brightness(1.12);
}

.btn.primary {
  border-color: #2a77d8;
  background: linear-gradient(#2f80ed, #1764d1);
  color: #fff;
}

.btn.secondary {
  border-color: #3d4652;
  background: #12161c;
  color: #fff;
}

.btn.quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.btn.danger {
  border-color: rgba(239, 90, 77, 0.55);
  background: rgba(239, 90, 77, 0.14);
  color: #ffd1cc;
}

.btn.wide {
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-btn {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--brand-bright);
  padding: 0;
}

.cockpit {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.cockpit.rail-collapsed {
  grid-template-columns: 84px minmax(0, 1fr);
}

.rail {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #050607, #020303);
  padding: 18px 14px;
}

.rail-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.rail-brand strong,
.rail-brand span {
  display: block;
}

.rail-brand span,
.rail-footer span {
  color: var(--muted);
  font-size: 0.8rem;
}

.rail-toggle {
  min-height: 34px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--quiet);
  text-align: left;
  cursor: pointer;
}

.nav-groups {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-groups p {
  margin: 16px 10px 4px;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-item {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 780;
}

.nav-item span {
  min-width: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 1px 7px;
  text-align: center;
  font-size: 0.74rem;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(90deg, #165bd7, #174cb0);
  color: #fff;
}

.nav-item:hover span,
.nav-item.active span {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.rail-footer {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.cockpit.rail-collapsed .rail {
  padding-inline: 10px;
}

.cockpit.rail-collapsed .rail-brand div,
.cockpit.rail-collapsed .nav-groups p,
.cockpit.rail-collapsed .nav-item span,
.cockpit.rail-collapsed .rail-footer span,
.cockpit.rail-collapsed .rail-footer .btn,
.cockpit.rail-collapsed .rail-toggle {
  display: none;
}

.cockpit.rail-collapsed .nav-item {
  grid-template-columns: 1fr;
  min-height: 48px;
  padding: 8px;
  font-size: 0.72rem;
  text-align: center;
}

.main-shell {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.command-bar {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(260px, 420px) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 22, 0.88);
  backdrop-filter: blur(12px);
  padding: 12px 18px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0d10;
  padding: 0 10px;
}

.search-box span {
  color: var(--quiet);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.search-box input {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.command-actions,
.toolbar,
.panel-head,
.tour-actions,
.tour-card-head,
.document-tools {
  display: flex;
  align-items: center;
}

.command-actions {
  justify-content: flex-end;
  gap: 10px;
}

.status-chip {
  border: 1px solid var(--line);
  background: #0b0d10;
  color: var(--ink);
  padding: 8px 11px;
}

#api-chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
}

#api-chip-dot.ok {
  background: var(--green);
}

#api-chip-dot.error {
  background: var(--red);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--line);
  padding-left: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.user-chip button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
}

.content {
  min-width: 0;
  padding: 16px 18px 28px;
}

.content:focus {
  outline: none;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.metrics-dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
}

.metric-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 64px),
    #14171c;
  padding: 16px;
}

.metric-card.primary {
  border-color: rgba(74, 163, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(0, 119, 181, 0.32), transparent 62%),
    #14171c;
}

.metric-card span,
.dashboard-strip span {
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1;
}

.metric-card small,
.dashboard-strip small {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 10px;
}

.dashboard-strip section {
  min-width: 0;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(11, 13, 16, 0.8);
  padding: 14px 16px;
}

.dashboard-strip strong {
  overflow-wrap: anywhere;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.82fr) minmax(280px, 0.82fr);
  gap: 12px;
  align-items: stretch;
}

.chart-panel {
  min-height: 260px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.chart-wide {
  grid-column: span 2;
}

.line-chart,
.bar-chart,
.funnel-chart,
.donut-chart {
  min-width: 0;
  min-height: 190px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.line-chart svg {
  width: 100%;
  height: 170px;
  overflow: visible;
}

.line-chart line {
  stroke: var(--line);
  stroke-width: 2;
}

.line-chart polyline {
  fill: none;
  stroke: var(--brand-bright);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart circle {
  fill: #f3f6f8;
  stroke: var(--brand-bright);
  stroke-width: 3;
}

.chart-axis,
.donut-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-axis strong {
  color: var(--ink);
}

.chart-bar-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(90px, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.chart-bar-row span,
.funnel-step span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.chart-bar-row strong,
.funnel-step strong {
  color: var(--ink);
  font-size: 0.84rem;
}

.chart-bar-track {
  height: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #0b0d10;
  overflow: hidden;
}

.chart-bar-track i {
  height: 100%;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, #2479d6, #7ee39a);
}

.funnel-step {
  width: var(--step-width);
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(74, 163, 255, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(0, 119, 181, 0.24), rgba(23, 25, 29, 0.94));
  padding: 9px 11px;
}

.donut-chart {
  justify-items: center;
}

.donut {
  width: 150px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #14171c 0 58%, transparent 59%),
    conic-gradient(var(--brand-bright) calc(var(--pct) * 1%), #2a3038 0);
  padding: 28px;
}

.donut strong,
.donut span {
  text-align: center;
}

.donut strong {
  font-size: 1.8rem;
  line-height: 1;
}

.donut span {
  max-width: 86px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1.15;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.cockpit-grid {
  display: grid;
  grid-template-columns: minmax(235px, 0.85fr) minmax(360px, 1.55fr) minmax(220px, 0.95fr) minmax(250px, 1.02fr);
  gap: 12px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 64px),
    rgba(23, 25, 29, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  padding: 14px;
}

.queue-panel,
.review-panel {
  grid-column: span 2;
}

.api-panel,
.apps-panel {
  grid-column: span 1;
}

.panel-head {
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  margin-bottom: 12px;
}

.panel-head span {
  color: var(--quiet);
  font-size: 0.8rem;
}

.drop-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px dashed #596271;
  border-radius: var(--radius);
  background: rgba(5, 6, 7, 0.38);
  padding: 16px;
}

.drop-zone input {
  width: 100%;
  min-width: 0;
  color: transparent;
}

.drop-zone input::file-selector-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #232832;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 6px 9px;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone span {
  color: var(--muted);
  font-size: 0.84rem;
}

.source-list,
.compact-list,
.event-list,
.document-board,
.worklist,
.format-lab {
  display: grid;
  gap: 8px;
}

.source-list {
  margin-top: 12px;
}

.source-row,
.compact-row,
.event-row,
.work-row,
.field-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, max-content);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  padding: 9px 0;
}

.source-row:first-child,
.compact-row:first-child,
.event-row:first-child,
.work-row:first-child,
.field-row:first-child {
  border-top: 0;
}

.row-title {
  display: block;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
  word-break: normal;
  font-weight: 850;
}

.row-meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.status {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-align: center;
}

.status.ok {
  border-color: rgba(80, 200, 120, 0.45);
  color: #7ee39a;
}

.status.warn {
  border-color: rgba(217, 163, 34, 0.55);
  color: #f3cc68;
}

.status.error {
  border-color: rgba(239, 90, 77, 0.55);
  color: #ffaba4;
}

.status.info {
  border-color: rgba(74, 163, 255, 0.45);
  color: #91c8ff;
}

.queue-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
  padding-bottom: 8px;
}

.queue-tabs button {
  min-height: 30px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 8px;
}

.queue-tabs button.active {
  background: var(--blue-soft);
  color: #fff;
}

.data-table {
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.table th {
  color: var(--quiet);
  font-size: 0.72rem;
  text-align: left;
  text-transform: uppercase;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 8px;
  vertical-align: middle;
}

.table tr.is-active {
  background: rgba(0, 119, 181, 0.12);
  box-shadow: inset 2px 0 0 var(--brand-bright);
}

.table button,
.row-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101216;
  color: var(--ink);
  cursor: pointer;
  padding: 5px 8px;
}

.health-meter {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line-soft);
  background: rgba(5, 6, 7, 0.36);
  padding: 12px;
}

.health-meter strong {
  font-size: 2.1rem;
  line-height: 1;
}

.health-meter span,
.mini-metrics span {
  color: var(--muted);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 12px 0;
  background: var(--line-soft);
}

.mini-metrics div {
  min-width: 0;
  display: grid;
  gap: 4px;
  background: var(--panel);
  padding: 10px;
}

.mini-metrics strong {
  font-size: 1.05rem;
}

.review-desk,
.review-workspace,
.two-column {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.92fr);
  gap: 12px;
}

.training-model-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 0.95fr);
  gap: 16px;
  align-items: center;
}

.training-model-panel p:not(.kicker) {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.training-format-field {
  margin-top: 14px;
}

.training-sample-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.training-sample-form input[type="file"] {
  color: transparent;
}

.training-sample-form input[type="file"]::file-selector-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #232832;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 6px 9px;
}

.training-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line-soft);
}

.training-metrics div {
  min-width: 0;
  background: #111419;
  padding: 10px;
}

.training-metrics dt {
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.training-metrics dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.document-preview,
.large-document {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 0 28px, rgba(0, 119, 181, 0.16) 28px 30px, transparent 30px),
    repeating-linear-gradient(0deg, #f5f7fa 0 22px, #dbe4ec 22px 23px);
  color: #12161c;
  padding: 16px;
}

.large-document {
  min-height: 500px;
  transform-origin: top left;
}

.paper-head {
  display: grid;
  grid-template-columns: auto minmax(0, 0.85fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid #1d2733;
  margin-bottom: 16px;
  padding-bottom: 10px;
  font-weight: 900;
}

.paper-head span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.paper-cell {
  min-height: 54px;
  border: 1px solid #7d8792;
  padding: 6px;
  overflow-wrap: anywhere;
}

.paper-cell span {
  display: block;
  color: #5a6370;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.paper-cell strong {
  font-size: 0.9rem;
}

.ocr-image-shell {
  display: grid;
  gap: 10px;
}

.ocr-image-stage {
  position: relative;
  max-height: 620px;
  overflow: auto;
  border: 1px solid #88929f;
  border-radius: var(--radius);
  background: #0b0d10;
}

.ocr-image-map {
  position: relative;
  width: 100%;
}

.ocr-image-stage img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.ocr-box {
  position: absolute;
  z-index: 1;
  min-width: 22px;
  min-height: 14px;
  display: grid;
  align-content: space-between;
  border: 2px solid #70d98f;
  background: rgba(80, 200, 120, 0.14);
  color: #f8fbff;
  padding: 4px 5px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.ocr-image-shell.is-calibrating .ocr-box {
  cursor: move;
  pointer-events: auto;
}

.ocr-image-shell.is-calibrating .ocr-box.selected,
.ocr-box.selected {
  border-color: var(--brand-bright);
  background: rgba(74, 163, 255, 0.2);
  box-shadow:
    0 0 0 2px rgba(13, 16, 21, 0.78),
    0 0 0 4px rgba(74, 163, 255, 0.22);
}

.ocr-box.warn {
  border-color: #f3cc68;
  background: rgba(217, 163, 34, 0.16);
}

.ocr-box b,
.ocr-box em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.58rem;
  line-height: 1.05;
}

.ocr-box em {
  justify-self: end;
  font-style: normal;
  font-weight: 900;
}

.ocr-resize {
  width: 13px;
  height: 13px;
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: none;
  border: 2px solid #0d1015;
  border-radius: 50%;
  background: var(--brand-bright);
  cursor: nwse-resize;
}

.ocr-image-shell.is-calibrating .ocr-resize {
  display: block;
}

.ocr-image-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.ocr-image-caption span,
.ocr-image-caption strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ocr-image-caption strong {
  color: var(--ink);
}

.scan-line {
  height: 2px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, #2f80ed, transparent);
}

.extraction-preview,
.field-table {
  display: grid;
  gap: 8px;
}

.field-row {
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1fr) minmax(54px, auto);
  align-items: start;
  overflow-wrap: anywhere;
}

.field-row input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d0f12;
  color: var(--ink);
  padding: 7px 8px;
}

.confidence {
  color: #8bd2ff;
  font-weight: 900;
}

.document-tools {
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
  padding-top: 12px;
}

.calibration-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 850;
}

.work-form,
.settings-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(23, 25, 29, 0.94);
  padding: 14px;
}

.format-design-home {
  display: grid;
  grid-template-columns: minmax(230px, 0.44fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.format-home-copy {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(74, 163, 255, 0.08), transparent 120px),
    rgba(11, 13, 16, 0.86);
  padding: 16px;
}

.format-home-copy p:not(.kicker) {
  margin: 10px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.format-design-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.format-design-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(23, 25, 29, 0.94);
  padding: 14px;
}

.format-design-card header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.format-design-card h3 {
  overflow-wrap: anywhere;
  text-transform: none;
}

.format-design-card dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line-soft);
}

.format-design-card dl div {
  min-width: 0;
  background: #111419;
  padding: 9px;
}

.format-design-card dt {
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.format-design-card dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.designer-shell {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.designer-tools {
  position: sticky;
  top: 86px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.designer-tools .field {
  margin-top: 12px;
}

.designer-tools input[type="file"] {
  color: transparent;
}

.designer-tools input[type="file"]::file-selector-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #232832;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 6px 9px;
}

.flow-card {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  margin: 14px 0;
  padding: 14px 0;
}

.format-editor-stage {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(23, 25, 29, 0.94);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.sheet-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sheet-scroll {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 18px;
}

.format-sheet {
  width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  color: #101216;
  box-shadow: 0 0 0 1px #9aa4ae;
}

.format-sheet col {
  width: 140px;
}

.format-sheet td {
  min-height: 30px;
  height: 30px;
  border: 1px solid #1d2733;
  padding: 4px 6px;
  vertical-align: middle;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.15;
}

.format-sheet td[contenteditable="true"]:focus {
  outline: 2px solid #1d73d8;
  outline-offset: -2px;
}

.format-sheet td.selected-cell {
  box-shadow: inset 0 0 0 3px #1d73d8;
}

.format-sheet td.sheet-title-cell {
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.format-sheet td.sheet-header-cell {
  background: #e9eef4;
  font-weight: 900;
  text-transform: uppercase;
}

.format-sheet td.sheet-section-cell {
  background: #dfe6ee;
  font-weight: 900;
  text-align: center;
}

.format-sheet td.sheet-input-cell {
  color: #1e2732;
}

.format-sheet td.sheet-image-cell {
  text-align: center;
  padding: 2px;
}

.format-sheet img {
  max-width: 100%;
  max-height: 96px;
  object-fit: contain;
}

.print-root {
  display: none;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.work-row {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(23, 25, 29, 0.94);
  padding: 12px;
}

.work-row + .work-row {
  margin-top: 0;
}

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

.format-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(23, 25, 29, 0.94);
  padding: 14px;
}

.format-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.field-token {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

.definition-list {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}

.definition-list div {
  min-width: 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.definition-list div:first-child {
  border-top: 0;
  padding-top: 0;
}

.range-field {
  grid-column: span 2;
}

.range-field input {
  width: 100%;
  accent-color: var(--brand-bright);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(5, 6, 7, 0.35);
  color: var(--muted);
  padding: 18px;
}

.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.tour-spotlight {
  position: fixed;
  border: 2px solid var(--brand-bright);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.55),
    0 0 0 6px rgba(74, 163, 255, 0.16);
  transition:
    left 180ms ease,
    top 180ms ease,
    width 180ms ease,
    height 180ms ease;
}

.tour-card {
  position: fixed;
  width: min(420px, calc(100vw - 28px));
  border: 1px solid #6d7682;
  border-radius: var(--radius);
  background: #0d1015;
  box-shadow: var(--shadow);
  padding: 16px;
  pointer-events: auto;
}

.tour-card-head {
  justify-content: space-between;
  gap: 10px;
  color: var(--brand-bright);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tour-card-head button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.tour-card h2 {
  margin: 10px 0 8px;
  font-size: 1.2rem;
}

.tour-card p {
  color: var(--muted);
}

.tour-progress {
  display: grid;
  grid-auto-flow: column;
  gap: 5px;
  margin: 12px 0;
}

.tour-progress span {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}

.tour-progress span.active {
  background: var(--brand-bright);
}

.tour-actions {
  justify-content: space-between;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: min(430px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-bright);
  border-radius: var(--radius);
  background: #0d1015;
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  font-weight: 780;
}

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

@media (max-width: 1300px) {
  .metrics-dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .queue-panel,
  .review-panel {
    grid-column: span 2;
  }

  .command-bar {
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 360px);
  }

  .command-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .login-card,
  .cockpit,
  .review-desk,
  .review-workspace,
  .two-column,
  .format-design-home,
  .training-model-panel,
  .dashboard-strip {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    min-height: auto;
    max-height: 48vh;
    overflow-y: auto;
  }

  .cockpit.rail-collapsed {
    grid-template-columns: 1fr;
  }

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

  .nav-groups p {
    grid-column: 1 / -1;
  }

  .command-bar {
    position: static;
    grid-template-columns: 1fr;
  }

  .cockpit-grid,
  .dashboard-charts,
  .work-form,
  .format-design-list,
  .designer-shell,
  .settings-board {
    grid-template-columns: 1fr;
  }

  .designer-tools {
    position: static;
  }

  .sheet-scroll {
    max-height: 70vh;
  }

  .queue-panel,
  .review-panel {
    grid-column: span 1;
  }

  .chart-wide {
    grid-column: span 1;
  }
}

@media (max-width: 680px) {
  .login-screen,
  .content {
    padding: 10px;
  }

  .login-brand,
  .login-form {
    min-height: auto;
    padding: 18px;
  }

  .login-signals,
  .mini-metrics,
  .metrics-dashboard,
  .training-metrics,
  .paper-grid {
    grid-template-columns: 1fr;
  }

  .view-heading,
  .panel-head,
  .command-actions,
  .user-chip {
    align-items: stretch;
    flex-direction: column;
  }

  .source-row,
  .compact-row,
  .event-row,
  .work-row,
  .field-row {
    grid-template-columns: 1fr;
  }

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

  .drop-zone {
    grid-template-columns: 1fr;
  }

  .training-sample-form {
    grid-template-columns: 1fr;
  }

  .chart-wide {
    grid-column: span 1;
  }

  .chart-bar-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .funnel-step {
    width: 100%;
  }

  .format-design-card header,
  .format-design-card dl {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    overflow: visible;
  }

  .rail,
  .command-bar,
  .view-heading,
  .designer-tools,
  .sheet-toolbar,
  .toast,
  .tour-layer,
  .skip-link {
    display: none !important;
  }

  .cockpit,
  .main-shell,
  .content,
  .view.active,
  .designer-shell,
  .format-editor-stage,
  .sheet-scroll {
    display: block !important;
    width: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .view:not([data-view-panel="designer"]) {
    display: none !important;
  }

  .format-sheet {
    width: 100% !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  .format-sheet td {
    color: #000 !important;
    border-color: #000 !important;
  }

  @page {
    size: legal portrait;
    margin: 8mm;
  }
}

/* ── Wizard stepper ─────────────────────────────────────────────────────────── */
.wizard-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 0 24px;
  user-select: none;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
  font-size: 0.82rem;
  transition: color 0.15s, background 0.15s;
}

.wizard-step:hover {
  color: var(--text-base, #e2e8f0);
  background: rgba(255,255,255,0.06);
}

.wizard-step.is-active {
  color: var(--brand-bright, #4aa3ff);
  font-weight: 600;
}

.wizard-step.is-done {
  color: #70d98f;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-step.is-done .step-num::before {
  content: "✓";
}
.wizard-step.is-done .step-num {
  font-size: 0;
}
.wizard-step.is-done .step-num::before {
  font-size: 0.8rem;
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border, #2a2f3a);
  min-width: 20px;
  max-width: 60px;
}

/* Wizard panes */
.wizard-pane {
  display: none;
}
.wizard-pane.is-active {
  display: block;
}
.wizard-pane[data-wizard-pane="3"].is-active {
  display: contents;
}

.wizard-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.wizard-actions--row {
  padding: 16px 0 8px;
}

/* ── OCR legend ─────────────────────────────────────────────────────────────── */
.ocr-legend {
  display: flex;
  gap: 12px;
  padding: 8px 0 12px;
  font-size: 0.75rem;
  flex-wrap: wrap;
}

.ocr-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted, #6b7280);
}

.ocr-legend-item::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 2px solid currentColor;
}

.ocr-legend-item.ocr-source-ocr    { color: #70d98f; }
.ocr-legend-item.ocr-source-manual { color: #f3cc68; }
.ocr-legend-item.ocr-source-template { color: #6b7280; }

/* OCR box source states */
.ocr-box[data-source="ocr"]      { border-color: #70d98f; background: rgba(80,200,120,0.14); }
.ocr-box[data-source="manual"]   { border-color: #f3cc68; background: rgba(217,163,34,0.14); }
.ocr-box[data-source="template"] { border-color: #6b7280; background: rgba(100,100,120,0.12); }

/* ── Field confidence bar ───────────────────────────────────────────────────── */
.field-confidence-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted, #6b7280);
  margin-top: 3px;
}

.field-confidence-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.field-confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

.field-confidence-fill.conf-high   { background: #70d98f; }
.field-confidence-fill.conf-medium { background: #f3cc68; }
.field-confidence-fill.conf-low    { background: #e05c5c; }
