:root {
  color-scheme: light;
  --bg: #f0f3ff;
  --card: #ffffff;
  --text: #222436;
  --muted: #5f6384;
  --line: #b8bed6;
  --line-soft: #d9deee;
  --head: #d3d8e9;
  --row: #f7f7fb;
  --row-alt: #eef1fb;
  --blue: #0a64ff;
  --blue-50: #d6e9ff;
  --blue-100: #b9dcff;
  --green: #078833;
  --green-50: #dcf7e2;
  --amber: #a65300;
  --amber-50: #fff1d9;
  --red: #e10000;
  --red-50: #fff0f0;
  --shadow: 0 2px 8px rgba(30, 38, 69, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  margin: 32px 0 14px;
  font-size: 17px;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 12px 40px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.workpaper-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  white-space: nowrap;
}

.workpaper-title span {
  padding-right: 10px;
  border-right: 1px solid var(--text);
}

.workpaper-title strong {
  font-size: 21px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.save-state {
  color: var(--green);
  white-space: nowrap;
}

.status-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 5px;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--text);
  background: #fff;
  color: var(--text);
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.step-nav {
  position: sticky;
  top: 64px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  min-height: 40px;
  padding: 0 40px;
  background: #fff;
  box-shadow: 0 5px 12px rgba(31, 37, 62, 0.22);
}

.step {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 22px 0 0;
  border: 0;
  background: transparent;
  color: #62678d;
  font-size: 14px;
  font-weight: 800;
}

.step::before {
  content: "";
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1.5px dashed #6c7198;
  border-radius: 50%;
}

.step.complete::before {
  content: "✓";
  border: 1.5px solid #22a447;
  color: #22a447;
  font-size: 11px;
  line-height: 1;
}

.step.active {
  color: var(--text);
}

.step.active::before {
  border: 4px solid var(--blue);
  background: #fff;
}

.step:not(:last-child)::after {
  content: "›";
  position: absolute;
  right: 8px;
  color: #62678d;
  font-size: 28px;
  line-height: 1;
}

.workspace {
  padding: 32px 40px 104px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.page-heading {
  max-width: 1320px;
  margin-bottom: 28px;
}

.page-heading p {
  max-width: 1260px;
  margin-bottom: 0;
  font-size: 17px;
}

.tabs {
  display: inline-flex;
  margin-bottom: 24px;
  border: 1px solid #9aa6c8;
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
}

.tab {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid #b2bad4;
  background: #fff;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.tab:last-child {
  border-right: 0;
}

.tab.is-active {
  border-bottom: 4px solid var(--blue);
  background: var(--blue-100);
  color: #001a70;
}

.card {
  width: 100%;
  max-width: 1440px;
  padding: 32px 24px;
  border: 1px solid #e5e7f0;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 36px;
}

.account-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 16px;
}

.metric-tabs {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #9aa6c8;
  border-radius: 5px;
}

.metric {
  min-width: 176px;
  padding: 14px 16px;
  border: 0;
  border-right: 1px solid #b2bad4;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.metric:last-child {
  border-right: 0;
}

.metric strong,
.metric span {
  display: block;
  white-space: nowrap;
}

.metric strong {
  margin-bottom: 6px;
  color: #001a70;
  font-size: 17px;
}

.metric span {
  color: #6d7194;
  font-weight: 800;
}

.metric.is-active {
  border-bottom: 4px solid var(--blue);
  background: var(--blue-100);
}

.search-field {
  display: flex;
  align-items: center;
  min-width: 320px;
  border: 1px solid #555c81;
  border-radius: 5px;
  background: #fff;
}

.search-field input {
  width: 100%;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
}

.search-field span:last-child {
  padding: 0 12px;
  font-size: 26px;
}

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

.data-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.data-table th,
.data-table td {
  min-height: 48px;
  padding: 12px 16px;
  border-right: 1px solid #c5d9fb;
  border-bottom: 1px solid #cdd2e3;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--head);
  color: #353851;
  font-size: 13px;
  font-weight: 800;
}

.data-table td {
  background: var(--row);
}

.data-table tr:nth-child(even) td {
  background: var(--row-alt);
}

.data-table tr.selected td {
  background: #eef5ff;
}

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

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

.numeric {
  text-align: right !important;
  white-space: nowrap;
}

.table-footer,
.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.table-footer {
  justify-content: space-between;
}

.table-footer strong {
  font-size: 20px;
}

.pagination {
  justify-content: flex-end;
  color: var(--text);
}

.pagination button,
.select-button {
  min-width: 32px;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #5d6389;
  font-weight: 800;
}

.select-button {
  min-width: 62px;
  border: 1px solid #606789;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
}

.page-number.is-active {
  color: var(--blue);
}

.form-card {
  padding: 36px 24px;
}

.form-card p {
  margin-bottom: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: 464px 220px;
  gap: 14px;
  max-width: 700px;
}

label span,
.choice-question legend {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

input[type="text"],
input[type="search"],
textarea {
  color: var(--text);
  font-size: 16px;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid #4f567a;
  border-radius: 4px;
  background: #fff;
}

input[type="text"] {
  min-height: 40px;
  padding: 0 8px;
}

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

.wide-field {
  display: block;
  max-width: 700px;
  margin-top: 22px;
}

.wide-field textarea {
  min-height: 150px;
}

.wide-field small {
  display: block;
  margin-top: 4px;
  color: #70769a;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.question-list {
  display: grid;
  gap: 26px;
  max-width: 760px;
  margin-top: 28px;
}

.choice-question {
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-question label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
}

.choice-question input[type="radio"],
.confirm-control input,
.data-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #202236;
}

.conditional-field {
  display: none;
  margin-top: 12px;
}

.conditional-field.is-visible {
  display: block;
}

.compact-card {
  margin-bottom: 0;
}

.three-up {
  gap: 24px;
}

.analysis-card {
  padding: 32px 24px 36px;
}

.analysis-panel {
  display: none;
}

.analysis-panel.is-active {
  display: block;
}

.analysis-table {
  margin-top: 28px;
}

.analysis-table td {
  height: 48px;
}

.total-row td {
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 900;
}

.pill.green {
  background: var(--green-50);
  color: var(--green);
}

.pill.amber {
  background: var(--amber-50);
  color: var(--amber);
}

.pill.red {
  background: var(--red-50);
  color: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  overflow: hidden;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.summary-grid span {
  padding: 14px 16px;
  border-bottom: 1px solid #cdd2e3;
  background: var(--row);
}

.summary-grid span:nth-child(n + 5) {
  border-bottom: 0;
  background: var(--row-alt);
}

.summary-grid span:not(:nth-child(4n + 1)) {
  text-align: right;
}

.ai-field textarea {
  min-height: 184px;
  border-color: var(--blue);
  background: #f7fbff;
}

.ai-field span::after,
.ai-badge {
  content: "AI";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 1px solid var(--blue);
  border-radius: 2px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.ratio-table th:first-child,
.ratio-table td:first-child {
  width: 340px;
}

.ratio-table th:nth-child(2),
.ratio-table th:nth-child(3),
.ratio-table th:nth-child(4),
.ratio-table td:nth-child(2),
.ratio-table td:nth-child(3),
.ratio-table td:nth-child(4) {
  width: 160px;
}

.ratio-table th:last-child,
.ratio-table td:last-child {
  min-width: 420px;
}

.row-expander {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: #606789;
  font-size: 24px;
  line-height: 1;
  vertical-align: -2px;
}

.nested-comment td {
  padding: 0;
  background: #fff !important;
}

.comment-section {
  margin: 32px 40px 40px;
  padding: 18px 20px;
  border: 1px solid #c8d7f3;
  border-radius: 5px;
  background: #f7fbff;
}

.comment-section strong {
  display: block;
}

.comment-section p {
  max-width: 1050px;
  margin-bottom: 0;
  color: #333852;
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.sales-table {
  margin-top: 28px;
}

.sales-comment {
  margin-top: 32px;
}

.analytics-extra[hidden],
.aging-comment[hidden] {
  display: none;
}

.empty-card {
  max-width: 720px;
}

.bottom-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 40px;
  border-top: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 -4px 12px rgba(31, 37, 62, 0.14);
}

.confirm-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 27, 42, 0.34);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(672px, 100%);
  padding: 32px 32px 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(18, 24, 45, 0.28);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
}

.modal-field {
  display: block;
  margin-top: 20px;
}

.modal-field span {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.modal-field textarea {
  min-height: 136px;
  border-color: var(--blue);
  background: #f7fbff;
}

.modal-field span::after {
  content: "AI";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 1px solid var(--blue);
  border-radius: 2px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 960px) {
  .app-header,
  .bottom-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .bottom-actions {
    width: 100%;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .bottom-actions {
    gap: 10px;
  }

  .confirm-control {
    margin-left: 0;
  }

  .step-nav {
    top: 117px;
    padding-inline: 20px;
  }

  .workspace {
    padding: 28px 20px 180px;
  }

  .account-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    min-width: 0;
  }

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

@media (max-width: 620px) {
  .app-header,
  .step-nav,
  .workspace,
  .bottom-actions {
    padding-inline: 16px;
  }

  .workpaper-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .workpaper-title span {
    padding-right: 0;
    border-right: 0;
  }

  .tab {
    font-size: 16px;
  }

  .card {
    padding: 22px 16px;
  }

  .table-footer,
  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }
}
