:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-subtle: #fbfbf8;
  --text: #1e2024;
  --muted: #666c75;
  --faint: #8b929c;
  --line: #dcded8;
  --line-soft: #ecede8;
  --accent: #1f6feb;
  --accent-soft: #e8f0ff;
  --success: #167c3b;
  --success-soft: #e7f5eb;
  --warning: #9a6700;
  --warning-soft: #fff4d8;
  --danger: #b42318;
  --danger-soft: #ffe9e6;
  --ink: #111318;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(20, 24, 31, .08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .68;
}

:focus-visible {
  outline: 3px solid rgba(31, 111, 235, .28);
  outline-offset: 2px;
}

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

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

.entry {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.entry__panel {
  width: min(980px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 48px);
}

.entry h1 {
  max-width: 780px;
  margin: 28px 0;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 1;
  font-weight: 760;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--ink);
  font-weight: 760;
  font-size: 18px;
}

.demo-note,
.eyebrow,
.screen-heading p,
.role-card span:last-child,
.muted {
  color: var(--muted);
}

.demo-note {
  margin: 4px 0 0;
  font-size: 13px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.role-card {
  min-height: 150px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.role-card:hover,
.role-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.role-card__title {
  display: block;
  color: var(--ink);
  font-weight: 740;
  font-size: 20px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
}

.sidebar__brand {
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}

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

.nav-item,
.mobile-nav__item {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
}

.nav-item.active,
.mobile-nav__item.active {
  color: var(--ink);
  background: var(--bg);
  font-weight: 700;
}

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

.topbar,
.screen-heading,
.panel-header,
.button-row,
.topbar__actions,
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.screen-heading {
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h2,
.screen-heading h3 {
  margin-bottom: 4px;
}

.topbar h2 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

.screen-heading {
  margin-bottom: 18px;
}

.screen-heading h3 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.12;
}

.screen-heading p {
  max-width: 760px;
  margin-bottom: 0;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 740;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.mobile-nav {
  display: none;
}

.primary-button,
.outline-button,
.text-button,
.danger-button,
.chip {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--ink);
}

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

.text-button {
  color: var(--accent);
  background: transparent;
  padding-inline: 8px;
}

.danger-button {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffc7c1;
}

.chip {
  min-height: 38px;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
}

.chip.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(31, 111, 235, .34);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.metric-card {
  padding: 16px;
}

.metric-value {
  display: block;
  margin-bottom: 2px;
  font-size: 32px;
  line-height: 1;
  font-weight: 780;
}

.metric-label {
  color: var(--muted);
  font-size: 14px;
}

.dashboard-grid,
.split-layout,
.workflow-grid,
.settings-grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
}

.split-layout,
.workflow-grid {
  grid-template-columns: minmax(300px, .95fr) minmax(0, 1.25fr);
}

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

.panel {
  padding: 18px;
}

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

.panel h3 {
  margin-bottom: 10px;
}

.next-card {
  display: grid;
  gap: 12px;
}

.next-card h4 {
  margin: 0;
  font-size: 20px;
}

.activity-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-list li {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
}

.activity-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.record-card.selected,
.record-card:hover,
.record-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.record-card__top,
.record-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.record-card__title {
  font-weight: 740;
}

.record-card__meta {
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 740;
}

.status-draft {
  color: var(--muted);
}

.status-needs_fix,
.status-changes_requested {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #f2d897;
}

.status-submitted {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(31, 111, 235, .28);
}

.status-approved {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bde6c9;
}

.status-rejected,
.status-missing_both,
.status-missing_raw,
.status-missing_report,
.status-missing,
.status-blocked,
.severity-high {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffc7c1;
}

.severity-medium {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #f2d897;
}

.status-ready,
.status-uploaded,
.severity-low {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bde6c9;
}

.status-imported {
  color: var(--ink);
  background: var(--bg);
}

.status-uploading,
.status-pending {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(31, 111, 235, .28);
}

.detail-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.detail-list dt {
  color: var(--faint);
}

.detail-list dd {
  margin: 0;
  min-width: 0;
}

.issue-list,
.field-list,
.destination-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.issue-row,
.field-row,
.destination-row {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.field-row,
.destination-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.workflow-shell {
  display: grid;
  gap: 14px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.step.active,
.step.done {
  border-color: rgba(31, 111, 235, .3);
  background: var(--accent-soft);
  color: var(--accent);
}

form {
  margin: 0;
}

.form-panel,
.decision-form,
.mapping-editor {
  display: grid;
  gap: 12px;
  align-content: start;
}

label,
legend {
  color: var(--ink);
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  padding: 9px 10px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
}

fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.radio-line,
.checkbox-line {
  display: flex;
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-weight: 500;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.success-line {
  margin: 0;
  color: var(--success);
  font-weight: 700;
}

.loading-box,
.success-box,
.business-error,
.empty-state {
  padding: 16px;
  border-radius: var(--radius);
}

.loading-box {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(31, 111, 235, .24);
}

.success-box {
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid #bde6c9;
}

.business-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #ffc7c1;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 8px;
  background: var(--surface-subtle);
  border: 1px dashed var(--line);
}

.empty-state h3,
.empty-state p {
  margin-bottom: 0;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mapping-card {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
}

.mapping-card h3 {
  margin-bottom: 0;
}

.login-form {
  max-width: 460px;
  display: grid;
  gap: 12px;
}

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

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

.search-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.quick-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.results-panel {
  display: grid;
  gap: 12px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(0, 1.1fr);
  gap: 16px;
}

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

.upload-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.upload-card h4 {
  margin: 0;
  font-size: 18px;
}

.compact-detail {
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 10px;
}

.full-log {
  max-width: 900px;
}

.danger-text {
  color: var(--danger);
  justify-self: start;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(380px, calc(100vw - 36px));
  color: #ffffff;
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 19, 24, .42);
}

.modal {
  width: min(460px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal h3 {
  margin-bottom: 8px;
}

.modal .button-row {
  justify-content: flex-end;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .mobile-nav__item {
    min-width: max-content;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    text-align: center;
  }

  .dashboard-grid,
  .split-layout,
  .workflow-grid,
  .settings-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .metric-row,
  .mapping-grid,
  .upload-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  body {
    font-size: 15px;
  }

  .entry {
    padding: 14px;
  }

  .role-grid,
  .metric-row,
  .mapping-grid,
  .upload-grid,
  .search-field {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .screen-heading,
  .topbar__actions,
  .button-row,
  .record-card__top {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .outline-button,
  .danger-button {
    width: 100%;
  }

  .filter-row {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .chip {
    min-width: max-content;
  }

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

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

  .detail-list dt {
    margin-top: 6px;
  }

  .field-row,
  .destination-row {
    grid-template-columns: 1fr;
  }
}

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