:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #17202e;
  --muted: #667085;
  --accent: #1f7a68;
  --accent-2: #a5472a;
  --danger: #b42318;
  --warning: #b76e00;
  --info: #2563a6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: var(--accent);
}

.primary-action,
#dashboard-validate-button,
#validate-button,
#save-questionnaire-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.view-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 6px 0 18px;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.user-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #b9d8ce;
  border-radius: 6px;
  background: #eef8f4;
  color: #145345;
  font-size: 13px;
  font-weight: 700;
}

.user-badge.demo {
  border-color: #f1c27d;
  background: #fff7ed;
  color: #8a4b00;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.muted {
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 10;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #b9d8ce;
  border-radius: 8px;
  background: #eef8f4;
  color: #145345;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.start-panel {
  min-height: 360px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 22px;
  padding: 34px 0;
}

.visa-config-picker {
  width: 100%;
}

.config-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
}

.config-option {
  min-height: 86px;
  display: grid;
  gap: 4px;
  justify-items: start;
  align-content: center;
  text-align: left;
}

.config-option.selected {
  border-color: var(--accent);
  background: #eef8f4;
}

.config-option small {
  color: var(--muted);
}

.summary-band,
.dashboard,
.action-grid {
  display: grid;
  gap: 12px;
}

.summary-band {
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.summary-band div,
.metric {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.summary-band span,
.metric span,
.metric small {
  color: var(--muted);
  font-size: 14px;
}

.summary-band strong {
  overflow-wrap: anywhere;
}

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

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

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f4;
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

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

.applications-dashboard,
.my-applications-list {
  width: 100%;
}

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

.my-application-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 320px) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.my-application-row.selected {
  border-color: var(--accent);
  background: #eef8f4;
}

.my-application-row div {
  display: grid;
  gap: 3px;
}

.my-application-row small {
  color: var(--muted);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.reuse-document-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #b7d7cf;
  border-radius: 6px;
  background: #eef8f4;
}

.reuse-document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.notice-band {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #f0c36a;
  border-radius: 8px;
  background: #fff8e6;
}

.notice-band h2 {
  margin-bottom: 4px;
  color: var(--warning);
}

.package-band {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #b9d8ce;
  border-radius: 8px;
  background: #eef8f4;
}

.package-band h2 {
  margin-bottom: 4px;
  color: var(--accent);
}

.reconciliation-band {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.reconciliation-band.warning {
  border-color: #f0c36a;
  background: #fffdf5;
}

.reconciliation-band h2 {
  margin-bottom: 4px;
}

.reconciliation-band p {
  color: var(--muted);
  line-height: 1.45;
}

.reconciliation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-list,
.conflict-list {
  display: grid;
  gap: 8px;
}

.suggestion-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 190px);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.suggestion-item.warning {
  border-color: #f0c36a;
  background: #fff8e6;
}

.suggestion-item div:first-child {
  display: grid;
  gap: 4px;
}

.generated-file-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.package-note {
  border: 1px solid #b7d7cf;
  border-radius: 6px;
  color: var(--accent);
  margin-bottom: 10px;
  padding: 10px 12px;
}

.package-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.package-summary span {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid #b7d7cf;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.package-summary strong {
  color: var(--text);
  font-size: 18px;
}

.download-link {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.download-link:hover {
  border-color: var(--accent);
}

.zip-link {
  margin-bottom: 8px;
  border-color: var(--accent);
  font-weight: 700;
}

.view-heading {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-band {
  padding: 18px 0 24px;
  border-bottom: 1px solid var(--line);
}

.section-band h3 {
  margin-bottom: 12px;
  text-transform: capitalize;
}

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

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

.field span {
  min-height: 22px;
  font-size: 14px;
  font-weight: 650;
}

.field input,
.field select,
.document-actions input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px 10px;
}

.field small,
.document-item small,
.validation-item small {
  color: var(--muted);
  line-height: 1.35;
}

.required {
  display: inline-block;
  margin-left: 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 650;
}

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

.consent-band {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.consent-band label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--text);
  line-height: 1.4;
}

.ocr-test-band,
.batch-extraction-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ocr-test-band p,
.batch-extraction-band p {
  color: var(--muted);
  line-height: 1.4;
}

#ocr-test-result,
#batch-extraction-result {
  grid-column: 1 / -1;
}

.batch-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.batch-progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8e5;
}

.batch-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: var(--accent);
  animation: batch-progress-move 1.1s ease-in-out infinite;
}

@keyframes batch-progress-move {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(245%);
  }
}

.read-data-panel {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.read-data-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.read-data-row small {
  padding: 3px 6px;
  border-radius: 999px;
  background: #eef5f2;
  color: var(--accent);
}

.read-data-row.failed small,
.read-data-row.conflict small,
.read-data-row.low_confidence small {
  background: #fff7e8;
  color: #955a00;
}

.empty-state.compact {
  padding: 14px;
}

.document-item,
.validation-item {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.document-item {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
}

.document-item.uploaded {
  border-color: var(--accent);
}

.document-item.rejected {
  border-color: var(--danger);
  background: #fff7f5;
}

.document-item h3 {
  margin-bottom: 4px;
}

.document-item p,
.validation-item p {
  color: var(--muted);
  line-height: 1.45;
}

.document-actions {
  display: grid;
  gap: 8px;
}

.document-actions.inline {
  align-content: start;
}

.document-actions.inline > button[data-extract-document] {
  display: none;
}

.debug-extraction-tools,
.debug-extraction-panel {
  color: var(--muted);
}

.debug-extraction-tools summary,
.debug-extraction-panel summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 650;
}

.debug-extraction-tools button {
  margin-top: 8px;
  background: #edf3f1;
  color: var(--text);
}

.uploaded-file-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.uploaded-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 210px);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
}

.uploaded-file-row > div:first-child {
  display: grid;
  gap: 4px;
}

.operator-comment {
  margin-top: 8px;
  color: var(--danger);
  font-weight: 650;
}

.extraction-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #b9d8ce;
  border-radius: 8px;
  background: #eef8f4;
}

.extraction-panel.warning {
  border-color: #f0c36a;
  background: #fff8e6;
}

.extraction-panel h4 {
  margin: 0;
}

.extraction-warning {
  padding: 8px 10px;
  border: 1px solid #f0c36a;
  border-radius: 6px;
  background: #fff8e6;
  color: var(--warning);
  font-size: 13px;
  line-height: 1.35;
}

.batch-category-list {
  display: grid;
  gap: 8px;
}

.batch-category-row {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid #b7d7cf;
  border-radius: 6px;
  background: var(--surface);
}

.batch-category-row.warning {
  border-color: #f0c36a;
  background: #fffdf5;
}

.batch-category-row small {
  color: var(--muted);
}

.extraction-fields {
  display: grid;
  gap: 8px;
}

.extraction-fields label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
}

.validation-group {
  border-bottom: 0;
}

.validation-item {
  grid-template-columns: 92px minmax(0, 1fr);
  margin-bottom: 10px;
}

.validation-item.error strong {
  color: var(--danger);
}

.validation-item.warning strong {
  color: var(--warning);
}

.validation-item.info strong {
  color: var(--info);
}

.validation-item div {
  display: grid;
  gap: 4px;
}

.comment-item {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.comment-item p {
  color: var(--muted);
  line-height: 1.45;
}

.comment-item small {
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 840px) {
  .summary-band,
  .dashboard,
  .action-grid,
  .field-grid,
  .my-application-row,
  .generated-file-list,
  .package-summary,
  .ocr-test-band,
  .suggestion-item,
  .uploaded-file-row,
  .document-item {
    grid-template-columns: 1fr;
  }

  .topbar,
  .view-heading {
    display: grid;
    justify-items: start;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 14px;
  }

  h1 {
    font-size: 23px;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }
}
