:root {
  --ink-950: #172033;
  --ink-800: #25324a;
  --ink-700: #394760;
  --ink-600: #59667b;
  --ink-500: #758196;
  --line-strong: #cbd3df;
  --line: #dfe4ec;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --canvas: #f2f4f7;
  --sidebar: #111d31;
  --sidebar-soft: #1c2b45;
  --blue-700: #1558c0;
  --blue-600: #2468d8;
  --blue-100: #e8f0ff;
  --amber-800: #8a4b0f;
  --amber-100: #fff2cf;
  --green-800: #17603b;
  --green-100: #dcf7e8;
  --red-700: #ad2d27;
  --red-100: #ffe9e7;
  --shadow-sm: 0 1px 2px rgb(23 32 51 / 5%);
  --shadow-panel: 0 6px 22px rgb(23 32 51 / 5%);
  --radius-sm: 8px;
  --radius: 12px;
  --sidebar-width: 232px;
}

.bom-upload-form { max-width: 900px; padding: 24px; }
.bom-upload-form .action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.bom-mode { margin: 0; padding: 0; border: 0; }
.bom-mode legend { margin-bottom: 8px; font-weight: 650; }
.bom-mode #id_mode { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.bom-mode label, .bom-replace-confirm label { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.bom-mode input, .bom-replace-confirm input { flex: 0 0 18px; width: 18px; min-height: 18px; height: 18px; }
.bom-mode-help { margin: 12px 0 22px; padding: 12px 16px; background: var(--surface-soft); border-radius: var(--radius-sm); }
.bom-mode-help p { margin: 4px 0; font-size: 14px; }
.bom-help, .bom-empty { color: var(--ink-600); font-size: 13px; overflow-wrap: anywhere; }
.bom-replace-confirm { margin: 16px 0; padding: 12px; background: var(--amber-100); border-radius: var(--radius-sm); font-size: 14px; }
.bom-upload-feedback { margin: 12px 0; color: var(--ink-700); }
.bom-upload-progress { width: 100%; height: 12px; margin-bottom: 16px; accent-color: var(--blue-600); }
.bom-current, .bom-job { margin-bottom: 24px; }
.bom-warning { padding: 10px 14px; border: 1px solid #e9d9ae; border-radius: var(--radius-sm); background: #fff8e9; color: var(--amber-800); font-size: 13px; overflow-wrap: anywhere; }
.bom-warning span { display: block; margin-top: 4px; }
.bom-product-count { margin: 0 0 8px; color: var(--ink-600); font-size: 12px; }
.bom-product-scroll { max-height: 320px; overflow: auto; overscroll-behavior: contain; }
.bom-product-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.bom-product-list li { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 12px; overflow-wrap: anywhere; }
.bom-product-list li > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.bom-product-list strong { color: var(--ink-800); font-size: 13px; font-variant-numeric: tabular-nums; }
.bom-kind { display: inline-flex; padding: 1px 6px; border-radius: 4px; background: var(--blue-100); color: var(--blue-700); font-size: 11px; }
.bom-product-list li > span { color: var(--ink-600); }
.bom-products-compact { width: 270px; max-width: 100%; white-space: normal; }
.bom-products-compact .bom-product-scroll { max-height: 160px; }
.bom-products-compact .bom-product-list { grid-template-columns: 1fr; gap: 6px; }
.bom-products-compact .bom-product-list li { padding: 6px 8px; }
.workbench-table .bom-empty { min-width: 190px; max-width: 260px; white-space: normal; margin: 0; }
.bom-detail-panel { margin-bottom: 24px; }
.bom-source-list { margin: 0; padding: 0; list-style: none; }
.bom-source-list li { display: flex; justify-content: space-between; align-items: start; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.bom-source-list li > div { min-width: 0; }
.bom-source-list small { display: block; color: var(--ink-600); }
.bom-source-list summary { display: flex; align-items: center; min-height: 44px; font-size: 12px; color: var(--ink-600); }
.bom-filename { overflow-wrap: anywhere; }
@media (max-width: 1023px) {
  .bom-product-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  .bom-product-list { grid-template-columns: 1fr; }
  .bom-upload-form { padding: 16px; }
  .bom-source-list li { flex-direction: column; gap: 8px; }
  .bom-mode #id_mode { display: block; }
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  color: var(--ink-950);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink-950);
  background: var(--canvas);
  font-size: 16px;
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--blue-700);
  text-underline-offset: 3px;
}

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

button,
.button,
input,
select {
  min-height: 44px;
}

button,
.button,
summary,
a[href] {
  cursor: pointer;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 3px solid #75a7ff;
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--sidebar);
  transform: translateY(-160%);
}

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

.app-frame,
.app-workspace {
  min-width: 0;
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: min(84vw, 272px);
  padding: 18px 14px;
  color: #eef4ff;
  background: var(--sidebar);
  box-shadow: 20px 0 48px rgb(5 15 31 / 24%);
  transform: translateX(-102%);
  transition: transform 200ms ease;
}

.app-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 54px;
  padding: 4px 10px 16px;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  color: #fff;
  text-decoration: none;
}

.sidebar-brand img {
  width: auto;
  height: 36px;
  object-fit: contain;
}

.sidebar-brand span,
.sidebar-brand small,
.account-copy {
  display: grid;
}

.sidebar-brand strong {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.sidebar-brand small {
  color: #99aac4;
  font-size: 11px;
  letter-spacing: 0.14em;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

.nav-section-label {
  margin: 12px 10px 5px;
  color: #71839f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.sidebar-nav a {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: #bdc9da;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgb(255 255 255 / 6%);
}

.sidebar-nav a[aria-current="page"] {
  color: #fff;
  background: var(--sidebar-soft);
  box-shadow: inset 3px 0 0 #6aa1ff;
}

.sidebar-nav svg,
.account-logout svg,
.nav-toggle svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-account {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 14px 4px 0;
  border-top: 1px solid rgb(255 255 255 / 10%);
}

.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #dbe8ff;
  background: #294263;
  font-size: 14px;
  font-weight: 800;
}

.account-copy {
  min-width: 0;
}

.account-copy strong,
.account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  color: #fff;
  font-size: 13px;
}

.account-copy small {
  color: #8fa0b9;
  font-size: 11px;
}

.account-logout {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: #aab8cc;
}

.account-logout:hover {
  color: #fff;
  background: rgb(255 255 255 / 7%);
}

.nav-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: rgb(8 17 31 / 48%);
  opacity: 0;
}

.nav-backdrop.is-visible {
  display: block;
  opacity: 1;
}

.app-topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.nav-toggle {
  display: grid;
  width: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  background: var(--surface);
}

.topbar-brand {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  color: var(--ink-950);
  text-decoration: none;
}

.topbar-brand img {
  width: auto;
  height: 30px;
  object-fit: contain;
}

.topbar-brand strong {
  font-size: 15px;
}

.app-topbar > p,
.topbar-user {
  display: none;
}

.page-shell {
  width: min(calc(100% - 32px), 1480px);
  margin: 0 auto;
  padding: 24px 0 56px;
}

.page-shell.narrow {
  max-width: 800px;
}

.page-heading {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

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

.page-heading h1 {
  margin: 1px 0 4px;
  color: var(--ink-950);
  font-size: clamp(27px, 5vw, 36px);
  line-height: 1.22;
  letter-spacing: -0.025em;
}

.page-heading p {
  max-width: 760px;
  margin: 0;
  color: var(--ink-600);
}

.eyebrow {
  color: var(--blue-700) !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.button-primary {
  color: #fff;
  background: var(--blue-600);
  box-shadow: 0 1px 2px rgb(21 88 192 / 20%);
}

.button-primary:hover {
  background: var(--blue-700);
}

.button-secondary {
  border-color: var(--line-strong);
  color: var(--ink-700);
  background: var(--surface);
}

.button-secondary:hover {
  border-color: #9aa7b8;
  color: var(--ink-950);
  background: var(--surface-soft);
}

.button-danger {
  border-color: #efb4b0;
  color: var(--red-700);
  background: var(--surface);
}

.button-danger:hover {
  background: var(--red-100);
}

.button-small {
  min-height: 44px;
  padding: 6px 11px;
  font-size: 13px;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page-heading > .button,
.page-actions .button {
  width: 100%;
}

.panel,
.workbench-summary,
.summary-strip,
.workbench-controls,
.records-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.panel {
  padding: 20px;
}

.panel + .panel,
.panel + .case-exceptions,
.records-section + .panel,
.auxiliary-panel {
  margin-top: 16px;
}

.flush-panel {
  padding: 0;
  overflow: hidden;
}

.panel h2,
.section-heading h2,
.panel-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.panel > p,
.section-heading p,
.panel-heading p,
.section-intro {
  color: var(--ink-600);
}

.workbench-summary,
.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 16px;
  overflow: hidden;
}

.workbench-summary > div,
.summary-strip > div {
  min-width: 0;
  padding: 13px 15px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

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

.workbench-summary > div:last-child {
  grid-column: 1 / -1;
  border-bottom: 0;
}

.workbench-summary dt,
.summary-strip dt,
.summary-strip small {
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 650;
}

.workbench-summary dd,
.summary-strip dd {
  margin: 2px 0 0;
  color: var(--ink-950);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.workbench-summary dd small {
  color: var(--ink-500);
  font-size: 12px;
}

.workbench-summary .needs-action dd {
  color: var(--amber-800);
}

.month-analysis-summary {
  grid-template-columns: 1fr;
}

.month-analysis-summary > div {
  border-right: 0;
}

.month-analysis-summary > div:last-child {
  border-bottom: 0;
}

.month-analysis-summary .needs-action dd {
  color: var(--amber-800);
}

.summary-strip small {
  display: block;
  margin-top: 2px;
  font-weight: 400;
}

.view-tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.view-tabs a {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 12px 8px;
  border-bottom: 2px solid transparent;
  color: var(--ink-600);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.view-tabs a:hover {
  color: var(--ink-950);
  background: var(--surface-soft);
}

.view-tabs a[aria-current="page"] {
  border-bottom-color: var(--blue-600);
  color: var(--blue-700);
}

.status-view-description {
  margin: 8px 4px 12px;
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.5;
}

.workbench-controls {
  margin-bottom: 16px;
  padding: 16px;
}

.control-label {
  margin: 0 0 10px;
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.quick-filters,
.search-toolbar,
.advanced-filter-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.advanced-filters {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.advanced-filters summary,
.auxiliary-panel > summary,
.record-details summary,
.form-drawer summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--blue-700);
  font-size: 14px;
  font-weight: 750;
}

.advanced-filters summary::after,
.auxiliary-panel > summary::after,
.record-details summary::after,
.form-drawer summary::after {
  margin-left: auto;
  color: var(--ink-500);
  content: "+";
  font-size: 18px;
  line-height: 1;
}

.advanced-filters[open] > summary::after,
.auxiliary-panel[open] > summary::after,
.record-details[open] > summary::after,
.form-drawer[open] > summary::after {
  content: "−";
}

.advanced-filter-grid {
  padding-top: 10px;
}

.field {
  min-width: 0;
  margin-bottom: 18px;
}

.field.compact,
.stack-form > div,
.exception-card form > div,
.form-drawer form > div {
  margin: 0;
}

.field label,
form > div > label,
.stack-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #aeb8c6;
  border-radius: var(--radius-sm);
  color: var(--ink-950);
  background: var(--surface);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #8491a5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgb(36 104 216 / 13%);
}

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

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  margin: 0 8px 0 0;
  vertical-align: middle;
  accent-color: var(--blue-600);
}

input[type="file"] {
  padding: 12px;
  border-style: dashed;
  background: var(--surface-soft);
}

.help,
.helptext,
small {
  color: var(--ink-600);
  font-size: 12px;
}

.field-error,
.errorlist,
.form-help {
  color: var(--red-700);
  font-weight: 650;
}

.errorlist {
  margin: 6px 0;
  padding-left: 20px;
}

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

.records-section {
  padding: 0;
  overflow: hidden;
}

.section-heading,
.panel-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-heading {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  margin-bottom: 16px;
}

.section-heading p,
.panel-heading p {
  margin: 3px 0 0;
  font-size: 13px;
}

.desktop-records {
  display: none;
}

.mobile-records {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.record-card,
.person-card,
.batch-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.record-card > header,
.person-card > header,
.batch-card > header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.record-card header > div,
.person-card header > div,
.batch-card header > div {
  min-width: 0;
}

.record-card header a,
.record-card header strong,
.person-card header strong,
.batch-card header strong {
  display: block;
  color: var(--ink-950);
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.record-card header a {
  display: flex;
  min-height: 44px;
  align-items: center;
}

.record-card header p,
.person-card header small,
.batch-card header small {
  display: block;
  margin: 3px 0 0;
  color: var(--ink-600);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.record-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line);
}

.record-metrics > div {
  min-width: 0;
  padding: 9px 10px;
  background: var(--surface-soft);
}

.record-metrics dt {
  color: var(--ink-600);
  font-size: 11px;
}

.record-metrics dd {
  margin: 1px 0 0;
  color: var(--ink-950);
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.batch-card .record-metrics > div:last-child {
  grid-column: 1 / -1;
}

.batch-card .record-metrics > div:last-child dd {
  font-size: 15px;
}

.record-details {
  border-top: 1px solid var(--line);
}

.record-details > dl,
.person-card > dl {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 4px 0 12px;
}

.person-card > dl {
  margin: 14px 0;
}

.record-details dt,
.person-card dt {
  color: var(--ink-600);
  font-size: 12px;
}

.record-details dd,
.person-card dd {
  margin: 0;
  color: var(--ink-800);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.record-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--blue-700);
  background: var(--surface);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

.record-action:hover {
  border-color: #9cadc2;
  background: var(--blue-100);
}

.batch-actions {
  display: grid;
  min-width: 180px;
  gap: 8px;
}

.batch-void-control {
  position: relative;
}

.batch-void-control > summary {
  list-style: none;
  cursor: pointer;
}

.batch-void-control > summary::-webkit-details-marker {
  display: none;
}

.batch-void-control > form {
  display: grid;
  min-width: min(320px, calc(100vw - 48px));
  gap: 10px;
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #efc3c0;
  border-radius: 10px;
  background: #fffafa;
}

.batch-void-control p {
  margin: 0;
  color: var(--ink-600);
  font-size: 12px;
}

.batch-void-control label:not(.confirmation-check) {
  font-size: 13px;
  font-weight: 750;
}

.confirmation-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--ink-700);
  font-size: 12px;
}

.confirmation-check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
}

.danger-action {
  color: #a32e29;
}

.void-audit {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: #7f2824;
  background: #fff0ef;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-wrap:focus-visible {
  outline-offset: -3px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink-800);
  font-size: 13px;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  z-index: 3;
  top: 0;
  color: var(--ink-600);
  background: #f3f5f8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8faff;
}

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

td a {
  font-weight: 750;
}

td small,
.cell-stack {
  display: grid;
  gap: 2px;
}

.workbench-table {
  min-width: 1120px;
  table-layout: auto;
}

.history-table {
  min-width: 1300px;
}

.workbench-table th,
.workbench-table td,
.history-table th,
.history-table td {
  white-space: nowrap;
}

.workbench-table th:first-child,
.workbench-table td:first-child {
  width: 64px;
}

.workbench-table th:nth-child(2),
.workbench-table td:nth-child(2) {
  width: 160px;
  min-width: 160px;
  white-space: normal;
}

.workbench-table th:first-child,
.workbench-table td:first-child {
  position: sticky;
  z-index: 2;
  left: 0;
  background: var(--surface);
}

.workbench-table th:first-child {
  z-index: 5;
  background: #f3f5f8;
}

.workbench-table th:nth-child(2),
.workbench-table td:nth-child(2) {
  position: sticky;
  z-index: 2;
  left: 64px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}

.column-settings {
  margin-bottom: 16px;
  padding: 0;
  overflow: hidden;
}

.column-settings > summary {
  display: flex;
  min-height: 52px;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--ink-800);
  font-weight: 800;
}

.column-settings > summary small {
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
}

.column-settings[open] > summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.column-settings form {
  padding: 16px;
}

.column-settings fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.column-settings legend {
  margin-bottom: 10px;
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 800;
}

.column-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.column-option {
  display: flex;
  min-height: 44px;
  padding: 8px 10px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.column-option:hover {
  border-color: #8db2ef;
  background: var(--blue-100);
}

.column-option input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
}

.column-settings-actions {
  display: flex;
  margin-top: 14px;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.column-settings-actions small {
  color: var(--ink-500);
}

.workbench-table th:nth-child(2) {
  z-index: 5;
  background: #f3f5f8;
}

.history-table .hash-value {
  min-width: 290px;
  white-space: normal;
}

.allocation-line {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink-700);
  background: #edf0f4;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.warning,
.badge.pending {
  color: var(--amber-800);
  background: var(--amber-100);
}

.badge.success,
.badge.active {
  color: var(--green-800);
  background: var(--green-100);
}

.badge.danger,
.badge.inactive {
  color: var(--red-700);
  background: var(--red-100);
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  color: var(--ink-600);
  font-size: 13px;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
}

.empty-state {
  padding: 36px 20px;
  color: var(--ink-600);
  text-align: center;
}

.empty-state h2 {
  color: var(--ink-950);
}

.messages {
  width: min(calc(100% - 32px), 1480px);
  margin: 16px auto 0;
}

.message {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid #9bd9b7;
  border-radius: var(--radius-sm);
  color: var(--green-800);
  background: var(--green-100);
}

.message.error {
  border-color: #efb4b0;
  color: var(--red-700);
  background: var(--red-100);
}

.auxiliary-panel {
  padding: 10px 18px 16px;
  box-shadow: none;
}

.auxiliary-panel > summary {
  color: var(--ink-700);
}

.auxiliary-panel > p {
  margin-top: 0;
  font-size: 13px;
}

.inline-facts,
dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 14px;
}

dt {
  color: var(--ink-600);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-grid,
.analysis-workspace,
.settings-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

.financial-facts {
  margin-bottom: 16px;
}

.all-source-fields {
  margin-top: 16px;
  min-width: 0;
}

.source-fields-heading h2 {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.source-fields-heading h2 span,
.source-field-group > header span {
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 650;
}

.source-field-groups {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.source-field-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.source-field-group > header {
  display: flex;
  min-height: 28px;
  padding: 4px 8px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #f4f6fa;
}

.source-field-group h3 {
  margin: 0;
  color: var(--ink-900);
  font-size: 14px;
}

.all-source-field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0;
  background: var(--surface);
}

.all-source-field-grid > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  min-height: 32px;
  padding: 5px 8px;
  align-items: start;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.all-source-field-grid dt {
  margin: 0;
  color: var(--ink-600);
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.all-source-field-grid dd {
  margin: 0;
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.all-source-field-grid dt small {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--blue-700);
  background: var(--blue-100);
  font-size: 10px;
  font-weight: 750;
}

.source-value-unavailable {
  color: var(--warning-ink, #8a4b0f) !important;
}

.correction-evidence {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #b9cff7;
  border-radius: 10px;
  background: var(--blue-100);
}

.correction-evidence strong {
  color: var(--blue-700);
}

.correction-evidence p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.financial-facts > dl:not(.facts-grid) {
  grid-template-columns: 120px minmax(0, 1fr);
}

.facts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 2px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.facts-grid > div {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.facts-grid > div:last-child {
  border-bottom: 0;
}

.facts-grid dt {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 650;
}

.facts-grid dd {
  color: var(--ink-950);
  font-size: 14px;
  font-weight: 700;
}

.analysis-workspace {
  grid-template-columns: 1fr;
}

.analysis-column,
.analysis-panel,
.exception-sidebar {
  min-width: 0;
}

.hash-value {
  max-width: 420px;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.financial-facts .hash-value {
  display: block;
  margin-top: 3px;
}

.analysis-card,
.exception-card {
  margin-top: 14px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.analysis-card:first-of-type,
.exception-card:first-of-type {
  margin-top: 0;
}

.analysis-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.analysis-heading h3 {
  margin: 0;
  font-size: 16px;
}

.quantity-origin {
  margin: 12px 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--blue-700);
  background: var(--blue-100);
  font-size: 13px;
  font-weight: 750;
}

.allocation-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line);
}

.allocation-summary > div {
  min-width: 0;
  padding: 9px 10px;
  background: var(--blue-100);
}

.allocation-summary dt {
  color: var(--ink-600);
  font-size: 11px;
}

.allocation-summary dd {
  color: var(--blue-700);
  font-size: 15px;
  font-weight: 800;
}

.reason-quantity-summary {
  grid-template-columns: minmax(0, 220px);
}

.quantity-history-panel {
  margin-top: 16px;
}

.monthly-source-panel {
  margin: 0 0 16px;
}

.monthly-source-table {
  min-width: 1680px;
}

.monthly-source-table td:first-child strong,
.monthly-source-table td:first-child small {
  display: block;
}

.monthly-source-table td:first-child small {
  margin-top: 3px;
}

.monthly-source-table .selected-source-row td {
  background: var(--blue-100);
}

.monthly-source-table .selected-source-row td:first-child {
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.current-selection {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 800;
}

.quantity-history-cards {
  padding: 0;
}

.quantity-history-cards .record-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.monthly-source-cards .selected-source-card {
  border-color: #8db2ef;
  background: var(--blue-100);
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.monthly-source-cards .record-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.monthly-source-cards .record-metrics > div:last-child {
  grid-column: 1 / -1;
}

.monthly-source-cards .month-select-link {
  width: 100%;
}

.analysis-facts {
  grid-template-columns: 120px minmax(0, 1fr);
}

.exception-heading {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.exception-card form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.dimension-correction-intro {
  margin-top: 13px;
  padding: 12px 13px;
  border-left: 3px solid var(--blue-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--blue-100);
}

.dimension-correction-intro strong {
  color: var(--blue-700);
}

.dimension-correction-intro p {
  margin: 5px 0;
  font-size: 14px;
}

.dimension-correction-form select {
  text-overflow: ellipsis;
}

.dimension-readonly-values {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.dimension-readonly-values > strong {
  color: var(--ink-950);
  font-size: 13px;
}

.dimension-readonly-values dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 9px;
}

.dimension-readonly-values dt {
  color: var(--ink-600);
  font-size: 12px;
}

.dimension-readonly-values dd {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--ink-950);
  font-size: 14px;
  font-weight: 750;
}

.missing-dimension-fields {
  display: grid;
  gap: 12px;
}

.dimension-suggestions {
  border-top: 1px solid var(--line);
}

.dimension-suggestions summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--blue-700);
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}

.dimension-suggestions > p {
  margin: 0 0 12px;
  color: var(--ink-600);
  font-size: 13px;
}

@media (max-width: 479px) {
  .dimension-readonly-values dl {
    grid-template-columns: 1fr;
  }
}

.resolution-note {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--green-100);
}

.resolution-note p {
  margin: 4px 0;
}

.compact-empty {
  padding: 16px 0;
}

.form-drawer {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.form-drawer form {
  display: grid;
  gap: 14px;
  padding-bottom: 8px;
}

.timeline {
  margin-top: 18px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.timeline h4 {
  margin-bottom: 10px;
}

.timeline article {
  margin-left: 5px;
  padding: 1px 0 8px 14px;
  border-left: 2px solid #b8cdf4;
}

.timeline article p {
  margin: 5px 0;
}

.revision {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.metric {
  min-width: 170px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--ink-600);
  font-size: 12px;
}

.metric strong {
  font-size: 22px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.danger-zone {
  border-color: #f0c6c3;
  background: #fffafa;
}

.upload-layout {
  display: grid;
  gap: 16px;
}

.upload-guide {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: upload-step;
}

.upload-guide li {
  position: relative;
  min-height: 58px;
  padding: 10px 10px 10px 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  counter-increment: upload-step;
}

.upload-guide li::before {
  position: absolute;
  top: 11px;
  left: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue-700);
  background: var(--blue-100);
  content: counter(upload-step);
  font-size: 13px;
  font-weight: 800;
}

.upload-guide strong,
.upload-guide span {
  display: block;
}

.upload-guide strong {
  font-size: 14px;
}

.upload-guide span {
  color: var(--ink-600);
  font-size: 12px;
}

.upload-panel form {
  display: grid;
  gap: 16px;
}

.upload-mode-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.upload-mode-field legend {
  margin-bottom: 8px;
  color: var(--ink-800);
  font-size: 13px;
  font-weight: 750;
}

.upload-mode-options {
  display: grid;
  gap: 10px;
}

.upload-mode-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.upload-mode-card:hover {
  border-color: #9cadc2;
  background: var(--blue-100);
}

.upload-mode-card:has(input:checked) {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 2px rgb(42 98 191 / 12%);
}

.upload-mode-card input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.upload-mode-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.upload-mode-copy strong {
  color: var(--ink-950);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.upload-mode-copy small {
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.55;
}

.upload-field {
  margin: 0;
}

.upload-note,
.context-note {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-600);
  background: var(--surface-soft);
  font-size: 13px;
}

.attention-metric {
  border-color: #efd38b;
  background: #fffbef;
}

.attention-metric strong {
  color: var(--amber-800);
}

.directory-search {
  margin-bottom: 16px;
}

.directory-table {
  min-width: 980px;
}

.department-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.department-card header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.department-card dl {
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 14px 0;
  font-size: 13px;
}

.login-page {
  color: var(--ink-950);
  background: #edf1f6;
}

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

.login-layout {
  display: grid;
  width: min(100%, 980px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgb(23 32 51 / 14%);
  overflow: hidden;
}

.login-context {
  padding: 30px 26px;
  color: #e9f1ff;
  background: var(--sidebar);
}

.login-context h1 {
  margin: 18px 0 10px;
  color: #fff;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.2;
}

.login-context > p:last-of-type {
  max-width: 480px;
  color: #b8c5d8;
}

.login-context ul {
  display: grid;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.login-context li {
  position: relative;
  padding-left: 20px;
  color: #d8e3f4;
  font-size: 14px;
}

.login-context li::before {
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #75a7ff;
  content: "";
}

.login-kicker {
  margin: 20px 0 0;
  color: #8fb6f7;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.login-panel {
  align-self: center;
  padding: 30px 26px;
}

.login-panel h2 {
  margin: 4px 0 8px;
  font-size: 26px;
}

.login-panel > p:not(.eyebrow) {
  color: var(--ink-600);
}

.login-panel .button {
  width: 100%;
  margin-top: 16px;
}

.login-panel > small {
  display: block;
  margin-top: 12px;
  text-align: center;
}

.login-logo {
  width: auto;
  height: 50px;
  object-fit: contain;
}

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

@media (min-width: 600px) {
  .page-shell {
    width: min(calc(100% - 48px), 1480px);
    padding-top: 30px;
  }

  .page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  .page-heading > .button,
  .page-actions .button {
    width: auto;
  }

  .workbench-summary,
  .summary-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workbench-summary > div:nth-child(2n),
  .summary-strip > div:nth-child(2n) {
    border-right: 1px solid var(--line);
  }

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

  .workbench-summary > div:last-child {
    grid-column: 1 / -1;
  }

  .month-analysis-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .month-analysis-summary > div {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

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

  .quick-filters,
  .search-toolbar {
    grid-template-columns: 180px minmax(240px, 1fr) auto;
  }

  .access-search-toolbar {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 240px) auto;
  }

  .candidate-search-toolbar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

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

  .record-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

  .facts-grid > div {
    border-right: 1px solid var(--line);
  }

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

  .facts-grid > div:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .facts-grid .wide-fact {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }

  .login-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  }

  .login-context,
  .login-panel {
    padding: 48px 42px;
  }

  .upload-guide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .desktop-records {
    display: block;
  }

  .mobile-records {
    display: none;
  }

  .panel {
    padding: 24px;
  }

  .flush-panel {
    padding: 0;
  }

  .workbench-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .workbench-summary > div,
  .summary-strip > div {
    border-bottom: 0;
  }

  .workbench-summary > div:nth-child(4) {
    border-right: 1px solid var(--line);
  }

  .workbench-summary > div:last-child {
    grid-column: auto;
    border-right: 0;
  }

  .advanced-filter-grid {
    grid-template-columns: repeat(5, minmax(140px, 1fr));
  }

  .detail-grid {
    grid-template-columns: minmax(0, 2fr) minmax(290px, 0.8fr);
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  }

  .financial-facts > dl:not(.facts-grid) {
    grid-template-columns: repeat(2, 120px minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  body.nav-open {
    overflow: auto;
  }

  .app-sidebar {
    width: var(--sidebar-width);
    box-shadow: none;
    transform: none;
  }

  .app-workspace {
    margin-left: var(--sidebar-width);
  }

  .nav-backdrop,
  .nav-backdrop.is-visible,
  .nav-toggle,
  .topbar-brand {
    display: none;
  }

  .app-topbar {
    justify-content: space-between;
    min-height: 58px;
    padding: 0 28px;
  }

  .app-topbar > p {
    display: block;
    margin: 0;
    color: var(--ink-600);
    font-size: 13px;
  }

  .topbar-user {
    display: block;
    max-width: 220px;
    overflow: hidden;
    color: var(--ink-700);
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-shell {
    width: min(calc(100% - 56px), 1480px);
    padding-top: 32px;
  }

  .financial-facts .facts-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .all-source-field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .facts-grid > div:nth-child(2n) {
    border-right: 1px solid var(--line);
  }

  .facts-grid > div:nth-child(4n) {
    border-right: 0;
  }

  .facts-grid .span-two {
    grid-column: span 2;
    border-right: 0;
  }
}

@media (min-width: 1200px) {
  .financial-facts > dl:not(.facts-grid) {
    grid-template-columns: repeat(4, 108px minmax(0, 1fr));
  }

  .inline-facts {
    grid-template-columns: repeat(4, max-content minmax(0, 1fr));
  }
}

@media (min-width: 1360px) {
  .analysis-workspace {
    grid-template-columns: minmax(0, 1.85fr) minmax(300px, 0.75fr);
  }

  .exception-sidebar {
    position: sticky;
    top: 76px;
  }
}

@media (max-width: 599px) {
  .page-actions {
    display: grid;
  }

  .quick-filters .button,
  .search-toolbar .button {
    width: 100%;
  }

  .allocation-line {
    display: grid;
    gap: 3px;
  }

  .analysis-heading,
  .section-heading,
  .panel-heading {
    display: grid;
  }

  .metric {
    width: 100%;
  }

  .inline-facts,
  dl,
  .financial-facts > dl:not(.facts-grid) {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  dl dd {
    margin-bottom: 9px;
  }

  .record-details > dl,
  .person-card > dl {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 8px 12px;
  }
}

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

.bulk-entry .bulk-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.bulk-entry .bulk-search {
  grid-column: 1 / -1;
}

.bulk-help {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--blue-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-700);
  background: var(--blue-100);
  font-size: 13px;
}

.bulk-help p {
  margin: 0;
}

.bulk-help p + p {
  margin-top: 5px;
}

.bulk-toolbar {
  position: sticky;
  z-index: 8;
  top: 58px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.bulk-count {
  display: inline-block;
  margin-left: 12px;
  color: var(--ink-600);
  font-size: 12px;
}

.bulk-toolbar p {
  margin: 3px 0 0;
  color: var(--ink-600);
  font-size: 12px;
}

.bulk-entry button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.bulk-feedback {
  margin: 10px 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--green-800);
  background: var(--green-100);
  font-size: 14px;
}

.bulk-feedback.is-error {
  color: var(--red-700);
  background: var(--red-100);
}

.bulk-table-wrap {
  max-height: 72vh;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}

.bulk-table {
  min-width: 1100px;
  table-layout: fixed;
}

.bulk-table-analysis {
  min-width: 1150px;
}

.bulk-table th,
.bulk-table td {
  padding: 9px 8px;
  border-right: 1px solid var(--line);
  vertical-align: top;
}

.bulk-table th:last-child,
.bulk-table td:last-child {
  border-right: 0;
}

.bulk-table .bulk-cell {
  position: relative;
}

.bulk-table thead th {
  padding-top: 12px;
  padding-bottom: 12px;
  font-size: 12px;
}

.bulk-table .bulk-identity {
  position: sticky;
  z-index: 2;
  left: 0;
  width: 210px;
  min-width: 210px;
  color: var(--ink-800);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 400;
  white-space: normal;
}

.bulk-table tbody .bulk-identity {
  top: auto;
}

.bulk-table thead .bulk-identity {
  z-index: 4;
  font-weight: 800;
}

.bulk-identity strong,
.bulk-identity small {
  display: block;
}

.bulk-identity small {
  margin-top: 4px;
  color: var(--ink-600);
  font-size: 12px;
}

.bulk-table .bulk-result {
  width: 170px;
}

.bulk-entry [data-bulk-input] {
  min-height: 44px;
  padding: 9px 8px;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.5;
}

.bulk-entry textarea[data-bulk-input] {
  min-height: 68px;
}

.bulk-entry [data-bulk-input][readonly] {
  border-color: transparent;
  color: var(--ink-600);
  background: var(--surface-soft);
}

.bulk-entry [data-bulk-input]:disabled {
  color: var(--ink-600);
  background: var(--surface-soft);
}

.bulk-entry [data-bulk-input][aria-invalid='true'] {
  border-color: var(--red-700);
}

.bulk-entry .is-dirty .bulk-identity,
.bulk-entry .bulk-card.is-dirty {
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.bulk-row-message,
.bulk-field-error {
  margin: 5px 0 0;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.bulk-row-message:empty,
.bulk-field-error:empty {
  display: none;
}

.bulk-row-message.is-error,
.bulk-field-error {
  color: var(--red-700);
}

.bulk-row-message.is-success {
  color: var(--green-800);
}

.bulk-detail-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}

.bulk-shared {
  display: block;
  margin: 6px 0 0;
  color: var(--amber-800);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.bulk-cards {
  padding-top: 12px;
}

.bulk-card-quantity {
  margin: 8px 0;
  color: var(--ink-600);
  font-size: 13px;
}

.bulk-card-fields {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.bulk-card-fields label small {
  margin-left: 8px;
  color: var(--ink-600);
  font-weight: 400;
}

.bulk-preview-dialog {
  width: min(840px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-950);
  background: var(--surface);
  box-shadow: 0 20px 70px rgb(23 32 51 / 25%);
}

.bulk-preview-dialog::backdrop {
  background: rgb(17 29 49 / 55%);
}

.bulk-preview-dialog > p {
  margin: 8px 0 16px;
  color: var(--ink-600);
  font-size: 13px;
}

.bulk-preview-heading,
.bulk-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.bulk-preview-heading h2 {
  margin: 0;
  font-size: 20px;
}

.bulk-preview-content {
  max-height: 55vh;
  overflow: auto;
  overscroll-behavior: contain;
}

.bulk-preview-record {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.bulk-preview-record + .bulk-preview-record {
  margin-top: 12px;
}

.bulk-preview-record h3 {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.bulk-preview-record dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.bulk-preview-record dl > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.bulk-preview-record dt,
.bulk-preview-record dd {
  margin: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.bulk-preview-record dd {
  display: grid;
  gap: 5px;
  white-space: pre-wrap;
}

.bulk-before {
  color: var(--ink-600);
}

.bulk-after {
  color: var(--blue-700);
  font-weight: 650;
}

.bulk-preview-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

@media (min-width: 768px) {
  .bulk-entry .bulk-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bulk-entry .bulk-search {
    grid-column: auto;
  }
}

@media (min-width: 1360px) {
  .bulk-entry .bulk-filters {
    grid-template-columns: 140px 135px 125px minmax(180px, 1fr) 110px auto;
  }
}

@media (max-width: 767px) {
  .bulk-entry [data-bulk-input] {
    font-size: 16px;
  }

  .bulk-toolbar {
    padding: 12px;
  }

  .bulk-count {
    display: block;
    margin: 2px 0;
  }

  .bulk-preview-dialog {
    padding: 16px;
  }

  .bulk-preview-record dl > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
