/* ============================================
   CargoNote — design tokens & base styles
   ============================================ */
:root {
  /* Paper / surface */
  --bg: #f6f4ef;            /* warm off-white, "paper" */
  --bg-soft: #efece4;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --hairline: #e7e3d6;
  --hairline-strong: #d8d2bf;

  /* Ink */
  --ink: #14171c;
  --ink-2: #2a2f37;
  --muted: #6b6e76;
  --muted-2: #93939a;
  --muted-3: #b6b5af;

  /* Sidebar / chrome */
  --chrome: #11161c;
  --chrome-2: #1a2128;
  --chrome-ink: #d8dde3;
  --chrome-muted: #7d8590;
  --chrome-hairline: #232b34;

  /* Brand accent — confident indigo */
  --accent: oklch(53% 0.14 256);
  --accent-2: oklch(45% 0.16 256);
  --accent-soft: oklch(95% 0.03 256);
  --accent-ink: #ffffff;

  /* Semantic — confidence */
  --hi: oklch(58% 0.13 152);        /* green */
  --hi-bg: oklch(96% 0.03 152);
  --hi-ink: oklch(34% 0.08 152);

  --med: oklch(72% 0.14 78);        /* amber */
  --med-bg: oklch(96% 0.05 85);
  --med-ink: oklch(40% 0.09 60);

  --lo: oklch(60% 0.18 28);         /* coral/red */
  --lo-bg: oklch(96% 0.04 28);
  --lo-ink: oklch(40% 0.13 28);

  --edited: oklch(55% 0.14 285);    /* violet — manually edited */
  --edited-bg: oklch(96% 0.03 285);
  --edited-ink: oklch(38% 0.11 285);

  --conflict: oklch(58% 0.18 12);   /* magenta-red — disagreement */
  --conflict-bg: oklch(96% 0.03 12);
  --conflict-ink: oklch(38% 0.13 12);

  /* Status */
  --status-processing: oklch(65% 0.13 240);
  --status-review:     oklch(72% 0.14 78);
  --status-approved:   oklch(58% 0.13 152);
  --status-error:      oklch(60% 0.18 28);

  /* Spacing scale */
  --s-0: 2px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* Radius */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 8px;
  --r-4: 12px;
  --r-pill: 999px;

  /* Type scale */
  --t-xs: 11px;
  --t-sm: 12px;
  --t-md: 13px;
  --t-base: 14px;
  --t-lg: 16px;
  --t-xl: 20px;
  --t-2xl: 24px;
  --t-3xl: 32px;

  /* Fonts */
  --font-sans: "Inter Tight", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Shadow */
  --shadow-1: 0 1px 0 rgba(20, 23, 28, 0.04), 0 1px 2px rgba(20, 23, 28, 0.04);
  --shadow-2: 0 2px 4px rgba(20, 23, 28, 0.06), 0 8px 24px rgba(20, 23, 28, 0.06);
  --shadow-3: 0 12px 40px rgba(20, 23, 28, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  background: var(--bg);
  color: var(--ink);
  font-size: var(--t-base);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { min-height: 100vh; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d8d2bf; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b9b29c; }

.mono { font-family: var(--font-mono); font-feature-settings: "ss01"; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--chrome);
  color: var(--chrome-ink);
  border-right: 1px solid var(--chrome-hairline);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}
.sidebar .brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25);
}
.sidebar .section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--chrome-muted);
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--chrome-ink);
  font-size: 13px;
  transition: background 120ms ease;
  cursor: pointer;
  user-select: none;
}
.nav-item .icon { width: 16px; height: 16px; opacity: 0.8; flex: 0 0 16px; }
.nav-item:hover { background: var(--chrome-2); }
.nav-item.active { background: var(--chrome-2); color: #fff; }
.nav-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chrome-muted);
}
.sidebar .user {
  margin-top: auto;
  display: flex; gap: 10px; align-items: center;
  padding: 10px 8px;
  border-top: 1px solid var(--chrome-hairline);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(60% 0.12 30), oklch(55% 0.14 256));
  color: #fff; font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
  flex: 0 0 28px;
}
.user .name { font-size: 12px; color: #fff; line-height: 1.2; }
.user .org { font-size: 11px; color: var(--chrome-muted); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: auto;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.topbar .breadcrumb {
  font-size: 12px;
  color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.topbar .breadcrumb b { color: var(--ink); font-weight: 500; }
.topbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.page { padding: 22px 28px 80px; max-width: 1600px; }
.page > header { display: flex; align-items: end; gap: 16px; margin-bottom: 18px; }
.page h1 { font-size: 22px; letter-spacing: -0.015em; font-weight: 600; margin: 0; }
.page .sub { font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  transition: background 120ms, border-color 120ms, transform 60ms;
  white-space: nowrap;
  height: 30px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn.primary:hover { background: #000; }
.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.accent:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.sm { height: 26px; padding: 4px 8px; font-size: 12px; border-radius: 5px; }
.btn .icon { width: 14px; height: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 6px; border: 1px solid transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.5;
}
.chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.chip.hi   { background: var(--hi-bg);   color: var(--hi-ink);   border-color: color-mix(in oklab, var(--hi) 30%, transparent); }
.chip.hi .dot { background: var(--hi); }
.chip.med  { background: var(--med-bg);  color: var(--med-ink);  border-color: color-mix(in oklab, var(--med) 35%, transparent); }
.chip.med .dot { background: var(--med); }
.chip.lo   { background: var(--lo-bg);   color: var(--lo-ink);   border-color: color-mix(in oklab, var(--lo) 30%, transparent); }
.chip.lo .dot { background: var(--lo); }
.chip.neutral { background: var(--bg-soft); color: var(--ink-2); border-color: var(--hairline); }
.chip.edited { background: var(--edited-bg); color: var(--edited-ink); border-color: color-mix(in oklab, var(--edited) 30%, transparent); }
.chip.edited .dot { background: var(--edited); }
.chip.conflict { background: var(--conflict-bg); color: var(--conflict-ink); border-color: color-mix(in oklab, var(--conflict) 30%, transparent); }
.chip.conflict .dot { background: var(--conflict); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  line-height: 1.6;
  white-space: nowrap;
}
.status .dot { width: 6px; height: 6px; border-radius: 50%; }
.status[data-s="processing"] { color: oklch(35% 0.1 240); background: oklch(96% 0.02 240); border-color: oklch(86% 0.05 240); }
.status[data-s="processing"] .dot { background: var(--status-processing); }
.status[data-s="review"]     { color: var(--med-ink); background: var(--med-bg); border-color: color-mix(in oklab, var(--med) 30%, transparent); }
.status[data-s="review"] .dot { background: var(--med); }
.status[data-s="approved"]   { color: var(--hi-ink); background: var(--hi-bg); border-color: color-mix(in oklab, var(--hi) 30%, transparent); }
.status[data-s="approved"] .dot { background: var(--hi); }
.status[data-s="error"]      { color: var(--lo-ink); background: var(--lo-bg); border-color: color-mix(in oklab, var(--lo) 30%, transparent); }
.status[data-s="error"] .dot { background: var(--lo); }

/* Processing dot pulses */
.status[data-s="processing"] .dot {
  animation: pulseDot 1.4s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}
.card .card-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.card .card-head h3 {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
}
.card .card-head .sub { font-size: 11.5px; color: var(--muted); }
.card .card-body { padding: 12px 14px; }

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0;
}
.table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: color-mix(in oklab, var(--accent) 6%, transparent); }
.table .ref { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.table .route { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
.table .route .arr { color: var(--muted-2); }

/* ---------- Field card (review form) ---------- */
.field {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 120ms, box-shadow 120ms;
}
.field:hover { border-color: var(--hairline-strong); }
.field.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
}
.field .label-row {
  display: flex; align-items: center; gap: 8px;
}
.field .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
}
.field .box-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  background: var(--bg-soft);
  border-radius: 3px;
  padding: 1px 4px;
}
.field .value {
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink);
  min-height: 19px;
  outline: none;
  white-space: pre-wrap;
}
.field .value[contenteditable="true"]:focus {
  background: color-mix(in oklab, var(--accent) 6%, transparent);
  border-radius: 4px;
}
.field .value.empty::before {
  content: attr(data-placeholder);
  color: var(--muted-3);
  font-style: italic;
}
.field .chip { align-self: flex-start; }
.field .acc-bar {
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}
.field[data-conf="hi"]  .acc-bar { background: var(--hi); }
.field[data-conf="med"] .acc-bar { background: var(--med); }
.field[data-conf="lo"]  .acc-bar { background: var(--lo); }
.field[data-conf="edited"] .acc-bar { background: var(--edited); }
.field[data-conf="conflict"] .acc-bar { background: var(--conflict); }
.field[data-conf="med"] { background: color-mix(in oklab, var(--med) 4%, var(--surface)); }
.field[data-conf="lo"]  { background: color-mix(in oklab, var(--lo) 5%, var(--surface)); }
.field[data-conf="conflict"] { background: color-mix(in oklab, var(--conflict) 5%, var(--surface)); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.field-grid.cols-1 { grid-template-columns: 1fr; }
.field-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Group section in review form */
.group {
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--hairline);
}
.group:last-child { border-bottom: 0; }
.group > header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.group h2 {
  margin: 0; font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-2);
}
.group .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--hairline);
  padding: 0 12px;
  background: var(--surface);
}
.tab {
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .pill {
  font-size: 10px;
  padding: 0 5px;
  height: 14px;
  display: inline-grid; place-items: center;
  background: var(--bg-soft);
  border-radius: 999px;
  color: var(--muted);
}

/* ---------- Sticky action bar ---------- */
.action-bar {
  position: sticky;
  bottom: 0;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  z-index: 5;
}
.action-bar .summary {
  font-size: 12px; color: var(--muted);
}
.action-bar .summary b { color: var(--ink); font-weight: 600; }

/* ---------- Doc viewer ---------- */
.docpane {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  min-width: 0;
}
.docpane .doc-canvas {
  position: relative;
  flex: 1;
  overflow: auto;
  background: var(--bg-soft);
  padding: 24px;
  display: flex; justify-content: center;
}
.doc-page {
  position: relative;
  background: #fff;
  width: min(780px, 100%);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-2);
  border-radius: 4px;
  padding: 36px 44px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  min-height: 980px;
}
.doc-page .doc-h {
  font-size: 15px; font-weight: 600; margin: 0 0 4px;
  color: var(--ink);
}
.doc-page .doc-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.doc-page hr.doc-hr { border: 0; border-top: 1px solid var(--hairline); margin: 16px 0; }

.highlight {
  position: absolute;
  border-radius: 3px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transition: background 140ms, border-color 140ms, box-shadow 140ms;
  box-sizing: border-box;
}
.highlight[data-conf="hi"]   { border-color: color-mix(in oklab, var(--hi) 35%, transparent); }
.highlight[data-conf="med"]  { border-color: color-mix(in oklab, var(--med) 45%, transparent); }
.highlight[data-conf="lo"]   { border-color: color-mix(in oklab, var(--lo) 45%, transparent); }
.highlight:hover {
  background: color-mix(in oklab, var(--accent) 10%, transparent);
  border-color: var(--accent);
}
.highlight.active {
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.highlight[data-conf="med"].active { background: color-mix(in oklab, var(--med) 18%, transparent); border-color: var(--med); box-shadow: 0 0 0 3px color-mix(in oklab, var(--med) 20%, transparent); }
.highlight[data-conf="lo"].active  { background: color-mix(in oklab, var(--lo) 18%, transparent);  border-color: var(--lo);  box-shadow: 0 0 0 3px color-mix(in oklab, var(--lo) 20%, transparent); }

/* ---------- Drop zone ---------- */
.dropzone {
  border: 1.5px dashed var(--hairline-strong);
  border-radius: 12px;
  padding: 40px 30px;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
  transition: background 140ms, border-color 140ms;
}
.dropzone.over {
  background: color-mix(in oklab, var(--accent) 6%, var(--surface-2));
  border-color: var(--accent);
  color: var(--ink-2);
}
.dropzone .big { font-size: 15px; color: var(--ink); margin-bottom: 4px; font-weight: 500; }

/* ---------- Filter bar ---------- */
.filterbar {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 0 14px;
}
.search {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 4px 8px 4px 10px;
  border-radius: 6px;
  height: 30px;
  flex: 1;
  max-width: 340px;
}
.search input {
  border: 0; outline: 0; background: transparent;
  flex: 1; font-size: 13px;
}
.search input::placeholder { color: var(--muted-2); }
.search .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--muted);
}

.segctl {
  display: inline-flex; background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 2px;
  height: 30px;
}
.segctl button {
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
  border-radius: 4px;
}
.segctl button.active {
  background: var(--ink);
  color: #fff;
}
.segctl button .count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  margin-left: 5px;
  opacity: 0.7;
}

/* ---------- Goods table ---------- */
.goods {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.goods thead th {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  padding: 6px 8px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  font-weight: 500;
}
.goods thead th .num {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--muted-2);
  font-size: 9.5px;
  border-radius: 2px;
  padding: 0 3px;
  margin-left: 4px;
}
.goods tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.goods tbody td .v {
  outline: none;
  min-height: 18px;
  display: block;
  border-radius: 3px;
  padding: 1px 3px;
  margin: -1px -3px;
}
.goods tbody td .v:focus { background: color-mix(in oklab, var(--accent) 8%, transparent); }
.goods tbody tr.lo td:first-child { box-shadow: inset 3px 0 0 var(--lo); }
.goods tbody tr.med td:first-child { box-shadow: inset 3px 0 0 var(--med); }
.goods tbody tr.hi td:first-child { box-shadow: inset 3px 0 0 var(--hi); }
.goods tfoot td {
  padding: 8px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
}

/* ---------- CMR print form ---------- */
.cmr-sheet {
  background: #fff;
  border: 1px solid #888;
  width: min(1000px, 100%);
  margin: 0 auto;
  font-family: var(--font-sans);
  color: #111;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: var(--shadow-2);
}
.cmr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.cmr-cell {
  border: 1px solid #444;
  margin: -1px 0 0 -1px;
  padding: 6px 8px;
  min-height: 60px;
  position: relative;
}
.cmr-cell .n {
  font-size: 9.5px;
  font-weight: 700;
  color: #111;
  margin-bottom: 2px;
  font-family: var(--font-mono);
}
.cmr-cell .l { font-size: 9px; color: #444; margin-bottom: 4px; }
.cmr-cell .v { font-size: 11px; color: #111; white-space: pre-wrap; }
.cmr-cell.full { grid-column: 1 / -1; }
.cmr-head {
  padding: 10px 14px;
  border-bottom: 2px solid #111;
  display: flex; align-items: center; gap: 12px;
}
.cmr-head .title { font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.cmr-head .sub { font-size: 10px; color: #555; }
.cmr-head .lang { margin-left: auto; font-size: 9.5px; color: #555; }

/* Process visualization */
.proc-wrap {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}
.proc-steps {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.proc-steps li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
}
.proc-steps li .marker {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--hairline-strong);
  display: grid; place-items: center;
  font-size: 10px; color: var(--muted);
  flex: 0 0 18px;
}
.proc-steps li.done { color: var(--ink-2); }
.proc-steps li.done .marker { background: var(--hi); border-color: var(--hi); color: #fff; }
.proc-steps li.active { color: var(--ink); background: var(--accent-soft); }
.proc-steps li.active .marker {
  background: var(--accent); border-color: var(--accent); color: #fff;
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.proc-steps li .t { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: auto; }

/* Skeleton */
.sk {
  background: linear-gradient(90deg, var(--bg-soft) 0%, #ece9df 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px;
  display: inline-block;
  height: 12px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-3);
  z-index: 100;
  display: flex; align-items: center; gap: 10px;
}

/* ---------- Compact density ---------- */
body[data-density="compact"] .table tbody td { padding: 7px 12px; }
body[data-density="compact"] .field { padding: 6px 10px 6px 12px; }
body[data-density="compact"] .field .value { font-size: 13px; }
body[data-density="compact"] .group { padding: 10px 14px 12px; }
body[data-density="compact"] .field-grid { gap: 6px; }
body[data-density="compact"] .goods tbody td { padding: 4px 8px; }

/* ---------- Confidence viz variants ---------- */
body[data-conf-viz="border"] .field { background: var(--surface) !important; }
body[data-conf-viz="border"] .field .chip { display: none; }
body[data-conf-viz="dot"] .field { background: var(--surface) !important; }
body[data-conf-viz="dot"] .field .acc-bar { display: none; }
body[data-conf-viz="dot"] .field .chip {
  position: absolute; top: 8px; right: 8px;
  padding: 0; width: 8px; height: 8px; border-radius: 50%;
  border: 0;
}
body[data-conf-viz="dot"] .field .chip span:not(.dot) { display: none; }
body[data-conf-viz="dot"] .field .chip .dot { width: 8px; height: 8px; }
body[data-conf-viz="tint"] .field .acc-bar { display: none; }

/* Print */
@media print {
  .sidebar, .topbar, .action-bar, .tweaks-panel-host { display: none !important; }
  body { background: #fff; }
  .main { display: block; }
  .cmr-sheet { box-shadow: none; border-color: #000; }
}
