:root {
  color-scheme: dark;
  --bg: #111318;
  --bg-soft: #222731;
  --surface: #181B21;
  --surface-hover: #1E222A;
  --modal: #1E222A;
  --border: #2B3039;
  --text: #F5F7FA;
  --muted: #A8AFBB;
  --primary: #3b82f6;
  --primary-on: #0B1730;
  --primary-bg: rgba(59, 130, 246, 0.15);
  --green: #17C995;
  --green-bg: rgba(23, 201, 149, 0.12);
  --red: #F06A6A;
  --red-bg: rgba(240, 106, 106, 0.12);
  --radius: 18px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.38);

  /* Motion language: subtle, consistent, performance-first */
  --dur-hover: 140ms;
  --dur-press: 100ms;
  --dur-state: 180ms;
  --dur-sheet: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #F3F5F8;
  --bg-soft: #F4F6F9;
  --surface: #ffffff;
  --surface-hover: #FAFBFC;
  --modal: #FAFBFC;
  --border: #E2E6EC;
  --text: #171A20;
  --muted: #5E6673;
  --primary: #2563EB;
  --primary-on: #ffffff;
  --primary-bg: rgba(37, 99, 235, 0.09);
  --green: #078A68;
  --green-bg: rgba(7, 138, 104, 0.08);
  --red: #C94C4C;
  --red-bg: rgba(201, 76, 76, 0.08);
  --shadow: 0 3px 12px rgba(17, 24, 39, 0.05);
  --shadow-lg: 0 16px 32px rgba(17, 24, 39, 0.1);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #F3F5F8;
    --bg-soft: #F4F6F9;
    --surface: #ffffff;
    --surface-hover: #FAFBFC;
    --modal: #FAFBFC;
    --border: #E2E6EC;
    --text: #171A20;
    --muted: #5E6673;
    --primary: #2563EB;
    --primary-on: #ffffff;
    --primary-bg: rgba(37, 99, 235, 0.09);
    --green: #078A68;
    --green-bg: rgba(7, 138, 104, 0.08);
    --red: #C94C4C;
    --red-bg: rgba(201, 76, 76, 0.08);
    --shadow: 0 3px 12px rgba(17, 24, 39, 0.05);
    --shadow-lg: 0 16px 32px rgba(17, 24, 39, 0.1);
  }
}

/* Smooth transition for theme variables */
body, .card, .rate-card, .kpi-card, .breakdown-details, .details-body, .step, .input-wrap input, .chip-btn, .icon-btn, .tiny-icon, .segmented-control, .segment-btn, .status-pill, .toast, .toggle, .calculator-display-wrap, .bank-profile-trigger, .bank-profile-option {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(8px + env(safe-area-inset-top)) 8px calc(16px + env(safe-area-inset-bottom)) 8px;
  -webkit-text-size-adjust: 100%;
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Native-feeling selection policy: chrome and dashboard data stay stable;
   editable and intentionally copyable content retain normal selection. */
.topbar,
.quick-row,
.bank-profile-field,
.bs-helper-trigger,
.rates-grid,
.kpi-grid,
.breakdown-trigger-btn,
.support-title,
.support-actions,
footer,
.modal-header,
.icon-btn,
.chip-btn,
.segment-btn,
.tiny-icon,
.bs-helper-confirm,
.btn-support-trigger,
.kpi-copy-btn {
  -webkit-user-select: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

.rate-card,
.kpi-card {
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
.formula-box,
#supportPanel .modal-content {
  -webkit-user-select: text;
  user-select: text;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  margin: 0 auto;
  padding: 0 0 3px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.brand {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@media (max-width: 480px) {
  .header-icon {
    width: 20px;
    height: 20px;
  }
}

.brand-title .divider {
  color: var(--muted);
  font-weight: 300;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 1px 2px -5px;
}

.rates-updated-status {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.subtitle {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

.rates-refresh-btn {
  width: 30px;
  height: 30px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.rates-refresh-btn .material-symbols-rounded {
  font-size: 1rem;
}

.rates-refresh-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-hover);
}

.rates-refresh-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.rates-refresh-btn:focus {
  outline: none;
}

.rates-refresh-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.rates-refresh-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.rates-refresh-btn.loading .material-symbols-rounded {
  animation: spin 0.8s linear infinite;
}

.icon-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0;
}

.icon-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease, filter 150ms ease;
}

.header-telegram-icon {
  width: 23px;
  height: 23px;
  fill: currentColor;
}

.icon-btn:hover {
  background: var(--surface-hover);
  filter: brightness(1.08);
}

.icon-btn:active {
  transform: scale(0.97);
}

/* Base Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* Layout stacking */
.layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layout:focus {
  outline: none;
}

.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* Calculator Card */
.calculator-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calculator-display-wrap {
  position: relative;
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
}

.calculator-display-wrap:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.calculator-display-wrap.is-invalid,
.calculator-display-wrap.is-invalid:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-bg);
}

.amount-input-error {
  margin: -4px 4px 0;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.3;
}

.calculator-display-wrap input {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
  border: none;
  outline: none;
  background: transparent;
  caret-color: var(--primary);
  text-align: left;
  padding: 0;
  margin: 0;
}

.calculator-display-wrap .unit-part {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.65;
  margin-left: 8px;
  user-select: none;
  align-self: center;
  display: inline-block;
  line-height: 1;
}

/* Quick Chips */
.quick-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 8px;
}

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

.chip-btn {
  min-height: 44px;
  border-radius: 19px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, color var(--dur-state) ease, transform var(--dur-press) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chip-btn:hover:not(.active) {
  background: var(--surface-hover);
  border-color: var(--muted);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-on);
}

.bank-profile-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bank-profile-label {
  padding-left: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.bank-profile-trigger {
  width: 100%;
  min-height: 52px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-soft);
  color: var(--text);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

@media (hover: hover) and (pointer: fine) {
  .bank-profile-trigger:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
    background: var(--surface-hover);
    transform: translateY(-1px);
  }
}

.bank-profile-trigger:active {
  transform: scale(0.98);
}

.bank-profile-trigger:focus {
  outline: none;
}

.bank-profile-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.bank-profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.bank-profile-avatar.has-logo {
  background: transparent;
}

.bank-profile-avatar img {
  width: calc(100% * var(--bank-logo-scale, 0.8));
  height: calc(100% * var(--bank-logo-scale, 0.8));
  border-radius: 50%;
  object-fit: contain;
}

html[data-theme="dark"] .bank-profile-avatar.has-logo img {
  filter: var(--bank-logo-dark-filter, none);
}

.bank-profile-neutral-icon {
  color: var(--primary);
  font-size: 20px;
}

.bank-profile-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bank-profile-summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-summary-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-chevron {
  color: var(--muted);
  font-size: 1.15rem;
}

.bs-helper-trigger {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft);
  color: var(--text);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

.bs-helper-trigger .material-symbols-rounded {
  font-size: 1rem;
  color: var(--muted);
}

.bs-helper-chevron {
  opacity: 0.65;
}

@media (hover: hover) and (pointer: fine) {
  .bs-helper-trigger:hover {
    background: var(--surface-hover);
    border-color: var(--muted);
  }
}

.bs-helper-trigger:active {
  transform: scale(0.98);
}

.bs-helper-trigger:focus {
  outline: none;
}

.bs-helper-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.bs-helper-content {
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 8px 72px;
}

.bs-helper-input input {
  padding-right: 44px;
  font-size: 1rem;
}

.bs-helper-preview {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--muted);
}

.bs-helper-preview-label,
.bs-helper-preview-detail,
.bs-helper-message {
  display: block;
  font-size: 0.68rem;
}

.bs-helper-preview-primary {
  margin: 4px 0;
  color: var(--text);
}

.bs-helper-preview-primary strong {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.bs-helper-preview-secondary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
}

.bs-helper-preview-secondary strong {
  color: var(--text);
  white-space: nowrap;
}

.bs-helper-message {
  margin-top: -2px;
  color: var(--muted);
}

.bs-helper-message:empty {
  display: none;
}

.bs-helper-actions {
  display: flex;
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-top: 6px;
  background: var(--modal);
}

.bs-helper-confirm {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: var(--primary-on);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-state) ease, filter var(--dur-state) ease, transform var(--dur-press) ease;
}

.bs-helper-confirm:hover:not(:disabled) {
  filter: brightness(1.08);
}

.bs-helper-confirm:active:not(:disabled) {
  transform: scale(0.98);
}

.bs-helper-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bs-helper-confirm:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.p2p-editor-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 8px 72px;
}

.p2p-editor-form {
  display: grid;
  gap: 12px;
}

.p2p-editor-input input {
  padding-right: 72px;
  font-size: 1rem;
}

.p2p-editor-message {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.35;
}

.p2p-editor-message.is-error {
  color: var(--red);
}

.p2p-editor-actions {
  position: sticky;
  z-index: 1;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 6px;
  background: var(--modal);
}

.p2p-editor-actions .bank-profile-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Rates Grid */
.rates-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 6px;
}

.rate-card {
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 68%, transparent);
  border-radius: 24px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 64px;
  gap: 5px;
}

.rate-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.rate-val {
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.rate-card .card-icon {
  font-size: 0.72rem;
}

.rate-value-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.rate-card--editable {
  appearance: none;
  width: 100%;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

@media (hover: hover) and (pointer: fine) {
  .rate-card--editable:hover {
    background: var(--surface-hover);
    border-color: color-mix(in srgb, var(--muted) 48%, var(--border));
    transform: translateY(-1px);
  }
}

.rate-card--editable:active {
  transform: scale(0.98);
}

.rate-card--editable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.rate-card--editable.is-manual {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
}

.rate-card-heading {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.rate-metadata {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.46rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-metadata::before {
  content: '·';
  margin-right: 3px;
  opacity: 0.72;
}

.rate-metadata:empty {
  display: none;
}

.rate-manual-indicator {
  flex: 0 0 auto;
  padding: 1px 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  color: var(--muted);
  font-size: 0.46rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

/* P2P card: semantic exchange icon leads; pencil stays as a secondary edit hint */
.rate-exchange-icon {
  font-size: 0.66rem;
  color: var(--muted);
  opacity: 0.8;
  transition: color var(--dur-state) ease, transform var(--dur-state) ease;
}

.rate-edit-icon {
  flex: 0 0 auto;
  font-size: 0.6rem;
  opacity: 0.4;
  transition: opacity var(--dur-state) ease, transform var(--dur-press) ease;
}

@media (hover: hover) and (pointer: fine) {
  .rate-card--editable:hover .rate-exchange-icon {
    color: var(--primary);
    transform: translateY(-1px);
  }

  .rate-card--editable:hover .rate-edit-icon {
    opacity: 0.75;
  }

  .rate-card--editable:active .rate-edit-icon {
    transform: scale(0.9);
  }
}

/* Brecha spread: compact pill centered in the gap between the two rate cards */
.rate-spread {
  align-self: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 7px 3px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
}

.rate-spread .brecha-label {
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.1;
  opacity: 0.68;
}

.rate-spread-value {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1;
}

.rate-spread .brecha-icon {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.75;
  line-height: 1;
}

.rate-spread .brecha-val {
  font-size: 0.64rem;
  white-space: nowrap;
  line-height: 1.2;
}

@media (max-width: 390px) {
  .rates-grid {
    gap: 4px;
  }

  .rate-card {
    padding-inline: 7px;
  }

  .rate-spread {
    gap: 0;
    padding: 2px 4px 3px;
  }

  .rate-spread .brecha-icon {
    font-size: 0.68rem;
  }

  .rate-spread .brecha-val {
    font-size: 0.6rem;
  }
}

.brecha-val {
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.3;
}

.brecha-val.brecha-green {
  color: var(--green);
}

.brecha-val.brecha-yellow {
  color: #f59e0b;
}

.brecha-val.brecha-red {
  color: var(--red);
}

.updated-time {
  color: var(--muted);
  font-size: inherit;
  font-weight: 500;
  white-space: nowrap;
}

/* Results KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 92px;
  transition: background-color var(--dur-state) ease, color var(--dur-state) ease, border-color var(--dur-state) ease, box-shadow var(--dur-state) ease;
  cursor: default;
}

.kpi-label {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.kpi-val {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}

.kpi-desc {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: auto;
  font-weight: 500;
  line-height: 1.2;
}

.kpi-meta {
  margin-top: 3px;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--green);
}

.ves-sub-usdt {
  display: block;
  margin-top: 3px;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.65rem;
}


/* KPI Operational (Level 2: Bs necesarios, USDT Finales) */
.kpi-operational {
  border-color: var(--border);
  background: var(--surface);
}

html[data-theme="light"] .kpi-operational {
  border-color: var(--border);
  background: var(--surface);
}

.kpi-operational .kpi-val {
  font-size: 1.45rem;
  font-weight: 800;
}

/* KPI Highlight (Level 3 Outcome: Ganancia - Positive) */
.kpi-highlight {
  border-color: rgba(23, 201, 149, 0.28);
  background: linear-gradient(135deg, var(--green-bg), var(--surface) 70%);
}

html[data-theme="light"] .kpi-highlight {
  border-color: rgba(7, 138, 104, 0.22);
  background: linear-gradient(135deg, var(--green-bg), var(--surface) 70%);
}

.kpi-highlight .kpi-label {
  color: var(--green);
  font-weight: 700;
}

.kpi-highlight .kpi-val {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--green);
}

.kpi-highlight .kpi-desc {
  color: var(--green);
  font-weight: 600;
}

/* KPI Highlight (Level 3 Outcome: Ganancia, ROI - Negative/Loss) */
.kpi-loss {
  border-color: rgba(239, 68, 68, 0.22);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.04), var(--surface));
}

html[data-theme="light"] .kpi-loss {
  border-color: rgba(239, 68, 68, 0.28);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.03), var(--surface));
}

.kpi-loss .kpi-label {
  color: var(--red);
  font-weight: 700;
}

.kpi-loss .kpi-val {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--red);
}

.kpi-loss .kpi-desc {
  color: var(--red);
  font-weight: 600;
}

.kpi-loss .kpi-meta {
  color: var(--red);
}

/* Breakdown Trigger Button */
.breakdown-trigger-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  outline: none;
  font-family: var(--font);
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

.breakdown-trigger-btn:hover {
  background: var(--surface-hover);
}

.breakdown-trigger-btn:active {
  transform: scale(0.98);
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-amount {
  font-weight: 600;
  color: var(--muted);
}

/* Shared adaptive modal shell */
.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
  background: rgba(15, 17, 21, 0.85); /* Fallback */
  padding: 24px 16px;
  overflow: hidden;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .modal-shell {
    background: rgba(15, 17, 21, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

.modal-shell.open {
  display: grid;
  place-items: center;
  animation: fade-in 200ms ease-out forwards;
}

.modal-shell.closing {
  display: grid;
  place-items: center;
  animation: fade-out 200ms ease-in 50ms forwards;
}

.modal-panel {
  width: 100%;
  background: var(--modal);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: modal-in var(--dur-sheet) var(--ease-out) 50ms backwards;
}

.modal-panel--compact { max-width: 400px; }
.modal-panel--medium { max-width: 440px; }
.modal-panel--large { max-width: 520px; }

.modal-shell.closing .modal-panel {
  animation: modal-out var(--dur-sheet) var(--ease-out) forwards;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex: 0 0 auto;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-description {
  max-width: none;
  margin-top: 2px;
}

.modal-close {
  flex: 0 0 auto;
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.modal-panel--medium .modal-content,
.modal-panel--large .modal-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.formula-box {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
}

.breakdown-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 12px;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

.breakdown-note .material-symbols-rounded {
  font-size: 1.0rem;
  color: var(--primary);
}

/* Animations */
@keyframes modal-in {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes modal-out {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.96); opacity: 0; }
}

@keyframes sheet-in {
  0% { transform: translateY(100%); }
  100% { transform: translateY(0); }
}

@keyframes sheet-out {
  0% { transform: translateY(0); }
  100% { transform: translateY(100%); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes content-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes content-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(4px); }
}

.modal-shell.open .modal-content {
  animation: content-fade-in 150ms ease-out 100ms backwards;
}

.modal-shell.closing .modal-content {
  animation: content-fade-out 100ms ease-in forwards;
}

.bank-profiles-card {
  min-height: min(680px, calc(100dvh - 48px));
}

.bank-profiles-content,
.bank-profile-list-view {
  min-height: 0;
}

.bank-profiles-content {
  scroll-padding-block: 8px 88px;
}

.bank-profile-context-label {
  margin: 0 0 2px;
  color: var(--primary);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.bank-profile-list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bank-profile-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--bg-soft) 88%, var(--primary-bg));
  color: var(--muted);
  line-height: 1.35;
}

.bank-profile-notice .material-symbols-rounded {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.92rem;
}

.bank-profile-notice > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bank-profile-notice strong {
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 800;
}

.bank-profile-notice > span:last-child > span {
  font-size: 0.61rem;
  font-weight: 500;
}

.bank-profile-view-back {
  align-self: flex-start;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.bank-profile-view-back .material-symbols-rounded {
  font-size: 1rem;
}

.bank-profile-view-back:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.bank-profile-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bank-profile-option {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  padding: 8px 7px 8px 9px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-soft);
  color: var(--text);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  overflow: hidden;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

.bank-profile-option.is-selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.bank-profile-option .bank-profile-avatar {
  width: 36px;
  height: 36px;
  font-size: 0.58rem;
}

.bank-profile-option-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bank-profile-option-name {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-option-detail {
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 600;
  line-height: 1.2;
}

.bank-profile-option-trailing {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.bank-profile-check {
  display: none;
  color: var(--primary);
  font-size: 1.05rem;
}

.bank-profile-option.is-selected .bank-profile-check {
  display: inline;
}

.bank-profile-edit-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.bank-profile-group-chevron {
  color: var(--muted);
  font-size: 1rem;
}

.bank-profile-option:hover {
  background: color-mix(in srgb, var(--surface-hover) 72%, transparent);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .bank-profile-option:hover {
    transform: translateY(-1px);
  }
}

.bank-profile-option:active {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: color-mix(in srgb, var(--primary-bg) 62%, var(--bg-soft));
}

.bank-profile-option:focus,
.bank-profile-back:focus,
.bank-profile-action:focus,
.bank-profile-list-action:focus,
.bank-profile-settings-manage:focus {
  outline: none;
}

.bank-profile-option:focus-visible,
.bank-profile-back:focus-visible,
.bank-profile-action:focus-visible,
.bank-profile-list-action:focus-visible,
.bank-profile-settings-manage:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.bank-profile-list-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bank-profile-management-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

.bank-profile-management-toolbar .bank-profile-view-back {
  min-width: 0;
  justify-self: start;
}

.bank-profile-management-toolbar .bank-profile-list-action {
  min-width: 124px;
}

.bank-profile-management-danger {
  display: grid;
  gap: 7px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.bank-profile-management-danger p {
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

.bank-profile-management-danger .bank-profile-list-action {
  width: 100%;
  background: transparent;
}

.bank-profile-list-action {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.bank-profile-list-action .material-symbols-rounded {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 1rem;
}

.bank-profile-list-action--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-on);
}

.bank-profile-list-action--primary .material-symbols-rounded {
  color: var(--primary-on);
}

.bank-profile-list-action--danger {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--red) 38%, var(--border));
  color: var(--red);
}

.bank-profile-list-action--danger .material-symbols-rounded {
  color: var(--red);
}

.bank-profile-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bank-profile-editor-head {
  display: flex;
  align-items: center;
}

.bank-profile-back {
  min-height: 44px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.bank-profile-back .material-symbols-rounded {
  font-size: 1rem;
}

.bank-profile-editor-description {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.bank-profile-form-error {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 600;
}

.bank-profile-logo-control {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft);
}

.bank-profile-logo-preview {
  width: 48px;
  height: 48px;
  font-size: 0.7rem;
}

.bank-profile-logo-preview img {
  width: 100%;
  height: 100%;
}

.bank-profile-logo-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bank-profile-logo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bank-profile-logo-actions .bank-profile-action {
  min-height: 36px;
  padding: 6px 9px;
}

.bank-profile-logo-help,
.bank-profile-logo-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.61rem;
  line-height: 1.35;
}

.bank-profile-logo-status:not(:empty) {
  color: var(--primary);
  font-weight: 700;
}

.bank-profile-quick-field {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft);
  overflow: hidden;
}

.bank-profile-quick-summary {
  width: 100%;
  min-height: 54px;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.bank-profile-quick-summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.bank-profile-quick-summary-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.bank-profile-quick-summary-mode,
.bank-profile-quick-summary-values {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-quick-summary-values {
  font-weight: 600;
}

.bank-profile-quick-chevron {
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 0.18s ease;
}

.bank-profile-quick-field.is-open .bank-profile-quick-chevron {
  transform: rotate(180deg);
}

.bank-profile-quick-details {
  display: grid;
  gap: 9px;
  padding: 0 10px 10px;
}

.bank-profile-quick-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.bank-profile-quick-mode,
.bank-profile-quick-actions,
.bank-profile-quick-editor,
.bank-profile-quick-list {
  display: grid;
  gap: 8px;
}

.bank-profile-quick-editor {
  margin-top: 8px;
}

.bank-profile-quick-mode label {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.bank-profile-quick-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 38px;
  gap: 6px;
  align-items: center;
}

.bank-profile-quick-item input {
  min-height: 38px;
}

.bank-profile-quick-prefix {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.bank-profile-quick-icon {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.bank-profile-quick-icon .material-symbols-rounded {
  font-size: 1rem;
}

.bank-profile-quick-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 7px;
}

.bank-profile-logo-field {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft);
  overflow: hidden;
}

.bank-profile-optional-summary {
  min-height: 48px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.bank-profile-optional-summary::-webkit-details-marker {
  display: none;
}

.bank-profile-optional-summary > span:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bank-profile-optional-summary .material-symbols-rounded {
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 180ms ease;
}

.bank-profile-logo-field[open] .bank-profile-optional-summary .material-symbols-rounded {
  transform: rotate(180deg);
}

.bank-profile-optional-summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.bank-profile-logo-field .bank-profile-logo-control {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.general-quick-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.general-quick-item {
  min-width: 0;
  min-height: 48px;
  grid-template-columns: auto minmax(0, 1fr) 44px;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.general-quick-item:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.general-quick-item .bank-profile-quick-prefix {
  padding-left: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.72;
}

.general-quick-item input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  appearance: textfield;
}

.general-quick-item input::-webkit-inner-spin-button,
.general-quick-item input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.general-quick-item input:focus {
  outline: none;
}

.general-quick-remove {
  width: 44px;
  min-width: 44px;
  min-height: 46px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.general-quick-remove:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.general-quick-remove:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -3px;
}

.general-quick-remove:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.bank-profile-quick-preview-chip {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
}

.bank-profile-quick-general-note,
.bank-profile-quick-limit {
  margin: 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.35;
}

.general-quick-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.general-quick-secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.general-quick-secondary-actions .bank-profile-action {
  background: transparent;
  color: var(--muted);
}

.general-quick-secondary-actions .bank-profile-action:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.general-quick-actions .bank-profile-action--primary {
  font-size: 0.75rem;
}

.general-quick-message {
  margin-top: 2px;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
}

.field-label {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.bank-profile-editor-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.bank-profile-editor-actions .bank-profile-action--primary {
  grid-column: 1 / -1;
  font-size: 0.74rem;
}

.bank-profile-editor-danger {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.bank-profile-editor-danger .bank-profile-action {
  flex: 1 1 150px;
  background: transparent;
}

.bank-profile-action {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease, filter var(--dur-state) ease;
}

.bank-profile-action--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-on);
}

.bank-profile-action--danger {
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  color: var(--red);
}

.bank-profile-action:hover {
  filter: brightness(1.08);
}

@media (hover: hover) and (pointer: fine) {
  .bank-profile-action:hover:not(:disabled) {
    transform: translateY(-1px);
  }

  .bank-profile-action:active:not(:disabled) {
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .modal-shell.open {
    animation: fade-in 150ms ease-out forwards !important;
  }
  .modal-shell.closing {
    animation: fade-out 150ms ease-in forwards !important;
  }
  .modal-panel, .modal-content {
    animation: none !important;
  }
  .skeleton-shimmer,
  .skeleton-shimmer::after {
    animation: none !important;
  }
}

/* Mobile Bottom Sheet adaptation */
@media (max-width: 860px) {
  .modal-shell.open {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .modal-shell.closing {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: fade-out 200ms ease-in 50ms forwards;
  }

  .modal-panel {
    border-radius: 24px 24px 0 0;
    max-width: none;
    max-height: calc(100dvh - env(safe-area-inset-top) - 12px);
    width: 100%;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    gap: 12px;
    animation: sheet-in var(--dur-sheet) var(--ease-out) 50ms backwards;
  }

  .bank-profiles-card {
    min-height: min(720px, calc(100dvh - env(safe-area-inset-top) - 12px));
  }

  .bank-profile-editor-actions {
    position: sticky;
    z-index: 2;
    bottom: -1px;
    padding: 10px 0 calc(2px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .modal-shell.closing .modal-panel {
    animation: sheet-out var(--dur-sheet) var(--ease-out) forwards;
  }
}

.flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.step {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--bg-soft);
  border: none;
  border-radius: 12px;
}

.num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.75rem;
}

.step h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
}

.step p {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 1px;
}

.amount {
  font-weight: 800;
  font-size: 0.8rem;
}

.amount.positive {
  color: var(--green);
}

.amount.negative {
  color: var(--red);
}

.amount.highlight {
  color: var(--primary);
}

/* ── Unit label typography — numbers dominate, units secondary ──────────────────────── */

/* Inline unit for KPI big values: Bs, USD, USDT */
.value-unit {
  font-size: 0.55em;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-left: 0.25em;
  vertical-align: middle;
  color: var(--muted);
  opacity: 0.5;
}

/* Highlight/loss cards: echo the accent color at reduced opacity */
.kpi-highlight .value-unit,
.kpi-loss .value-unit {
  color: currentColor;
  opacity: 0.45;
}

/* Inline unit for rate-card values: Bs/USD, Bs/USDT */
.rate-unit {
  font-size: 0.58rem;
  font-weight: 500;
  display: block;
  margin-top: 1px;
  color: var(--muted);
  opacity: 0.6;
}

/* Breakdown flow amounts: slightly quiet unit */
.amount .value-unit {
  font-size: 0.72em;
  font-weight: 500;
  opacity: 0.6;
  margin-left: 0.15em;
  color: currentColor;
}


/* Highlighted step for "Monto a ingresar en Bpay" */
.step.step-highlight {
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.06);
}

html[data-theme="light"] .step.step-highlight {
  background: rgba(59, 130, 246, 0.05);
}

.step.step-highlight h3 {
  color: var(--primary);
}

.num.num-highlight {
  background: var(--primary);
  color: var(--primary-on);
}

.step-desc-pos {
  color: var(--green) !important;
  font-weight: 500;
}

.step-desc-neg {
  color: var(--red) !important;
  font-weight: 500;
}

/* Collapsible formula details summary reset */
.formula-details summary {
  list-style: none;
  outline: none;
}
.formula-details summary::-webkit-details-marker {
  display: none;
}

.formula-chevron {
  font-size: 1.0rem;
  color: var(--primary);
  transition: transform 0.2s ease;
  display: inline-block;
}

.formula-details[open] .formula-chevron {
  transform: rotate(-180deg);
}

/* Collapsible formula details summary custom design */
.formula-details summary {
  list-style: none;
  outline: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.formula-details summary:hover {
  opacity: 0.85;
}

/* Formula list animation when details open */
.formula-details[open] .formula-box {
  animation: formula-slide-down 0.15s ease-out;
}

@keyframes formula-slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI copy button styles */
.kpi-copy-btn {
  background: none;
  border: none;
  padding: 4px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-right: -4px;
}

.kpi-copy-btn:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.kpi-copy-btn:focus {
  outline: none;
}

.kpi-copy-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.kpi-copy-btn span {
  font-size: 0.95rem !important;
}

/* Pulse dot for green updated status */
.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--green);
  border-radius: 50%;
  display: inline-block;
}



/* Status Alert Message */
.status {
  display: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
  margin-top: 8px;
}

.status.show {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status.ok {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.2);
}

.status.warn {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.status.err {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
}

.status-action {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid currentColor;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.status-action:hover:not(:disabled) {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.status-action:focus {
  outline: none;
}

.status-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.status-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.settings-content {
  gap: 14px;
  padding: 2px 2px 4px 0;
  scroll-padding-block: 8px 24px;
}

/* Compact mobile overrides for Settings screen */
@media (max-width: 860px) {
  .settings-content {
    gap: 10px !important;
  }
  .settings-section {
    gap: 6px !important;
  }
  .settings-section:not(:last-child) {
    padding-bottom: 8px !important;
  }
}

.settings-section {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section:not(:last-child) {
  border-bottom: 1px solid rgba(156, 163, 175, 0.1);
  padding-bottom: 12px;
}

.settings-section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.settings-disclosure > summary {
  min-height: 44px;
  margin: 0;
  cursor: pointer;
  list-style: none;
}

.settings-disclosure > summary::-webkit-details-marker {
  display: none;
}

.settings-disclosure-chevron {
  margin-left: auto;
  transition: transform 180ms ease;
}

.settings-disclosure[open] .settings-disclosure-chevron {
  transform: rotate(180deg);
}

.settings-disclosure > summary:focus-visible {
  border-radius: 8px;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.advanced-settings-grid,
.advanced-settings-group,
.advanced-settings-reset {
  display: grid;
  gap: 8px;
}

.advanced-auto-rates {
  margin-bottom: 2px;
}

.advanced-settings-group {
  margin-top: 4px;
}

.advanced-settings-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.advanced-settings-reset {
  justify-items: start;
  margin-top: 4px;
}

.advanced-settings-reset .bank-profile-action {
  width: 100%;
}

@media (max-width: 860px) and (max-height: 560px) {
  .bs-helper-card,
  .p2p-editor-card {
    gap: 8px;
    padding-top: 12px;
  }

  .bs-helper-content,
  .p2p-editor-content {
    gap: 8px;
  }

  .bs-helper-preview {
    padding: 10px;
  }
}

.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  float: left;
  width: 100%;
}

.section-title .material-symbols-rounded {
  font-size: 1.05rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field .label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.field .small {
  font-size: 0.65rem;
  color: var(--muted);
}

#cardFeeProfile {
  max-width: 62%;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-settings-summary {
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bank-profile-settings-summary.bank-profile-settings-manage {
  width: 100%;
  min-height: 52px;
  padding: 8px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
}

.bank-profile-settings-summary.bank-profile-settings-manage:focus-visible {
  border-radius: 8px;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.bank-profile-settings-active {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.bank-profile-settings-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bank-profile-settings-summary strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-profile-settings-copy > span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
}

.bank-profile-settings-manage {
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.bank-profile-settings-manage .material-symbols-rounded {
  color: var(--muted);
  font-size: 1rem;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
}

.input-wrap input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.input-wrap input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.input-wrap .unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.card-icon {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.72;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: none;
  border-radius: 12px;
}

.switch-row strong {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.switch-row span {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
}

.toggle {
  width: 44px;
  height: 24px;
  appearance: none;
  border-radius: 12px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle:checked {
  background: var(--primary);
}

.toggle::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  left: 3px;
  top: 3px;
  background: #ffffff;
  transition: transform 0.2s;
}

.toggle:checked::before {
  transform: translateX(20px);
}

.auto-save-note {
  font-size: 0.72rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tiny-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-soft);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tiny-icon:hover {
  background: var(--surface-hover);
}

footer {
  text-align: center;
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1.35;
  padding: 10px 6px;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bicycle-easter-egg-trigger {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 500 0.7rem/1.3 var(--font);
  opacity: 0.72;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-hover) ease, opacity var(--dur-hover) ease, background-color var(--dur-hover) ease;
}

.bicycle-footer-icon {
  width: 24px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
  .bicycle-easter-egg-trigger:hover {
    color: var(--text);
    opacity: 0.9;
    background: var(--surface-hover);
  }
}

.bicycle-easter-egg-trigger:active {
  opacity: 1;
}

.bicycle-easter-egg-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  opacity: 1;
}

.bicycle-ride-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

.bicycle-ride {
  position: absolute;
  left: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 92px;
  color: var(--primary);
  opacity: 0;
  will-change: transform, opacity;
}

.bicycle-ride-layer.is-riding .bicycle-ride {
  animation: bicycle-ride-across 2.9s cubic-bezier(0.35, 0, 0.65, 1) forwards;
}

.bicycle-ride-caption {
  position: absolute;
  left: 50%;
  bottom: 49px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font: 600 0.62rem/1.2 var(--font);
  white-space: nowrap;
  transform: translateX(-50%);
}

.bicycle-ride-body {
  width: 84px;
  height: 48px;
  animation: bicycle-body-bounce 320ms ease-in-out infinite alternate;
}

.bicycle-ride-body svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bicycle-wheel {
  transform-box: view-box;
  animation: bicycle-wheel-spin 380ms linear infinite;
}

.bicycle-wheel--left {
  transform-origin: 20px 34px;
}

.bicycle-wheel--right {
  transform-origin: 64px 34px;
}

.bicycle-frame {
  stroke-width: 2.4;
}

@keyframes bicycle-ride-across {
  0% {
    opacity: 0;
    transform: translate3d(-120%, 0, 0);
  }
  8%, 92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(100vw + 20%), 0, 0);
  }
}

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

@keyframes bicycle-body-bounce {
  to {
    transform: translate3d(0, -1px, 0);
  }
}

@keyframes bicycle-reduced-fade {
  0%, 100% {
    opacity: 0;
    transform: translate3d(-50%, 3px, 0) scale(0.98);
  }
  30%, 70% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bicycle-ride-layer.is-riding .bicycle-ride {
    left: 50%;
    animation: bicycle-reduced-fade 500ms ease-out forwards !important;
  }

  .bicycle-ride-body,
  .bicycle-wheel {
    animation: none !important;
  }
}

/* Responsiveness helper for larger viewports */
@media (min-width: 480px) {
  body {
    padding: 32px 16px;
  }
}

@media (max-width: 480px) {
  body {
    padding: calc(5px + env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom));
  }

  .app {
    gap: 8px;
  }

  .topbar {
    min-height: 46px;
    padding-bottom: 2px;
  }

  .brand-title {
    font-size: 1.08rem;
    line-height: 1.05;
  }

  .layout {
    gap: 8px;
  }

  .calculator-card {
    gap: 9px;
    padding: 12px;
  }

  .calculator-display-wrap {
    min-height: 56px;
    padding: 7px 12px;
  }

  .calculator-display-wrap input {
    font-size: 2.15rem;
  }

  .quick-row {
    gap: 6px;
  }

  .bank-profile-field {
    gap: 4px;
  }

  .bank-profile-trigger {
    min-height: 50px;
  }

  footer {
    padding-block: 8px;
  }
}

/* ── Toast / Snackbar (Material Design 3) ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.22s ease, transform 0.22s ease;
  will-change: opacity, transform;
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-err {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
}

.toast.toast-warn {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

/* ── Refresh button spin animation ────────────────────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.icon-btn.loading .material-symbols-rounded,
.tiny-icon.loading .material-symbols-rounded {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

/* ── Copy button flash animation ──────────────────────────────────────────── */
@keyframes copy-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.85); }
  70%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.icon-btn.copy-success, .tiny-icon.copy-success {
  animation: copy-pop 0.35s ease-out;
  color: var(--green) !important;
}

/* ── Floating keyboard "Done" button ──────────────────────────────────────── */
#keyboardDoneBtn {
  position: fixed;
  bottom: -56px;            /* hidden off-screen by default */
  left: 0;
  right: 0;
  height: 48px;
  background: var(--surface);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--primary);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  transition: bottom 0.18s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#keyboardDoneBtn.kbd-visible {
  bottom: 0;
}

#keyboardDoneBtn:active {
  background: var(--surface-hover);
}

/* Segmented Control for Appearance selection */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-soft);
  border: none;
  border-radius: 12px;
  padding: 3px;
  margin-top: 4px;
}

.segment-btn {
  min-height: 44px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0.7;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.segment-btn .material-symbols-rounded {
  font-size: 1.15rem;
  color: var(--muted);
  transition: color 0.2s;
}

.segment-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.segment-btn.active .material-symbols-rounded {
  color: var(--primary);
}

.field-desc {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Button Microinteractions */
.icon-btn, .chip-btn, .segment-btn, .tiny-icon, .breakdown-trigger-btn {
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease, box-shadow var(--dur-state) ease, filter var(--dur-state) ease;
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover,
  .tiny-icon:hover,
  .segment-btn:hover:not(.active),
  .chip-btn:hover:not(.active),
  .breakdown-trigger-btn:hover {
    transform: translateY(-1px);
  }
}

.icon-btn:hover, .tiny-icon:hover {
  background: var(--surface-hover);
  filter: brightness(1.08);
}

.chip-btn:hover:not(.active) {
  background: var(--surface-hover);
  border-color: var(--muted);
  filter: brightness(1.05);
}

.segment-btn:hover:not(.active) {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.05);
}
html[data-theme="light"] .segment-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.03);
}

.breakdown-trigger-btn:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
  filter: brightness(1.02);
}

.icon-btn:active, .chip-btn:active, .segment-btn:active, .tiny-icon:active, .breakdown-trigger-btn:active {
  transform: scale(0.98) !important;
}

/* PWA Install Prompt Card styling */
.install-prompt {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  width: 92%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  transition: transform var(--dur-sheet) var(--ease-out), opacity var(--dur-sheet) ease;
  opacity: 0;
  pointer-events: none;
}

.install-prompt.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.install-prompt-content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.install-prompt-content p {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.install-prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.install-prompt-actions button {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: background-color 150ms, filter 150ms, transform 100ms;
}

.install-prompt-actions .btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
}

.install-prompt-actions .btn-secondary:hover {
  background: var(--surface-hover);
}

.install-prompt-actions .btn-primary {
  background: var(--primary);
  color: var(--primary-on);
}

.install-prompt-actions .btn-primary:hover {
  filter: brightness(1.08);
}

.install-prompt-actions button:active {
  transform: scale(0.97);
}

.ios-share-icon {
  display: inline-block;
  vertical-align: middle;
  width: 16px;
  height: 16px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%233b82f6" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"/></svg>');
  background-repeat: no-repeat;
  background-size: contain;
  margin: 0 2px;
}

/* Accessibility & Focus States */
.icon-btn:focus,
.chip-btn:focus,
.segment-btn:focus,
.tiny-icon:focus,
.breakdown-trigger-btn:focus {
  outline: none;
}

.icon-btn:focus-visible,
.chip-btn:focus-visible,
.segment-btn:focus-visible,
.tiny-icon:focus-visible,
.breakdown-trigger-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chevron-icon {
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  display: inline-block;
  vertical-align: middle;
}

.breakdown-trigger-btn[aria-expanded="true"] .chevron-icon {
  transform: rotate(-180deg);
}

.sheet-grab-handle {
  display: none !important;
}

@media (max-width: 860px) {
  .sheet-grab-handle {
    display: none !important;
  }
}

body.modal-open {
  position: fixed !important;
  width: 100% !important;
  overflow: hidden !important;
}

html.modal-open {
  overflow: hidden !important;
  height: 100% !important;
}

/* Skeleton Loading Placeholder */
.skeleton-shimmer {
  display: inline-block;
  width: 55px;
  height: 14px;
  background: var(--border);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  animation: fade-in-skeleton 200ms ease-out forwards;
}

.skeleton-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.08) 20%,
    rgba(255, 255, 255, 0.15) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer-anim 1.2s infinite;
}

html[data-theme="light"] .skeleton-shimmer::after {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.03) 20%,
    rgba(0, 0, 0, 0.08) 60%,
    rgba(0, 0, 0, 0) 100%
  );
}

@keyframes shimmer-anim {
  100% {
    transform: translateX(100%);
  }
}

@keyframes fade-in-skeleton {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Community Support Section ────────────────────────────────────────── */
.support-section {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 12px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  text-align: left;
}

.support-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text);
}

.changelog-trigger {
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-state) ease, border-color var(--dur-state) ease, transform var(--dur-press) ease;
}

.changelog-trigger-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.changelog-trigger-copy strong {
  font-size: 0.72rem;
  line-height: 1.2;
}

.changelog-trigger-copy > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.changelog-trigger-end {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.changelog-trigger-end .material-symbols-rounded {
  color: var(--muted);
  font-size: 1.05rem;
}

@media (hover: hover) and (pointer: fine) {
  .changelog-trigger:hover {
    background: var(--surface-hover);
    transform: translateY(-1px);
  }
}

.changelog-trigger:active {
  transform: scale(0.98);
}

.changelog-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.community-row-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.community-telegram-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
  color: var(--muted);
}

.community-install-icon {
  font-size: 18px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--muted);
}

.settings-community-section {
  padding-top: 2px;
}

.settings-community-trigger {
  background: transparent;
  border-color: color-mix(in srgb, var(--border) 72%, transparent);
}

/* Shared Telegram Community modal */
.qr-panel {
  z-index: 110;
}

.qr-content {
  align-items: center;
  padding-bottom: 8px;
}

.community-handle {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.community-handle .community-telegram-icon {
  color: currentColor;
}

.community-handle:hover {
  text-decoration: underline;
}

.community-handle:focus-visible,
.qr-image-link:focus-visible,
.community-primary-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.qr-image-link {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
}

.qr-modal-img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
}

.community-primary-action {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  text-decoration: none;
}

.community-primary-action .community-telegram-icon {
  color: currentColor;
}

@media (min-width: 400px) {
  .qr-image-link {
    max-width: 280px;
  }
}

/* Share Result Bottom Sheet */
.share-panel {
  z-index: 110;
}

.share-card-panel {
  max-width: 420px;
}

.share-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 8px;
}

.share-preview-wrap {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.share-preview-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.share-actions-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.share-actions-subgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-actions-subgrid .share-action-btn {
  padding: 0 10px;
  font-size: 0.82rem;
}

/* Community Promo Centered Modal */
.community-promo-shell {
  z-index: 120;
}

.community-promo-card {
  max-width: 380px;
  border-radius: 20px;
  padding: 20px;
  gap: 14px;
}

.community-promo-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.community-promo-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.community-promo-badge .community-telegram-icon {
  width: 14px;
  height: 14px;
  color: currentColor;
}

.community-promo-title {
  font-size: 1.15rem;
  line-height: 1.25;
  margin: 0;
}

.community-promo-desc {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
  margin: 0;
}

.community-promo-subtext {
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
  margin: 0;
}

.community-promo-actions {
  margin-top: 4px;
}

.community-promo-cta {
  font-size: 0.9rem;
  min-height: 44px;
}

/* Force centered compact modal behavior on mobile viewports */
@media (max-width: 600px) {
  .community-promo-shell.open,
  .community-promo-shell.closing {
    display: grid !important;
    place-items: center !important;
    padding: 16px !important;
  }

  .community-promo-shell .community-promo-card {
    border-radius: 20px !important;
    max-width: 360px !important;
    width: 100% !important;
    max-height: calc(100dvh - 32px) !important;
    margin: auto !important;
    animation: modal-in 200ms var(--ease-out) forwards !important;
  }

  .community-promo-shell.closing .community-promo-card {
    animation: modal-out 180ms var(--ease-out) forwards !important;
  }
}
