:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d6ddea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --soft: #eef6ff;
  --ok: #047857;
  --warn: #9a3412;
  --warn-bg: #fffbeb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

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

h1 {
  font-size: 22px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

p {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

.app-shell {
  min-height: 76px;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow,
.module-kicker {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.session-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.workspace {
  width: min(1440px, calc(100% - 32px));
  margin: 20px auto 48px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
}

.module-nav,
.module-stage,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.module-nav {
  position: sticky;
  top: 96px;
  height: fit-content;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.module-link {
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

.module-link span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.module-link strong {
  font-size: 14px;
}

.module-link.active {
  background: var(--soft);
  color: var(--accent);
}

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

.module-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.module-actions {
  flex: 0 0 auto;
}

.metrics {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metrics[hidden] {
  display: none;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

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

.module-content {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.section-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

.section-tab {
  flex: 0 0 auto;
  min-height: 40px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.section-tab:hover,
.section-tab:focus-visible {
  background: var(--soft);
  color: var(--accent);
  outline: none;
}

.section-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbff;
}

.panel-actions {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.task-list {
  display: grid;
}

.task-row {
  min-height: 64px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
}

.task-row:last-child {
  border-bottom: 0;
}

.task-row span {
  color: var(--muted);
  font-size: 13px;
}

.money-stack {
  display: grid;
}

.money-stack > div {
  min-height: 64px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.money-stack > div:last-child {
  border-bottom: 0;
}

.money-stack span {
  color: var(--muted);
  font-size: 13px;
}

.money-stack strong {
  font-size: 18px;
}

.process-list {
  display: grid;
}

.process-step {
  min-height: 58px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.process-step:last-child {
  border-bottom: 0;
}

.process-step > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.financial-summary > div {
  min-height: 92px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.financial-summary > div:nth-child(3n) {
  border-right: 0;
}

.financial-summary > div:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.financial-summary span {
  color: var(--muted);
  font-size: 13px;
}

.financial-summary strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

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

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

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

th {
  color: var(--muted);
  background: #fbfcff;
  font-size: 12px;
  text-transform: uppercase;
}

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

.empty-cell,
.error {
  color: var(--warn);
}

.error {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: var(--warn-bg);
}

.status-pill {
  width: fit-content;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill--warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-pill--neutral {
  background: #ecfdf5;
  color: var(--ok);
}

.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.field input,
.field select,
.field textarea {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.line-table input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--accent);
}

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

.order-form-panel {
  border-color: #b9c8e5;
}

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

.line-editor-head,
.order-total,
.form-footer {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-editor-head {
  background: #fafbff;
  border-bottom: 1px solid var(--line);
}

.line-table {
  min-width: 940px;
}

.line-table th:nth-child(1) {
  width: 28%;
}

.line-table th:nth-child(2) {
  width: 15%;
}

.line-table th:nth-child(3),
.line-table th:nth-child(4) {
  width: 16%;
}

.line-table th:last-child {
  width: 48px;
}

.line-table input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--ink);
  background: #fff;
}

.line-amount {
  white-space: nowrap;
  font-weight: 700;
}

.secondary-button,
.icon-button {
  background: var(--surface);
  color: var(--accent);
}

.secondary-button {
  flex: 0 0 auto;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.order-total {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.order-total span {
  color: var(--muted);
  font-size: 13px;
}

.order-total strong {
  min-width: 150px;
  text-align: right;
  font-size: 18px;
}

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

.submit-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.submit-status.is-error {
  color: #b42318;
}

.submit-status.is-loading {
  color: var(--accent);
}

.success-notice {
  padding: 12px 14px;
  border: 1px solid #86c9ad;
  border-radius: 8px;
  background: #ecfdf5;
  color: var(--ok);
  font-weight: 700;
}

.empty-state {
  min-height: 112px;
  padding: 24px 16px;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: var(--muted);
}

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

.empty-state span {
  font-size: 14px;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .module-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .content-grid,
  .form-grid,
  .financial-summary {
    grid-template-columns: 1fr;
  }

  .financial-summary > div,
  .financial-summary > div:nth-child(3n),
  .financial-summary > div:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 720px) {
  .app-shell,
  .module-head,
  .session-box {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .process-step {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .process-step .status-pill {
    grid-column: 2;
  }

  .line-editor-head,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .order-total {
    justify-content: space-between;
  }

  .order-total strong {
    min-width: 0;
  }

  .form-footer button,
  .secondary-button {
    width: 100%;
  }
}
