/* ==========================================================================
   bolos · Design System (iOS style)
   ========================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f2f2f7;
  --card: #ffffff;
  --card-inset: #f2f2f7;
  --text: #1c1c1e;
  --text-2: #6e6e73;
  --text-3: #a3a3a8;
  --sep: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --hairline: rgba(60, 60, 67, 0.29);

  --green: #34c759;
  --red: #ff3b30;
  --red-text: #e11d48;
  --orange: #ff9500;
  --emerald-400: #34d399;
  --rose-400: #fb7185;

  --topbar: rgba(15, 23, 42, 0.78);
  --topbar-text: #f8fafc;

  --r-card: 20px;
  --r-cell: 14px;
  --r-field: 12px;
  --r-sheet: 24px;

  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --accent: #f59e0b;
  --accent-2: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --accent-glow: rgba(245, 158, 11, 0.42);
  --accent-text: #b45309;
}

[data-profile="personal"] {
  --accent: #0ea5e9;
  --accent-2: #0284c7;
  --accent-soft: rgba(14, 165, 233, 0.15);
  --accent-glow: rgba(14, 165, 233, 0.42);
  --accent-text: #0369a1;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-inset: #2c2c2e;
  --text: #f2f2f7;
  --text-2: #9a9aa0;
  --text-3: #7c7c82;
  --sep: rgba(84, 84, 88, 0.6);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.36);
  --hairline: rgba(84, 84, 88, 0.65);
  --red-text: #fb7185;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --card-inset: #2c2c2e;
    --text: #f2f2f7;
    --text-2: #9a9aa0;
    --text-3: #7c7c82;
    --sep: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --hairline: rgba(84, 84, 88, 0.65);
    --red-text: #fb7185;
  }
}

[data-profile="empresa"] { --accent-dot: #f59e0b; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-profile="empresa"] { --accent-text: #fbbf24; }
  :root:not([data-theme="light"])[data-profile="personal"] { --accent-text: #38bdf8; }
}
:root[data-theme="dark"][data-profile="empresa"] { --accent-text: #fbbf24; }
:root[data-theme="dark"][data-profile="personal"] { --accent-text: #38bdf8; }

/* ---------- reset ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
  transition: background-color 0.4s var(--ease);
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; color: inherit; }
input, button, select, textarea {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
button { touch-action: manipulation; cursor: pointer; }
::selection { background: var(--accent-soft); }

[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.svg-icon { display: inline-block; vertical-align: middle; flex: none; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--fill-2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Splash + Auth
   ========================================================================== */

.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(120% 90% at 80% 0%, #1c2740 0%, #0b1120 55%, #070b14 100%);
  transition: opacity 0.45s var(--ease), visibility 0.45s;
}
.splash.out { opacity: 0; visibility: hidden; }
.splash-logo svg { width: 84px; height: 84px; border-radius: 21px; box-shadow: 0 18px 50px rgba(245, 158, 11, 0.25); }
.splash-name {
  color: #f8fafc;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.splash-dots { display: flex; gap: 7px; }
.splash-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f59e0b;
  animation: dotPulse 1.1s infinite var(--ease);
}
.splash-dots span:nth-child(2) { animation-delay: 0.15s; background: #fbbf24; }
.splash-dots span:nth-child(3) { animation-delay: 0.3s; background: #38bdf8; }
@keyframes dotPulse {
  0%, 100% { transform: scale(0.7); opacity: 0.45; }
  50% { transform: scale(1); opacity: 1; }
}

.auth-wrap {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 80% 0%, #1c2740 0%, #0b1120 55%, #070b14 100%);
  overflow: auto;
}
.auth-glow {
  position: fixed;
  width: 420px; height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  background: radial-gradient(circle, var(--accent) 0%, transparent 65%);
  bottom: -140px; right: -120px;
  transition: background 0.6s var(--ease);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: riseIn 0.6s var(--spring) both;
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.auth-logo svg { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 16px 44px rgba(245, 158, 11, 0.28); }
.auth-title {
  color: #f8fafc;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 10px;
}
.auth-sub { color: #8b93a7; font-size: 15px; margin-bottom: 18px; }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.auth-form .field > label { color: #a9b2c6; }
.auth-form input[type="password"],
.auth-form input[type="text"] {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}
.auth-form input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.auth-form input[type="password"]:focus,
.auth-form input[type="text"]:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}
.auth-form input::placeholder { color: #59617a; }
.auth-form .input-group .input-trailing { color: #8b93a7; }
.auth-foot { color: #59617a; font-size: 12.5px; margin-top: 20px; }

/* ==========================================================================
   Campos, botones, chips
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.field .opt { color: var(--text-3); font-weight: 400; }

input[type="text"],
input[type="date"],
input[type="password"],
input[inputmode="decimal"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--card-inset);
  border: 1px solid transparent;
  border-radius: var(--r-field);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.25s;
}
input::placeholder { color: var(--text-3); }
input[type="text"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
input[inputmode="decimal"]:focus {
  outline: none;
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input[type="date"] { min-height: 47px; }
input.invalid { border-color: var(--red); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group input { padding-right: 46px; }
.input-trailing {
  position: absolute;
  right: 6px;
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text-2);
}
.input-trailing:active { background: var(--fill); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 20px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 0;
  border-radius: 14px;
  transition: transform 0.15s var(--ease), opacity 0.2s, background-color 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 130%);
  box-shadow: 0 8px 22px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-green {
  color: #fff;
  background: linear-gradient(180deg, #34c759 0%, #248a3d 130%);
  box-shadow: 0 8px 22px -8px rgba(52, 199, 89, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-secondary { color: var(--text); background: var(--fill); }
.btn-danger { color: #fff; background: var(--red); }
.btn-danger-soft { color: var(--red); background: rgba(255, 59, 48, 0.12); }
.btn.loading { pointer-events: none; }
.btn .spinner {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  color: var(--red-text);
  font-size: 14px;
  font-weight: 500;
  padding: 2px 2px 0;
}
.form-error.shake { animation: shake 0.4s var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--card-inset);
  border: 1.5px solid transparent;
  border-radius: 999px;
  transition: all 0.2s var(--ease);
}
.chip-opt:active { transform: scale(0.96); }
.chip-opt[aria-pressed="true"] {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.chip-opt .svg-icon { width: 16px; height: 16px; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  padding-top: var(--safe-top);
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background-color 0.4s var(--ease);
}
.topbar-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; }
.brand-mark svg { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brand-name {
  color: var(--topbar-text);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.topbar .segmented { margin-left: auto; background: rgba(255, 255, 255, 0.1); }
.topbar .seg-btn { color: rgba(248, 250, 252, 0.62); }
.topbar .seg-btn[aria-selected="true"] { color: var(--accent-text); }
.topbar .seg-btn .svg-icon { width: 15px; height: 15px; }
.topbar .seg-pill { background: #ffffff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.topbar-btn {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  color: var(--topbar-text);
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 12px;
  transition: transform 0.15s var(--ease), background-color 0.2s;
}
.topbar-btn:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.16); }

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: #7c4a03;
  background: #fde68a;
}
.offline-banner .svg-icon { width: 16px; height: 16px; }

/* ==========================================================================
   Segmented control (iOS)
   ========================================================================== */

.segmented {
  position: relative;
  display: inline-flex;
  padding: 3px;
  background: var(--fill);
  border-radius: 11px;
}
.seg-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: 8.5px;
  white-space: nowrap;
  transition: color 0.25s var(--ease);
}
.seg-btn[aria-selected="true"] { color: var(--text); }
.seg-pill {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  border-radius: 8.5px;
  background: var(--card);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.35s var(--spring), width 0.35s var(--spring), background-color 0.4s var(--ease);
}
.seg-pre .seg-pill { transition: none; }
.seg-mode { width: 100%; }
.seg-mode .seg-btn { flex: 1; min-height: 40px; font-size: 14px; }
.seg-small .seg-btn { min-height: 36px; padding: 0 14px; font-size: 13px; }
.seg-status-wrap { display: flex; }
.seg-status .seg-btn { min-height: 42px; flex: 1; }

/* ==========================================================================
   Layout + tarjetas
   ========================================================================== */

.page {
  max-width: 1024px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent);
  animation: cardIn 0.5s var(--spring) both;
  transition: background-color 0.4s var(--ease);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.kpis .card:nth-child(2) { animation-delay: 0.05s; }
.kpis .card:nth-child(3) { animation-delay: 0.1s; }
.form-card { animation-delay: 0.14s; }
.history-card { animation-delay: 0.18s; }

.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.kpi { padding: 15px 16px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.kpi-value {
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.kpi-value.danger { color: var(--red-text); }
.kpi-unit { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.kpi-sub { font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 5px; }

.mini-btn {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 0;
  border-radius: 10px;
  transition: transform 0.15s var(--ease), background-color 0.2s;
}
.mini-btn:active { transform: scale(0.92); }
.mini-btn .svg-icon { width: 17px; height: 17px; }
.mini-btn.muted { color: var(--text-2); background: var(--fill); }
.mini-btn.spinning .svg-icon { animation: spin 0.8s linear infinite; }

.balance {
  position: relative;
  overflow: hidden;
  color: #f8fafc;
  background: linear-gradient(145deg, #1b2436 0%, #101827 55%, #0b1120 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.balance .kpi-label { color: rgba(248, 250, 252, 0.65); }
.balance .kpi-unit { color: rgba(248, 250, 252, 0.45); }
.balance-glow {
  position: absolute;
  top: -90px; right: -70px;
  width: 260px; height: 260px;
  border-radius: 50%;
  filter: blur(60px);
  background: var(--accent-glow);
  opacity: 0.55;
  pointer-events: none;
  transition: background 0.6s var(--ease);
}
.balance-wallet { color: rgba(248, 250, 252, 0.4); }
.balance-wallet .svg-icon { width: 19px; height: 19px; }
.kpi-value.pos { color: var(--emerald-400); }
.kpi-value.neg { color: var(--rose-400); }
.balance-chip {
  align-self: flex-start;
  margin-top: 8px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  position: relative;
}
.balance-sub { font-size: 13px; color: rgba(248, 250, 252, 0.55); margin-top: 8px; position: relative; }

/* ---------- cinta de resumen ---------- */

.ribbon {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.ribbon::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent);
  border-radius: 999px;
  white-space: nowrap;
  animation: cardIn 0.5s var(--spring) both;
  transition: background-color 0.4s var(--ease);
}
.pill b { color: var(--text); font-weight: 700; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pill.muted { color: var(--text-3); }

.rates {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.rates::-webkit-scrollbar { display: none; }
.rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  min-height: 42px;
  padding: 0 15px;
  font-size: 13.5px;
  color: var(--text-2);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent);
  border-radius: 999px;
  transition: transform 0.15s var(--ease), background-color 0.4s var(--ease);
}
.rate-pill:active { transform: scale(0.97); }
.rate-pill b { color: var(--text); font-weight: 700; font-size: 14.5px; }
.rate-pill .svg-icon { width: 15px; height: 15px; color: var(--accent-text); }
.rate-pill.stale b { color: var(--orange); }
.rates-age { flex: none; font-size: 12px; color: var(--text-3); padding-left: 4px; }

/* ==========================================================================
   Formulario
   ========================================================================== */

.card-head { padding: 16px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }

.form-card form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field.span-2 { grid-column: 1 / -1; }
.seg-status-wrap { min-height: 47px; }

.calc {
  background: var(--card-inset);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background-color 0.4s var(--ease);
}
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc .field { gap: 5px; }
.calc .field > label { font-size: 12.5px; }
.calc input { background: var(--card); font-size: 17px; font-weight: 600; }
.calc input:focus { border-color: var(--accent); }
.calc-hero { grid-column: 1 / -1; }
.calc-hero input {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 14px;
}
.calc input.flash { animation: fieldFlash 0.7s var(--ease); }
@keyframes fieldFlash {
  0% { background: var(--accent-soft); border-color: var(--accent); }
  100% { background: var(--card); border-color: transparent; }
}
.calc-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill);
  animation: cardIn 0.3s var(--ease) both;
}
.calc-preview b { color: var(--accent-text); font-weight: 700; }
.calc-preview .warn { color: var(--orange); font-weight: 600; }

/* ==========================================================================
   Historial
   ========================================================================== */

.history-wrap { padding: 0 16px 16px; }
.exports { display: flex; flex-wrap: wrap; gap: 8px; }
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 0;
  border-radius: 11px;
  transition: transform 0.15s var(--ease), background-color 0.4s var(--ease);
}
.export-btn:active { transform: scale(0.95); }
.export-btn .svg-icon { width: 15.5px; height: 15.5px; }

.history-head {
  display: none;
  padding: 12px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.history-head .ta-right { text-align: right; }

.history-list { display: flex; flex-direction: column; gap: 10px; }

.txn {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent);
  transition: background-color 0.4s var(--ease);
}
.txn-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "date amounts"
    "info amounts";
  column-gap: 12px;
  row-gap: 2px;
  padding: 13px 15px;
  background: var(--card);
  transition: transform 0.35s var(--spring), background-color 0.4s var(--ease);
}
.txn.open .txn-main { transform: translateX(-128px); }

.txn-date { grid-area: date; font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: 0.02em; }
.txn-info { grid-area: info; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.txn-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.txn-concept { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.txn-sub { font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.txn-ref { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }

.txn-amounts { grid-area: amounts; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 3px; text-align: right; }
.txn-dest { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.txn-dest .cur { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 4px; }
.txn-rate { font-size: 12.5px; color: var(--text-3); }
.txn-usdt { font-size: 13.5px; font-weight: 700; }
.txn-usdt.pos { color: var(--green); }
.txn-usdt.neg { color: var(--red-text); }
.txn-deposit-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #1d8a45;
  background: rgba(52, 199, 89, 0.14);
  border: 1px solid rgba(52, 199, 89, 0.3);
  padding: 3px 9px;
  border-radius: 999px;
}
:root[data-theme="dark"] .txn-deposit-badge { color: #4ade80; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .txn-deposit-badge { color: #4ade80; }
  :root:not([data-theme="light"]) .chip-paid { color: #4ade80; }
  :root:not([data-theme="light"]) .chip-pending { color: #fbbf24; }
}
:root[data-theme="dark"] .chip-paid { color: #4ade80; }
:root[data-theme="dark"] .chip-pending { color: #fbbf24; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform 0.15s var(--ease), opacity 0.2s;
}
.chip:active { transform: scale(0.94); }
.chip-paid {
  color: #1d8a45;
  background: rgba(52, 199, 89, 0.14);
  border-color: rgba(52, 199, 89, 0.3);
}
.chip-pending {
  color: #b45309;
  background: rgba(255, 149, 0, 0.15);
  border-color: rgba(255, 149, 0, 0.35);
}
.chip-busy { opacity: 0.5; pointer-events: none; }

.txn-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  z-index: 0;
  display: flex;
  width: 128px;
}
.txn-actions .act {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 4px;
  color: #fff;
  background: #64748b;
  border: 0;
  font-size: 10.5px;
  font-weight: 600;
}
.txn-actions .act .svg-icon { width: 19px; height: 19px; }
.txn-actions .act + .act { border-left: 1px solid rgba(255, 255, 255, 0.18); }
.txn-actions .act-del { background: var(--red); }
.txn-actions .act:active { filter: brightness(0.9); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 42px 20px;
  color: var(--text-2);
  text-align: center;
}
.empty .svg-icon { width: 38px; height: 38px; color: var(--text-3); }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text); }
.empty-sub { font-size: 13.5px; max-width: 300px; }

.skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, var(--fill) 40%, var(--fill-2) 50%, var(--fill) 60%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
  min-height: 14px;
}
@keyframes shimmer { to { background-position: -120% 0; } }

/* ==========================================================================
   Sheets + Alertas + Toasts
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}
.sheet-backdrop.on { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 101;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.28);
  transform: translateY(102%);
  transition: transform 0.48s var(--spring), background-color 0.4s var(--ease);
  will-change: transform;
}
.sheet.on { transform: translateY(0); }
.sheet.dragging { transition: none; }

.sheet-handle {
  padding: 10px 0 4px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
}
.sheet-handle::before {
  content: "";
  width: 38px; height: 5px;
  border-radius: 999px;
  background: var(--fill-2);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 20px 12px;
}
.sheet-title { font-size: 21px; font-weight: 800; letter-spacing: -0.025em; }
.sheet-close {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: var(--fill);
  border: 0;
  border-radius: 50%;
}
.sheet-body {
  padding: 0 20px calc(24px + var(--safe-bottom));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sheet-note { font-size: 13px; color: var(--text-2); line-height: 1.45; }

.sheet-list {
  border-radius: var(--r-cell);
  background: var(--card);
  overflow: hidden;
}
.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  font-size: 15.5px;
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
}
.sheet-row + .sheet-row { border-top: 1px solid var(--sep); }
.sheet-row:active { background: var(--fill); }
.sheet-row .svg-icon { color: var(--text-2); }
.sheet-row .row-value { margin-left: auto; color: var(--text-2); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.sheet-row.danger { color: var(--red); }
.sheet-row.danger .svg-icon { color: var(--red); }

.ratehero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px 6px;
}
.ratehero-value {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--accent-text);
}
.ratehero-cur { font-size: 14px; font-weight: 600; color: var(--text-2); }
.ratehero-meta { font-size: 12.5px; color: var(--text-3); text-align: center; }
.ratehero-meta.stale { color: var(--orange); font-weight: 600; }

.conv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.conv-grid .field > label { font-size: 12.5px; }
.conv-grid input { background: var(--card); font-size: 17px; font-weight: 600; }
.conv-sep { display: grid; place-items: center; color: var(--text-3); }
.conv-sep .svg-icon { width: 18px; height: 18px; }

.alert-box {
  position: fixed;
  left: 50%; top: 50%;
  z-index: 120;
  width: min(320px, 88vw);
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-radius: 16px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  transition: transform 0.28s var(--spring), opacity 0.24s var(--ease);
}
.alert-box.on { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.alert-content { padding: 22px 20px 18px; display: flex; flex-direction: column; gap: 6px; }
.alert-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.alert-msg { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.alert-actions { display: flex; border-top: 1px solid var(--hairline); }
.alert-actions button {
  flex: 1;
  min-height: 48px;
  font-size: 16.5px;
  font-weight: 500;
  color: var(--blue, #007aff);
  background: transparent;
  border: 0;
}
.alert-actions button + button { border-left: 1px solid var(--hairline); }
.alert-actions button:active { background: var(--fill); }
.alert-actions .danger { color: var(--red); }
.alert-actions .bold { font-weight: 700; }

#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 140;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 17px;
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
  background: color-mix(in srgb, #1c1c1e 92%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  animation: toastIn 0.42s var(--spring) both;
}
.toast.out { animation: toastOut 0.3s var(--ease) both; }
.toast .svg-icon { width: 17px; height: 17px; }
.toast.success .svg-icon { color: #34d399; }
.toast.error .svg-icon { color: #fb7185; }
.toast.info .svg-icon { color: #93c5fd; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* ==========================================================================
   Responsive (≥ 900px) — escritorio
   ========================================================================== */

@media (min-width: 900px) {
  body { font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr 1.15fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .exports { flex-wrap: nowrap; }

  .history-head {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 170px 110px 140px 104px;
    column-gap: 14px;
  }
  .history-list { gap: 0; border-radius: 16px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent); }
  .txn {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 170px 110px 140px 104px;
    column-gap: 14px;
    align-items: center;
    padding: 12px 16px;
    border: 0;
    border-radius: 0;
  }
  .txn + .txn { border-top: 1px solid var(--sep); }
  .txn-main { display: contents; }
  .txn-date, .txn-info { grid-area: auto; }
  .txn-amounts { display: contents; }
  .txn-date { align-self: center; }
  .txn-dest, .txn-rate, .txn-usdt { text-align: right; }
  .txn-rate { align-self: center; }
  .txn-usdt { align-self: center; }
  .txn-actions {
    position: static;
    width: auto;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
  }
  .txn-actions .act {
    width: 40px; height: 40px;
    flex: none;
    border-radius: 11px;
    font-size: 0;
  }
  .txn-actions .act + .act { border-left: 0; }
  .txn-actions .act { background: var(--fill); color: var(--text-2); }
  .txn-actions .act-del { background: rgba(255, 59, 48, 0.12); color: var(--red); }
  .txn.open .txn-main { transform: none; }

  .sheet {
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    width: min(470px, 92vw);
    max-height: 86dvh;
    border-radius: var(--r-sheet);
    transform: translate(-50%, -50%) scale(0.94);
    opacity: 0;
    transition: transform 0.34s var(--spring), opacity 0.26s var(--ease);
  }
  .sheet.on { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 20px; }
  .sheet-body { padding-bottom: 24px; }

  .page { padding-top: 20px; gap: 16px; }
}

/* ---------- accesibilidad de movimiento ---------- */

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

/* ---------- utilidades ---------- */

.ta-right { text-align: right; }
.mt-2 { margin-top: 8px; }
