:root {
  --exchange-line: #dfe7df;
  --exchange-muted: #526762;
  --exchange-canvas: #f4f6f0;
}

body { color: var(--ink); background: var(--exchange-canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #3b896b; outline-offset: 3px; }
button:disabled { cursor: default; }

.portal-back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: .8rem;
  font-weight: 650;
  text-decoration: none;
}
.portal-back-button:hover { background: #ebf1eb; }

.exchange-shell { width: min(calc(100% - 48px), 1120px); margin: clamp(28px, 5vw, 64px) auto; }
.page-heading, .section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.page-heading { margin-bottom: 24px; }
h1 { margin: 0; font-size: clamp(27px, 4vw, 48px); line-height: 1.08; letter-spacing: -.055em; }
h2 { margin: 0; font-size: 1.13rem; letter-spacing: -.025em; }
h3 { margin: 0 0 15px; font-size: .96rem; letter-spacing: -.02em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.price-pane { display: grid; min-width: 0; gap: 16px; }
.panel, .collection {
  min-width: 0;
  border-radius: 22px;
  border: 1px solid var(--exchange-line);
  background: #fff;
  box-shadow: 0 8px 28px #16443d09;
}
.panel, .collection-body, .summary-panel { padding: clamp(17px, 2.5vw, 26px); }
.collection { overflow: visible; }
.price-fields, .payment-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.price-fields { margin-top: 16px; }
.price-fields label, .payment-fields label, legend {
  display: block;
  margin-bottom: 7px;
  padding: 0;
  color: var(--exchange-muted);
  font-size: .78rem;
  font-weight: 700;
}
input[type="text"], select {
  width: 100%;
  min-width: 0;
  min-height: 45px;
  padding: 8px 12px;
  border: 1px solid #afc2b6;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: .87rem;
}
#fee, #payment-amount { font-variant-numeric: tabular-nums; font-size: 1.16rem; font-weight: 700; }
input:disabled, select:disabled { opacity: 1; background: #f2f6f1; color: #35534b; }
.currency-picker { position: relative; min-width: 0; }
.currency-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  width: 100%;
  min-width: 0;
  min-height: 45px;
  padding: 6px 11px;
  border: 1px solid #afc2b6;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.currency-trigger:hover:not(:disabled), .currency-trigger[aria-expanded="true"] { border-color: #5b8a73; background: #f4f8f4; }
.currency-trigger:disabled { background: #f2f6f1; color: #35534b; }
.currency-trigger:disabled .currency-chevron { opacity: .4; }
.currency-value, .currency-label { min-width: 0; }
.currency-label { display: flex; align-items: center; gap: 8px; }
.currency-code { font-size: .8rem; font-weight: 800; }
.currency-name { overflow: hidden; color: var(--exchange-muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.currency-flag {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
}
.currency-flag img { display: block; width: 26px; height: 26px; }
.currency-flag-placeholder { border-radius: 6px; background: #e8f1ea; color: var(--green); font-size: .85rem; }
.currency-chevron { flex: 0 0 7px; width: 7px; height: 7px; margin: -3px 2px 0 0; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.currency-trigger[aria-expanded="true"] .currency-chevron { margin-top: 3px; transform: rotate(225deg); }
.currency-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 7px);
  right: 0;
  width: max(100%, 248px);
  max-width: calc(100vw - 40px);
  max-height: min(345px, 52vh, var(--available-menu-height, 345px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid #cbdcd0;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 12px 32px #16443d26;
  outline: none;
}
.currency-menu.opens-up { top: auto; bottom: calc(100% + 7px); }
.currency-group:first-child { padding-bottom: 4px; border-radius: 9px; background: #f5f8f3; }
.currency-group + .currency-group { margin-top: 5px; border-top: 1px solid var(--exchange-line); }
.currency-group-heading { padding: 9px 9px 5px; color: var(--exchange-muted); font-size: .69rem; font-weight: 800; }
.currency-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-height: 37px;
  margin: 0 3px;
  padding: 3px 7px;
  border-radius: 7px;
  cursor: pointer;
}
.currency-option[aria-selected="true"] { background: #dbece0; }
.currency-option[aria-selected="true"]::after { content: "✓"; color: var(--green-dark); font-size: .86rem; font-weight: 800; }
.currency-option:hover, .currency-option.active { background: #e1eee4; outline: 1px solid #86ad98; outline-offset: -1px; }
[aria-invalid="true"] { border-color: #a22a27 !important; }
.hint, .error { font-size: .77rem; line-height: 1.5; }
.hint { color: var(--exchange-muted); }
.error { color: #a22a27; margin: 8px 0 0; font-weight: 600; }

.quotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 15px 0 9px; }
.quote {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-width: 0;
  min-height: 95px;
  padding: 10px 12px;
  border: 1px solid #d9e5db;
  border-radius: 12px;
  background: #f4f8f3;
  color: var(--ink);
  text-align: left;
}
.quote:hover:not(:disabled), .quote:focus-visible { background: #e7f0e8; border-color: #82aa92; }
.quote span { color: var(--green); font-size: .72rem; font-weight: 800; }
.quote strong { font-size: clamp(.94rem, 2vw, 1.35rem); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.quote small { color: var(--exchange-muted); font-size: .68rem; overflow-wrap: anywhere; }
#quote-help, #rate-status, #retry { margin: 7px 0 0; }
details { border-top: 1px solid var(--exchange-line); margin-top: 14px; padding-top: 12px; }
summary { cursor: pointer; font-size: .83rem; font-weight: 700; }
.rate-content > p { margin: 9px 0; }
.manual-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.rate-row { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); gap: 6px; align-items: center; font-size: .75rem; font-weight: 700; }
.rate-row input { min-height: 37px; padding-inline: 7px; }

.summary-panel { border-radius: 21px 21px 0 0; background: var(--green-dark); color: #f9fcf7; }
.status { padding: 5px 8px; border-radius: 999px; background: #e8f1e822; color: #f0f7ee; font-weight: 650; font-size: .71rem; text-align: center; }
.status[data-state="complete"] { background: #def1df; color: #1b4a34; }
.status[data-state="over"] { background: #f7e6bb; color: #5b3b08; }
.totals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 17px 0 0; }
.totals dt { color: #e0eee3; font-size: .76rem; }
.totals dd { margin: 5px 0 0; font-size: 1.04rem; font-weight: 700; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.totals .balance { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid #e3f3e747; }
.totals .balance dd { font-size: clamp(25px, 4vw, 36px); letter-spacing: -.035em; }

fieldset { margin: 13px 0 0; border: 0; padding: 0; min-width: 0; }
.methods { display: flex; gap: 8px; }
.methods label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--exchange-line);
  border-radius: 9px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.methods label:has(:checked) { background: #e8f1ea; border-color: #79a28a; }
.methods input { margin: 0; accent-color: var(--green); }
.payment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.button { min-height: 41px; padding: 8px 13px; border-radius: 9px; border: 1px solid transparent; font-size: .8rem; font-weight: 700; }
.primary { background: var(--green-dark); color: #fff; }
.primary:hover:not(:disabled) { background: var(--green); }
.primary:disabled { background: #e7ede8; color: #526b60; }
.secondary { background: #fff; color: var(--ink); border-color: #cddcd1; }
.secondary:hover { background: #edf3ed; }
.history { margin-top: 21px; padding-top: 17px; border-top: 1px solid var(--exchange-line); }
.history h3 { margin-bottom: 10px; }
#empty-history, #payment-list { margin: 0; }
#payment-list { list-style: none; padding: 0; }
#payment-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--exchange-line); font-size: .85rem; }
#payment-list li:last-child { border: 0; }
#payment-list strong, #payment-list small { overflow-wrap: anywhere; }
#payment-list small { display: block; color: var(--exchange-muted); margin-top: 4px; }
.row-actions { flex-shrink: 0; }
.text-button { padding: 6px; border: 0; background: transparent; color: var(--green); font-size: .73rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; }

@media (max-width: 800px) {
  .exchange-shell { width: calc(100% - 32px); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 365px) {
  .exchange-shell { width: calc(100% - 24px); }
  .button { padding-inline: 9px; }
  .section-heading { gap: 7px; }
  .manual-rates { grid-template-columns: minmax(0, 1fr); }
}
