:root {
  --ink: #211f1b;
  --muted: #6d675d;
  --line: #d8d0c3;
  --bg: #f3eee5;
  --panel: #fffdf8;
  --green: #9f2f2b;
  --green-soft: #f3e3df;
  --blue: #4d5d67;
  --blue-soft: #e7ebec;
  --amber: #8a5a12;
  --amber-soft: #f7ecd8;
  --red: #9f2f2b;
  --red-soft: #f3e3df;
  --critical: #8f1d1d;
  --critical-soft: #f8dddd;
  --high: #8a5a12;
  --high-soft: #f7ecd8;
  --open: #9f2f2b;
  --open-soft: #f3e3df;
  --acknowledged: #6f5412;
  --acknowledged-soft: #f7efcf;
  --resolved: #356049;
  --resolved-soft: #e3f0e8;
  --violet: #665b75;
  --shadow: 0 12px 28px rgba(51, 43, 31, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(-150%);
}

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

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

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(115deg, rgba(159, 47, 43, 0.08), transparent 38%),
    var(--bg);
}

.login-card {
  width: min(100%, 480px);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.login-brand h1 {
  font-size: 30px;
}

.login-intro {
  color: var(--muted);
  line-height: 1.55;
  margin: 20px 0 4px;
}

.login-setup-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.password-control {
  position: relative;
  display: block;
}

.decision-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.password-control input {
  padding-right: 72px;
}

.password-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 30px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--green);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

.sidebar {
  background: #25221d;
  color: #fffdf8;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #a5342f;
  color: #fffdf8;
  font-weight: 800;
  border-radius: 8px;
}

.brand-title {
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  color: #bdb4a7;
  font-size: 13px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #d9d1c5;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #d9a49f;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.pilot-status {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px;
}

.status-label,
.status-note {
  color: #bdb4a7;
  font-size: 12px;
}

.status-date {
  font-weight: 800;
  margin: 6px 0 10px;
}

.status-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.status-bar span {
  display: block;
  height: 100%;
  width: 42%;
  background: #a5342f;
}

.main {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

h1,
h2,
h3 {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 750;
  letter-spacing: -0.025em;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
label:focus-within {
  outline: 3px solid rgba(159, 47, 43, 0.35);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.modal-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(84vh, 860px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 24px 80px rgba(33, 31, 27, 0.25);
}

.modal-dialog::backdrop {
  background: rgba(33, 31, 27, 0.48);
  backdrop-filter: blur(2px);
}

.dialog-shell {
  padding: 22px;
}

.dialog-wide {
  width: min(100%, 980px);
}

#inventory-detail-dialog {
  width: min(980px, calc(100vw - 32px));
}

.dialog-search-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#global-search-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: 56vh;
  overflow-y: auto;
  margin-top: 14px;
  padding-right: 4px;
}

.search-result {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.search-result:hover {
  border-left-color: var(--green);
  background: #f8f2e9;
}

.search-result span {
  color: var(--muted);
  font-size: 12px;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.topbar-actions,
.button-row,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-identity {
  display: grid;
  gap: 1px;
  padding: 3px 10px;
  border-left: 1px solid var(--line);
}

.user-identity strong {
  font-size: 13px;
}

.user-identity span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.upload-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-button,
.primary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-button {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
  font-weight: 800;
}

.ghost-button:hover,
.upload-button:hover {
  border-color: #aeb8c4;
}

.inline-alert {
  background: var(--blue-soft);
  border: 1px solid #b9d0ea;
  color: #153d69;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.compact-alert {
  margin: 12px 0 16px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.inline-alert.warning-alert {
  color: #68440d;
  background: var(--high-soft);
  border-color: #d5b16d;
}

.inline-alert.error-alert {
  color: var(--critical);
  background: var(--critical-soft);
  border-color: #d8a2a2;
}

.inline-alert.success-alert {
  color: var(--resolved);
  background: var(--resolved-soft);
  border-color: #a9cbb7;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.kpi-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
  min-height: 122px;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-value {
  font-size: 34px;
  font-weight: 800;
  margin: 10px 0 5px;
}

.kpi-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.compact {
  min-height: 230px;
}

.panel-intro,
.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.panel-intro {
  margin: -4px 0 14px;
}

.field-help {
  margin: -4px 0 0;
}

.content-grid {
  display: grid;
  gap: 18px;
}

.content-grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

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

.workflow-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
}

.quality-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(460px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.quality-detail-panel {
  position: sticky;
  top: 18px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-button {
  min-height: 32px;
  padding: 5px 9px;
  text-decoration: none;
  font-size: 12px;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compact-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
  margin-bottom: 10px;
}

.compact-filter-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.compact-filter-grid input,
.compact-filter-grid select,
.register-search-label input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 9px;
}

.register-search-label {
  width: min(230px, 32vw);
}

.inventory-panel-heading {
  align-items: flex-start;
}

.bounded-list {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.stack-button {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.stack-button:hover {
  border-color: var(--green);
  background: #f8f2e9;
}

.filter-grid label,
.decision-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-search {
  grid-column: 1 / -1;
}

select,
input[type="search"],
.decision-form input,
.decision-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}

.decision-form textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.exception-list {
  display: grid;
  gap: 8px;
  max-height: 760px;
  overflow-y: auto;
  padding-right: 4px;
}

.exception-row {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 4px;
  background: #fffdf8;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.exception-row:hover,
.exception-row.selected {
  border-left-color: var(--green);
  background: #f8f2e9;
}

.exception-row-top,
.exception-tags,
.detail-heading,
.decision-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exception-row-top {
  justify-content: space-between;
}

.exception-rule,
.exception-source {
  color: var(--muted);
  font-size: 11px;
}

.exception-rule {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}

.severity-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.severity-label.critical {
  color: var(--critical);
  background: var(--critical-soft);
  border-style: double;
  border-width: 3px;
  padding: 1px 5px;
}

.severity-label.high {
  color: var(--high);
  background: var(--high-soft);
}

.severity-label.warning {
  color: var(--amber);
}

.quality-detail h3 {
  margin: 12px 0 6px;
  font-size: 21px;
}

.quality-detail > p,
.resolution-note p {
  color: var(--muted);
  line-height: 1.5;
}

.lineage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 16px 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.lineage-grid > div {
  min-width: 0;
  background: var(--panel);
  padding: 10px;
}

.lineage-grid .lineage-wide {
  grid-column: 1 / -1;
}

.lineage-grid dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lineage-grid dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.source-trace {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  padding: 14px;
}

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

.source-trace h4 {
  margin: 2px 0 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.source-trace > p {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.source-trace-table table {
  min-width: 760px;
}

.source-trace-table th,
.source-trace-table td {
  padding: 9px 8px;
  font-size: 12px;
  vertical-align: top;
}

.source-trace-table td strong,
.source-trace-table td span {
  display: block;
}

.source-trace-table td span {
  margin-top: 3px;
  color: var(--muted);
}

.source-trace-table code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.source-trace-empty {
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
}

.resolution-note {
  border-left: 3px solid var(--green);
  background: var(--green-soft);
  padding: 10px 12px;
}

.decision-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.user-form {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.account-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.account-summary > div {
  min-width: 0;
  background: var(--panel);
  padding: 10px 12px;
}

.account-summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.account-summary strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.password-reset-section {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.control-steps {
  display: grid;
  gap: 12px;
  margin: 4px 0 18px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.control-steps strong {
  color: var(--ink);
}

.upload-register {
  display: grid;
  gap: 8px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.8fr) 120px 140px auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.upload-row:hover,
.upload-row.selected {
  border-left-color: var(--green);
  background: #f8f2e9;
}

.upload-row strong,
.upload-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload-row > span:first-child,
.upload-row .upload-target {
  display: grid;
  gap: 4px;
}

.upload-row .item-meta {
  display: block;
  line-height: 1.35;
}

.upload-row-meta {
  color: var(--muted);
  font-size: 12px;
}

.upload-validation-grid {
  margin-top: 18px;
}

.upload-validation-grid h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.backup-control-grid {
  margin-top: 18px;
}

.backup-control-grid h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.compact-output {
  min-height: 92px;
  margin-bottom: 12px;
}

.confirmation-phrase {
  display: block;
  border: 1px solid var(--line);
  background: var(--blue-soft);
  padding: 10px 12px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two-fields {
  grid-template-columns: 1fr 1fr;
}

.form-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

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

.form-section-heading span {
  color: var(--muted);
  font-size: 11px;
}

.decision-heading {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.authenticated-actor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--blue-soft);
  padding: 10px 12px;
  font-size: 12px;
}

.authenticated-actor span {
  color: var(--muted);
}

.certification-position-heading {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.decision-actions {
  flex-wrap: wrap;
}

.danger-button {
  border-color: var(--red);
  color: var(--red);
}

.disabled-form {
  opacity: 0.55;
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: #356049;
}

.action-guidance {
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.audit-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.audit-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.tag.alert {
  color: var(--red);
  background: var(--red-soft);
}

.tag.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.tag.neutral {
  color: var(--blue);
  background: var(--blue-soft);
}

.tag.status-open {
  color: var(--open);
  background: var(--open-soft);
  border-style: solid;
}

.tag.status-acknowledged {
  color: var(--acknowledged);
  background: var(--acknowledged-soft);
  border-style: dashed;
}

.tag.status-resolved {
  color: var(--resolved);
  background: var(--resolved-soft);
  border-style: solid;
}

.tag.status-dismissed {
  color: var(--blue);
  background: var(--blue-soft);
  border-style: dotted;
}

.action-list,
.stack-list,
.approval-list,
.check-list,
.schema-list,
.bar-list {
  display: grid;
  gap: 10px;
}

.action-item,
.stack-item,
.approval-item,
.check-item,
.schema-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.action-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
}

button.action-item {
  width: 100%;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

button.action-item:hover {
  border-color: var(--green);
  background: #f8f2e9;
}

.severity-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--green);
}

.severity-dot.high {
  background: var(--red);
}

.severity-dot.medium {
  background: var(--amber);
}

.item-title {
  font-weight: 800;
  line-height: 1.3;
}

.item-meta,
.item-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 64px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf0f3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

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

.overview-scroll-body:focus-visible,
.viewport-scroll-body:focus-visible,
.viewport-panel-scroll:focus-visible,
.bounded-workspace-list:focus-visible,
.workspace-scroll-view:focus-visible {
  outline: 3px solid rgba(159, 47, 43, 0.35);
  outline-offset: 2px;
}

.inventory-register-scroll {
  max-height: 540px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.inventory-register-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.inventory-register-scroll tbody tr {
  cursor: pointer;
}

.inventory-register-scroll tbody tr:hover td {
  background: #f8f2e9;
}

.inventory-record-button {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 0;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.inventory-detail-body {
  max-height: 66vh;
  overflow-y: auto;
}

.inventory-detail-body .lineage-grid {
  margin-top: 0;
}

.gate-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.gate-button:hover {
  border-color: var(--green);
  background: #f8f2e9;
}

.gate-button .check-item {
  border: 0;
  padding: 0;
  background: transparent;
}

.user-table table {
  min-width: 680px;
}

.user-table tr.selected td {
  background: #f8f2e9;
}

.user-table .mini-button {
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #35404d;
  background: #f0f3f6;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.large-input,
.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.large-input {
  min-height: 230px;
  resize: vertical;
  padding: 13px;
  line-height: 1.5;
}

.text-input {
  min-height: 42px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.assistant-output {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
  min-height: 230px;
  line-height: 1.5;
}

.assistant-output h3 {
  font-size: 15px;
  margin: 14px 0 7px;
}

.assistant-output h3:first-child {
  margin-top: 0;
}

.assistant-output ul {
  padding-left: 18px;
  margin: 8px 0;
}

.empty-state {
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  border: 0;
  background: #ffffff;
  min-height: 32px;
  padding: 6px 12px;
  cursor: pointer;
}

.segment.active {
  background: var(--blue);
  color: #ffffff;
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.approval-note {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.approval-note input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.mini-button {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
  min-height: 32px;
  padding: 6px 10px;
  cursor: pointer;
}

.mini-button.approve {
  border-color: var(--green);
  color: var(--green);
}

.mini-button.reject {
  border-color: var(--red);
  color: var(--red);
}

.check-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: start;
}

.check-box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-radius: 5px;
  margin-top: 1px;
}

.check-item.ready .check-box {
  background: var(--green);
  border-color: var(--green);
}

.schema-item code {
  display: inline-block;
  background: #eef2f5;
  padding: 3px 6px;
  border-radius: 6px;
  margin-bottom: 6px;
}

@media (min-width: 1081px) {
  body:has(.app-shell:not(.hidden)) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .topbar,
  .inline-alert:not(.hidden) {
    flex: 0 0 auto;
  }

  .view.active {
    flex: 1 1 auto;
    min-height: 0;
    gap: 14px;
  }

  .view {
    font-size: 12px;
  }

  .view .kpi-grid,
  .view .content-grid,
  .view .workflow-layout,
  .view .quality-layout {
    gap: 14px;
  }

  .view .kpi-card {
    min-height: 96px;
    padding: 13px 14px;
  }

  .view .kpi-label {
    font-size: 12px;
  }

  .view .kpi-value {
    margin: 5px 0 2px;
    font-size: 28px;
    line-height: 1.05;
  }

  .view .kpi-sub {
    font-size: 11px;
    line-height: 1.3;
  }

  .view .panel {
    padding: 14px;
  }

  .view .panel.compact {
    min-height: 210px;
  }

  .view .panel-heading {
    margin-bottom: 10px;
  }

  .view h2 {
    font-size: 17px;
  }

  .view h3,
  .view .form-section-heading h3,
  .view .audit-section h3 {
    font-size: 14px;
  }

  .view .section-kicker {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .view .tag,
  .view .compact-button {
    min-height: 24px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .view .panel-intro,
  .view .field-help,
  .view .form-message {
    font-size: 11px;
    line-height: 1.35;
  }

  .view .panel-intro {
    margin-bottom: 10px;
  }

  .view .primary-button,
  .view .ghost-button,
  .view .upload-button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .view .action-list,
  .view .stack-list,
  .view .approval-list,
  .view .check-list,
  .view .schema-list,
  .view .bar-list {
    gap: 8px;
  }

  .view .action-item,
  .view .stack-item,
  .view .approval-item,
  .view .check-item,
  .view .schema-item,
  .view .stack-button,
  .view .gate-button,
  .view .exception-row {
    padding: 10px;
  }

  .view .action-item {
    gap: 8px;
  }

  .view .item-title {
    font-size: 13px;
  }

  .view .item-meta,
  .view .item-body,
  .view .exception-source,
  .view .source-trace > p,
  .view .lineage-grid dd,
  .view .account-summary strong,
  .view .upload-row-meta {
    font-size: 12px;
  }

  .view .quality-detail h3 {
    font-size: 18px;
  }

  .view .quality-detail > p,
  .view .resolution-note p {
    font-size: 12px;
  }

  .view .lineage-grid {
    margin: 12px 0;
  }

  .view .lineage-grid > div,
  .view .account-summary > div {
    padding: 8px 10px;
  }

  .view .source-trace {
    margin: 14px 0;
    padding: 12px;
  }

  .view .source-trace h4 {
    font-size: 16px;
  }

  .view .decision-form {
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
  }

  .view .user-form {
    margin-top: 0;
    padding-top: 0;
  }

  .view .decision-form label {
    gap: 3px;
    font-size: 11px;
  }

  .view select,
  .view input[type="search"],
  .view .decision-form input,
  .view .decision-form textarea,
  .view .text-input {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .view .decision-form textarea {
    min-height: 90px;
  }

  .view .large-input,
  .view .assistant-output {
    padding: 12px;
    font-size: 12px;
  }

  .view .assistant-output h3 {
    font-size: 14px;
  }

  .view .authenticated-actor,
  .view .confirmation-phrase {
    padding: 8px 10px;
    font-size: 11px;
  }

  .view .audit-section {
    margin-top: 14px;
    padding-top: 12px;
  }

  .view table th {
    padding: 8px;
    font-size: 10px;
  }

  .view table td {
    padding: 8px;
    font-size: 12px;
  }

  .view .segment,
  .view .mini-button {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
  }

  .view .upload-row {
    gap: 10px;
    padding: 10px;
  }

  #sales-view.active,
  #documents-view.active,
  #approvals-view.active,
  #data-view.active {
    grid-template-rows: minmax(0, 1fr);
  }

  #inventory-view.active {
    grid-template-rows: minmax(230px, 0.46fr) minmax(260px, 0.54fr);
  }

  #quality-view.active,
  #certification-view.active {
    grid-template-rows: auto minmax(0, 1fr);
  }

  #users-view.active {
    grid-template-rows: auto minmax(220px, 1fr) minmax(170px, 0.72fr);
  }

  .viewport-fill-grid {
    min-height: 0;
    align-items: stretch;
  }

  .viewport-fill-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .viewport-fill-panel > .panel-heading,
  .viewport-fill-panel > .button-row,
  .viewport-fill-panel > .form-message,
  .viewport-fill-panel > .panel-intro,
  .viewport-fill-panel > h2 {
    flex: 0 0 auto;
  }

  .viewport-fill-panel > h2 {
    margin-bottom: 14px;
  }

  .viewport-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }

  .viewport-scroll-body thead th {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .viewport-panel-scroll {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .viewport-flex-input {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
  }

  #quality-view .quality-layout {
    align-items: stretch;
  }

  #quality-view .quality-detail-panel {
    position: static;
  }

  .workspace-scroll-view.active {
    overflow: hidden;
  }

  .bounded-workspace-list {
    max-height: 260px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }

  .bounded-workspace-list thead th {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  #procurement-view.active {
    grid-template-rows: 82px minmax(145px, 0.72fr) minmax(112px, 0.5fr) minmax(170px, 1fr);
    gap: 12px;
    overflow: hidden;
  }

  #procurement-view.active:has(#upload-detail-panel:not(.hidden)) {
    grid-template-rows: minmax(132px, 0.3fr) minmax(0, 1fr);
  }

  #procurement-view.active:has(#upload-detail-panel:not(.hidden)) > #uploads-kpi-grid,
  #procurement-view.active:has(#upload-detail-panel:not(.hidden)) > .imports-control-grid,
  #procurement-view.active:has(#upload-detail-panel:not(.hidden)) > .imports-planning-grid {
    display: none;
  }

  #procurement-view #uploads-kpi-grid,
  #procurement-view .imports-control-grid,
  #procurement-view .imports-planning-grid {
    gap: 16px;
  }

  #procurement-view .kpi-card {
    min-height: 0;
    padding: 10px 14px;
  }

  #procurement-view .kpi-label {
    font-size: 13px;
  }

  #procurement-view .kpi-value {
    margin: 3px 0 1px;
    font-size: 27px;
    line-height: 1.05;
  }

  #procurement-view .kpi-sub {
    font-size: 12px;
    line-height: 1.35;
  }

  #procurement-view .panel {
    padding: 14px;
  }

  #procurement-view .panel-heading {
    margin-bottom: 10px;
  }

  #procurement-view h2 {
    font-size: 19px;
    line-height: 1.25;
  }

  #procurement-view .section-kicker {
    margin-bottom: 4px;
    font-size: 11px;
  }

  #procurement-view .tag,
  #procurement-view .compact-button {
    font-size: 12px;
  }

  #procurement-view .imports-compact-panel {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  #procurement-view .decision-form {
    gap: 8px;
  }

  #procurement-view .decision-form label {
    gap: 3px;
    font-size: 12px;
  }

  #procurement-view .decision-form input,
  #procurement-view .decision-form textarea {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
  }

  #procurement-view .field-help {
    font-size: 12px;
    line-height: 1.45;
  }

  #procurement-view .primary-button,
  #procurement-view .ghost-button {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }

  #procurement-view button:disabled {
    border-color: #d8d0c3;
    background: #f2eee7;
    color: #817a70;
    opacity: 1;
  }

  #procurement-view .control-steps {
    gap: 9px;
    margin: 0 0 10px;
    padding-left: 22px;
    font-size: 13px;
    line-height: 1.45;
  }

  #procurement-view .imports-register-panel {
    min-height: 0;
  }

  #procurement-view .imports-planning-grid > .panel {
    min-height: 0;
  }

  #procurement-view #upload-detail-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  #procurement-view .bounded-workspace-list {
    max-height: 300px;
    font-size: 13px;
  }

  #procurement-view #uploads-list {
    min-height: 0;
    max-height: none;
  }

  #procurement-view .assistant-output {
    min-height: 0;
    padding: 14px;
  }

  #procurement-view .panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  #procurement-view #upload-detail-panel > .panel-heading,
  #procurement-view #upload-detail-panel > .account-summary,
  #procurement-view #upload-detail-panel > .inline-alert {
    flex: 0 0 auto;
  }

  #procurement-view .upload-validation-grid {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
  }

  #procurement-view .upload-validation-grid > div,
  #procurement-view .upload-validation-grid > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #procurement-view #upload-validation-findings {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  #procurement-view #upload-decision-form {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }

  #procurement-view th {
    font-size: 11px;
  }

  #procurement-view td {
    padding: 10px 9px;
    font-size: 13px;
  }

  #overview-view.active {
    overflow: hidden;
    grid-template-rows: auto minmax(230px, 1.2fr) minmax(180px, 0.8fr);
  }

  #overview-view .overview-control-grid {
    min-height: 0;
  }

  #overview-view .overview-scroll-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  #overview-view .overview-scroll-panel > .panel-heading {
    flex: 0 0 auto;
  }

  #overview-view .overview-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }

  #overview-view .overview-scroll-body thead th {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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

  .pilot-status {
    display: none;
  }

  .content-grid.two,
  .content-grid.three,
  .workflow-layout,
  .quality-layout,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .upload-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr) auto;
  }

  .upload-row .upload-secondary {
    display: none;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 27px;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

  .nav-item {
    grid-template-columns: 28px 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .filter-grid,
  .compact-filter-grid,
  .lineage-grid,
  .form-grid.two-fields {
    grid-template-columns: 1fr;
  }

  .filter-search,
  .lineage-grid .lineage-wide {
    grid-column: auto;
  }

  .register-search-label {
    width: 100%;
  }

  .panel-tools {
    width: 100%;
    align-items: stretch;
  }

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

  .upload-row {
    grid-template-columns: 1fr auto;
  }

  .upload-row .upload-target {
    display: none;
  }
}
