:root {
  color-scheme: light;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --brand: #0b1830;
  --brand-raised: #13294b;
  --brand-soft: #eaf0f8;
  --accent: #eeb85b;
  --accent-strong: #d99a31;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --background: #f3f5f9;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --success: #067647;
  --success-bg: #ecfdf3;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 12px 32px rgba(11, 24, 48, 0.09);
  --shadow-lg: 0 24px 64px rgba(11, 24, 48, 0.14);
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.4rem;
  --nav-height: 4.6rem;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--background); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #edf1f7 0, var(--background) 22rem),
    var(--background);
}

button, input, select, textarea { font: inherit; }
button, a, label[for] { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-raised); text-underline-offset: 0.2em; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(5rem);
  pointer-events: none;
  opacity: 0.18;
}
.ambient-one { top: -9rem; right: -8rem; background: var(--accent); }
.ambient-two { bottom: 15%; left: -12rem; background: #8aace1; }

.app-shell {
  width: min(100%, 46rem);
  min-height: 100vh;
  margin: 0 auto;
  padding:
    max(1.15rem, env(safe-area-inset-top))
    1rem
    calc(var(--nav-height) + max(1.5rem, env(safe-area-inset-bottom)));
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 10vw, 3.3rem);
  font-weight: 850;
  letter-spacing: -0.045em;
  line-height: 0.98;
}
h2 {
  margin-bottom: 0.4rem;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
h3 { font-size: 1rem; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.75rem 0 1.35rem;
}
.topbar-actions { display: flex; align-items: center; gap: 0.7rem; }

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.section-intro { max-width: 32rem; margin-bottom: 1.15rem; color: var(--muted); line-height: 1.5; }
.muted, .hint { color: var(--muted); }
.hint { margin: 0.45rem 0 0; font-size: 0.79rem; line-height: 1.45; }

.card {
  margin-bottom: 1rem;
  padding: 1.2rem;
  border: 1px solid rgba(208, 213, 221, 0.72);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(1rem);
}
.card-subtle { box-shadow: var(--shadow-sm); }
.card-dark {
  overflow: hidden;
  position: relative;
  color: white;
  border-color: rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 100% 0, rgba(238, 184, 91, 0.28), transparent 42%),
    linear-gradient(145deg, var(--brand-raised), var(--brand));
  box-shadow: var(--shadow-lg);
}
.card-dark .muted, .card-dark .hint { color: rgba(255, 255, 255, 0.68); }
.stack { display: grid; gap: 0.82rem; }

.profile-switcher {
  display: flex;
  min-height: 2.75rem;
  padding: 0.22rem;
  border: 1px solid rgba(208, 213, 221, 0.75);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-sm);
}
.profile-switcher a {
  display: grid;
  min-width: 3.6rem;
  min-height: 2.3rem;
  padding: 0.45rem 0.65rem;
  place-items: center;
  border-radius: 0.66rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}
.profile-switcher a[aria-current="page"] {
  color: white;
  background: var(--brand);
  box-shadow: 0 0.25rem 0.75rem rgba(11, 24, 48, 0.2);
}

label { color: var(--ink-soft); font-size: 0.85rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 3.15rem;
  padding: 0.78rem 0.88rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.82rem;
  outline: 0;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.03);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #98a2b3; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(238, 184, 91, 0.2);
}

button, .button {
  display: inline-grid;
  min-height: 3.15rem;
  padding: 0.78rem 1rem;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 0.82rem;
  color: white;
  background: var(--brand);
  font-weight: 820;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 0.45rem 1rem rgba(11, 24, 48, 0.16);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
button:hover, .button:hover { background: var(--brand-raised); box-shadow: 0 0.6rem 1.3rem rgba(11, 24, 48, 0.2); }
button:active, .button:active { transform: translateY(1px) scale(0.995); }
button:focus-visible, .button:focus-visible, a:focus-visible, summary:focus-visible, label[for]:focus-visible {
  outline: 3px solid rgba(238, 184, 91, 0.72);
  outline-offset: 3px;
}
button:disabled { opacity: 0.58; cursor: wait; }
button.secondary, .button.secondary {
  color: var(--ink-soft);
  border-color: var(--line);
  background: white;
  box-shadow: var(--shadow-sm);
}
button.secondary:hover, .button.secondary:hover { color: var(--ink); background: #f9fafb; }
.button-wide { width: 100%; }

.capture-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.capture-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.upload-option {
  display: grid;
  min-height: 8.5rem;
  padding: 1.2rem;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.34);
  border-radius: var(--radius-md);
  color: white;
  background: rgba(255, 255, 255, 0.07);
  text-align: center;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.upload-option:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.11); }
.upload-option:active { transform: scale(0.992); }
.upload-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.7rem;
  place-items: center;
  border-radius: 50%;
  color: var(--brand);
  background: var(--accent);
  font-size: 1.35rem;
  box-shadow: 0 0.5rem 1.5rem rgba(238, 184, 91, 0.24);
}
.upload-title { display: block; font-size: 1rem; font-weight: 820; }
.upload-help { display: block; margin-top: 0.3rem; color: rgba(255, 255, 255, 0.62); font-size: 0.78rem; font-weight: 500; }
.upload-source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.upload-source:focus-visible + .upload-option {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.file-selection {
  display: none;
  align-items: center;
  gap: 0.65rem;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
}
.file-selection.has-file { display: flex; }
.file-selection-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.6rem;
  color: var(--brand);
  background: var(--accent);
  font-weight: 900;
}
.capture-fields { display: grid; gap: 0.9rem; margin-top: 0.2rem; }
.field-group { display: grid; gap: 0.38rem; }
.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); margin: 0.15rem 0; font-size: 0.78rem; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.utility-panel summary, .transaction-editor summary {
  list-style: none;
  cursor: pointer;
}
.utility-panel summary::-webkit-details-marker, .transaction-editor summary::-webkit-details-marker { display: none; }
.utility-panel summary {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 800;
}
.utility-panel summary::after, .transaction-editor summary::after {
  content: "⌄";
  color: var(--muted);
  font-size: 1.15rem;
  transition: transform 160ms ease;
}
.utility-panel[open] summary::after, .transaction-editor[open] summary::after { transform: rotate(180deg); }
.utility-content { display: grid; gap: 0.75rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  left: max(0.75rem, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(calc(100% - 1.5rem), 28rem);
  min-height: var(--nav-height);
  margin: 0 auto;
  padding: 0.42rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 1.35rem;
  background: rgba(11, 24, 48, 0.94);
  box-shadow: 0 1.1rem 3rem rgba(11, 24, 48, 0.34);
  backdrop-filter: blur(1.25rem);
}
.bottom-nav a {
  display: grid;
  min-height: 3.7rem;
  place-items: center;
  align-content: center;
  gap: 0.15rem;
  border-radius: 1rem;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.68rem;
  font-weight: 750;
  text-decoration: none;
}
.bottom-nav svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bottom-nav a[aria-current="page"] { color: var(--brand); background: var(--accent); }

.toast-stack { position: relative; z-index: 30; }
.toast, .error, .notice, .warning {
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-sm);
  line-height: 1.45;
}
.toast { display: flex; align-items: center; gap: 0.65rem; box-shadow: var(--shadow-md); }
.toast-mark { display: grid; width: 1.6rem; height: 1.6rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.72); color: inherit; }
.error { color: var(--danger); background: var(--danger-bg); }
.notice { color: var(--success); background: var(--success-bg); }
.warning { color: var(--warning); background: var(--warning-bg); }
.errorlist { margin: 0.25rem 0 0; padding-left: 1.25rem; color: var(--danger); font-size: 0.82rem; }

.status-hero { padding: 1.35rem; }
.status-hero-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 0.9rem; }
.status-orb {
  display: grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 1.2rem;
  font-weight: 900;
}
.status-orb.success { color: var(--success); background: var(--success-bg); }
.status-orb.caution { color: var(--warning); background: var(--warning-bg); }
.status-orb.danger { color: var(--danger); background: var(--danger-bg); }
.status-copy h2 { margin: 0 0 0.18rem; }
.status-copy p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.status {
  display: inline-flex;
  width: fit-content;
  padding: 0.3rem 0.58rem;
  align-items: center;
  border-radius: 999px;
  color: var(--ink-soft);
  background: #eef2f6;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}
.status-ready, .status-imported { color: var(--success); background: var(--success-bg); }
.status-needs_details { color: var(--warning); background: var(--warning-bg); }
.status-failed { color: var(--danger); background: var(--danger-bg); }
.processing-message { display: flex; align-items: center; gap: 0.58rem; margin-bottom: 0; }
.spinner {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  border: 2px solid #d0d5dd;
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.transaction-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-sm);
}
.transaction-editor + .transaction-editor { margin-top: 0.75rem; }
.transaction-editor summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  min-height: 4.5rem;
  padding: 0.9rem;
  align-items: center;
  gap: 0.7rem;
}
.transaction-summary-title { display: grid; gap: 0.15rem; min-width: 0; }
.transaction-summary-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-summary-title span { color: var(--muted); font-size: 0.76rem; }
.transaction-amount { font-weight: 850; white-space: nowrap; }
.transaction-editor-body { padding: 0 0.9rem 0.95rem; border-top: 1px solid var(--line); }
.confirmation-grid { display: grid; grid-template-columns: 1fr; gap: 0.82rem; padding-top: 0.9rem; }
.confirmation-grid > div { min-width: 0; }
.draft { padding: 1rem 0; border-top: 1px solid var(--line); }
.draft:first-child { border-top: 0; }
.draft p { margin-bottom: 0.75rem; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
dl div { min-width: 0; }
dt { color: var(--muted); font-size: 0.72rem; font-weight: 750; }
dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }

.chat { display: grid; gap: 0.65rem; margin-bottom: 1rem; }
.chat p {
  max-width: 92%;
  margin: 0;
  padding: 0.78rem 0.85rem;
  border-radius: 0.95rem 0.95rem 0.95rem 0.25rem;
  background: #eef2f6;
  line-height: 1.45;
}
.chat .chat-user {
  justify-self: end;
  border-radius: 0.95rem 0.95rem 0.25rem 0.95rem;
  color: white;
  background: var(--brand-raised);
}

.history-list { margin: 0; padding: 0; list-style: none; }
.history-list li + li { border-top: 1px solid var(--line); }
.history-row {
  display: grid;
  grid-template-columns: 2.65rem minmax(0, 1fr) auto;
  min-height: 5.25rem;
  padding: 0.9rem 0;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink);
  text-decoration: none;
}
.history-icon {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border-radius: 0.85rem;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 1rem;
  font-weight: 900;
}
.history-icon.activity { color: var(--warning); background: var(--warning-bg); }
.history-main { display: grid; gap: 0.25rem; min-width: 0; }
.history-title { overflow: hidden; font-weight: 780; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.history-side { display: grid; justify-items: end; gap: 0.35rem; }
.history-time { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.pagination { display: flex; min-height: 3.2rem; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; font-size: 0.82rem; }

.status-grid { display: grid; gap: 0.7rem; }
.health-row {
  display: flex;
  min-height: 3.8rem;
  padding: 0.8rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
}
.health-label { display: flex; align-items: center; gap: 0.65rem; font-weight: 750; }
.health-dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0.25rem var(--success-bg); }
.health-dot.missing { background: var(--danger); box-shadow: 0 0 0 0.25rem var(--danger-bg); }

.pair-page .app-shell { display: grid; align-items: center; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
.pair-card { width: 100%; margin: 2rem auto; padding: 1.45rem; }
.brand-mark {
  display: grid;
  width: 3.7rem;
  height: 3.7rem;
  margin-bottom: 1.25rem;
  place-items: center;
  border-radius: 1.15rem;
  color: var(--brand);
  background: var(--accent);
  font-size: 1.55rem;
  font-weight: 900;
  box-shadow: 0 0.75rem 2rem rgba(238, 184, 91, 0.25);
}
.back-link { font-weight: 800; text-decoration: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 23rem) {
  .app-shell { padding-inline: 0.75rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar .profile-switcher { align-self: stretch; }
  .profile-switcher a { flex: 1; }
  .history-row { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .history-side { grid-column: 2; justify-items: start; }
}

@media (min-width: 40rem) {
  .app-shell { padding-inline: 1.5rem; }
  .card { padding: 1.55rem; }
  .capture-fields, .confirmation-grid { grid-template-columns: 1fr 1fr; }
  .capture-fields .field-span, .confirmation-grid .field-span { grid-column: 1 / -1; }
  .pair-card { max-width: 30rem; padding: 2rem; }
}

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

@media (forced-colors: active) {
  .bottom-nav, .card-dark, button, .button { border: 1px solid ButtonText; }
  .status, .health-dot { forced-color-adjust: none; }
}
