/* =========================================================================
   Financial Control — Design tokens
   Paleta: Sapphire / Blue Grey / Pearl Aqua / Platinum / Sunflower Gold
   ========================================================================= */
:root {
  --sapphire: #4059ad;
  --sapphire-600: #35488c;
  --sapphire-700: #2a3971;
  --sapphire-tint: #eaedf9;
  --sapphire-ink: var(--sapphire-700);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --blue-grey: #6b9ac4;
  --blue-grey-tint: #eaf1f8;
  --aqua: #97d8c4;
  --aqua-600: #1f9376;
  --aqua-tint: #e6f8f2;
  --platinum: #eff2f1;
  --gold: #f4b942;
  --gold-600: #c9911f;
  --gold-tint: #fef4e0;
  --danger: #e15554;
  --danger-600: #b23a39;
  --danger-tint: #fceaea;

  --bg: var(--platinum);
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --border: #dfe4ea;
  --border-strong: #c9d1db;
  --text: #1c2333;
  --text-muted: #667085;
  --text-soft: #97a1b0;
  --accent: var(--sapphire);
  --public: var(--aqua-600);
  --protected: var(--blue-grey);

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(28, 35, 51, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(64, 89, 173, 0.18);
  --shadow-lg: 0 20px 45px -12px rgba(64, 89, 173, 0.28);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Tema oscuro: paleta redefinida solo para superficies/texto/tintes; los
   colores de marca (sapphire/blue-grey/aqua/gold/danger) se mantienen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1320;
    --surface: #171c2b;
    --surface-2: #1f2536;
    --border: #2b3245;
    --border-strong: #3c4560;
    --text: #e8eaf1;
    --text-muted: #9aa3b7;
    --text-soft: #6b7385;
    --sapphire-tint: rgba(64, 89, 173, 0.28);
    --blue-grey-tint: rgba(107, 154, 196, 0.2);
    --aqua-tint: rgba(151, 216, 196, 0.16);
    --gold-tint: rgba(244, 185, 66, 0.18);
    --danger-tint: rgba(225, 85, 84, 0.2);
    --sapphire-ink: #aec2f2;
    --topbar-bg: rgba(15, 19, 32, 0.75);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 50px -14px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1320;
  --surface: #171c2b;
  --surface-2: #1f2536;
  --border: #2b3245;
  --border-strong: #3c4560;
  --text: #e8eaf1;
  --text-muted: #9aa3b7;
  --text-soft: #6b7385;
  --sapphire-tint: rgba(64, 89, 173, 0.28);
  --blue-grey-tint: rgba(107, 154, 196, 0.2);
  --aqua-tint: rgba(151, 216, 196, 0.16);
  --gold-tint: rgba(244, 185, 66, 0.18);
  --danger-tint: rgba(225, 85, 84, 0.2);
  --sapphire-ink: #aec2f2;
  --topbar-bg: rgba(15, 19, 32, 0.75);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px -14px rgba(0, 0, 0, 0.6);
}

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 420px at 100% -10%, var(--sapphire-tint) 0%, transparent 60%),
    radial-gradient(900px 380px at -10% 0%, var(--aqua-tint) 0%, transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }

::selection { background: var(--gold-tint); color: var(--sapphire-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--blue-grey); }

a { color: var(--sapphire); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--sapphire-600); text-decoration: underline; }

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

/* -------------------------------------------------------------------------
   Topbar
   ------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.topbar.is-scrolled { box-shadow: 0 6px 24px -12px rgba(28, 35, 51, 0.25); }

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sapphire) 0%, var(--blue-grey) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; }

.topbar nav {
  display: flex;
  gap: 2px;
  flex: 1;
  font-size: 13.5px;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.active { background: var(--sapphire-tint); color: var(--sapphire-ink); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* -------------------------------------------------------------------------
   Menu de usuario (avatar -> popup con correo, tema y salir)
   ------------------------------------------------------------------------- */
.user-menu { position: relative; flex-shrink: 0; }

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 999px;
  color: var(--text-soft);
  transition: background 0.15s var(--ease);
}
.avatar-btn:hover { background: var(--surface-2); }
.avatar-chevron { width: 14px; height: 14px; transition: transform 0.18s var(--ease); }
.avatar-btn[aria-expanded="true"] .avatar-chevron { transform: rotate(180deg); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--sapphire) 130%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 60;
  animation: dropdown-in 0.16s var(--ease);
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.user-dropdown-email {
  padding: 8px 12px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.user-dropdown-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.user-dropdown-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-soft); }
.user-dropdown-danger { color: var(--danger-600); }
.user-dropdown-danger svg { color: var(--danger-600); }
.user-dropdown-danger:hover { background: var(--danger-tint); color: var(--danger-600); }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* -------------------------------------------------------------------------
   Page shell + entrance transition
   ------------------------------------------------------------------------- */
.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 36px 24px 72px;
  animation: page-in 0.45s var(--ease) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1 { font-size: 26px; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 700; }
.subtitle { color: var(--text-muted); margin: 0; font-size: 14px; }
.page-head .subtitle { margin: 0; }

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  animation: card-in 0.45s var(--ease) both;
  animation-delay: 0.05s;
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease), border-color 0.25s var(--ease);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin: 0 0 8px; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--sapphire-ink); margin: 0; }
.stat-value.tone-good { color: var(--aqua-600); }
.stat-value.tone-warn { color: var(--gold-600); }
.stat-value.tone-bad { color: var(--danger-600); }
.stat-caption { font-size: 11.5px; color: var(--text-soft); margin: 6px 0 0; line-height: 1.4; }
.lbl-muted { color: var(--text-soft); }

.section-lead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 36px 0 16px; }
.section-lead h2 { margin: 0; font-size: 19px; }
.section-lead .subtitle { margin: 0; }

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--sapphire-tint); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.actions-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--sapphire);
  background: var(--sapphire);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
  box-shadow: 0 1px 2px rgba(28, 35, 51, 0.08);
}
.btn:hover { background: var(--sapphire-600); border-color: var(--sapphire-600); text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(28, 35, 51, 0.1); }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: none; }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-soft); color: var(--text); }

.btn-accent { background: var(--gold); border-color: var(--gold); color: var(--sapphire-700); }
.btn-accent:hover { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-600); border-color: var(--danger-600); }

.btn-sm { padding: 7px 14px; font-size: 12.5px; }

form.inline { display: inline; }

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */
.field { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input:hover, .field select:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--sapphire);
  box-shadow: 0 0 0 4px var(--sapphire-tint);
}
.field-checkbox { flex-direction: row; align-items: center; gap: 9px; }
.field-checkbox input { accent-color: var(--sapphire); width: 16px; height: 16px; }

.field-locked-value {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
}
.field-locked-value svg { width: 15px; height: 15px; color: var(--text-soft); flex-shrink: 0; }

.form-card { max-width: 460px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* -------------------------------------------------------------------------
   Badges / pills
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-public { color: var(--aqua-600); background: var(--aqua-tint); }
.badge-protected { color: var(--sapphire-ink); background: var(--sapphire-tint); }
.badge-warning { color: var(--gold-600); background: var(--gold-tint); }
.badge-danger { color: var(--danger-600); background: var(--danger-tint); }

/* -------------------------------------------------------------------------
   Flash messages
   ------------------------------------------------------------------------- */
.flash-stack { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  animation: flash-in 0.35s var(--ease) both;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.flash-error { background: var(--danger-tint); color: var(--danger-600); border-color: rgba(225, 85, 84, 0.25); }
.flash-success { background: var(--aqua-tint); color: var(--aqua-600); border-color: rgba(31, 147, 118, 0.25); }

.period-select { margin-bottom: 20px; }

/* -------------------------------------------------------------------------
   Barras de estadisticas (gasto / pago por tarjeta)
   ------------------------------------------------------------------------- */
.bar-cell { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--sapphire), var(--blue-grey)); transition: width 0.6s var(--ease); }
.bar-fill.gold { background: linear-gradient(90deg, var(--gold-600), var(--gold)); }
.bar-value { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-muted); min-width: 62px; text-align: right; }

/* -------------------------------------------------------------------------
   Auth (login / register)
   ------------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  color: #fff;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(244, 185, 66, 0.28), transparent 60%),
    linear-gradient(150deg, var(--sapphire) 0%, var(--sapphire-700) 60%, var(--blue-grey) 130%);
}
.auth-panel-mark {
  width: 46px; height: 46px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.14);
  display: grid; place-items: center;
  margin-bottom: 28px;
  backdrop-filter: blur(6px);
}
.auth-panel-mark svg { width: 24px; height: 24px; }
.auth-panel h2 { font-size: 30px; margin: 0 0 14px; max-width: 380px; line-height: 1.25; }
.auth-panel p { font-size: 14.5px; line-height: 1.6; color: rgba(255, 255, 255, 0.82); max-width: 360px; margin: 0 0 28px; }
.auth-panel-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-panel-features li { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: rgba(255, 255, 255, 0.92); }
.auth-panel-features .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex-shrink: 0; box-shadow: 0 0 0 4px rgba(244, 185, 66, 0.25); }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: card-in 0.5s var(--ease) both;
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .subtitle { margin-bottom: 26px; }
.muted-link { font-size: 13px; color: var(--text-muted); margin-top: 18px; text-align: center; }

@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel { padding: 40px 28px; min-height: 240px; }
  .auth-panel h2 { font-size: 22px; }
  .auth-panel-features { display: none; }
}

/* -------------------------------------------------------------------------
   Tarjetas de credito (vista visual tipo fintech)
   ------------------------------------------------------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  margin-bottom: 32px;
}

.credit-card {
  position: relative;
  border-radius: 20px;
  padding: 22px 24px;
  color: #fff;
  overflow: hidden;
  aspect-ratio: 1.68 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  background: var(--cc-bg, linear-gradient(135deg, var(--sapphire) 0%, var(--sapphire-700) 100%));
}
.credit-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 85% -10%, rgba(255, 255, 255, 0.22), transparent 55%),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 1px, transparent 1px, transparent 14px);
  pointer-events: none;
}
.credit-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.credit-card.tone-b { --cc-bg: linear-gradient(135deg, var(--blue-grey) 0%, var(--sapphire-700) 100%); }
.credit-card.tone-c { --cc-bg: linear-gradient(135deg, var(--aqua-600) 0%, var(--sapphire-700) 120%); }
.credit-card.tone-d { --cc-bg: linear-gradient(135deg, var(--gold-600) 0%, var(--sapphire-700) 130%); }
.credit-card.inactive { --cc-bg: linear-gradient(135deg, #6b7385 0%, #3a4257 100%); opacity: 0.75; }

.credit-card-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 1; }
.credit-card-bank { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; font-weight: 600; }
.credit-card-role {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
}

.credit-card-chip {
  width: 34px;
  height: 25px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.5));
  position: relative;
  z-index: 1;
  margin-top: 14px;
}
.credit-card-chip::before, .credit-card-chip::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  height: 1px;
  background: rgba(64, 89, 173, 0.35);
}
.credit-card-chip::before { top: 8px; }
.credit-card-chip::after { top: 16px; }

.credit-card-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

.credit-card-bottom { position: relative; z-index: 1; }
.credit-card-meta { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; opacity: 0.9; margin-bottom: 8px; }
.credit-card-meta strong { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.credit-card-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.credit-card-fill { height: 100%; border-radius: 999px; background: #fff; transition: width 0.6s var(--ease); }
.credit-card-fill.tone-bad { background: var(--gold); }

.card-actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* -------------------------------------------------------------------------
   Empty states
   ------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 40px 20px;
}
.empty-state-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--blue-grey);
}
.empty-state-icon svg { width: 22px; height: 22px; }

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */

/* Escritorio angosto / tablet: 6 opciones con texto no caben junto a la
   marca y el avatar entre ~721px y ~1099px -- antes "Empresas" (o mas de
   una opcion) quedaba fuera de vista sin ninguna pista de scroll. Solo
   iconos (sin apilar, sigue siendo una fila) resuelve esto con margen de
   sobra. Debajo de 720px sigue el tratamiento movil de mas abajo. */
@media (max-width: 1099px) and (min-width: 721px) {
  .topbar-inner { gap: 12px; }
  .topbar nav { gap: 0; justify-content: space-between; }
  .topbar nav a { padding: 9px 11px; }
  .nav-label { display: none; }
}

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 10px 12px; justify-content: space-between; }
  .brand-text { display: none; }

  /* Solo iconos en el menu: el texto ("Resumen", "Movimientos", ...) no
     cabe para 6 opciones en pantallas angostas y quedaba fuera de vista
     dependiendo de scroll horizontal sin pista visual. Los iconos, bien
     espaciados y con buen tamano de toque, son mas confiables aqui.

     "width: 100%" solo no basta para forzar el salto de linea: el "flex:
     1" de escritorio ya fija flex-basis en 0, y flex-basis manda sobre
     width en el calculo del tamano del item. Sin flex-basis:100% aqui,
     nav terminaba compartiendo la primera fila con brand + user-menu en
     vez de bajar a su propia fila completa (por eso el menu de usuario
     tambien quedaba pegado a la izquierda, junto al logo). */
  .topbar nav {
    order: 3;
    flex: 1 1 100%;
    overflow-x: visible;
    justify-content: space-between;
    gap: 2px;
  }
  .topbar nav a {
    flex-direction: column;
    gap: 3px;
    padding: 7px 4px;
    flex: 1;
    border-radius: 12px;
  }
  .nav-label { font-size: 9.5px; font-weight: 700; }
  .nav-icon { width: 19px; height: 19px; }

  .user-dropdown { right: -8px; min-width: 210px; }

  .page { padding: 20px 16px 56px; }
  .card { padding: 18px; }
}

@media (max-width: 400px) {
  .nav-label { display: none; }
  .topbar nav a { padding: 8px; }
}
