:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #617080;
  --line: #d9e0e7;
  --paper: #ffffff;
  --canvas: #f6f8fb;
  --accent: #126e82;
  --accent-strong: #0a5363;
  --warm: #f3b35b;
  --warm-strong: #b5771f;
  --success: #146c43;
  --danger: #9b2c2c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

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

button,
.connect-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

button:hover,
.connect-button:hover {
  background: var(--accent-strong);
}

button:disabled {
  background: #c8d2da;
  color: #697987;
  cursor: not-allowed;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 800;
}

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

h1 {
  font-size: clamp(2rem, 6vw, 3.8rem);
}

h2 {
  font-size: 1.35rem;
}

.workflow {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
}

.step.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.step.complete {
  background: #edf2f5;
  border-color: #ced9e2;
  color: #6f7e8b;
}

.step.complete.active {
  background: #dfe8ee;
  color: #52616e;
  border-color: #bdcbd6;
}

.activity-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.activity-panel h2 {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.posted-documents {
  display: grid;
  gap: 8px;
}

.posted-document {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 9px;
}

.posted-document strong {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.posted-document span,
.empty-activity {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.panel {
  display: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  min-height: 620px;
}

.panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 18px;
}

.panel-header p {
  color: var(--muted);
  margin: 7px 0 0;
  max-width: 760px;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 2px dashed #a8b7c5;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 14px;
  text-align: center;
}

.dropzone input {
  position: absolute;
  opacity: 0;
}

textarea,
input[type="text"],
input[type="date"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

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

.notice {
  margin: 16px 0;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fbfc;
  color: var(--muted);
}

.notice.success {
  color: var(--success);
  border-color: #b8dbc8;
  background: #f0fbf5;
}

.post-success {
  display: grid;
  gap: 8px;
  padding: 18px;
  font-size: 1rem;
}

.post-success strong {
  font-size: 1.25rem;
}

.post-success a {
  color: var(--accent-strong);
  font-weight: 800;
}

.notice.error {
  color: var(--danger);
  border-color: #e7b9b9;
  background: #fff6f6;
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ocr-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
}

.ocr-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent-strong);
}

.ocr-details pre {
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.85rem;
  color: #334756;
}

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

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

th {
  background: #f2f6f8;
  color: #324454;
  font-size: 0.85rem;
}

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

.connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
  background: #fbfcfd;
}

.connection-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.connection-action {
  white-space: nowrap;
}

.supported-receipts {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fbfcfd;
  color: var(--muted);
}

.supported-receipts strong {
  color: var(--ink);
}

.choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.field-stack {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  border-radius: 999px;
  border: 1px solid #b8cad6;
  color: #24424d;
  background: #f2f8fa;
  padding: 7px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

.inline-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 18px;
}

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

.alignment-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 130px minmax(160px, 0.8fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-title {
  font-weight: 800;
}

.entry-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.secondary-setup {
  border: 1px solid #efd7ac;
  border-left: 4px solid var(--warm);
  background: #fffdf8;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
  display: grid;
  gap: 14px;
}

.secondary-setup .setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-setup .setup-head strong {
  font-size: 1rem;
}

.secondary-setup .setup-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--warm-strong);
}

.setup-body {
  display: grid;
  gap: 14px;
}

.setup-body.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.values-line {
  display: grid;
  gap: 8px;
}

.values-line .label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
}

.value-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.value-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.value-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid #eaca92;
  color: var(--warm-strong);
  background: #fff5e6;
  padding: 6px 8px 6px 12px;
  font-size: 0.88rem;
  font-weight: 700;
}

.value-chip button {
  all: unset;
  cursor: pointer;
  line-height: 1;
  color: var(--warm-strong);
  font-size: 1.05rem;
  padding: 0 2px;
}

.value-chip button:hover {
  color: var(--danger);
}

.empty-values {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.list-head {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 130px minmax(160px, 0.8fr);
  gap: 10px;
  padding: 0 12px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.list-head.has-secondary,
.alignment-row.has-secondary {
  grid-template-columns: minmax(0, 1.5fr) 96px minmax(140px, 0.8fr) minmax(140px, 0.8fr);
}

.list-head .align-right {
  text-align: right;
}

.list-head .col-secondary {
  color: var(--warm-strong);
}

.row-label {
  display: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 5px;
}

select.secondary-select {
  border-color: #e7cfa0;
  background: #fffdf8;
}

.summary-subhead {
  margin-top: 10px;
  color: var(--warm-strong);
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

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

  .topbar,
  .workflow {
    display: block;
  }

  .connect-button {
    margin-top: 14px;
    width: 100%;
  }

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

  .panel {
    min-height: auto;
    padding: 16px;
  }

  .choice-grid,
  .alignment-row,
  .alignment-row.has-secondary,
  .inline-create,
  .name-row,
  .connection-row {
    grid-template-columns: 1fr;
  }

  .list-head {
    display: none;
  }

  .row-label {
    display: block;
  }

  .connection-row {
    display: grid;
  }

  .connection-action {
    width: 100%;
  }

  .supported-receipts {
    display: grid;
  }

  .amount {
    text-align: left;
  }
}
