/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);

  --space-1:  0.25rem;  --space-2:  0.5rem;
  --space-3:  0.75rem;  --space-4:  1rem;
  --space-5:  1.25rem;  --space-6:  1.5rem;
  --space-8:  2rem;     --space-10: 2.5rem;
  --space-12: 3rem;     --space-16: 4rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem;
  --radius-lg: 0.75rem;  --radius-xl: 1rem;
  --radius-full: 9999px;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --content-default: 980px;

  --font-body: 'General Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ============================================
   DARK THEME (default)
   ============================================ */
:root, [data-theme="dark"] {
  --color-bg:             #0a0f0f;
  --color-surface:        #0f1616;
  --color-surface-2:      #141e1e;
  --color-border:         #1e3030;
  --color-border-subtle:  #172626;

  --color-text:           #dfe8e6;
  --color-text-muted:     #7a9490;
  --color-text-faint:     #3e5c57;

  --color-primary:        #2dd4a8;
  --color-primary-hover:  #20b890;
  --color-primary-surface: rgba(45, 212, 168, 0.08);

  --color-accent:         #0fd9a3;
  --color-accent-hover:   #0bc08e;
  --color-accent-surface: rgba(15, 217, 163, 0.06);

  --color-success:        #34d399;
  --color-success-surface: rgba(52, 211, 153, 0.08);
  --color-warning:        #fbbf24;
  --color-error:          #f87171;
  --color-error-surface:  rgba(248, 113, 113, 0.06);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.45);
}

/* ============================================
   LIGHT THEME
   ============================================ */
[data-theme="light"] {
  --color-bg:             #f0f5f4;
  --color-surface:        #ffffff;
  --color-surface-2:      #f5faf9;
  --color-border:         #c8d8d4;
  --color-border-subtle:  #dde8e5;
  --color-text:           #0f1e1b;
  --color-text-muted:     #4a6b65;
  --color-text-faint:     #8faba5;
  --color-primary:        #0e9a78;
  --color-primary-hover:  #0a7d61;
  --color-primary-surface: rgba(14, 154, 120, 0.06);
  --color-accent:         #0e9a78;
  --color-accent-hover:   #0a7d61;
  --color-accent-surface: rgba(14, 154, 120, 0.05);
  --color-success:        #059669;
  --color-success-surface: rgba(5, 150, 105, 0.06);
  --color-warning:        #d97706;
  --color-error:          #dc2626;
  --color-error-surface:  rgba(220, 38, 38, 0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --color-bg: #f0f5f4; --color-surface: #ffffff; --color-surface-2: #f5faf9;
    --color-border: #c8d8d4; --color-border-subtle: #dde8e5;
    --color-text: #0f1e1b; --color-text-muted: #4a6b65; --color-text-faint: #8faba5;
    --color-primary: #0e9a78; --color-primary-hover: #0a7d61;
    --color-primary-surface: rgba(14,154,120,0.06);
    --color-accent: #0e9a78; --color-accent-hover: #0a7d61;
    --color-accent-surface: rgba(14,154,120,0.05);
    --color-success: #059669; --color-success-surface: rgba(5,150,105,0.06);
    --color-warning: #d97706; --color-error: #dc2626;
    --color-error-surface: rgba(220,38,38,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06); --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
  }
}

/* ============================================
   LAYOUT
   ============================================ */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
}

.logo {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-lg); font-weight: 700; color: var(--color-text);
  letter-spacing: -0.03em;
}
.logo-img {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  object-fit: cover;
}
.logo svg { color: var(--color-primary); }

[data-theme-toggle] { padding: var(--space-2); border-radius: var(--radius-md); color: var(--color-text-muted); }
[data-theme-toggle]:hover { background: var(--color-primary-surface); color: var(--color-primary); }

.main-content {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-6); padding: var(--space-6);
  max-width: var(--content-default); width: 100%; margin: 0 auto; align-items: start;
}
@media (max-width: 740px) {
  .main-content { grid-template-columns: 1fr; padding: var(--space-4); gap: var(--space-4); }
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--space-5);
}

/* ============================================
   MODE TABS
   ============================================ */
.mode-tabs {
  display: flex; gap: var(--space-1);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-5);
}

.mode-tab {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: center;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-interactive);
}

.mode-tab:hover { color: var(--color-text); }

.mode-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ============================================
   FORM INPUTS
   ============================================ */
.input-group { margin-bottom: var(--space-4); }

.input-group label {
  display: block; font-size: var(--text-xs); font-weight: 500;
  color: var(--color-text-muted); margin-bottom: var(--space-1); letter-spacing: 0.02em;
}

.input-wrapper { position: relative; display: flex; align-items: center; }

.input-suffix {
  position: absolute; right: var(--space-4);
  color: var(--color-text-faint); font-weight: 500; font-size: var(--text-sm);
  pointer-events: none;
}

input[type="number"],
input[type="text"],
select {
  width: 100%; padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base); color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}

.fee-wrapper input { padding-right: var(--space-8); }

select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23878a98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-4) center;
  padding-right: var(--space-10);
}

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 480px) { .input-row { grid-template-columns: 1fr; } }

.input-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}
.input-hint a {
  color: var(--color-primary);
  text-decoration: none;
}
.input-hint a:hover { text-decoration: underline; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ============================================
   FX RATE BAR (compact)
   ============================================ */
.fx-group { display: flex; flex-direction: column; }

.fx-rate-bar {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  height: 100%;
}

.fx-value {
  font-size: var(--text-base); font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums lining-nums;
  flex: 1;
}

.fx-refresh {
  padding: var(--space-1); border-radius: var(--radius-sm);
  color: var(--color-text-muted); display: flex; align-items: center;
}
.fx-refresh:hover { color: var(--color-primary); }
.fx-refresh svg { display: block; }

.fx-refresh.spinning svg { animation: spin 600ms linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* Top-3 live FX source list — small chips under the headline rate so the
   client can verify the app's number against named market sources */
.fx-sources {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
.fx-sources:empty { display: none; }
.fx-source-row {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 6px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}
.fx-source-primary {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.fx-source-rank { opacity: 0.7; font-weight: 600; flex-shrink: 0; }
.fx-source-label {
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-source-rate {
  font-variant-numeric: tabular-nums lining-nums;
  flex-shrink: 0;
  margin-left: auto;
}
.fx-source-empty { font-style: italic; white-space: normal; }

/* Shared section */
.shared-inputs {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

/* ============================================
   FETCH BUTTON + STATUS
   ============================================ */
.btn--full { width: 100%; justify-content: center; }

.fetch-status {
  font-size: var(--text-xs); margin-top: var(--space-2);
  min-height: 1.2em; font-weight: 500;
}
.fetch-status.loading { color: var(--color-primary); }
.fetch-status.success { color: var(--color-success); }
.fetch-status.error   { color: var(--color-error); }

/* ============================================
   RECEIPT
   ============================================ */
.receipt-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-5);
}
.receipt-header .card-title { margin-bottom: 0; }

.receipt-badge {
  font-size: var(--text-xs); font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface-2); color: var(--color-text-faint);
  letter-spacing: 0.02em;
}
.receipt-badge.status-active { background: var(--color-primary-surface); color: var(--color-primary); }
.receipt-badge.status-done   { background: var(--color-success-surface); color: var(--color-success); }
.receipt-badge.status-expired { background: var(--color-error-surface); color: var(--color-error); }

.receipt-placeholder {
  padding: var(--space-12) var(--space-4);
  text-align: center; color: var(--color-text-faint); font-size: var(--text-sm);
}

.estimate-notice {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md, 8px);
  background: color-mix(in srgb, var(--color-warning) 10%, transparent);
  color: var(--color-warning);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.estimate-notice svg { flex-shrink: 0; margin-top: 1px; }
.estimate-notice-text { color: var(--color-text); }
.estimate-notice-text strong { color: var(--color-warning); font-weight: 700; }
.val-estimate-tag {
  font-size: var(--text-xs); font-weight: 500;
  color: var(--color-warning);
  margin-left: var(--space-1);
  font-style: italic;
}

.receipt-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--space-3) 0; gap: var(--space-4);
}
.receipt-row-label { font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); flex-shrink: 0; }
.receipt-row-values { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.val-primary {
  font-size: var(--text-base); font-weight: 600; color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
}
.val-secondary {
  font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
.val-converted {
  font-size: var(--text-xs); color: var(--color-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
.val-fee { color: var(--color-error); }
.fee-pct-tag { font-size: var(--text-xs); font-weight: 500; color: var(--color-text-faint); margin-left: var(--space-1); }

.receipt-row--total { padding-top: var(--space-4); }
.val-total-usd {
  font-size: var(--text-base); font-weight: 600; color: var(--color-success);
  font-variant-numeric: tabular-nums lining-nums;
}
.val-total-mxn {
  font-size: var(--text-lg); font-weight: 700; color: var(--color-success);
  font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em;
}

.receipt-divider { height: 1px; background: var(--color-border-subtle); }
.receipt-divider--bold { height: 2px; background: var(--color-border); }

/* ============================================
   ADJUSTMENT SECTION
   ============================================ */
.adjust-section {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-label {
  user-select: none;
}

.adjust-fields {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.adjust-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 480px) {
  .adjust-row { grid-template-columns: 1fr; }
}

.adjust-summary {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  display: none;
}

.adjust-summary.positive {
  display: block;
  background: var(--color-success-surface);
  color: var(--color-success);
  border: 1px solid rgba(52, 211, 153, 0.15);
}

.adjust-summary.negative {
  display: block;
  background: var(--color-error-surface);
  color: var(--color-error);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

.adjust-summary.neutral {
  display: block;
  background: var(--color-primary-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ============================================
   CONFIRMATION TRACKER
   ============================================ */
.confirm-tracker {
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.confirm-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.confirm-count {
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
}

.confirm-count.done {
  color: var(--color-success);
}

.confirm-count.pending {
  color: var(--color-warning);
}

.confirm-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.confirm-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-warning);
  transition: width 400ms ease-out, background 400ms ease;
  min-width: 0;
}

.confirm-bar-fill.complete {
  background: var(--color-success);
}

.confirm-step {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Meta grid */
.receipt-meta {
  margin-top: var(--space-5); padding-top: var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-6);
}
@media (max-width: 480px) { .receipt-meta { grid-template-columns: 1fr; } }

.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-item--full { grid-column: 1 / -1; }
.meta-label { font-size: var(--text-xs); color: var(--color-text-faint); font-weight: 500; }
.meta-value { font-size: var(--text-sm); color: var(--color-text); font-weight: 500; word-break: break-all; }
.meta-value--mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.meta-value--link { color: var(--color-primary); text-decoration: none; }
.meta-value--link:hover { text-decoration: underline; }

.meta-value--copy {
  cursor: pointer;
  position: relative;
  padding-right: var(--space-5);
  transition: color var(--transition-interactive);
}
.meta-value--copy::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23878a98' stroke-width='2' stroke-linecap='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.5;
  transition: opacity var(--transition-interactive);
}
.meta-value--copy:hover { color: var(--color-primary); }
.meta-value--copy:hover::after { opacity: 1; }
.meta-value--copy.just-copied { color: var(--color-success); }
.meta-value--copy.just-copied::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2334d399' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  opacity: 1;
}

/* ============================================
   BUTTONS
   ============================================ */
.receipt-actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; border: none; white-space: nowrap;
}
.btn svg { display: block; flex-shrink: 0; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--outline { background: transparent; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn--outline:hover { background: var(--color-primary-surface); }

.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn.copied { background: var(--color-success) !important; color: #fff !important; border-color: var(--color-success) !important; }

/* ============================================
   FOOTER
   ============================================ */
.app-footer {
  padding: var(--space-4) var(--space-6); text-align: center;
  border-top: 1px solid var(--color-border-subtle);
}
.app-footer a, .footer-credit { font-size: var(--text-xs); color: var(--color-text-faint); text-decoration: none; }
.footer-credit a { color: var(--color-primary); }
.footer-credit a:hover { color: var(--color-primary-hover); text-decoration: underline; }
.app-footer a:hover { color: var(--color-text-muted); }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.receipt-content { animation: fadeIn 250ms ease-out; }

/* ============================================
   HISTORY SECTION (browser-only)
   ============================================ */
.history-section {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-1);
}
.history-title {
  font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0;
}
.history-hint {
  font-size: var(--text-xs); color: var(--color-text-faint);
  margin: 0 0 var(--space-3) 0;
}
.history-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--space-2);
}
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 56px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.history-item:hover { border-color: var(--color-primary); background: var(--color-surface-hover, var(--color-surface)); }
.history-item-main {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0; flex: 1;
}
.history-item-amount {
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text);
  line-height: 1.35;
  /* Order ID can be long; allow it to wrap rather than ellipsing the row */
  overflow-wrap: anywhere;
}
.history-item-meta {
  font-size: var(--text-xs); color: var(--color-text-muted);
  line-height: 1.4;
  /* Previously: white-space:nowrap + ellipsis — that compressed every row
     into one cramped clipped line once the dual-zone timestamp landed in
     here. The compact formatHistoryDate keeps this short, but we still
     allow a graceful wrap so long token labels (e.g. 'USDC on Polygon')
     don't get cut off at narrow widths. */
  white-space: normal;
  overflow-wrap: anywhere;
}
.history-item-arrow {
  color: var(--color-text-faint); flex-shrink: 0;
}
.history-item:hover .history-item-arrow { color: var(--color-primary); }
.btn--small {
  font-size: var(--text-xs); padding: var(--space-1) var(--space-2);
}
.history-toggle {
  margin-top: var(--space-3);
  background: none; border: none;
  color: var(--color-primary);
  font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; padding: var(--space-1) 0;
  text-align: left;
}
.history-toggle:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* History detail modal */
.history-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
}
.history-modal {
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  max-width: 640px; width: 100%;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.history-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.history-modal-title { font-size: var(--text-sm); font-weight: 600; margin: 0; }
.history-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); padding: var(--space-1);
  font-size: 20px; line-height: 1;
}
.history-modal-close:hover { color: var(--color-text); }
.history-modal-body {
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, monospace);
  font-size: var(--text-xs);
  white-space: pre-wrap; word-break: break-word;
  color: var(--color-text);
}
.history-modal-foot {
  display: flex; gap: var(--space-2); justify-content: flex-end;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* Accent buttons (teal) */
.btn--accent {
  background: var(--color-primary); color: #fff;
}
.btn--accent:hover { background: var(--color-primary-hover); }

.btn--outline-accent {
  background: transparent; color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn--outline-accent:hover { background: var(--color-primary-surface); }

input[type="email"] {
  width: 100%; padding: var(--space-3) var(--space-4);
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base); color: var(--color-text);
}
input[type="email"]:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}

/* ============================================
   SPLIT SECTION
   ============================================ */
.split-section {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.split-fields { margin-top: var(--space-4); }

/* Equal-split bar */
.split-equal-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.split-eq-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.split-equal-bar input[type="number"] {
  width: 4rem;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  text-align: center;
}
.split-equal-bar input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}

/* Each split row: label | amount input | usd+mxn | remove */
.split-row {
  display: grid;
  grid-template-columns: 6rem 8rem 1fr auto;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}
.split-part-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.split-row-values {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.split-row-usd {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}
.split-row-mxn {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 500;
  white-space: nowrap;
}
.split-row input[type="number"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  font-family: var(--font-body);
}
.split-row input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}

.split-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-faint);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  line-height: 0;
  transition: color var(--transition-interactive);
  flex-shrink: 0;
}
.split-remove:hover { color: var(--color-error); }

.split-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}
.split-total-indicator {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}
.split-total-indicator.ok    { color: var(--color-success); }
.split-total-indicator.over  { color: var(--color-error); }
.split-total-indicator.under { color: var(--color-warning); }

@media (max-width: 480px) {
  .split-row {
    grid-template-columns: 5rem 7rem 1fr auto;
    gap: var(--space-2);
  }
}
.split-total-indicator.under { color: var(--color-warning); }

.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  gap: var(--space-2);
}

@media (max-width: 480px) {
  .split-row {
    grid-template-columns: 1fr auto auto;
  }
}
