:root {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #fbfbf7;
  --ink: #171b1a;
  --muted: #69736f;
  --soft: #8d9692;
  --line: #e4e6df;
  --line-strong: #d3d7cf;
  --brand: #24584f;
  --brand-2: #0f766e;
  --brand-soft: #e7f2ee;
  --accent: #b88746;
  --warn: #a15c00;
  --danger: #aa3434;
  --ok: #277347;
  --chip: #f1f5f2;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, 0.06);
  --shadow: 0 18px 50px rgba(20, 31, 27, 0.08);
  --radius: 18px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --status-neutral: #344054;
  --status-neutral-bg: #f2f4f7;
  --status-info: #155dff;
  --status-info-bg: #eaf2ff;
  --status-waiting-bg: #e8f0ff;
  --status-warning: #b45309;
  --status-warning-bg: #fff3df;
  --status-danger: #cf244d;
  --status-critical: #d11f49;
  --status-danger-bg: #fff0f4;
  --status-success: #128257;
  --status-success-bg: #e9fbf3;
  --status-payment: #9d174d;
  --status-payment-bg: #ffe9f2;
  --status-credit: #0f766e;
  --status-credit-bg: #e6fbf6;

  /* Typography System v1: system fonts only, stable on Windows/Mac/mobile. */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --text-2xs: 10px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 28px;
  --text-4xl: 36px;
  --text-display: clamp(30px, 5vw, 54px);
  --text-brand: clamp(20px, 2.1vw, 28px);
  --text-number: clamp(23px, 2.5vw, 32px);

  --leading-none: 1;
  --leading-tight: 1.04;
  --leading-snug: 1.25;
  --leading-normal: 1.45;
  --leading-relaxed: 1.55;

  --weight-regular: 450;
  --weight-medium: 650;
  --weight-semibold: 750;
  --weight-bold: 850;
  --weight-black: 950;

  --tracking-tight: -0.04em;
  --tracking-title: -0.03em;
  --tracking-label: .10em;
}

.type-eyebrow {
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  line-height: var(--leading-snug);
}
.type-display {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-black);
  letter-spacing: -0.06em;
  line-height: .98;
}
.type-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-tight);
}
.type-section {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  line-height: var(--leading-snug);
}
.type-body {
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
}
.type-caption, .type-meta {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.type-number {
  font-size: var(--text-number);
  font-weight: var(--weight-black);
  letter-spacing: -0.05em;
  line-height: var(--leading-none);
}
.type-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 5% -10%, rgba(15,118,110,.16) 0, transparent 30%),
    radial-gradient(circle at 88% 2%, rgba(184,135,70,.12) 0, transparent 25%),
    linear-gradient(180deg, #fbfbf7 0%, var(--bg) 46%, #f3f4ef 100%);
  min-height: 100vh;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }

.app-shell {
  width: min(1260px, 100%);
  margin: 0 auto;
  padding: 22px 22px 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, .95fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, #153d37, var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: var(--weight-black);
  letter-spacing: -0.05em;
  box-shadow: 0 10px 24px rgba(15, 118, 110, .22);
}
.brand h1 {
  font-family: var(--font-display);
  font-size: var(--text-brand);
  line-height: var(--leading-tight);
  margin: 0;
  letter-spacing: var(--tracking-tight);
  font-weight: var(--weight-black);
}
.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  max-width: 690px;
}

.brand-subtitle {
  display: inline-block;
  margin-right: 10px;
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-label);
}
.brand-meta { color: var(--muted); }

.toolbar {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  justify-content: end;
}
.role-select, .search, input, select, textarea {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-sm);
}
.search { min-width: 240px; }
.role-select:focus-visible, .search:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: rgba(15, 118, 110, .55);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .10);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  background: var(--brand-gradient);
  color: #fff;
  border-radius: 14px;
  padding: 9px 13px;
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  line-height: var(--leading-none);
  box-shadow: 0 11px 24px rgba(21, 93, 255, .16);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 16px 30px rgba(21, 93, 255, .22); }
.btn.secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid #cbd8f4;
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost {
  background: transparent;
  color: var(--brand);
  box-shadow: none;
  padding: 6px 7px;
  min-height: auto;
}
.btn.danger {
  background: #fff4f7;
  color: var(--danger);
  border: 1px solid #ffd1dc;
  box-shadow: var(--shadow-sm);
}

.nav {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 12px 0 18px;
  padding: 6px;
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.tab {
  padding: 9px 12px;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
}
.tab:hover { background: #fff; color: var(--ink); border-color: var(--line); }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(360px, 0.43fr); align-items: start; }
.cards { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 10px; }
.card, .panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 18px; }
.panel h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -0.02em; }
.panel h3 { margin: 14px 0 8px; font-size: 14px; letter-spacing: -0.01em; }
.card {
  padding: 14px 13px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card .label {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  font-weight: var(--weight-bold);
  letter-spacing: -.01em;
}
.card .value {
  font-size: var(--text-number);
  font-weight: var(--weight-black);
  letter-spacing: -0.05em;
  margin-top: 8px;
}
.cards .card:nth-child(1),
.cards .card:nth-child(2),
.cards .card:nth-child(7),
.cards .card:nth-child(8) { border-color: rgba(15, 118, 110, .22); background: linear-gradient(180deg, #fff, #f4fbf8); }
.cards .card:nth-child(3),
.cards .card:nth-child(4),
.cards .card:nth-child(6) { border-color: rgba(184, 135, 70, .25); background: linear-gradient(180deg, #fff, #fff9ef); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
textarea { min-height: 78px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
  font-size: var(--text-base);
  box-shadow: var(--shadow-sm);
}
.check-pill input { width: auto; }

.list { display: grid; gap: 10px; }
.record {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(210px, auto);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.record:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: 0 10px 26px rgba(18, 31, 27, .08); }
.record .icons { display: grid; gap: 6px; font-size: 17px; text-align: center; }
.record h3 { margin: 0; font-size: 16px; letter-spacing: -0.02em; }
.record p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 300px;
}
.record-actions .btn { min-height: 31px; padding: 7px 9px; border-radius: 10px; font-size: 12px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 18px; background: rgba(255,255,255,.72); }
.supplier-row { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.supplier-row:last-child { border-bottom: 0; }
.small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.audit { max-height: 420px; overflow: auto; }
.audit-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit-item:last-child { border-bottom: 0; }
.notice {
  background: linear-gradient(180deg, #eff8f4, #f7fbf8);
  border: 1px solid #cde4db;
  border-radius: 16px;
  padding: 13px;
  color: #21483f;
  line-height: var(--leading-normal);
}
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.summary-cards { margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; font-size: 13px; }
th { color: var(--muted); background: #f7faf8; font-size: 12px; }
.message-box { white-space: pre-wrap; background: #f7faf8; border: 1px solid var(--line); border-radius: 14px; padding: 12px; max-height: 300px; overflow: auto; }
.danger-text { color: var(--danger) !important; }
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #152b27;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 18px 42px rgba(0,0,0,.22);
  z-index: 99;
  font-weight: var(--weight-bold);
}
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,20,18,.48); display: grid; place-items: center; z-index: 100; padding: 18px;
}
.modal {
  width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 24px; padding: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); position: relative;
}
.close-modal { position: absolute; top: 10px; right: 10px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 14px 0; }
.detail-grid p { margin: 0; color: var(--muted); }
.selected-record { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(15,118,110,.12); }
.advanced-box { border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; background: var(--surface-2); }
.advanced-box summary { cursor: pointer; color: var(--brand); font-weight: 900; margin-bottom: 10px; }

.thumb-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin: 9px 0; }
.thumb { width: 76px; margin: 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
.thumb img { width: 76px; height: 60px; object-fit: cover; display: block; background: #f4f5f7; }
.thumb figcaption { padding: 4px; font-size: 10px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-thumb div { width: 76px; height: 60px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); background: #f1f3f4; }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 150px minmax(220px, 1fr) auto auto auto; justify-content: stretch; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid.two, .form-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .record { grid-template-columns: 1fr; }
  .record .icons { display: flex; }
  .record-actions { justify-content: start; max-width: none; }
}
@media (max-width: 560px) {
  .app-shell { padding: 14px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr; }
  .brand { align-items: flex-start; }
  .logo { width: 40px; height: 40px; border-radius: 14px; }
}

/* v2.6 Guided Workflow: keep the first screen calm and sequential. */
.start-page { display: grid; gap: 16px; }
.hero-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  background: linear-gradient(135deg, #102f2b, #155f55);
  color: #fff;
  border-radius: 28px;
  padding: clamp(22px, 4vw, 38px);
  box-shadow: var(--shadow);
}
.hero-flow h2 { margin: 0; font-size: var(--text-display); letter-spacing: -0.06em; line-height: .98; max-width: 720px; font-weight: var(--weight-black); }
.hero-flow p { color: rgba(255,255,255,.78); max-width: 720px; line-height: 1.55; margin: 12px 0 0; }
.hero-flow .eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 900; color: rgba(255,255,255,.70); }
.hero-btn { background: #fff; color: #153d37; box-shadow: 0 14px 30px rgba(0,0,0,.22); min-height: 46px; padding: 13px 18px; }
.step-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step-card {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  min-height: 190px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.step-number { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 950; }
.step-card h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.03em; }
.step-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.guided-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .38fr); gap: 14px; align-items: start; }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0 14px; }
.mini-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.mini-stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 900; }
.mini-stat strong { display: block; font-size: 26px; letter-spacing: -0.05em; margin-top: 4px; }
.task-list { display: grid; gap: 10px; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 13px; }
.task-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.task-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.workflow-nav { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px); }
.record-more { margin-top: 8px; }
.record-more summary, .action-more summary { cursor: pointer; color: var(--brand); font-size: 12px; font-weight: 900; }
.action-more { position: relative; width: 100%; }
.action-more summary { list-style: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; text-align: center; }
.action-more[open] { display: grid; gap: 6px; }
.action-more[open] summary { margin-bottom: 6px; }
.compact-actions { max-width: 220px; }
.compact-actions .btn { width: 100%; }

@media (max-width: 980px) {
  .step-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guided-layout, .hero-flow { grid-template-columns: 1fr; }
  .hero-btn { justify-self: start; }
}
@media (max-width: 560px) {
  .step-grid, .mini-stats, .task-row { grid-template-columns: 1fr; }
  .task-actions { justify-content: start; }
  .step-card { min-height: auto; }
}

/* v2.7 Work Hub: make the app easier to understand at a glance. */
.workhub { display: grid; gap: 16px; }
.hub-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  background: linear-gradient(135deg, #102f2b, #155f55);
  color: #fff;
  border-radius: 28px;
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow);
}
.hub-hero h2 { margin: 0; font-size: var(--text-display); letter-spacing: -0.06em; line-height: .98; font-weight: var(--weight-black); }
.hub-hero p { color: rgba(255,255,255,.80); max-width: 720px; line-height: 1.5; margin: 12px 0 0; }
.eyebrow.dark { color: var(--brand); }
.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.action-card {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  min-height: 206px;
  display: grid;
  align-content: start;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.action-card.primary { border-color: rgba(15,118,110,.28); background: linear-gradient(180deg, #fff, #f2fbf8); }
.action-card.warn { border-color: rgba(184,135,70,.28); background: linear-gradient(180deg, #fff, #fff8ed); }
.action-card .action-value {
  width: fit-content;
  min-width: 46px;
  height: 46px;
  padding: 0 13px;
  border-radius: 15px;
  display: inline-grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 20px;
  font-weight: var(--weight-black);
  letter-spacing: -0.04em;
}
.action-card.warn .action-value { background: #fff1d5; color: var(--warn); }
.action-card h3 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.action-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 56px; }
.hub-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .34fr); gap: 14px; align-items: start; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; }
.queue-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.queue-col { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.queue-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.queue-head h3 { margin: 0; font-size: 14px; }
.queue-head span { min-width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); font-weight: 950; }
.task-list.compact { gap: 7px; }
.task-list.compact .task-row { grid-template-columns: minmax(0, 1fr) auto; padding: 10px; border-radius: 13px; }
.task-list.compact .task-row strong { font-size: 13px; }
.task-list.compact .task-row p { font-size: 12px; }
.mini-empty { padding: 18px 10px; font-size: 12px; }
.queue-open { width: 100%; }
.one-col { grid-template-columns: 1fr; }
.notice.compact { padding: 11px; font-size: 13px; }
.tool-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.capture-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, .38fr); gap: 14px; align-items: start; }
.capture-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 18px; }
.capture-steps div { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 16px; padding: 11px; }
.capture-steps strong { width: 28px; height: 28px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 950; }
.capture-steps span { font-size: 13px; font-weight: 850; }
.capture-file { border: 1px dashed rgba(15,118,110,.38); background: #f4fbf8; padding: 14px; border-radius: 16px; }
.inline-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-checks { margin: 2px 0; }
.save-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; }
.save-main { min-height: 44px; padding-inline: 18px; }
.helper-panel { position: sticky; top: 86px; }
.helper-list { display: grid; gap: 10px; margin-bottom: 14px; }
.helper-list div { border: 1px solid var(--line); border-radius: 15px; padding: 12px; background: var(--surface-2); }
.helper-list strong { display: block; font-size: 14px; margin-bottom: 4px; }
.helper-list span { color: var(--muted); font-size: 13px; line-height: 1.4; }

@media (max-width: 1080px) {
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-layout, .capture-screen, .hub-hero { grid-template-columns: 1fr; }
  .helper-panel { position: static; }
}
@media (max-width: 760px) {
  .queue-grid, .inline-fields, .capture-steps { grid-template-columns: 1fr; }
  .section-head { display: grid; }
  .tool-links { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .action-grid { grid-template-columns: 1fr; }
  .hub-hero h2 { font-size: 34px; }
}

/* v2.9 Role-aware Camera Capture + OCR Lab */
.toolbar.staff-toolbar {
  grid-template-columns: 150px auto auto;
  justify-content: end;
}
.staff-nav {
  max-width: 680px;
}
.staff-capture-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .34fr);
  gap: 16px;
  align-items: start;
}
.staff-capture-card {
  background: linear-gradient(135deg, #102f2b, #155f55);
  color: #fff;
  border-radius: 32px;
  padding: clamp(24px, 5vw, 46px);
  box-shadow: var(--shadow);
}
.staff-capture-card h2 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(38px, 7vw, 78px);
  line-height: .92;
  letter-spacing: -0.07em;
}
.staff-capture-card p {
  color: rgba(255,255,255,.78);
  max-width: 620px;
  line-height: 1.55;
}
.staff-capture-card .eyebrow {
  color: rgba(255,255,255,.72);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: var(--text-sm);
  font-weight: var(--weight-black);
}
.staff-capture-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
  max-width: 680px;
}
.staff-capture-form label {
  color: rgba(255,255,255,.80);
  font-size: 14px;
}
.staff-capture-form input,
.staff-capture-form select,
.staff-capture-form textarea {
  border-color: rgba(255,255,255,.18);
  box-shadow: none;
  font-size: 16px;
  padding: 15px 16px;
}
.staff-file {
  border: 2px dashed rgba(255,255,255,.32);
  border-radius: 22px;
  padding: 20px;
  background: rgba(255,255,255,.08);
}

.capture-choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.camera-file, .upload-file {
  cursor: pointer;
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 86px;
  font-weight: var(--weight-black);
}
.camera-file::before {
  content: '📷';
  font-size: 28px;
  line-height: 1;
}
.upload-file::before {
  content: '📄';
  font-size: 28px;
  line-height: 1;
}
.camera-file input, .upload-file input {
  width: 100%;
}
.staff-capture-form .capture-choice-row {
  max-width: 680px;
}
@media (max-width: 560px) {
  .capture-choice-row { grid-template-columns: 1fr; }
}

.staff-save {
  min-height: 62px;
  border-radius: 20px;
  font-size: 18px;
  background: #fff;
  color: #153d37;
  box-shadow: 0 18px 34px rgba(0,0,0,.22);
}
.staff-side {
  position: sticky;
  top: 86px;
}
.ocr-lab textarea {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-base);
}
.ocr-result {
  margin-top: 14px;
}
.ocr-result-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  padding: 14px;
}
.ocr-field {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.ocr-field:last-of-type { border-bottom: 0; }
.ocr-field span {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-black);
}
.ocr-field strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}
@media (max-width: 900px) {
  .staff-capture-page { grid-template-columns: 1fr; }
  .staff-side { position: static; }
}
@media (max-width: 560px) {
  .toolbar.staff-toolbar { grid-template-columns: 1fr; }
  .staff-capture-card { border-radius: 24px; }
  .staff-capture-card h2 { font-size: 42px; }
  .ocr-field { grid-template-columns: 1fr; gap: 4px; }
}

/* v3.1 vibetorq Branding + Unified Workflow + Permission Controls */
.unified-toolbar {
  grid-template-columns: 150px auto minmax(220px, 1fr) auto auto;
}
.unified-workflow .capture-first-hero {
  border: 1px solid rgba(255,255,255,.12);
}
.take-photo-cta {
  min-height: 76px;
  min-width: min(100%, 260px);
  border-radius: 24px;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.take-photo-cta::before { content: '📷'; font-size: 28px; }
.capture-first-screen .quick-panel {
  border-color: rgba(15, 118, 110, .22);
  box-shadow: var(--shadow);
}
.capture-first-screen h2 {
  font-size: clamp(30px, 5vw, 56px);
  line-height: .98;
  letter-spacing: -0.06em;
  max-width: 760px;
}
.primary-capture-row {
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, .75fr);
}
.mega-camera {
  min-height: clamp(150px, 24vw, 240px);
  border: 3px solid rgba(15,118,110,.35);
  border-radius: 30px;
  background: linear-gradient(135deg, #102f2b, #155f55);
  color: #fff;
  font-size: clamp(28px, 5vw, 58px);
  letter-spacing: -0.07em;
  box-shadow: 0 22px 46px rgba(15, 118, 110, .24);
  text-align: center;
}
.mega-camera::before {
  font-size: clamp(42px, 7vw, 78px);
}
.backup-upload {
  min-height: 150px;
  border-radius: 24px;
  background: #fff;
}
.supplier-step select {
  min-height: 58px;
  font-size: 18px;
}
.main-save-bar {
  align-items: stretch;
}
.main-save-bar .save-main {
  min-height: 58px;
  min-width: 220px;
  font-size: 17px;
  border-radius: 18px;
}
.quick-optional,
.advanced-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}
.quick-optional summary,
.advanced-box summary {
  cursor: pointer;
  font-weight: var(--weight-black);
  color: var(--brand);
}
.optional-fields { margin-top: 12px; }
.permission-denied { max-width: 680px; }
.permission-list { display: grid; gap: 10px; }
.permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-2);
  color: var(--ink);
}
.permission-row strong { display: block; font-size: 14px; }
.permission-row em { display: block; margin-top: 3px; color: var(--muted); font-style: normal; font-size: 12px; line-height: 1.35; }
.permission-row input { width: 22px; height: 22px; box-shadow: none; }
/* Permission Model V2: Owner-controlled Team Permissions and the signed-in
   member's own permission summary reuse the existing permission-row shell. */
.team-permission-row + .team-permission-row { margin-top: 10px; }
.team-permission-toggles { display: grid; gap: 8px; justify-items: start; }
.permission-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.permission-toggle input { width: 20px; height: 20px; box-shadow: none; }
.permission-summary { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.supplier-row.selected { background: var(--surface-2); border-radius: 12px; padding-left: 10px; padding-right: 10px; }
.supplier-contact-history { display: grid; gap: 10px; margin: 8px 0 14px; }
/* Product Search / Vendor product list. Reuses the supplier-row shell so no new
   design system is introduced; lifecycle markers stay deliberately quiet. */
.product-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.product-row:last-child { border-bottom: 0; }
.product-row.selected { background: var(--surface-2); border-radius: 12px; padding-left: 10px; padding-right: 10px; }
.product-row strong { font-size: 14px; }
.supplier-product-list { display: grid; margin: 6px 0 14px; }
.product-badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; letter-spacing: .02em; vertical-align: middle; }
.product-badge.new { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.product-badge.review { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.more-tool-links { margin-top: 14px; }
.queue-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 980px) {
  .unified-toolbar { grid-template-columns: 1fr; }
  .take-photo-cta { justify-self: start; }
  .primary-capture-row { grid-template-columns: 1fr; }
  .mega-camera { min-height: 180px; }
}

/* v3.2 vibetorq polished UI system: logo, colors, and capture-first mobile SaaS look */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --ink: #111827;
  --muted: #657084;
  --soft: #8a94a6;
  --line: #e4eaf2;
  --line-strong: #d6deeb;
  --brand: #155DFF;
  --brand-2: #00CFE8;
  --brand-3: #7C2DFF;
  --brand-soft: #eef7ff;
  --accent: #9D29FF;
  --warn: #ea7a14;
  --danger: #e23b58;
  --ok: #17a96b;
  --chip: #f4f7fb;
  --brand-gradient: linear-gradient(135deg, #6D28FF 0%, #155DFF 38%, #00B8FF 70%, #12D6D6 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(109,40,255,.12), rgba(0,184,255,.12), rgba(18,214,214,.14));
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .05);
  --shadow: 0 22px 60px rgba(17, 24, 39, .10);
  --shadow-card: 0 12px 30px rgba(17, 24, 39, .075);
}

html { background: var(--bg); }
body {
  background:
    radial-gradient(circle at 7% -5%, rgba(0, 207, 232, .16) 0, transparent 32%),
    radial-gradient(circle at 96% 0%, rgba(124, 45, 255, .13) 0, transparent 26%),
    linear-gradient(180deg, #fbfdff 0%, #f4f7fb 48%, #eef3f8 100%);
  color: var(--ink);
}

.app-shell { max-width: 1280px; padding: 24px 22px 44px; }

.app-header.topbar {
  grid-template-columns: minmax(320px, 1fr) minmax(420px, .9fr);
  padding: 16px;
  border: 1px solid rgba(214, 222, 235, .86);
  border-radius: 28px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}
.brand-vibetorq { gap: 14px; }
.logo-wrap { width: 104px; min-width: 104px; display: grid; place-items: center; }
.logo-mark { width: 104px; height: 52px; display: block; }
.logo-path {
  fill: none;
  stroke: url(#vibetorqGradient);
  stroke-width: 9.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.logo-cut {
  fill: none;
  stroke: rgba(255,255,255,.06);
  stroke-width: 4;
  stroke-linecap: round;
}
.brand-copy h1 {
  font-size: clamp(26px, 3vw, 38px);
  font-weight: var(--weight-black);
  letter-spacing: -0.055em;
}
.brand-copy .brand-subtitle {
  display: block;
  margin: 0;
  color: #334155;
  letter-spacing: .18em;
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
}
.brand-copy .brand-meta { margin-top: 5px; display: block; color: var(--muted); }

.unified-toolbar {
  display: grid;
  grid-template-columns: 150px auto minmax(220px, 1fr) auto auto;
  align-items: center;
}
.role-select, .search, input, select, textarea {
  border-color: var(--line-strong);
  background: rgba(255,255,255,.96);
  border-radius: 15px;
  min-height: 42px;
  box-shadow: 0 1px 0 rgba(15,23,42,.03);
}
.search { min-width: 260px; }
.role-select:focus-visible, .search:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: rgba(21, 93, 255, .42);
  box-shadow: 0 0 0 4px rgba(0, 184, 255, .13);
}
.brand-primary.top-capture { padding-inline: 18px; }

.workflow-nav.nav {
  position: sticky;
  top: 10px;
  z-index: 20;
  margin: 14px 0 18px;
  border-radius: 22px;
  padding: 7px;
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 32px rgba(17, 24, 39, .06);
}
.tab { border-radius: 15px; color: #596579; font-weight: 850; }
.tab.active { background: #155DFF; color: #fff; border-color: #155DFF; box-shadow: 0 9px 18px rgba(21, 93, 255, .18); }

.panel, .card {
  border-color: var(--line);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-card);
}
.panel { border-radius: 26px; }

/* Home screen */
.home-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, .36fr);
  gap: 16px;
  align-items: start;
}
.mobile-home-panel {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: clamp(18px, 2.7vw, 28px);
  box-shadow: var(--shadow);
}
.home-greeting { margin-bottom: 14px; }
.home-greeting h2 { margin: 0; font-size: clamp(26px, 4vw, 42px); letter-spacing: -.055em; line-height: 1; }
.eyebrow { color: #155DFF; font-size: 11px; font-weight: 950; letter-spacing: .14em; text-transform: uppercase; }
.capture-hero-button {
  width: 100%;
  min-height: clamp(92px, 13vw, 128px);
  border-radius: 26px;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  text-align: left;
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 24px 48px rgba(21, 93, 255, .22);
}
.capture-hero-button .camera-badge {
  width: 66px; height: 66px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.34);
  font-size: 28px;
}
.capture-hero-button strong { display: block; font-size: clamp(26px, 4vw, 42px); letter-spacing: -.055em; line-height: 1; }
.capture-hero-button em { display: block; margin-top: 7px; opacity: .84; font-style: normal; font-size: 14px; }
.chev { font-size: 34px; opacity: .84; }
.upload-hero-button {
  width: 100%;
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 14px 18px;
  border: 1px solid #cbd8f4;
  border-radius: 20px;
  background: #fff;
  color: #155DFF;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.upload-hero-button strong { font-size: 15px; }
.upload-hero-button em { color: var(--muted); font-style: normal; font-size: 12px; }

.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0 18px; }
.home-metric {
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  text-align: left;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 4px;
}
.home-metric span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; background: #eaf2ff; color: #155DFF; font-weight: 950; }
.home-metric.follow span { background: #e7fbfb; color: #00a8bd; }
.home-metric.calendar span { background: #f4e9ff; color: #9D29FF; }
.home-metric strong { font-size: 30px; line-height: 1; letter-spacing: -.06em; }
.home-metric em { font-size: 13px; font-style: normal; font-weight: 850; color: #1f2937; }
.home-metric small { color: #155DFF; font-weight: 850; }
.home-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.home-section-head h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.today-task-card { border: 1px solid var(--line); border-radius: 22px; background: #fff; overflow: hidden; box-shadow: var(--shadow-card); }
.home-task {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
}
.home-task:last-child { border-bottom: 0; }
.home-task strong { display: block; font-size: 14px; }
.home-task em { display: block; margin-top: 2px; color: var(--muted); font-style: normal; font-size: 12px; }
.home-task b { min-width: 32px; height: 26px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: #155DFF; font-size: 12px; }
.home-task i { color: var(--muted); font-style: normal; font-size: 24px; }
.task-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; background: #eaf2ff; color: #155DFF; }
.task-icon.search { width: 34px; min-width: 34px; }
.task-icon.follow { background: #e7fbfb; color: #00a8bd; }
.task-icon.payment { background: #f4e9ff; color: #9D29FF; }
.recent-list { display: grid; gap: 10px; }
.recent-capture {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.recent-capture:hover, .recent-capture:focus-visible { border-color: rgba(21,93,255,.45); box-shadow: 0 0 0 3px rgba(21,93,255,.10); }
.invoice-thumb { width: 56px; height: 56px; border-radius: 14px; background: #eef3f8; color: #155DFF; display: grid; place-items: center; font-size: 11px; font-weight: 950; overflow: hidden; }
.invoice-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-capture strong { font-size: 14px; }
.recent-capture p, .recent-capture small { margin: 2px 0 0; color: var(--muted); font-size: 12px; display: block; }
/* Capture screen refinements */
.capture-first-screen { grid-template-columns: minmax(0, 1fr) minmax(300px, .34fr); }
.capture-first-screen .quick-panel { border-radius: 32px; background: rgba(255,255,255,.96); }
.capture-first-screen h2 { font-size: clamp(28px, 4vw, 44px); }
.mega-camera {
  background: var(--brand-gradient);
  border: 0;
  color: #fff;
  box-shadow: 0 24px 48px rgba(21, 93, 255, .22);
  font-size: clamp(30px, 4.6vw, 54px);
}
.backup-upload { border: 1px solid #cbd8f4; color: #155DFF; background: #fff; }
.main-save-bar { background: #fff; border-radius: 22px; }
.main-save-bar .save-main { background: var(--brand-gradient); }
.quick-optional summary, .advanced-box summary, .record-more summary, .action-more summary { color: #155DFF; }

/* Records / Search cards */
.record {
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  border-color: var(--line);
}
.record h3 { font-size: 16px; letter-spacing: -.02em; }
.record-actions .btn.secondary { color: #155DFF; }
.icons .btn.ghost { color: #155DFF; }
.nav:not(.workflow-nav) { background: transparent; border: 0; box-shadow: none; padding: 0; gap: 8px; }
.nav:not(.workflow-nav) .tab { background: #fff; border-color: var(--line); }
.nav:not(.workflow-nav) .tab.active { background: #155DFF; border-color: #155DFF; color: #fff; }

@media (max-width: 1080px) {
  .app-header.topbar, .home-screen, .capture-first-screen { grid-template-columns: 1fr; }
  .unified-toolbar { grid-template-columns: 150px minmax(0, 1fr); }
  .unified-toolbar .top-capture { grid-column: 1 / -1; justify-self: start; }
  .home-side-panel { display: none; }
}
@media (max-width: 720px) {
  .app-shell { padding: 14px 12px; }
  .app-header.topbar { padding: 14px; border-radius: 24px; }
  .logo-wrap { width: 86px; min-width: 86px; }
  .logo-mark { width: 86px; }
  .brand-copy h1 { font-size: 29px; }
  .brand-copy .brand-meta { display: none; }
  .unified-toolbar { grid-template-columns: 1fr; }
  .search { width: 100%; min-width: 0; }
  .workflow-nav.nav {
    justify-content: space-around;
    border-radius: 24px;
  }
  .workflow-nav .tab { font-size: 11px; padding: 9px 8px; }
  .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .home-metric { min-height: 102px; padding: 10px; }
  .home-metric strong { font-size: 24px; }
  .capture-hero-button { min-height: 104px; }
  .capture-hero-button .camera-badge { width: 54px; height: 54px; }
  .capture-hero-button strong { font-size: 28px; }
  .upload-hero-button { grid-template-columns: auto minmax(0,1fr) auto; }
  .upload-hero-button em { display: none; }
  .primary-capture-row, .summary-strip { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
  .record-actions { max-width: none; }
}

/* v3.3 official logo asset + role selector cleanup */
.logo-wrap {
  width: 124px;
  min-width: 124px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-mark.official-logo-mark {
  width: 124px;
  height: 62px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0, 184, 255, .16));
}
.role-select {
  min-width: 118px;
  width: auto;
  font-weight: var(--weight-bold);
}
@media (max-width: 720px) {
  .logo-wrap { width: 96px; min-width: 96px; height: 48px; }
  .logo-mark.official-logo-mark { width: 96px; height: 48px; }
}

/* v3.4 issue templates, OCR review candidates, purchase insights */
.role-control {
  display: grid;
  gap: 4px;
  align-items: center;
}
.role-control small {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.ocr-field {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(0, 1.5fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  margin-bottom: 8px;
}
.ocr-field em {
  font-style: normal;
  font-size: var(--text-sm);
  font-weight: var(--weight-black);
  padding: 5px 8px;
  border-radius: 999px;
}
.ocr-found em { background: #dcfce7; color: #166534; }
.ocr-check em { background: #fef3c7; color: #92400e; }
.ocr-missing em { background: #fee2e2; color: #991b1b; }
.purchase-insights h3 { margin-top: 18px; }
.issue-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.issue-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 170px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  box-shadow: var(--shadow-card);
}
.issue-chip span {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  font-weight: var(--weight-black);
  background: var(--brand-gradient);
}

/* v3.9 Simple UX Pass: fewer top controls, search only in Invoices, app-like file buttons */
.simple-app-header.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px 16px;
  border-radius: 24px;
}
.simple-app-header .brand-vibetorq { gap: 12px; }
.simple-app-header .logo-wrap { width: 96px; min-width: 96px; height: 48px; }
.simple-app-header .logo-mark.official-logo-mark { width: 96px; height: 48px; }
.simple-app-header .brand-copy h1 { font-size: clamp(24px, 2.4vw, 32px); }
.simple-app-header .brand-copy .brand-subtitle { font-size: 10px; letter-spacing: .16em; }
.simple-app-header .brand-copy .brand-meta { font-size: 12px; margin-top: 4px; }
.header-status { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.demo-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.compact-role-select { min-height: 36px; min-width: 132px; padding: 8px 10px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.workflow-nav.nav { margin-top: 10px; }

/* Today: keep action and tasks visually dominant */
.mobile-home-panel { padding: clamp(16px, 2.3vw, 24px); }
.home-greeting h2 { font-size: clamp(25px, 3.3vw, 36px); }
.plan-line { opacity: .82; }
.home-side-panel { display: none; }
.home-screen { grid-template-columns: minmax(0, 1fr); max-width: 980px; margin: 0 auto; }
.capture-hero-button { min-height: clamp(88px, 11vw, 118px); }
.upload-hero-button { min-height: 58px; }

/* Capture: three-step screen with hidden native file input */
.simple-capture-screen { max-width: 1080px; margin: 0 auto; }
.simple-capture-head h2 { font-size: clamp(30px, 3.8vw, 46px); }
.simple-choice-row { align-items: stretch; }
.simple-capture-file {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
}
.simple-capture-file .capture-title { display: block; font-weight: 950; letter-spacing: -.045em; }
.simple-capture-file .capture-subtitle { display: block; font-size: 14px; font-weight: 800; opacity: .82; letter-spacing: normal; }
.camera-file input[type="file"], .upload-file input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.simple-step-line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.simple-step-line span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
}
.simple-step-line b {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eaf2ff;
  color: #155DFF;
  font-size: var(--text-sm);
}
.key-details-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}
.key-details-card .eyebrow { margin: 0 0 10px; }
.key-details-grid { gap: 10px; }
.simple-helper h2 { margin-bottom: 10px; }
.simple-helper .helper-list div { background: #fff; }

/* Invoices: search belongs here, not in global header */
.invoice-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 12px 0;
}
.invoice-search-bar .search { width: 100%; min-width: 0; min-height: 48px; font-size: 15px; }
.compact-filter-nav.nav { margin: 10px 0 14px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 7px; }
.compact-filter-nav .tab { white-space: nowrap; }

@media (max-width: 860px) {
  .simple-app-header.topbar { grid-template-columns: 1fr; }
  .header-status { justify-content: flex-start; }
  .simple-step-line, .primary-capture-row { grid-template-columns: 1fr; }
  .invoice-search-bar { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .simple-app-header .brand-copy .brand-meta { display: none; }
  .simple-app-header .logo-wrap { width: 82px; min-width: 82px; height: 42px; }
  .simple-app-header .logo-mark.official-logo-mark { width: 82px; height: 42px; }
  .header-status { display: none; }
  .capture-first-screen h2 { font-size: 32px; }
  .mega-camera { min-height: 132px; font-size: 32px; }
  .backup-upload { min-height: 96px; }
  .key-details-card { padding: 12px; }
}

/* v4.0 Real UX Cleanup: remove prototype feel from main flow */
:root {
  --ux-blue: #155DFF;
  --ux-cyan: #11BFD7;
  --ux-bg: #f6f8fb;
  --ux-card: #ffffff;
  --ux-text: #0f172a;
  --ux-muted: #64748b;
  --ux-line: #e2e8f0;
}
body {
  background: linear-gradient(180deg, #f9fbff 0%, #f4f7fb 48%, #f6f8fb 100%);
  color: var(--ux-text);
}
.app-shell { max-width: 1120px; padding: 14px 18px 40px; }
.ux-app-header.topbar {
  display: block;
  margin: 0 0 12px;
  padding: 14px 18px;
  border: 1px solid var(--ux-line);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
}
.ux-brand-row { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.ux-brand .logo-wrap { width: 92px; min-width: 92px; height: 48px; }
.ux-brand .logo-mark.official-logo-mark { width: 92px; height: 48px; object-fit: contain; }
.ux-brand .brand-copy h1 { font-size: 30px; line-height: 1; margin:0; letter-spacing:-.05em; }
.ux-brand .brand-copy .brand-subtitle { display:block; margin-top:4px; color:#334155; font-size:11px; font-weight:900; letter-spacing:.16em; }
.ux-header-capture { min-width: 150px; height: 42px; border-radius: 14px; }
.workflow-nav.nav {
  margin: 0 0 16px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--ux-line);
  box-shadow: none;
}
.workflow-nav .tab { flex: 0 0 auto; min-width: 104px; padding: 11px 14px; font-size: 14px; color:#526071; }
.workflow-nav .tab.active { background: var(--ux-blue); border-color: var(--ux-blue); color:white; box-shadow: 0 8px 18px rgba(21,93,255,.18); }
.ux-home { display:grid; gap:14px; }
.ux-hero-panel {
  display:grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap:18px;
  align-items:center;
  padding: 24px;
  border: 1px solid var(--ux-line);
  border-radius: 26px;
  background: white;
  box-shadow: 0 12px 32px rgba(15,23,42,.06);
}
.ux-hero-copy h2 { margin: 6px 0 8px; font-size: clamp(32px,4vw,48px); line-height: .98; letter-spacing:-.06em; }
.ux-hero-copy .small { max-width: 620px; font-size: 15px; color: var(--ux-muted); }
.ux-usage-line { margin-top: 12px; }
.ux-hero-actions { display:grid; gap:10px; }
.ux-primary-action, .ux-secondary-action {
  width:100%; text-align:left; border-radius:20px; padding: 18px;
  display:grid; grid-template-columns:auto 1fr; column-gap: 12px; align-items:center;
}
.ux-primary-action { background: linear-gradient(135deg, var(--ux-blue), var(--ux-cyan)); color:#fff; box-shadow: 0 14px 30px rgba(21,93,255,.18); }
.ux-secondary-action { background:#f8fafc; color:#0f172a; border: 1px solid var(--ux-line); }
.ux-primary-action span { width:44px; height:44px; border-radius:16px; display:grid; place-items:center; background: rgba(255,255,255,.18); font-size:22px; grid-row:span 2; }
.ux-primary-action strong, .ux-secondary-action strong { font-size:20px; letter-spacing:-.03em; }
.ux-primary-action em, .ux-secondary-action em { font-style:normal; font-size:13px; opacity:.82; }
.ux-focus-grid { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:12px; }
.ux-focus-card.home-metric {
  min-height:104px; border-radius:22px; background:#fff; border:1px solid var(--ux-line);
  box-shadow:none; display:grid; grid-template-columns:auto 1fr; align-items:center; text-align:left; padding:16px; gap:10px;
}
.ux-focus-card span { width:38px; height:38px; border-radius:14px; display:grid; place-items:center; background:#eef4ff; color:var(--ux-blue); }
.ux-focus-card strong { font-size:30px; line-height:1; letter-spacing:-.04em; }
.ux-focus-card em { grid-column:2; font-style:normal; color:#475569; font-weight:800; }
.ux-focus-card small { display:none; }
.ux-two-col { display:grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap:14px; align-items:start; }
.ux-clean-panel.panel { border-color: var(--ux-line); box-shadow:none; border-radius:24px; }
.ux-task-list.today-task-card { border:0; padding:0; background:transparent; box-shadow:none; }
.ux-recent-list .recent-capture { border-radius:18px; }
.ux-capture-page { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:14px; align-items:start; }
.ux-capture-card.panel, .ux-capture-help.panel { border-color:var(--ux-line); box-shadow:0 10px 28px rgba(15,23,42,.05); border-radius:26px; }
.ux-capture-title h2 { font-size: clamp(34px, 4vw, 52px); line-height: .98; letter-spacing:-.06em; margin-bottom: 8px; }
.ux-capture-choice { display:grid; grid-template-columns:1.2fr .8fr; gap:12px; }
.ux-file-tile {
  min-height: 118px; border-radius:24px; background:#f8fafc; color:#0f172a; border:1px solid var(--ux-line);
  box-shadow:none; padding:18px; display:grid; place-items:center; text-align:center;
}
.ux-file-tile.primary { background: linear-gradient(135deg, #155DFF, #11BFD7); color:#fff; }
.ux-file-tile .tile-icon { font-size:28px; display:block; margin-bottom:4px; }
.ux-file-tile .capture-title { font-size:24px; line-height:1.05; letter-spacing:-.045em; font-weight:950; }
.ux-file-tile .capture-subtitle { font-size:14px; font-weight:800; opacity:.82; }
.ux-key-fields { border:1px solid var(--ux-line); border-radius:22px; padding:16px; background:#fbfdff; }
.ux-fields-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.ux-fields-head strong { font-size:16px; }
.ux-fields-head span { color:var(--ux-muted); font-size:12px; font-weight:700; }
.ux-save-row { display:flex; gap:10px; flex-wrap:wrap; }
.ux-save-row .btn { min-height:46px; padding:12px 18px; }
.ux-more-details { border:1px solid var(--ux-line); border-radius:18px; padding:13px 14px; background:#fff; }
.ux-more-details summary { cursor:pointer; font-weight:850; color:#334155; }
.ux-capture-help .helper-list div { background:#f8fafc; border-color:var(--ux-line); }
.ux-prototype-controls { border-style:dashed; background:#fbfdff; }
.demo-pill, .header-status, .brand-meta { display:none !important; }
@media (max-width: 900px) {
  .ux-hero-panel, .ux-two-col, .ux-capture-page { grid-template-columns: 1fr; }
  .ux-focus-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ux-header-capture { display:none; }
}
@media (max-width: 700px) {
  .app-shell { padding: 10px; }
  .ux-brand .logo-wrap { width:76px; min-width:76px; height:40px; }
  .ux-brand .logo-mark.official-logo-mark { width:76px; height:40px; }
  .ux-brand .brand-copy h1 { font-size:26px; }
  .workflow-nav.nav { overflow-x:auto; flex-wrap:nowrap; }
  .workflow-nav .tab { min-width:92px; }
  .ux-hero-panel { padding:18px; border-radius:22px; }
  .ux-focus-grid { grid-template-columns: 1fr; }
  .ux-capture-choice { grid-template-columns:1fr; }
  .ux-fields-head { display:block; }
}

/* v4.0.1 review fixes: complete status pill palette + toast visible above modals */
.toast { z-index: 240; }
.status-pill.review, .status-pill.needs-review { color: var(--status-warning); background: var(--status-warning-bg); }
.status-pill.payment-due { color: var(--status-payment); background: var(--status-payment-bg); }
.status-pill.waiting-for-reply { color: var(--status-info); background: var(--status-waiting-bg); }
.status-pill.credit-pending { color: var(--status-credit); background: var(--status-credit-bg); }
.status-pill.duplicate-suspected { color: var(--status-critical); background: var(--status-danger-bg); }
.status-pill.closed { color: var(--status-success); background: var(--status-success-bg); }

/* v4.1 Premium UX Cleanup: calm, simple, retail-ready workflow */
:root {
  --v41-bg: #f6f8fc;
  --v41-card: #ffffff;
  --v41-text: #0f172a;
  --v41-muted: #667085;
  --v41-line: #e5eaf1;
  --v41-blue: #155dff;
  --v41-cyan: #12bfd7;
  --v41-soft-blue: #eef5ff;
  --v41-warn: var(--status-warning);
  --v41-danger: var(--status-danger);
  --v41-ok: var(--status-success);
  --v41-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
body {
  background: linear-gradient(180deg, #fbfdff 0%, var(--v41-bg) 45%, #f7f9fc 100%);
  color: var(--v41-text);
}
.app-shell {
  max-width: 1080px;
  padding: 14px 16px 42px;
}
.v41-header.topbar {
  margin: 0 0 10px;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.94);
  border-color: var(--v41-line);
  box-shadow: 0 6px 18px rgba(15,23,42,.045);
}
.v41-brand-row { justify-content: flex-start; }
.v41-header .ux-brand .logo-wrap { width: 82px; min-width: 82px; height: 42px; }
.v41-header .ux-brand .logo-mark.official-logo-mark { width: 82px; height: 42px; object-fit: contain; }
.v41-header .brand-copy h1 { font-size: 28px; line-height: .95; }
.v41-header .brand-copy .brand-subtitle { margin-top: 3px; font-size: 10px; letter-spacing: .17em; color: #344054; }
.v41-tagline { margin: 4px 0 0; color: var(--v41-muted); font-size: 12px; font-weight: 650; }
.ux-header-capture { display: none !important; }
.workflow-nav.nav {
  margin: 0 0 14px;
  padding: 5px;
  border-radius: 16px;
  box-shadow: none;
  background: rgba(255,255,255,.94);
  border-color: var(--v41-line);
}
.workflow-nav .tab {
  min-width: 94px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: var(--text-base);
  color: #596579;
}
.workflow-nav .tab.active {
  background: var(--v41-blue);
  border-color: var(--v41-blue);
  box-shadow: 0 7px 16px rgba(21,93,255,.16);
}
.v41-home { display: grid; gap: 12px; }
.v41-today-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 330px);
  gap: 14px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--v41-line);
  border-radius: 24px;
  background: var(--v41-card);
  box-shadow: var(--v41-shadow);
}
.v41-today-copy h2 {
  margin: 5px 0 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -.055em;
}
.v41-today-copy .small { max-width: 560px; font-size: 14px; }
.v41-usage-line { margin-top: 12px; color: #475467; }
.v41-main-capture {
  min-height: 132px;
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(135deg, var(--v41-blue), var(--v41-cyan));
  color: white;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 14px;
  align-content: center;
  text-align: left;
  box-shadow: 0 16px 32px rgba(21,93,255,.18);
}
.v41-main-capture:hover { transform: translateY(-1px); box-shadow: 0 20px 38px rgba(21,93,255,.22); }
.v41-main-icon {
  grid-row: 1 / span 2;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,.18);
  font-size: 24px;
}
.v41-main-capture strong { font-size: 25px; letter-spacing: -.04em; line-height: 1.05; }
.v41-main-capture em { font-style: normal; font-size: 14px; opacity: .86; }
.v41-focus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.v41-focus-card.home-metric {
  min-height: 88px;
  border: 1px solid var(--v41-line);
  border-radius: 20px;
  background: #fff;
  box-shadow: none;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  text-align: left;
  padding: 14px;
  gap: 9px;
}
.v41-focus-card.home-metric:hover { border-color: #c8d5e7; transform: translateY(-1px); }
.v41-focus-card span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--v41-soft-blue);
  color: var(--v41-blue);
  font-weight: var(--weight-black);
}
.v41-focus-card strong { font-size: 28px; letter-spacing: -.04em; line-height: 1; }
.v41-focus-card em { grid-column: 2; font-style: normal; color: #475467; font-weight: 850; }
.v41-focus-card.is-empty { opacity: .68; }
.v41-focus-card.is-empty span { background: #f2f4f7; color: #98a2b3; }
.v41-work-grid { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 12px; align-items: start; }
.v41-panel.panel { border-radius: 22px; border-color: var(--v41-line); box-shadow: none; }
.v41-task-list.today-task-card { background: transparent; border: 0; box-shadow: none; padding: 0; }
.v41-task.home-task {
  border-radius: 16px;
  min-height: 64px;
  border: 1px solid var(--v41-line);
  background: #fff;
}
.v41-task.is-empty { opacity: .58; }
.v41-recent-list .recent-capture {
  border: 1px solid var(--v41-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: none;
}
.ux-capture-page {
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
}
.ux-capture-card.panel, .ux-capture-help.panel {
  border-radius: 24px;
  border-color: var(--v41-line);
  box-shadow: var(--v41-shadow);
}
.ux-capture-title h2 { font-size: clamp(30px, 4vw, 44px); }
.ux-file-tile { min-height: 108px; border-radius: 22px; }
.ux-file-tile .capture-title { font-size: 22px; }
.ux-key-fields { border-color: var(--v41-line); background: #fbfdff; }
.ux-fields-head span { color: var(--v41-muted); }
input, select, textarea, .search, .role-select { border-color: var(--v41-line); box-shadow: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .search:focus-visible, .role-select:focus-visible { border-color: rgba(21,93,255,.45); box-shadow: 0 0 0 4px rgba(21,93,255,.10); }
.invoices-panel.panel, .panel { border-color: var(--v41-line); }
.record {
  border-color: var(--v41-line);
  box-shadow: none;
  border-radius: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
}
.record:hover { box-shadow: 0 8px 22px rgba(15,23,42,.055); }
.record-actions .btn { min-height: 32px; }
.record-more summary, .action-more summary { cursor: pointer; font-weight: 850; color: #475467; }
.status-pill {
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--status-info);
  background: var(--status-info-bg);
  font-size: var(--text-xs);
  font-weight: 900;
  white-space: nowrap;
}
.badge {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--status-neutral);
  background: var(--status-neutral-bg);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
}
.status-pill.done,
.badge.ok { color: var(--status-success); background: var(--status-success-bg); }
.status-pill.follow-up,
.badge.warn { color: var(--status-warning); background: var(--status-warning-bg); }
.badge.danger { color: var(--status-danger); background: var(--status-danger-bg); }
.toast { z-index: 240; }
.modal { border-radius: 22px; }
@media (max-width: 900px) {
  .v41-today-hero, .v41-work-grid, .ux-capture-page { grid-template-columns: 1fr; }
  .v41-main-capture { min-height: 112px; }
}
@media (max-width: 700px) {
  .app-shell { padding: 10px; }
  .v41-header.topbar { padding: 10px 12px; }
  .v41-header .ux-brand .logo-wrap { width: 70px; min-width: 70px; height: 36px; }
  .v41-header .ux-brand .logo-mark.official-logo-mark { width: 70px; height: 36px; }
  .v41-header .brand-copy h1 { font-size: 24px; }
  .v41-tagline { display: none; }
  .workflow-nav.nav {
    border-radius: 20px;
    justify-content: space-between;
    box-shadow: 0 16px 36px rgba(15,23,42,.14);
    overflow: hidden;
  }
  .workflow-nav .tab { min-width: 0; flex: 1 1 auto; padding: 10px 7px; font-size: 12px; }
  .v41-focus-grid { grid-template-columns: 1fr; }
  .v41-today-hero { padding: 16px; }
  .v41-today-copy h2 { font-size: 31px; }
  .v41-main-capture strong { font-size: 23px; }
  .ux-capture-choice { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
  .record .icons { display: none; }
  .record-actions { justify-content: flex-start; max-width: none; }
}

/* v4.6 Line Item OCR Review Foundation */
.item-summary-line {
  margin: 6px 0 0;
  font-weight: var(--weight-medium);
}
.line-items-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}
.line-items-table {
  min-width: 760px;
}
.line-items-table th,
.line-items-table td {
  white-space: nowrap;
}
.item-backorder-row td {
  background: color-mix(in srgb, var(--warning) 8%, transparent);
}
.ocr-item-review {
  margin-top: 12px;
}
.section-mini-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.section-mini-head span {
  color: var(--muted);
  font-size: var(--text-sm);
}
.compact-pre {
  max-height: 180px;
  overflow: auto;
}
.detail-modal {
  max-width: 980px;
}

/* v4.7 Line Item Review UI polish */
.ocr-review-step {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
}
.ocr-review-step-block {
  margin-top: 12px;
}
.ocr-review-step-block.save-step {
  border-top: 1px solid var(--border, rgba(120, 120, 140, 0.25));
  padding-top: 10px;
}
.issues-detected {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.issues-detected strong {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.issues-detected p {
  flex-basis: 100%;
  margin: 2px 0 0;
}
.item-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  margin-right: 4px;
  white-space: nowrap;
}
.item-chip.ok {
  background: color-mix(in srgb, var(--success, #2f9e5f) 16%, transparent);
}
.item-chip.warn {
  background: color-mix(in srgb, var(--warning) 20%, transparent);
}
.item-reason {
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: 2px;
  white-space: normal;
}
.item-ignored-row td {
  opacity: 0.55;
  text-decoration: line-through;
}
.item-ignored-row td:last-child {
  text-decoration: none;
}
.item-review-row td {
  background: color-mix(in srgb, var(--warning) 5%, transparent);
}
.item-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.btn.mini {
  padding: 2px 8px;
  font-size: var(--text-xs);
  line-height: 1.4;
}
.add-item-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.add-item-row input {
  flex: 1;
  min-width: 0;
}
.detail-section-title {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--border, rgba(120, 120, 140, 0.25));
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}
.file-list {
  margin: 6px 0;
  padding-left: 18px;
  font-size: var(--text-sm);
}

/* Mobile: item rows collapse into cards */
@media (max-width: 640px) {
  .line-items-table {
    min-width: 0;
  }
  .line-items-table thead {
    display: none;
  }
  .line-items-table tr {
    display: block;
    border: 1px solid var(--border, rgba(120, 120, 140, 0.25));
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
  }
  .line-items-table td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    padding: 2px 0;
    white-space: normal;
    font-size: var(--text-sm);
  }
  .line-items-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .line-items-table td[data-label="Product"] {
    display: block;
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
  }
  .line-items-table td[data-label="Product"]::before {
    display: none;
  }
}

/* v5.0 OCR scan and review workflow */
.ocr-scan-shell,
.ocr-review-shell {
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
  animation: ocr-rise .42s ease-out both;
}

.ocr-runtime-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid;
  border-radius: 14px;
  font-size: .82rem;
}
.ocr-runtime-banner > * { min-width: 0; overflow-wrap: anywhere; }

.ocr-runtime-banner strong {
  flex: 0 0 auto;
  font-family: var(--font-display);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ocr-runtime-banner.demo { color: #74450b; background: #fff2cf; border-color: #e2b85f; }
.ocr-runtime-banner.server { color: #174f42; background: #dff3ea; border-color: #8dc8b7; }

@keyframes ocr-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ocr-scan-hero,
.ocr-review-head {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-end;
  padding: 30px;
  border-radius: 24px;
  color: #f8fbf8;
  background:
    linear-gradient(120deg, rgba(255,255,255,.08), transparent 42%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.025) 22px 23px),
    #173f38;
  box-shadow: 0 24px 70px rgba(18, 62, 54, .18);
}

.ocr-scan-hero::after,
.ocr-review-head::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  right: -60px;
  top: -85px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(255,255,255,.035), 0 0 0 58px rgba(255,255,255,.025);
}

.ocr-scan-hero > *,
.ocr-review-head > * { position: relative; z-index: 1; }
.ocr-scan-hero .eyebrow,
.ocr-review-head .eyebrow { color: #a9d7c8; }
.ocr-scan-hero h2,
.ocr-review-head h2 { margin: 4px 0 8px; color: #fff; font-size: clamp(28px, 4vw, 46px); letter-spacing: -.055em; line-height: .98; }
.ocr-scan-hero p,
.ocr-review-head p { margin: 0; max-width: 650px; color: rgba(248,251,248,.76); }

.ocr-usage-unit,
.ocr-confidence-score {
  flex: 0 0 210px;
  display: grid;
  gap: 3px;
  padding: 15px 17px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 15px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}
.ocr-usage-unit strong,
.ocr-confidence-score strong { color: #fff; font-size: var(--text-xl); }
.ocr-usage-unit .ocr-usage-label {
  color: rgba(255,255,255,.78);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.ocr-usage-unit span,
.ocr-confidence-score span { color: rgba(255,255,255,.68); font-size: var(--text-xs); }
.ocr-confidence-score { text-align: right; }
.ocr-confidence-score strong { font-size: 34px; letter-spacing: -.06em; }

.ocr-drop-panel {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  border: 1.5px dashed #9ab8ae;
  background:
    radial-gradient(circle at center, rgba(36,88,79,.08), transparent 48%),
    var(--surface);
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}
.ocr-drop-panel.dragging { border-color: var(--brand-2); transform: translateY(-2px); background: var(--brand-soft); }
.ocr-drop-panel h3 { margin: 13px 0 5px; font-size: var(--text-2xl); }
.ocr-drop-panel p { margin: 0 0 20px; color: var(--muted); }
.ocr-drop-panel small { margin-top: 16px; color: var(--muted); }
.ocr-drop-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: .14em;
  box-shadow: 0 14px 32px rgba(36,88,79,.22);
}
.ocr-upload-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }

.ocr-file-queue ol { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.ocr-upload-file {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}
.ocr-upload-file strong,
.ocr-upload-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocr-upload-file small { color: var(--muted); }
.ocr-file-grip { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--brand); background: var(--brand-soft); font-weight: var(--weight-bold); }
.ocr-file-actions { display: flex; gap: 5px; }
.ocr-action-row { display: flex; justify-content: flex-end; align-items: center; gap: 9px; margin-top: 16px; flex-wrap: wrap; }

.ocr-message { padding: 14px 16px; border-radius: 14px; border: 1px solid; }
.ocr-message p { margin: 3px 0; }
.ocr-message.error { color: #7c2424; border-color: #e6b4b4; background: #fff2f1; }
.ocr-message.warning { color: #714300; border-color: #e4c798; background: #fff8e9; }

.ocr-loading,
.ocr-processing-stage { min-height: 440px; display: grid; place-items: center; align-content: center; text-align: center; }
.ocr-processing-stage h2 { margin: 8px 0; font-size: var(--text-3xl); }
.ocr-processing-stage > p:not(.eyebrow) { max-width: 520px; color: var(--muted); }
.ocr-spinner,
.ocr-progress-orbit { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand-2); animation: ocr-spin .8s linear infinite; }
.ocr-progress-orbit { width: 96px; height: 96px; display: grid; place-items: center; border-width: 1px; }
.ocr-progress-orbit span { width: 54px; height: 54px; border-radius: 17px; background: linear-gradient(145deg, var(--brand), var(--brand-2)); transform: rotate(45deg); }
@keyframes ocr-spin { to { transform: rotate(360deg); } }
.ocr-progress-track { width: min(460px, 80%); height: 6px; margin: 18px 0; overflow: hidden; border-radius: 99px; background: var(--line); }
.ocr-progress-track i { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--brand-2); animation: ocr-progress 1.2s ease-in-out infinite alternate; }
@keyframes ocr-progress { from { transform: translateX(-40%); } to { transform: translateX(180%); } }

.ocr-review-grid { display: grid; grid-template-columns: minmax(300px, .82fr) minmax(0, 1.45fr); gap: 18px; align-items: start; width: 100%; min-width: 0; max-width: 100%; transition: grid-template-columns .18s ease; }
.ocr-review-grid.original-collapsed { grid-template-columns: minmax(170px, .24fr) minmax(0, 1.76fr); }
.ocr-review-grid > * { min-width: 0; }
.ocr-preview-pane { position: sticky; top: 78px; min-width: 0; padding: 12px; }
.ocr-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ocr-preview-header strong { font-size: var(--text-sm); }
.ocr-preview-pane.is-collapsed .ocr-preview-header { align-items: stretch; flex-direction: column; margin-bottom: 0; }
.ocr-preview-body[hidden] { display: none; }
.ocr-preview-toolbar { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ocr-preview-toolbar span { color: var(--muted); font-size: var(--text-xs); }
.ocr-preview-toolbar .selected { color: #fff; border-color: var(--brand-2); background: var(--brand-2); }
.ocr-preview-canvas { width: 100%; height: 60vh; min-width: 0; max-width: 100%; min-height: 320px; max-height: 600px; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; border-radius: 13px; background: #26302d; }
.ocr-preview-document { min-height: 100%; transition: width .18s ease; }
.ocr-preview-page { position: relative; }
.ocr-preview-document img { display: block; max-width: none; height: auto; }
.ocr-preview-document iframe { display: block; width: 100%; height: 100%; min-height: 0; border: 0; background: #fff; }
.ocr-preview-canvas[data-ocr-fit="page"] { overflow: hidden; }
.ocr-preview-canvas[data-ocr-fit="page"] .ocr-preview-document { display: grid; width: 100% !important; height: 100%; min-height: 0; place-items: start center; }
.ocr-preview-canvas[data-ocr-source="image"][data-ocr-fit="page"] .ocr-preview-page { position: relative; aspect-ratio: var(--ocr-page-aspect, 8.5 / 11); max-width: 100%; max-height: 100%; }
.ocr-preview-canvas[data-ocr-source="image"][data-ocr-fit="page"] img { width: 100%; height: 100%; object-fit: contain; object-position: top center; }
.ocr-preview-canvas[data-ocr-source="pdf"][data-ocr-fit="page"] .ocr-preview-page { width: 100%; height: 100%; }
.ocr-preview-canvas[data-ocr-fit="page"] iframe { height: 100%; }
.ocr-preview-canvas[data-ocr-fit="width"] .ocr-preview-page,
.ocr-preview-canvas[data-ocr-fit="zoom"] .ocr-preview-page { width: 100%; }
.ocr-preview-canvas[data-ocr-fit="width"] img,
.ocr-preview-canvas[data-ocr-fit="zoom"] img { width: 100%; height: auto; }
/* inset:0 gives the layer a definite height equal to the image's own rendered
   height (which is otherwise "auto"), so the highlight rectangle inside it can
   then be positioned with ordinary percentages. */
.ocr-preview-highlight-layer { position: absolute; inset: 0; pointer-events: none; }
.ocr-census-highlight { position: absolute; border: 2px solid #ffb020; background: rgba(255, 176, 32, .22); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.ocr-pdf-source-card { display: grid; place-items: center; gap: 10px; padding: 28px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); text-align: center; background: var(--surface-2); }
.ocr-pdf-source-card h3,
.ocr-pdf-source-card p { margin: 0; overflow-wrap: anywhere; }
.ocr-pdf-source-card > p:not(.eyebrow) { color: var(--muted); }
.ocr-preview-pane > p { margin: 10px 4px 0; }
.ocr-review-form { display: grid; gap: 14px; min-width: 0; }
.ocr-header-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ocr-invoice-more-details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 9px; }
.ocr-invoice-more-details summary { min-height: 36px; cursor: pointer; color: var(--brand-2); font-weight: var(--weight-bold); }
.ocr-invoice-more-details:not([open]) > .ocr-header-fields { display: none; }
.ocr-invoice-more-details .ocr-header-fields { margin-top: 7px; }

.ocr-edit-field { display: grid; gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.ocr-edit-field > span,
.ocr-line-table td label > span { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.ocr-edit-field input,
.ocr-line-table input { width: 100%; min-width: 80px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: #fff; }
.ocr-edit-field small { color: var(--muted); line-height: 1.3; }
.ocr-edit-field.needs-review,
.ocr-line-table td.needs-review { border-color: #dcad65; background: #fff8e9; }
.ocr-edit-field.has-conflict { border-color: #d27870; background: #fff3f1; }
.confidence-pill { padding: 2px 6px; border-radius: 99px; font-size: 9px; font-style: normal; }
.confidence-pill.high { color: #17623a; background: #e5f5ea; }
.confidence-pill.medium { color: #79500b; background: #fff0c9; }
.confidence-pill.low { color: #8b2929; background: #ffe2de; }
.confidence-dot { width: 8px; height: 8px; border-radius: 50%; }
.confidence-dot.high,
.confidence-legend i.high { background: #2a8a53; }
.confidence-dot.medium,
.confidence-legend i.medium { background: #cf8c24; }
.confidence-dot.low,
.confidence-legend i.low { background: #c84c43; }
.confidence-legend { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--text-xs); }
.confidence-legend i { width: 7px; height: 7px; border-radius: 50%; margin-left: 5px; }

.ocr-line-table table { min-width: 860px; }
.ocr-line-table td { padding: 7px 5px; vertical-align: top; }
.ocr-line-table td:first-child { color: var(--muted); font-weight: var(--weight-bold); }
.ocr-line-table td.needs-review { border-radius: 8px; }
.ocr-line-table td label { display: grid; gap: 4px; }
.ocr-line-filter-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-3) 0; }
.ocr-line-list-header,
.ocr-line-summary {
  display: grid;
  grid-template-columns: 32px minmax(110px, 2fr) minmax(72px, 1fr) repeat(2, 46px) repeat(2, 64px) 86px 34px;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.ocr-line-list-header.prices-hidden,
.ocr-line-table.prices-hidden .ocr-line-summary { grid-template-columns: 32px minmax(140px, 2fr) minmax(90px, 1fr) repeat(2, 52px) 86px 34px; }
.ocr-line-list-header {
  position: sticky;
  top: 70px;
  z-index: 4;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-2xs);
  font-weight: var(--weight-black);
}
.ocr-product-lines { display: grid; gap: 5px; margin-top: 5px; }
.ocr-product-line { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ocr-product-line.is-expanded { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ocr-line-summary { min-height: 56px; padding: 6px 10px; }
.ocr-line-summary-number { color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-black); }
.ocr-line-summary-product,
.ocr-line-summary-sku { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocr-line-summary-product { color: var(--ink); font-size: var(--text-sm); }
.ocr-line-summary-sku { color: var(--muted); font-size: var(--text-xs); }
.ocr-line-qty-summary,
.ocr-line-price-summary { display: contents; }
.ocr-line-qty-summary > span,
.ocr-line-price-summary > span { min-width: 0; color: var(--ink); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.ocr-line-summary small { display: none; color: var(--muted); font-size: var(--text-2xs); font-weight: var(--weight-bold); }
.ocr-line-status { justify-self: start; border-radius: 999px; padding: 4px 7px; font-size: var(--text-2xs); font-weight: var(--weight-black); white-space: nowrap; }
.ocr-line-status.ok { color: var(--status-success); background: var(--status-success-bg); }
.ocr-line-status.needs-review { color: var(--status-warning); background: var(--status-warning-bg); }
.ocr-line-status.flagged { color: var(--status-danger); background: var(--status-danger-bg); }
.ocr-line-expand { width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; }
.ocr-line-expand span { display: block; font-size: 18px; transition: transform .15s ease; }
.ocr-line-expand[aria-expanded="true"] span { transform: rotate(180deg); }
.ocr-line-expand:focus-visible { outline: 3px solid rgba(21,93,255,.22); outline-offset: 2px; }
.ocr-line-expanded { padding: 10px; border-top: 1px solid var(--line); background: var(--surface-2); }
.ocr-line-expanded-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.ocr-line-essential-grid { display: grid; grid-template-columns: repeat(4, minmax(125px, 1fr)); gap: 7px; }
.ocr-line-field { display: grid; gap: 4px; padding: 6px; border: 1px solid transparent; border-radius: 10px; }
.ocr-line-field > span { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.ocr-line-field input,
.ocr-product-match select { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: #fff; }
.ocr-line-field.needs-review { border-color: #dcad65; background: #fff8e9; }
.ocr-product-match { display: grid; grid-template-columns: auto minmax(180px, 1fr) minmax(210px, .8fr); align-items: center; gap: 7px 12px; padding: 9px 10px; border-radius: 12px; }
.ocr-product-match.warning { border: 1px solid #dcad65; background: #fff8e9; }
.ocr-product-match.clear { color: #245d42; background: #edf7f0; }
.ocr-product-match span { color: var(--muted); font-size: var(--text-xs); }
.ocr-line-details { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.ocr-line-details summary { min-height: 36px; cursor: pointer; color: var(--brand-2); font-weight: var(--weight-bold); }
.ocr-line-details:not([open]) > .ocr-line-detail-grid { display: none; }
.ocr-raw-description { display: grid; gap: 3px; margin-top: 7px; padding: 8px 10px; border-radius: 10px; background: #f1f3ef; }
.ocr-raw-description span { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.ocr-line-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: 7px; margin-top: 6px; }
.ocr-line-filter-empty { padding: 16px; min-height: 0; }

.ocr-conflict-card { padding: 14px; border: 1px solid #df9e97; border-radius: 14px; background: linear-gradient(120deg, #fff4f2, #fff); }
.ocr-conflict-card p { margin: 3px 0 10px; color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.ocr-conflict-card > div { display: flex; gap: 8px; flex-wrap: wrap; }
.ocr-validation-list { display: grid; gap: 8px; }
.ocr-validation-list > label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ocr-validation-list > label:last-child { border-bottom: 0; }
.ocr-validation-list span,
.ocr-validation-list small { display: block; }
.ocr-validation-list small { color: var(--muted); }
.ocr-ack { display: flex; align-items: center !important; gap: 9px; font-weight: var(--weight-semibold); }
.ocr-ack input { width: 18px; height: 18px; accent-color: var(--brand-2); }
.ocr-duplicate-warning { border: 1px solid #d88f86; background: #fff7f4; }
.ocr-duplicate-warning h3 { color: #85342e; }
.ocr-duplicate-warning > div { display: flex; gap: 8px; flex-wrap: wrap; }
.ocr-duplicate-warning .selected { color: #fff; background: var(--brand); }
.ocr-confirm-panel { border-color: #b8cdc5; background: linear-gradient(135deg, #f7fbf9, #fff); }
.ocr-repeat-invoice-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; padding: 16px 18px; border-style: dashed; background: #fbfcfe; box-shadow: none; }
.ocr-repeat-invoice-action p { margin: 4px 0 0; color: var(--muted); }
.ocr-manual-fallback { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 12px 0 2px; color: var(--muted); }

/* C1F: durable Possible Item Rows section. */
.ocr-row-census.warn { border-color: #e0c27a; background: #fffaf0; }
.ocr-row-census.danger { border-color: #d88f86; background: #fff7f4; }
.ocr-row-census.danger h3 { color: var(--danger); }
.ocr-census-rows { display: grid; gap: 10px; margin-top: 12px; }
.ocr-census-row { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ocr-census-row.resolved { background: var(--surface-2); }
.ocr-census-row > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ocr-census-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ocr-census-attach-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ocr-census-target { min-width: 0; flex: 1 1 200px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: var(--text-xs); }
.ocr-census-restricted { color: var(--muted); font-style: italic; }
.ocr-no-item-confirmed { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; color: var(--ok); font-weight: var(--weight-semibold); }

@media (max-width: 940px) {
  .ocr-review-grid { grid-template-columns: 1fr; }
  .ocr-review-grid.original-collapsed { grid-template-columns: 1fr; }
  .ocr-preview-pane { position: static; }
  .ocr-preview-pane.is-collapsed .ocr-preview-header { align-items: center; flex-direction: row; }
  .ocr-preview-canvas { height: 40vh; min-height: 250px; max-height: 380px; }
  .ocr-line-essential-grid { grid-template-columns: repeat(2, minmax(125px, 1fr)); }
  .ocr-product-match { grid-template-columns: 1fr; }
  /* Row-census action buttons stack full-width on narrow viewports, and gain
     extra vertical padding so each tap target clears a comfortable ~40px --
     scoped to these buttons only, not a change to .btn.mini everywhere else. */
  .ocr-census-row-actions { flex-direction: column; align-items: stretch; }
  .ocr-census-row-actions .btn { width: 100%; padding-top: 10px; padding-bottom: 10px; }
  .ocr-census-attach-row { flex-direction: column; align-items: stretch; }
  .ocr-census-attach-row .btn,
  .ocr-census-target { padding-top: 10px; padding-bottom: 10px; }
}

@media (max-width: 640px) {
  .ocr-scan-hero,
  .ocr-review-head { align-items: flex-start; flex-direction: column; padding: 23px; }
  .ocr-usage-unit,
  .ocr-confidence-score { width: 100%; flex-basis: auto; text-align: left; }
  .ocr-drop-panel { min-height: 270px; padding: 22px 14px; }
  .ocr-upload-file { grid-template-columns: 30px minmax(0, 1fr); }
  .ocr-file-actions { grid-column: 2; flex-wrap: wrap; }
  .ocr-header-fields { grid-template-columns: 1fr; }
  .ocr-review-grid { gap: 12px; }
  .ocr-review-form .panel { padding: 14px; }
  .ocr-line-list-header { display: none; }
  .ocr-line-summary,
  .ocr-line-table.prices-hidden .ocr-line-summary {
    grid-template-columns: 28px repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "number product product product expand"
      ". sku sku status status";
    gap: 5px 8px;
    min-height: 0;
    padding: 10px;
  }
  .ocr-line-table.prices-hidden .ocr-line-summary {
    grid-template-areas:
      "number product product product expand"
      ". sku sku status status";
  }
  .ocr-line-summary-number { grid-area: number; align-self: start; padding-top: 2px; }
  .ocr-line-summary-product { grid-area: product; }
  .ocr-line-summary-sku { grid-area: sku; }
  .ocr-line-qty-summary,
  .ocr-line-price-summary { display: contents; }
  .ocr-line-qty-summary > span,
  .ocr-line-price-summary > span { grid-row: 3; min-width: 0; }
  .ocr-line-qty-summary > span:nth-child(1) { grid-column: 2; }
  .ocr-line-qty-summary > span:nth-child(2) { grid-column: 3; }
  .ocr-line-price-summary > span:nth-child(1) { grid-column: 4; }
  .ocr-line-price-summary > span:nth-child(2) { grid-column: 5; }
  .ocr-line-table.prices-hidden .ocr-line-qty-summary > span:nth-child(1) { grid-column: 2 / 4; }
  .ocr-line-table.prices-hidden .ocr-line-qty-summary > span:nth-child(2) { grid-column: 4 / 6; }
  .ocr-line-summary small { display: block; margin-bottom: 2px; }
  .ocr-line-status { grid-area: status; }
  .ocr-line-expand { grid-area: expand; }
  .ocr-line-expanded { padding: 10px; }
  .ocr-line-essential-grid,
  .ocr-line-detail-grid { grid-template-columns: 1fr; }
  .ocr-manual-fallback { flex-direction: column; }
}

/* V5.1 authenticated session bootstrap */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at top, rgba(73, 94, 255, .16), transparent 38%), #f5f7fb; }
.auth-card { width: min(520px, 100%); background: #fff; border: 1px solid rgba(20, 29, 48, .1); border-radius: 24px; padding: 30px; box-shadow: 0 24px 80px rgba(31, 42, 68, .15); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-brand img { width: 48px; height: 48px; object-fit: contain; }
.auth-brand h1 { margin: 0; font-size: 1.6rem; }
.auth-brand p { margin: 2px 0 0; font-size: .74rem; letter-spacing: .12em; color: var(--muted, #667085); }
.auth-copy h2 { margin: 6px 0 10px; }
.auth-form { display: grid; gap: 16px; margin-top: 22px; }
.auth-form label { display: grid; gap: 7px; font-weight: 700; }
.auth-form input { width: 100%; }
.auth-error { margin: 16px 0; padding: 12px 14px; border-radius: 12px; background: #fff1f0; color: #9f1c18; border: 1px solid #ffd1ce; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.auth-loading { text-align: center; }
.auth-spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid #d9deea; border-top-color: #5965ff; border-radius: 50%; animation: auth-spin .8s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-org-list { display: grid; gap: 10px; margin: 20px 0; }
.auth-org-choice { display: flex; justify-content: space-between; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; border-radius: 14px; border: 1px solid #dce1ec; background: #fff; text-align: left; cursor: pointer; }
.auth-org-choice:hover, .auth-org-choice:focus-visible { border-color: #5965ff; box-shadow: 0 0 0 3px rgba(89, 101, 255, .12); }
.auth-org-choice span { text-transform: capitalize; color: var(--muted, #667085); }
.auth-context-pill { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.auth-context-pill span { display: grid; text-align: right; }
.auth-context-pill em { font-style: normal; text-transform: capitalize; font-size: .76rem; color: var(--muted, #667085); }
@media (max-width: 680px) { .auth-shell { padding: 16px; } .auth-card { padding: 22px; border-radius: 18px; } .auth-context-pill { width: 100%; justify-content: flex-end; margin-top: 12px; } }

/* V5.1 final review preview, confirm gate, and fixed-navigation clearance */
.ocr-confirm-requirements {
  margin: 8px 0 2px;
  padding: 10px 12px;
  border: 1px solid #f4c978;
  border-radius: 12px;
  color: #7a4b00;
  background: #fff6e8;
  font-size: .86rem;
  font-weight: 750;
  line-height: 1.4;
}
.ocr-confirm-requirements.ready {
  color: #17633f;
  border-color: #a9d9c1;
  background: #eaf8f1;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .46;
  filter: saturate(.35);
  box-shadow: none;
  transform: none;
}
.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  box-shadow: none;
  transform: none;
}

@media (max-width: 720px) {
  :root {
    --mobile-fixed-nav-height: 56px;
    --mobile-fixed-nav-clearance: calc(var(--mobile-fixed-nav-height) + 20px + env(safe-area-inset-bottom));
  }
  html,
  body {
    scroll-padding-bottom: var(--mobile-fixed-nav-clearance);
  }
  .app-shell {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: var(--mobile-fixed-nav-clearance);
    padding-left: max(10px, env(safe-area-inset-left));
    scroll-padding-bottom: var(--mobile-fixed-nav-clearance);
  }
  .workflow-nav.nav {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    top: auto;
    min-height: var(--mobile-fixed-nav-height);
    z-index: 90;
    margin: 0;
    gap: 2px;
    justify-content: space-between;
    overflow: hidden;
  }
  .workflow-nav .tab {
    min-width: 0;
    flex: 1 1 0;
    padding: 10px 2px;
    font-size: 10px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .ocr-file-queue,
  #ocrStartScan,
  .ocr-repeat-invoice-action,
  .ocr-confirm-panel,
  .invoices-panel,
  .followup-panel,
  .record-list,
  .record:last-child,
  .record-actions {
    scroll-margin-bottom: var(--mobile-fixed-nav-clearance);
  }
  .record-list {
    scroll-padding-bottom: var(--mobile-fixed-nav-clearance);
  }
  .ocr-repeat-invoice-action { align-items: stretch; flex-direction: column; }
}

@media (max-width: 430px) {
  .ocr-preview-canvas { height: 38vh; min-height: 230px; max-height: 340px; }
  .ocr-preview-toolbar { justify-content: flex-start; }
}

/* V5.1 More destination secondary navigation */
.more-tool-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 6px;
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.more-tool-tab {
  padding: 8px 12px;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 12.5px;
}
.more-tool-tab:hover { background: #fff; color: var(--ink); border-color: var(--line); }
.more-tool-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.more-tool-tab.more-tool-root { color: var(--muted); font-weight: 900; }
.more-tool-tab.more-tool-root::after { content: '›'; margin-left: 6px; }

/* C2 — durable Page / Document Integrity review */
.ocr-document-integrity.warn { border-color: color-mix(in srgb, var(--warning, #b7791f) 45%, transparent); }
.ocr-document-integrity.danger { border-color: color-mix(in srgb, var(--danger, #b42318) 50%, transparent); }
.ocr-doc-issues { display: grid; gap: 8px; margin-top: 12px; }
.ocr-doc-issues p { margin: 0; line-height: 1.45; }
.ocr-doc-actions { align-items: center; flex-wrap: wrap; margin-top: 14px; }
.ocr-doc-decision-ok { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; }
.ocr-doc-recovery { margin-top: 12px; font-weight: 600; }
.ocr-page-recovery { max-width: 100%; min-width: 0; overflow: hidden; }
.ocr-recovery-preview { display: grid; gap: 8px; width: 100%; min-width: 0; margin-top: 12px; }
.ocr-recovery-preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 48vh;
  min-height: 240px;
  max-height: 560px;
  overflow: hidden;
  border-radius: 13px;
  background: #26302d;
}
.ocr-recovery-preview-stage img { position: absolute; inset: 0; display: block; width: 100%; max-width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.ocr-recovery-preview p { margin: 0; overflow-wrap: anywhere; }

/* C2 mobile: page-review actions must remain comfortable touch targets. */
@media (max-width: 940px) {
  .ocr-recovery-preview-stage { height: 38vh; min-height: 200px; max-height: 360px; }
  .ocr-doc-actions .btn {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* Business Slice 1 — Invoice Detail + Receiving */
.invoice-detail-modal .receiving-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.invoice-detail-modal .receiving-table th,
.invoice-detail-modal .receiving-table td { padding: 6px 8px; border-bottom: 1px solid var(--line, #e5e7eb); text-align: left; vertical-align: top; }
.invoice-detail-modal .receiving-table th.num,
.invoice-detail-modal .receiving-table td.num { text-align: right; white-space: nowrap; }
.invoice-detail-modal .receiving-table tr.muted-row td { color: var(--muted, #6b7280); }
.invoice-detail-modal .muted { color: var(--muted, #6b7280); }
.invoice-detail-modal .receiving-input { width: 84px; padding: 6px 8px; text-align: right; border: 1px solid var(--line, #cbd5e1); border-radius: 6px; }
.invoice-detail-modal textarea#receivingNotes { width: 100%; min-height: 64px; margin-top: 4px; }
