/* ---------------------------------------------------------------------------
   Design tokens
   --------------------------------------------------------------------------- */
:root {
  --green: #9fe870;
  --green-dark: #8fd960;
  --forest: #163300;
  --forest-soft: #1c4000;
  --ink: #0e0f0c;
  --ink-2: #454b45;
  --ink-3: #6b706b;
  --line: #e3e5e2;
  --line-soft: #eff1ee;
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #f2f4f0;
  --positive: #2f7c3d;
  --positive-bg: #eaf6e6;
  --negative: #a8200d;
  --negative-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4d9;
  --info-bg: #e8f1fb;
  --radius-s: 10px;
  --radius: 16px;
  --radius-l: 24px;
  --shadow-s: 0 1px 2px rgba(22, 51, 0, 0.06), 0 1px 3px rgba(22, 51, 0, 0.04);
  --shadow: 0 4px 16px rgba(22, 51, 0, 0.07), 0 1px 3px rgba(22, 51, 0, 0.05);
  --shadow-l: 0 18px 48px rgba(22, 51, 0, 0.16);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --forest: #9fe870;
  --forest-soft: #b6f08f;
  --ink: #f3f5f1;
  --ink-2: #b9c0b6;
  --ink-3: #8d948b;
  --line: #2c332a;
  --line-soft: #232a21;
  --bg: #0f120e;
  --surface: #181c16;
  --surface-2: #212619;
  --positive: #86d98a;
  --positive-bg: #1a2c19;
  --negative: #ff9c8b;
  --negative-bg: #331914;
  --warn: #f0c56a;
  --warn-bg: #302713;
  --info-bg: #16232f;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-l: 0 18px 48px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0; }

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

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--green);
  color: var(--forest);
}

:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
  border-radius: 6px;
}

:root[data-theme="dark"] :focus-visible { outline-color: var(--green); }

/* ---------------------------------------------------------------------------
   Boot state
   --------------------------------------------------------------------------- */
.app-loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.boot-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--forest);
  animation: spin 0.7s linear infinite;
}

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

/* ---------------------------------------------------------------------------
   Auth screen
   --------------------------------------------------------------------------- */
.auth {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-hero {
  background: var(--forest);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

:root[data-theme="dark"] .auth-hero { background: #10240a; }

.auth-hero::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -160px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: rgba(159, 232, 112, 0.14);
}

.auth-hero h1 {
  color: #fff;
  font-size: 44px;
  max-width: 12ch;
  position: relative;
}

.auth-hero .lede {
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
  max-width: 42ch;
  margin-top: 18px;
  position: relative;
}

.hero-rates {
  position: relative;
  display: grid;
  gap: 10px;
  margin-top: 40px;
  max-width: 380px;
}

.hero-rate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-variant-numeric: tabular-nums;
}

.hero-rate span:first-child {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
}

.hero-rate b {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card .logo {
  margin-bottom: 28px;
}

.demo-hint {
  margin-top: 22px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink-2);
}

.demo-hint b { color: var(--ink); }

.demo-hint button {
  background: none;
  border: none;
  padding: 0;
  margin-top: 8px;
  color: var(--forest);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* ---------------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
  padding: 0 10px 20px;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--green);
  color: #163300;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  flex: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover { background: var(--surface-2); color: var(--ink); }

.nav-item.active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

.nav-item .icon { width: 20px; display: grid; place-items: center; flex: none; }

.nav-badge {
  margin-left: auto;
  background: var(--green);
  color: #163300;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}

.user-chip:hover { background: var(--surface-2); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #163300;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

.user-chip .meta { min-width: 0; }
.user-chip .name { font-weight: 600; font-size: 14px; }
.user-chip .sub { font-size: 12px; color: var(--ink-3); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-scroll {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main {
  padding: 32px 40px 64px;
  max-width: 1180px;
  width: 100%;
  flex: 1;
}

.nav-section + .nav-section {
  margin-top: 14px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 0 12px 6px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.page-head .sub { color: var(--ink-3); margin-top: 6px; }

.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  /* The footer follows .main, so the clearance for the fixed bottom nav
     belongs on the footer rather than here. */
  .main { padding: 20px 16px 28px; }
  .site-footer .footer-inner {
    padding-bottom: calc(28px + 78px + env(safe-area-inset-bottom));
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .bottom-nav button {
    background: none;
    border: none;
    display: grid;
    gap: 3px;
    justify-items: center;
    font-size: 11px;
    color: var(--ink-3);
    padding: 6px 2px;
    cursor: pointer;
    border-radius: 10px;
  }
  .bottom-nav button.active { color: var(--ink); font-weight: 600; }

  /* Tighten the type scale so headings don't dominate a phone screen. */
  h1 { font-size: 25px; }
  h2 { font-size: 19px; }
  .total-card { padding: 22px; }
  .total-card .value { font-size: 34px; }
  .card { padding: 18px; border-radius: var(--radius); }
  .page-head { margin-bottom: 18px; }
}

/* ---------------------------------------------------------------------------
   Cards & primitives
   --------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 24px;
  box-shadow: var(--shadow-s);
}

.card.tight { padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

@media (max-width: 760px) {
  .grid.cols-2,
  .grid.cols-3 { grid-template-columns: 1fr; }
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; }
.stack.sm { gap: 10px; }
.stack.lg { gap: 26px; }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

/* Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: var(--green);
  color: #163300;
  transition: transform 0.08s ease, background 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--green-dark); }
.btn:active:not(:disabled) { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--ink);
}

.btn.secondary:hover:not(:disabled) { background: var(--line-soft); }

.btn.outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}

.btn.outline:hover:not(:disabled) { border-color: var(--ink-3); background: transparent; }

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  padding: 8px 12px;
}

.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn.danger { background: var(--negative-bg); color: var(--negative); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 16px; font-size: 14px; }
.btn.lg { padding: 15px 30px; font-size: 16px; }

.btn .spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(22, 51, 0, 0.25);
  border-top-color: #163300;
  animation: spin 0.6s linear infinite;
}

.btn.secondary .spinner,
.btn.outline .spinner {
  border-color: var(--line);
  border-top-color: var(--ink);
}

/* Quick actions ------------------------------------------------------------ */
/* Falls to a balanced 2x2 in a narrow card, one row when there's space. */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.action-tile {
  display: grid;
  justify-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px;
  min-width: 96px;
  flex: 1;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: border-color 0.12s ease, transform 0.08s ease;
}

.action-tile:hover { border-color: var(--forest); }
.action-tile:active { transform: scale(0.98); }

.action-tile .glyph {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: #163300;
  display: grid;
  place-items: center;
}

/* Forms -------------------------------------------------------------------- */
.field { display: grid; gap: 7px; }

.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.input,
.select,
textarea.input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--line);
  background: var(--surface);
  transition: border-color 0.12s ease;
}

.input:focus,
.select:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--forest);
}

.input.invalid { border-color: var(--negative); }

textarea.input { resize: vertical; min-height: 76px; }

.field-error {
  font-size: 12.5px;
  color: var(--negative);
  font-weight: 500;
}

.hint { font-size: 12.5px; color: var(--ink-3); }

.form-error {
  background: var(--negative-bg);
  color: var(--negative);
  border-radius: var(--radius-s);
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 500;
}

/* Amount + currency composite --------------------------------------------- */
.amount-field {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: stretch;
  background: var(--surface);
  transition: border-color 0.12s ease;
}

.amount-field:focus-within { border-color: var(--forest); }
.amount-field.invalid { border-color: var(--negative); }

.amount-field .amount-input {
  border: none;
  background: none;
  padding: 16px 8px 16px 16px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  width: 100%;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.amount-field .amount-input:focus { outline: none; }

.amount-field .amount-label {
  position: absolute;
  top: 8px;
  left: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.amount-field.labelled { position: relative; }
.amount-field.labelled .amount-input { padding-top: 26px; padding-bottom: 12px; }
.amount-field.labelled .currency-trigger { padding-top: 14px; }

.currency-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-left: 1.5px solid var(--line);
  background: none;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.currency-trigger:hover { background: var(--surface-2); }
.currency-trigger .flag { font-size: 19px; line-height: 1; }
.currency-trigger .chev { color: var(--ink-3); font-size: 11px; }

/* Currency picker popover -------------------------------------------------- */
/* Sits above .modal-backdrop: a picker is always opened from something else. */
.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 12, 0.35);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.14s ease;
}

@keyframes fade {
  from { opacity: 0; }
}

.picker {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
  width: min(440px, 100%);
  max-height: min(560px, 86vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

.picker-head {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.picker-list {
  overflow-y: auto;
  padding: 8px;
}

.picker-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: none;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.picker-option:hover,
.picker-option.highlight { background: var(--surface-2); }
.picker-option .flag { font-size: 24px; line-height: 1; }
.picker-option .code { font-weight: 700; }
.picker-option .name { font-size: 13px; color: var(--ink-3); }
.picker-option .right { margin-left: auto; text-align: right; font-size: 13px; }

.picker-empty { padding: 32px; text-align: center; color: var(--ink-3); }

/* Modal -------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 12, 0.4);
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.14s ease;
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
  width: min(520px, 100%);
  padding: 26px;
  animation: pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  margin: auto;
}

/* Balances ----------------------------------------------------------------- */
.total-card {
  background: var(--forest);
  color: #fff;
  border-radius: var(--radius-l);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

:root[data-theme="dark"] .total-card { background: #10240a; }

.total-card::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -90px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(159, 232, 112, 0.12);
}

.total-card .label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.total-card .value {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  position: relative;
}

.total-card .flows {
  display: flex;
  gap: 22px;
  margin-top: 20px;
  position: relative;
  flex-wrap: wrap;
}

.total-card .flow span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12.5px;
}

.total-card .flow b {
  display: block;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.balance-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.12s ease, transform 0.08s ease;
}

.balance-card:hover { border-color: var(--forest); }
.balance-card:active { transform: scale(0.995); }

.balance-card .flag {
  font-size: 26px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: none;
}

.balance-card .code { font-weight: 700; font-size: 14px; }
.balance-card .name { font-size: 12.5px; color: var(--ink-3); }

.balance-card .amount {
  margin-left: auto;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.balance-card .converted { font-size: 12px; color: var(--ink-3); font-weight: 500; }

.add-balance {
  border: 1.5px dashed var(--line);
  background: none;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 600;
  width: 100%;
}

.add-balance:hover { border-color: var(--forest); color: var(--ink); }

/* Transactions ------------------------------------------------------------- */
.tx-group-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
  padding: 16px 20px 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--line-soft);
}

.tx-row:first-of-type { border-top: none; }
.tx-row:hover { background: var(--surface-2); }

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 15px;
}

.tx-icon.in { background: var(--positive-bg); color: var(--positive); }
.tx-icon.out { background: var(--surface-2); color: var(--ink-2); }
.tx-icon.neutral { background: var(--info-bg); color: #1c5ba8; }

:root[data-theme="dark"] .tx-icon.neutral { color: #8ec0f5; }

.tx-main { min-width: 0; flex: 1; }
.tx-title { font-weight: 600; }
.tx-sub { font-size: 12.5px; color: var(--ink-3); }

.tx-amount {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tx-amount.in { color: var(--positive); }
.tx-amount .secondary { display: block; font-size: 12px; font-weight: 500; color: var(--ink-3); }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-3);
}

.empty .glyph {
  font-size: 30px;
  margin-bottom: 10px;
}

/* Badges ------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-2);
}

.badge.success { background: var(--positive-bg); color: var(--positive); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.failed { background: var(--negative-bg); color: var(--negative); }

.pill-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.pill-toggle button {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}

.pill-toggle button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-s);
}

/* Quote breakdown ---------------------------------------------------------- */
.breakdown {
  display: grid;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 6px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-size: 14px;
}

.breakdown-row .label { color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.breakdown-row .value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.breakdown-row.total {
  background: var(--surface);
  border-radius: 12px;
  font-weight: 700;
}
.breakdown-row.sub { font-size: 13px; padding: 4px 14px 4px 30px; color: var(--ink-3); }
.breakdown-row.sub .value { font-weight: 500; color: var(--ink-3); }

.rate-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--positive-bg);
  color: var(--positive);
  font-weight: 600;
  font-size: 14px;
  flex-wrap: wrap;
}

.rate-strip .countdown {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  opacity: 0.85;
}

.rate-strip.stale { background: var(--warn-bg); color: var(--warn); }

.info-note {
  background: var(--info-bg);
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 13.5px;
  color: var(--ink-2);
  display: flex;
  gap: 10px;
}

/* Chart -------------------------------------------------------------------- */
.chart-card { padding: 20px 22px 12px; }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 190px;
}

.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }

.chart-line { fill: none; stroke: var(--forest); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: url(#chartFade); }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-dot { fill: var(--forest); }

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
  padding-top: 8px;
}

.sparkline { width: 76px; height: 26px; display: block; }
.sparkline path { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }

.delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--negative); }
.delta.flat { color: var(--ink-3); }

/* Rate board --------------------------------------------------------------- */
.rate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  border-left: none;
  border-right: none;
  border-bottom: none;
  background: none;
  width: 100%;
  text-align: left;
}

.rate-row:hover { background: var(--surface-2); }
.rate-row .flag { font-size: 24px; width: 34px; flex: none; }
.rate-row .code { font-weight: 700; }
.rate-row .name { font-size: 12.5px; color: var(--ink-3); }
.rate-row .rate { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.tick-flash-up { animation: flashUp 0.6s ease; }
.tick-flash-down { animation: flashDown 0.6s ease; }

@keyframes flashUp {
  0% { color: var(--positive); }
  100% { color: inherit; }
}

@keyframes flashDown {
  0% { color: var(--negative); }
  100% { color: inherit; }
}

/* Steps / timeline --------------------------------------------------------- */
.timeline { display: grid; gap: 0; }

.timeline-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
}

.timeline-step:last-child { padding-bottom: 0; }

.timeline-step::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 20px;
  bottom: -2px;
  width: 2px;
  background: var(--line);
}

.timeline-step:last-child::before { display: none; }

.timeline-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--positive-bg);
  color: var(--positive);
  font-size: 12px;
  z-index: 1;
}

.timeline-dot.pending { background: var(--warn-bg); color: var(--warn); }
.timeline-step .label { font-weight: 600; font-size: 14px; }
.timeline-step .at { font-size: 12px; color: var(--ink-3); }

/* Stepper header ----------------------------------------------------------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stepper .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}

.stepper .step .num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.stepper .step.active { color: var(--ink); }
.stepper .step.active .num { background: var(--green); color: #163300; }
.stepper .step.done .num { background: var(--positive-bg); color: var(--positive); }
.stepper .sep { color: var(--line); }

/* Success screen ----------------------------------------------------------- */
.success-hero {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: 34px 20px 10px;
}

.success-check {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--green);
  color: #163300;
  display: grid;
  place-items: center;
  font-size: 32px;
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

/* Toasts ------------------------------------------------------------------- */
.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  background: var(--forest);
  color: #fff;
  border-radius: var(--radius);
  padding: 13px 17px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-l);
  animation: toastIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  display: flex;
  align-items: center;
  gap: 10px;
}

:root[data-theme="dark"] .toast { background: #24331c; border: 1px solid var(--line); }

.toast.error { background: var(--negative); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
}

@media (max-width: 860px) {
  .toasts { bottom: 84px; }
}

/* Misc --------------------------------------------------------------------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  border-top: 1px solid var(--line-soft);
}

.list-row:first-child { border-top: none; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 50%, var(--surface-2) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 6px;
}

.back-link:hover { color: var(--ink); }

.narrow { max-width: 560px; }
.wide { max-width: 820px; }

/* ---------------------------------------------------------------------------
   Site footer
   --------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  margin-top: 40px;
}

.footer-inner {
  max-width: 1180px;
  padding: 44px 40px 28px;
}

.footer-top {
  display: grid;
  grid-template-columns: minmax(210px, 0.85fr) 3.4fr;
  gap: 40px;
}

.footer-brand p {
  max-width: 34ch;
  margin-bottom: 16px;
}

.footer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 5px 11px;
}

/* Explicit counts rather than auto-fit, so the five columns break evenly
   instead of leaving one orphan on a second row. */
.footer-columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 1180px) {
  .footer-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
}

@media (max-width: 620px) {
  .footer-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.footer-column h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.footer-column ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.footer-column a,
.footer-inert {
  font-size: 13.5px;
  color: var(--ink-3);
}

.footer-column a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.footer-inert {
  cursor: default;
}

.footer-entities {
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line-soft);
}

.footer-entities h4 {
  font-size: 13px;
  margin-bottom: 14px;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

.entity p {
  margin-top: 3px;
  line-height: 1.45;
}

.footer-disclaimer {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 28px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
}

.footer-disclaimer p {
  line-height: 1.5;
}

.footer-disclaimer svg {
  flex: none;
  margin-top: 1px;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.footer-bottom-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-dot {
  color: var(--line);
}

@media (max-width: 900px) {
  .footer-top { grid-template-columns: 1fr; gap: 30px; }
  .footer-inner { padding: 34px 20px 24px; }
}

/* ---------------------------------------------------------------------------
   Card face
   --------------------------------------------------------------------------- */
.card-face {
  position: relative;
  border-radius: 20px;
  padding: 24px;
  min-height: 220px;
  color: #fff;
  background:
    radial-gradient(120% 120% at 85% 10%, rgba(159, 232, 112, 0.35) 0%, transparent 55%),
    linear-gradient(145deg, #1d4a05 0%, #163300 55%, #0d1f00 100%);
  box-shadow: var(--shadow-l);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.card-face::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.card-face-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.card-brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.card-chip {
  width: 42px;
  height: 32px;
  border-radius: 7px;
  background: linear-gradient(135deg, #e8d08a, #b8912f 55%, #f0dfa8);
  position: relative;
}

.card-chip::after {
  content: "";
  position: absolute;
  inset: 6px 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.card-number {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.09em;
  position: relative;
  margin-top: auto;
}

.card-face-bottom {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  position: relative;
}

.card-meta-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: rgba(255, 255, 255, 0.55);
}

.card-meta-value {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.card-scheme {
  margin-left: auto;
  font-size: 21px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -0.02em;
}

.card-face.frozen .card-number,
.card-face.frozen .card-face-bottom,
.card-face.frozen .card-chip {
  opacity: 0.35;
}

.card-frozen-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  background: rgba(10, 20, 4, 0.55);
  backdrop-filter: blur(2px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
   Detail rows & meters
   --------------------------------------------------------------------------- */
.detail-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-top: 1px solid var(--line-soft);
}

.detail-row:first-child { border-top: none; }

.detail-label {
  font-size: 13px;
  color: var(--ink-3);
  flex: none;
  width: 42%;
}

.detail-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  flex: 1;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.3s ease;
}

.meter-fill.hot { background: #e8a33d; }

.recipient-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recipient-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  max-width: 150px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 13px 5px 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.recipient-chip:hover { border-color: var(--forest); }

@media (max-width: 560px) {
  .detail-label { width: 100%; }
  .detail-row { flex-wrap: wrap; gap: 2px; }
}

/* ---------------------------------------------------------------------------
   Processing state
   --------------------------------------------------------------------------- */
.processing {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding: 44px 20px 34px;
  animation: fade 0.2s ease;
}

.processing h2 { margin-top: 12px; }

.processing-orb {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  position: relative;
  color: var(--forest);
  transition: background 0.25s ease, color 0.25s ease;
}

/* A masked conic gradient makes the sweeping ring around the orb. */
.processing-orb::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0turn, transparent 0turn, var(--green) 0.72turn, transparent 0.95turn);
  animation: spin 1.05s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
}

.processing-orb.done {
  background: var(--green);
  color: #163300;
  animation: pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}

.processing-orb.done::before { display: none; }

.progress-steps {
  display: grid;
  gap: 2px;
  width: min(370px, 100%);
  margin-top: 24px;
  text-align: left;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  transition: color 0.2s ease, background 0.2s ease;
}

.progress-step.active {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface-2);
}

.progress-step.done { color: var(--ink-2); }

.progress-step .marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  color: var(--ink-3);
  transition: background 0.2s ease, color 0.2s ease;
}

.progress-step.done .marker { background: var(--positive-bg); color: var(--positive); }
.progress-step.active .marker { background: var(--green); color: #163300; }

.progress-step .marker .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.mini-spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid rgba(22, 51, 0, 0.28);
  border-top-color: #163300;
  animation: spin 0.6s linear infinite;
}

/* Success screens ease in rather than snapping into place. */
.view-enter {
  animation: viewIn 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
}

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