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

:root {
  color-scheme: dark;
  --accent: #e87020;
  --accent-strong: #c95b12;
  --accent-soft: rgba(232, 112, 32, 0.14);
  --success: #28b777;
  --danger: #d9534f;
  --info: #4d84ff;
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --border-soft: 1px solid transparent;
  --ease: 180ms cubic-bezier(0.22, 1, 0.36, 1);
  --ease-fn: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --bg-accent: radial-gradient(circle at top left, rgba(232, 112, 32, 0.08), transparent 24%), radial-gradient(circle at top right, rgba(77, 132, 255, 0.08), transparent 26%), linear-gradient(180deg, #12151b 0%, #0e1014 100%);
  --panel: rgba(18, 22, 29, 0.92);
  --panel-strong: rgba(22, 27, 36, 0.98);
  --surface: #171b22;
  --surface-2: #1d232d;
  --surface-3: #242b37;
  --surface-soft: rgba(255, 255, 255, 0.03);
  --text: #eef2f7;
  --text-muted: #9ca6b5;
  --text-soft: #c9d2de;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 28px 60px rgba(0, 0, 0, 0.34);
  --ring: 0 0 0 3px rgba(232, 112, 32, 0.18);
  --input-bg: #12161d;
  --chip-bg: rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f0eb;
  --bg-accent: radial-gradient(circle at top left, rgba(232, 112, 32, 0.11), transparent 24%), radial-gradient(circle at top right, rgba(77, 132, 255, 0.08), transparent 26%), linear-gradient(180deg, #f7f4ef 0%, #efebe4 100%);
  --panel: rgba(250, 247, 242, 0.9);
  --panel-strong: rgba(255, 252, 247, 0.98);
  --surface: #f8f5f0;
  --surface-2: #f2ede5;
  --surface-3: #ebe4db;
  --surface-soft: rgba(0, 0, 0, 0.025);
  --text: #1b2430;
  --text-muted: #6d7685;
  --text-soft: #424d5d;
  --line: rgba(27, 36, 48, 0.08);
  --line-strong: rgba(27, 36, 48, 0.12);
  --shadow-sm: 0 10px 24px rgba(76, 60, 46, 0.08);
  --shadow-md: 0 18px 38px rgba(76, 60, 46, 0.12);
  --shadow-lg: 0 24px 52px rgba(76, 60, 46, 0.14);
  --ring: 0 0 0 3px rgba(232, 112, 32, 0.16);
  --input-bg: #f0ebe3;
  --chip-bg: rgba(27, 36, 48, 0.05);
}

html, body {
  min-height: 100%;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  background-image: var(--bg-accent);
}

[hidden] {
  display: none !important;
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.screen-loader {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.screen-loader-mark,
.auth-copy-mark {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.screen-loader-title,
.auth-copy-title {
  font-size: clamp(2.8rem, 10vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
  font-weight: 900;
}

.screen-loader-title span,
.auth-copy-title span {
  color: var(--accent);
}

.screen-loader-copy,
.auth-copy-lead {
  max-width: 52ch;
  color: var(--text-muted);
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 18%, rgba(232, 112, 32, 0.14), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(77, 132, 255, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 42%);
  pointer-events: none;
}

.auth-layout {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 16px 40px;
}

.auth-brand {
  text-align: center;
}

.auth-brand-mark {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-brand-title {
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
  font-weight: 900;
}

.auth-brand-title span {
  color: var(--accent);
}

.auth-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px 24px;
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.auth-panel-head {
  display: grid;
  gap: 8px;
}

.auth-panel-title {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.auth-panel-copy {
  color: var(--text-muted);
  max-width: 42ch;
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.auth-tab {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}

.auth-tab:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.auth-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #f2934b 100%);
  box-shadow: 0 16px 36px rgba(232, 112, 32, 0.24);
}

.auth-feedback {
  min-height: 24px;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-feedback.is-error {
  color: var(--danger);
}

.auth-feedback.is-success {
  color: var(--success);
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.auth-submit {
  margin-top: 6px;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-session-bar {
  display: none;
}

#top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 16px 12px;
}

.nav-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.nav-brand {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.nav-brand span {
  color: var(--accent);
}

.nav-userline {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.theme-toggle,
.nav-settings-btn {
  height: 40px;
  border: var(--border-soft);
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
  box-shadow: var(--shadow-sm);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.theme-toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #ffb06f 100%);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.theme-toggle:hover,
.nav-settings-btn:hover {
  transform: translateY(-1px);
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line-strong);
}

.nav-settings-btn {
  padding: 0 14px;
}

.auth-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 16px;
}

.nav-tab,
.nav-sidebar-btn,
.settings-menu-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  transition: transform var(--ease), background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
  cursor: pointer;
}

.nav-sidebar-btn:focus,
.settings-menu-item:focus,
.drawer-nav-item:focus,
.drawer-logout-btn:focus,
.modal-close:focus,
.icon-btn:focus {
  outline: none;
}

.nav-sidebar-btn:focus-visible,
.settings-menu-item:focus-visible,
.drawer-nav-item:focus-visible,
.drawer-logout-btn:focus-visible,
.modal-close:focus-visible,
.icon-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--accent-soft);
}

.nav-tab {
  min-height: 54px;
  padding: 0 14px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--surface-soft);
}

.tab-icon {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--line-strong);
  flex-shrink: 0;
}

.nav-tab[data-view="cargar"] .tab-icon {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.nav-tab[data-view="gastos"] .tab-icon {
  width: 18px;
  height: 16px;
  border-radius: 0;
  background:
    linear-gradient(var(--line-strong) 0 0) left top / 100% 2px no-repeat,
    linear-gradient(var(--line-strong) 0 0) left center / 82% 2px no-repeat,
    linear-gradient(var(--line-strong) 0 0) left bottom / 66% 2px no-repeat;
}

.nav-tab[data-view="resumen"] .tab-icon {
  width: 18px;
  height: 16px;
  border-radius: 0;
  background:
    linear-gradient(var(--line-strong) 0 0) left bottom / 3px 8px no-repeat,
    linear-gradient(var(--line-strong) 0 0) center bottom / 3px 12px no-repeat,
    linear-gradient(var(--line-strong) 0 0) right bottom / 3px 16px no-repeat;
}

.nav-tab[data-view="cargar"] .tab-icon {
  width: 18px;
  height: 18px;
  background: transparent;
}

.nav-tab[data-view="cargar"] .tab-icon::before,
.nav-tab[data-view="cargar"] .tab-icon::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  background: currentColor;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.nav-tab[data-view="cargar"] .tab-icon::before {
  width: 18px;
  height: 3px;
}

.nav-tab[data-view="cargar"] .tab-icon::after {
  width: 3px;
  height: 18px;
}

.nav-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-md);
}

.nav-tab.active[data-view="gastos"] .tab-icon {
  background:
    linear-gradient(var(--accent) 0 0) left top    / 100% 2px no-repeat,
    linear-gradient(var(--accent) 0 0) left center /  82% 2px no-repeat,
    linear-gradient(var(--accent) 0 0) left bottom /  66% 2px no-repeat;
}

.nav-tab.active[data-view="resumen"] .tab-icon {
  background:
    linear-gradient(var(--accent) 0 0) left   bottom / 3px  8px no-repeat,
    linear-gradient(var(--accent) 0 0) center bottom / 3px 12px no-repeat,
    linear-gradient(var(--accent) 0 0) right  bottom / 3px 16px no-repeat;
}

.nav-tab.active[data-view="cargar"] .tab-icon {
  color: var(--accent);
}

.nav-tab:hover,
.nav-sidebar-btn:hover,
.settings-menu-item:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  transform: translateY(-1px);
}

.nav-sidebar-actions,
.nav-footer {
  display: none;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.nav-footer-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-footer-copy {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.settings-menu {
  display: none;
  position: fixed;
  top: 72px;
  right: 16px;
  width: min(220px, calc(100vw - 32px));
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  z-index: 240;
}

.settings-menu.open {
  display: grid;
  gap: 6px;
}

.settings-menu-item {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  text-align: left;
}

.view {
  display: none;
  flex-direction: column;
  gap: 18px;
  padding: 18px 16px 32px;
  width: 100%;
}

.view.active {
  display: flex;
  animation: view-in 260ms var(--ease-fn);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.view-head-compact {
  gap: 4px;
}

.view-kicker,
.field-label,
.filter-bar-title,
.bal-label,
.sec-label,
.sec-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-bar-title,
.sec-title {
  color: var(--accent);
}

.view-title {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.05em;
  font-weight: 800;
}

.view-copy {
  max-width: 52ch;
  color: var(--text-muted);
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.65;
  cursor: pointer;
}

select option {
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
  padding: 14px;
}

.picker-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.picker-field {
  position: relative;
}

.picker-trigger {
  width: 100%;
  min-height: 50px;
  padding: 0 48px 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease), transform var(--ease);
  position: relative;
}

.picker-trigger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-65%) rotate(45deg);
  transition: border-color var(--ease), transform var(--ease);
}

.picker-trigger:hover {
  background: var(--surface);
  transform: translateY(-1px);
}

.picker-trigger:focus-visible,
.picker-trigger.is-active {
  border-color: rgba(232, 112, 32, 0.5);
  box-shadow: var(--ring);
  background: var(--surface);
  outline: none;
}

.picker-trigger:focus-visible::after,
.picker-trigger.is-active::after {
  border-color: var(--accent);
}

.picker-trigger.is-placeholder .picker-trigger-label {
  color: var(--text-muted);
}

.picker-trigger-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(232, 112, 32, 0.5);
  box-shadow: var(--ring);
  background: var(--surface);
}

.filter-bar,
.form-card,
.res-section,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.filter-bar {
  padding: 18px;
}

.filter-bar-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.filter-bar-title {
  margin-bottom: 0;
}

.filter-bar-summary {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding-right: 22px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-bar-summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform var(--ease), border-color var(--ease);
}

.filter-bar-body {
  display: grid;
  margin-top: 14px;
}

.filter-bar.is-collapsed .filter-bar-body {
  display: none;
}

.filter-bar:not(.is-collapsed) .filter-bar-summary::after {
  transform: translateY(-20%) rotate(-135deg);
  border-color: var(--accent);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

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

.type-selector {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}

.type-pill {
  min-height: 46px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}

.type-pill:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.type-pill.active-gasto,
.type-pill.active-ingreso,
.type-pill.active-transferencia {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.type-pill.active-gasto {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9b53 100%);
}

.type-pill.active-ingreso {
  background: linear-gradient(135deg, var(--success) 0%, #5dd39e 100%);
}

.type-pill.active-transferencia {
  background: linear-gradient(135deg, var(--info) 0%, #7da8ff 100%);
}

.form-card {
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.field-hero {
  grid-column: 1 / -1;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.amount-wrap {
  position: relative;
}

.amount-currency {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent);
}

.amount-input {
  min-height: 82px;
  padding: 0 18px 0 48px !important;
  border-radius: 22px !important;
  font-size: clamp(2rem, 5vw, 2.8rem) !important;
  font-weight: 800 !important;
  letter-spacing: -0.06em;
}

.amount-input:focus {
  color: var(--accent);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.transfer-dest {
  display: none;
}

.transfer-dest.show {
  display: flex;
}

.btn-primary,
.btn-add {
  border: none;
  cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease), background var(--ease), opacity var(--ease);
}

.btn-primary {
  grid-column: 1 / -1;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #f2934b 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 16px 36px rgba(232, 112, 32, 0.28);
}

.btn-primary:hover,
.btn-add:hover {
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-add:active {
  transform: translateY(0);
}

.btn-primary:disabled,
.btn-add:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
  box-shadow: none;
}

.btn-primary.is-loading {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary.is-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: btn-spin 0.75s linear infinite;
}

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

.txn-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.txn-day-group {
  display: grid;
  gap: 12px;
}

.txn-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.txn-day-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.txn-day-count {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.txn-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow: hidden;
  min-width: 0;
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease), background var(--ease);
}

.txn-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.txn-card:active {
  transform: translateY(0);
}

.txn-card.t-gasto {
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm);
}

.txn-card.t-ingreso {
  box-shadow: inset 3px 0 0 var(--success), var(--shadow-sm);
}

.txn-card.t-transferencia {
  box-shadow: inset 3px 0 0 var(--info), var(--shadow-sm);
}

.txn-icon,
.acc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.txn-icon {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  font-size: 1.1rem;
}

.acc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 1rem;
}

.txn-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.txn-cat {
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.txn-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 5px;
  overflow: hidden;
}

.txn-sub,
.txn-date-label,
.txn-notes-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.txn-notes-label {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge,
.bal-trend {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.b-gasto {
  background: rgba(232, 112, 32, 0.12);
  color: var(--accent);
}

.b-ingreso {
  background: rgba(40, 183, 119, 0.14);
  color: var(--success);
}

.b-transferencia {
  background: rgba(77, 132, 255, 0.14);
  color: var(--info);
}

.b-cat {
  background: var(--chip-bg);
  color: var(--text-soft);
}

.txn-amount {
  flex-shrink: 0;
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.txn-amount.t-gasto {
  color: var(--danger);
}

.txn-amount.t-ingreso {
  color: var(--success);
}

.txn-amount.t-transferencia {
  color: var(--info);
}

.empty-state {
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  gap: 10px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.4rem;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
}

.empty-sub {
  color: var(--text-muted);
}

.balance-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.bal-card {
  position: relative;
  padding: 20px;
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.bal-card::after {
  content: "";
  position: absolute;
  inset: auto -24px -24px auto;
  width: 88px;
  height: 88px;
  border-radius: 28px;
  opacity: 0.12;
}

.bal-card.featured::after {
  background: linear-gradient(135deg, var(--accent) 0%, #ffb06f 100%);
}

.bal-card.income::after {
  background: linear-gradient(135deg, var(--success) 0%, #6ed7a7 100%);
}

.bal-card.expense::after {
  background: linear-gradient(135deg, var(--danger) 0%, #ff8d86 100%);
}

.bal-amount {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.06em;
  font-weight: 800;
}

.bal-card.featured .bal-amount {
  color: var(--accent);
}

.bal-card.income .bal-amount {
  color: var(--success);
}

.bal-card.expense .bal-amount {
  color: var(--danger);
}

.bal-sub {
  margin-top: 8px;
  color: var(--text-muted);
}

.trend-up {
  background: rgba(40, 183, 119, 0.12);
  color: var(--success);
}

.trend-down {
  background: rgba(217, 83, 79, 0.12);
  color: var(--danger);
}

.resumen-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.res-section {
  padding: 20px;
}

.sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stats-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats-nav-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  min-width: 120px;
  text-align: center;
  white-space: nowrap;
}

.stats-nav-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
  padding: 0;
}
.stats-nav-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }
.stats-nav-btn:disabled { opacity: 0.3; cursor: default; }

#accounts-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
}

.acc-card {
  width: 100%;
  text-align: center;
  cursor: pointer;
  border-radius: 18px;
  border: 1px solid var(--acc-border, var(--line));
  background: var(--acc-bg, var(--surface));
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 132px;
  transition: border-color var(--ease), transform var(--ease), filter var(--ease);
}

.acc-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.acc-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--acc-icon-bg, rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 20px;
  flex-shrink: 0;
}

.acc-card-name {
  width: 100%;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-card-bal {
  font-size: 1.06rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-top: auto;
}

.acc-card-converted {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1;
}

.acc-card-no-rate {
  color: var(--warn, #e09000);
}

.wallet-total-note {
  font-size: 0.74rem;
  color: var(--warn, #e09000);
  margin-top: 4px;
}

.acc-item,
.item-row,
.sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.acc-item-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}

.acc-item-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

/* Overrides para cards en grilla */
.acc-card.acc-item-btn {
  text-align: center;
}

.acc-card.acc-item-btn:hover {
  background: var(--acc-bg, var(--surface-raised));
  border-color: var(--acc-border-hover, var(--acc-border, var(--line-strong)));
}

.acc-item + .acc-item,
.item-row + .item-row,
.sub-item + .sub-item,
.cat-item + .cat-item {
  margin-top: 10px;
}

.acc-name,
.item-row-name {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.item-row-icon {
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.acc-bal {
  font-size: 0.94rem;
  font-weight: 800;
}

.acc-bal.positive {
  color: var(--success);
}

.acc-bal.negative {
  color: var(--danger);
}

.acc-bal.neutral {
  color: var(--accent);
}

.account-detail-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.account-detail-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 8px 0 2px;
}

.account-detail-icon {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  font-size: 1.9rem;
}

.account-detail-name {
  font-size: 1.18rem;
  font-weight: 800;
}

.account-detail-balance {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.account-detail-balance.positive { color: var(--success); }
.account-detail-balance.negative { color: var(--danger); }
.account-detail-balance.neutral { color: var(--accent); }

.account-detail-initial,
.account-detail-subcopy,
.account-category-copy span,
.txn-remote-status {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.account-detail-cotiz {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.account-detail-cotiz--none {
  color: var(--warn, #e09000);
}

.account-adjust-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-adjust-toggle {
  width: 100%;
}

.account-adjust-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.account-adjust-panel input {
  min-width: 0;
}

.account-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-edit-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.account-edit-excluded {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  flex: 1 1 200px;
  justify-content: space-between;
}

.account-edit-excluded-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-soft);
}

.account-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.account-detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-detail-stat {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-detail-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.account-detail-stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.account-detail-stat-value.positive { color: var(--success); }
.account-detail-stat-value.negative { color: var(--danger); }

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

.account-category-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-category-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}

.account-category-group-toggle {
  width: 100%;
  border: none;
  background: transparent;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.account-category-group-toggle::after {
  content: '▾';
  margin-left: 2px;
  color: var(--text-muted);
  transition: transform var(--ease);
}

.account-category-group:not(.is-open) .account-category-group-toggle::after {
  transform: rotate(-90deg);
}

.account-category-group-meta {
  margin-left: auto;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 112, 32, 0.14);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}

.account-category-group .account-category-list {
  padding: 0 12px 12px;
}

.account-category-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}

.account-category-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.account-category-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-category-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

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

.account-category-copy strong {
  font-size: 0.92rem;
}

.account-category-amount {
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.account-category-amount.positive { color: var(--success); }
.account-category-amount.negative { color: var(--danger); }
.account-category-amount.neutral { color: var(--accent); }

.account-detail-empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  color: var(--text-muted);
}

.txn-remote-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 16px 0 6px;
}

.txn-load-more {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.txn-load-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.txn-remote-sentinel {
  width: 100%;
  height: 1px;
}

.cat-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.cat-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.cat-pct {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

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

.progress-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 280ms var(--ease);
}

.f-accent { background: linear-gradient(90deg, var(--accent) 0%, #ffad68 100%); }
.f-green  { background: linear-gradient(90deg, var(--success) 0%, #6ed7a7 100%); }
.f-blue   { background: linear-gradient(90deg, var(--info) 0%, #93b3ff 100%); }
.f-red    { background: linear-gradient(90deg, var(--danger) 0%, #ff9b95 100%); }
.f-purple { background: linear-gradient(90deg, #8a67ff 0%, #b6a0ff 100%); }
.f-teal   { background: linear-gradient(90deg, #1ea99a 0%, #6fd5cb 100%); }

#modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 12, 17, 0.44);
  backdrop-filter: blur(14px);
  z-index: 200;
}

#modal-overlay.open {
  display: flex;
}

.modal {
  display: none;
  width: min(680px, 100%);
  max-height: min(88vh, 860px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow-lg);
}

.modal.open {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modal-in 280ms var(--ease-fn);
}

.modal-header-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-category-picker .modal-sec {
  gap: 12px;
}

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

.catpick-tab {
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}

.catpick-tab.is-active {
  border-color: rgba(232, 112, 32, 0.38);
  background: rgba(232, 112, 32, 0.14);
  color: var(--accent);
}

.catpick-tab:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.catpick-search input {
  width: 100%;
  padding-left: 14px;
}

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

.catpick-cat {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}

.catpick-cat-head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
}

.catpick-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  font-size: 18px;
}

.catpick-name {
  font-size: 0.94rem;
  font-weight: 900;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catpick-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.catpick-expander {
  width: 26px;
  height: 26px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
}

.catpick-radio {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
}

.catpick-radio.is-selected {
  border-color: rgba(232, 112, 32, 0.6);
}

.catpick-radio-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: transparent;
}

.catpick-radio.is-selected .catpick-radio-dot {
  background: var(--accent);
}

.catpick-sublist {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 0 10px;
}

.catpick-cat.is-expanded .catpick-sublist {
  display: block;
}

.catpick-sub {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 52px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
}

.catpick-sub:hover {
  background: rgba(255, 255, 255, 0.04);
}

.catpick-sub-name {
  text-align: left;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-handle {
  width: 54px;
  height: 5px;
  margin: 0 auto 4px;
  border-radius: 999px;
  background: var(--line-strong);
}

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

.modal-title {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.config-version-inline {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-close,
.icon-btn,
.sub-item-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), border-color var(--ease), color var(--ease), background var(--ease);
  cursor: pointer;
}

.modal-close {
  min-width: 84px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
}

.modal-close:hover,
.icon-btn:hover,
.sub-item-remove:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.modal-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-row {
  flex-wrap: wrap;
}

.edit-input {
  flex: 1;
  min-width: 0;
}

.item-row-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 0.78rem;
}

.icon-btn.sub-btn {
  width: auto;
  min-width: 46px;
  padding: 0 10px;
}

.icon-btn.del,
.sub-item-remove {
  color: var(--danger);
}

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

.color-picker {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border-radius: 7px; border: none; }
.color-picker::-moz-color-swatch    { border-radius: 7px; border: none; }

.btn-add {
  min-width: 104px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.cat-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.cat-tab {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease), background var(--ease), color var(--ease);
}

.cat-tab.active {
  color: var(--text);
  border-color: rgba(232, 112, 32, 0.22);
  background: rgba(232, 112, 32, 0.12);
}

.cat-modal-cols {
  display: grid;
  gap: 10px;
}

.cat-order-note {
  display: none;
}

.picker-modal-list {
  display: grid;
  gap: 10px;
}

.picker-option {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease), background var(--ease), box-shadow var(--ease), color var(--ease);
}

.picker-option:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.picker-option.is-selected {
  border-color: rgba(232, 112, 32, 0.24);
  background: rgba(232, 112, 32, 0.12);
  box-shadow: 0 0 0 1px rgba(232, 112, 32, 0.12);
}

.picker-option-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.picker-option-check {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

/* ── Categorías: wrapper con panel de subcategorías inline ── */

.cat-row-wrapper {
  display: flex;
  flex-direction: column;
}

.cat-row-wrapper .item-row {
  border-radius: 14px;
  transition: border-radius 0.15s;
}

.category-item-row {
  gap: 10px;
  background: var(--cat-row-bg, var(--surface));
  border-color: var(--cat-row-border, var(--line));
  transition: background 0.2s, border-color 0.2s;
}

/* Icon edit area */
.cat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  transition: background 0.15s;
}

.cat-icon-btn:hover {
  background: rgba(255,255,255,0.07);
}

.cat-icon-display {
  font-size: 1.25rem;
  line-height: 1;
  user-select: none;
}

/* Icon picker popup */
.icon-picker-popup {
  position: fixed;
  z-index: 9999;
  width: 240px;
  max-height: 280px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ip-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  scrollbar-width: thin;
}

.ip-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-2);
  text-transform: uppercase;
  padding: 6px 4px 3px;
}

.ip-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.ip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  background: none;
  border: 2px solid transparent;
  border-radius: 7px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  padding: 0;
  line-height: 1;
}

.ip-btn:hover {
  background: rgba(255,255,255,0.1);
}

.ip-btn.ip-active {
  border-color: var(--accent);
  background: rgba(232,112,32,0.18);
}

/* Color swatch button (visible) */
.cat-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface-2);
  transition: border-color 0.15s, transform 0.15s, opacity 0.15s;
  opacity: 0.8;
  position: relative;
}
.cat-color-swatch:hover { opacity: 1; transform: scale(1.12); border-color: var(--accent); }
.cat-color-swatch.cat-color-none::after {
  content: '+';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1;
}

/* Hidden native color input (proxy for custom picker) */
.cat-color-inp { display: none; }

/* Color picker popup */
.color-picker-popup {
  position: fixed;
  z-index: 9999;
  width: 176px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  padding: 10px;
}

.cp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.cp-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  padding: 0;
}
.cp-swatch:hover { transform: scale(1.15); }
.cp-swatch.cp-active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.cp-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 0;
}

.cp-custom-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.78rem;
  padding: 5px 8px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.cp-custom-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.cp-custom-icon { font-size: 0.95rem; }

.cat-row-wrapper:has(.sub-panel.open) .item-row {
  border-radius: 14px 14px 0 0;
}

.order-input { display: none; }

/* ── Drag handle ── */
.drag-handle {
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: grab;
  padding: 0 2px;
  user-select: none;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.15s;
}

.drag-handle:active { cursor: grabbing; }
.item-row:hover .drag-handle,
.sub-chip:hover .drag-handle { opacity: 1; }

.drag-handle--sm { font-size: 0.95rem; }

/* ── Dragging state ── */
[draggable="true"].dragging {
  opacity: 0.5;
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* ── Expand button ── */
.cat-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 38px;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 6px;
  height: 30px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cat-expand-btn:hover,
.cat-expand-btn.is-open {
  color: var(--accent);
  border-color: rgba(232, 112, 32, 0.4);
  background: rgba(232, 112, 32, 0.08);
}

.expand-sub-count {
  font-weight: 700;
}

.expand-chevron {
  font-size: 0.7rem;
}

/* Panel expandible */
.sub-panel {
  display: none;
  background: var(--surface-raised, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 12px 14px 14px;
  gap: 0;
}

.sub-panel.open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Lista de chips */
.sub-panel-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.sub-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 8px 0;
}

/* Cada chip de subcategoría */
.sub-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
}

.sub-chip-name {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.sub-item-row .sub-chip-name,
.sub-item-row .sub-chip-inp {
  flex: 1;
}

.sub-chip .icon-btn {
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  border-radius: 8px;
  flex-shrink: 0;
}

.sub-chip-del {
  color: var(--danger);
}

/* Fila agregar */
.sub-panel-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sub-panel-add .sub-new-inp {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font-size: 0.88rem;
}

.sub-panel-add .sub-new-inp:focus {
  outline: none;
  border-color: var(--accent);
}

.sub-add-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.sub-add-btn:hover {
  background: rgba(232,112,32,0.1);
  border-color: var(--accent);
}

/* Compatibilidad con estilos viejos */
.sub-list { display: grid; gap: 8px; }
.sub-item { padding: 10px 12px; }
.sub-item-name { flex: 1; min-width: 0; color: var(--text-soft); font-size: 0.88rem; }
.sub-item-remove { width: 32px; height: 32px; border-radius: 10px; }

.txn-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 17, 0.48);
  backdrop-filter: blur(10px);
  z-index: 399;
}

.txn-menu {
  position: fixed;
  left: 50%;
  bottom: 16px;
  width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow-lg);
  z-index: 400;
}

.txn-menu-handle {
  width: 54px;
  height: 5px;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: var(--line-strong);
}

.txn-menu-title {
  font-size: 1.04rem;
  font-weight: 800;
}

.txn-menu-amount {
  margin-top: 6px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.txn-menu-amount.t-gasto {
  color: var(--danger);
}

.txn-menu-amount.t-ingreso {
  color: var(--success);
}

.txn-menu-amount.t-transferencia {
  color: var(--info);
}

.txn-menu-meta {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.txn-menu-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.menu-btn {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), background var(--ease), border-color var(--ease);
}

.menu-btn:hover {
  transform: translateY(-1px);
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.menu-btn.danger {
  color: var(--danger);
}

/* ── Banner pantalla muy angosta ── */
.narrow-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #e87020;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.35);
  animation: narrow-in 260ms var(--ease-fn) both;
}

.narrow-banner[hidden] {
  display: none;
}

.narrow-banner-text {
  flex: 1;
}

.narrow-banner-close {
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}

.narrow-banner-close:hover {
  background: rgba(255,255,255,0.35);
}

@keyframes narrow-in {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 500;
  white-space: nowrap;
}

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

@media (max-width: 767px) {
  .screen-loader {
    padding: 20px;
  }

  .txn-card {
    gap: 10px;
    padding: 12px 14px;
    border-radius: 18px;
  }

  .txn-icon {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    font-size: 0.95rem;
  }

  .txn-cat {
    font-size: 0.88rem;
  }

  .txn-amount {
    font-size: 0.94rem;
    max-width: 86px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .txn-meta {
    gap: 3px 5px;
    margin-top: 4px;
  }

  .txn-sub,
  .txn-date-label {
    font-size: 0.7rem;
  }

  .txn-notes-label {
    max-width: 120px;
    font-size: 0.7rem;
  }

  .auth-layout {
    padding: 24px 14px 32px;
  }

  .auth-panel {
    border-radius: 26px;
    padding: 22px 18px;
  }

  #top-nav {
    position: static;
    background: transparent;
    border-bottom: none;
    backdrop-filter: none;
  }

  .nav-header,
  .nav-sidebar-actions,
  .nav-footer,
  .settings-menu {
    display: none !important;
  }

  .app-main {
    padding-bottom: 86px;
  }

  .mobile-menu-btn {
    display: flex;
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 130;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), transform var(--ease);
  }

  .mobile-menu-btn[hidden] {
    display: none !important;
  }

  .mobile-menu-btn:active {
    transform: scale(0.93);
  }

  .hbg-line {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
  }

  .nav-tabs {
    position: fixed;
    left: -5px;
    right: -5px;
    bottom: 0px;
    z-index: 120;
    margin: 0;
    padding: 6px 10px 4px 10px;
    border-radius: 16px 16px 0px 0px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
  }

  .nav-tab {
    min-height: 52px;
    padding: 6px 4px;
    flex-direction: column;
    gap: 4px;
    border-radius: 14px;
    font-size: 0.6rem;
    letter-spacing: 0.02em;
  }

  .nav-tab[data-view="cargar"] span:not(.tab-icon) {
    display: none;
  }

  .nav-tab[data-view="cargar"] {
    min-height: 62px;
    margin-top: -10px;
    background: linear-gradient(135deg, var(--accent) 0%, #f2934b 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 -4px 24px rgba(232, 112, 32, 0.32);
  }

  .nav-tab[data-view="cargar"].active {
    background: linear-gradient(135deg, var(--accent) 0%, #f2934b 100%);
    color: #fff;
    box-shadow: 0 -4px 24px rgba(232, 112, 32, 0.36);
  }

  .nav-tab[data-view="cargar"] .tab-icon,
  .nav-tab[data-view="cargar"].active .tab-icon {
    color: #fff;
  }

  .nav-tab.active {
    box-shadow: none;
    background: var(--surface);
  }

  .nav-tab.active[data-view="resumen"] .tab-icon {
    background:
      linear-gradient(var(--accent) 0 0) left bottom / 3px 8px no-repeat,
      linear-gradient(var(--accent) 0 0) center bottom / 3px 12px no-repeat,
      linear-gradient(var(--accent) 0 0) right bottom / 3px 16px no-repeat;
  }

  .view {
    padding: 18px 14px 24px;
  }

  #view-cargar.active {
    position: fixed;
    inset: 0;
    z-index: 90;
    overflow-y: auto;
    background: var(--bg);
    padding: 18px 14px 118px;
  }

  #view-gastos.active,
  #view-resumen.active {
    min-height: calc(100vh - 102px);
  }

  .txn-menu-actions {
    grid-template-columns: 1fr;
  }

  .add-row {
    flex-wrap: wrap;
  }

  .btn-add {
    width: 100%;
  }
}

/* ============================================================
   MOBILE DRAWER (right-to-left panel)
   ============================================================ */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 300;
  backdrop-filter: blur(2px);
}

.mobile-drawer-overlay.open {
  display: block;
  animation: fade-in 200ms var(--ease-fn);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(80vw, 300px);
  height: 100dvh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 310;
  display: flex;
  flex-direction: column;
  gap: 0;
  transform: translateX(100%);
  transition: transform 300ms var(--ease-fn);
}

.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 20px 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-user {
  min-width: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: break-all;
}

.drawer-close-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.drawer-close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.drawer-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 12px;
  gap: 4px;
}

.drawer-nav-item {
  min-height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.drawer-nav-item:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.drawer-footer {
  padding: 16px 12px 28px;
  border-top: 1px solid var(--line);
}

.drawer-logout-btn {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.drawer-logout-btn:hover {
  background: var(--surface-2);
  border-color: var(--danger);
}

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

@media (min-width: 768px) {
  .mobile-menu-btn { display: none; }

  .auth-layout {
    padding: 40px 24px 48px;
  }

  .modal {
    border-radius: 28px;
  }

  .cat-modal-cols {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .auth-layout {
    padding: 48px 24px 56px;
  }

  .auth-panel {
    padding: 36px 34px;
  }

  #app {
    flex-direction: row;
  }

  #top-nav {
    width: 286px;
    min-width: 286px;
    height: 100vh;
    padding: 18px;
    border-right: 1px solid var(--line);
    border-bottom: none;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
  }

  .nav-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    margin-bottom: 22px;
    gap: 14px;
  }

  .nav-header-actions {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .theme-toggle {
    flex: 1;
    justify-content: center;
    font-size: 0.82rem;
    padding: 0 10px;
  }

  .nav-settings-btn {
    display: none;
  }

  .auth-logout-btn {
    display: inline-flex;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 0.82rem;
    padding: 0 14px;
  }

  .nav-tabs {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .nav-tab {
    justify-content: flex-start;
  }

  .nav-sidebar-actions,
  .nav-footer {
    display: block;
  }

  .nav-sidebar-actions {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
  }

  .nav-sidebar-btn {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 16px;
    text-align: left;
    font-size: 0.92rem;
    font-weight: 600;
  }

  .nav-sidebar-btn + .nav-sidebar-btn {
    margin-top: 8px;
  }

  .nav-footer {
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid var(--line);
  }

  .settings-menu {
    display: none !important;
  }

  .app-main {
    height: 100vh;
    overflow-y: auto;
  }

  .view {
    padding: 32px 36px 42px;
  }

  .form-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-card .divider,
  .form-card .transfer-dest,
  .form-card .btn-primary {
    grid-column: 1 / -1;
  }

  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .filter-grid .span2 {
    grid-column: span 2;
  }

  .balance-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bal-card.featured {
    grid-column: 1 / -1;
  }

  .resumen-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .view {
    padding: 38px 44px 52px;
  }
}

/* ============================================================
   CALENDARIO
   ============================================================ */
.calendar-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.cal-sum-card {
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
  overflow: hidden;
}

.cal-sum-card.income  { border-color: rgba(52, 199, 89, 0.3); }
.cal-sum-card.expense { border-color: rgba(255, 69, 58, 0.3); }
.cal-sum-card.positive { border-color: rgba(52, 199, 89, 0.4); }
.cal-sum-card.negative { border-color: rgba(255, 69, 58, 0.4); }

.cal-sum-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cal-sum-amount {
  font-size: clamp(0.72rem, 2.8vw, 1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  word-break: break-all;
  line-height: 1.2;
}

.cal-sum-card.income  .cal-sum-amount { color: var(--success); }
.cal-sum-card.expense .cal-sum-amount { color: var(--danger); }
.cal-sum-card.positive .cal-sum-amount { color: var(--success); }
.cal-sum-card.negative .cal-sum-amount { color: var(--danger); }

.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  overflow: hidden;
}

.calendar-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.calendar-title {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.calendar-nav-btn {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.calendar-nav-btn:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 8px 10px 4px;
  border-bottom: 1px solid var(--line);
}

.calendar-weekdays span {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  padding: 6px 8px 10px;
  background: var(--line);
}

.cal-day,
.cal-day.empty {
  background: var(--panel);
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 5px 2px 4px;
  min-height: 48px;
  gap: 2px;
}

.cal-day.empty {
  min-height: 48px;
}

.cal-day.today {
  background: var(--surface);
  border-radius: 6px;
}

.cal-day.today .cal-day-num {
  color: var(--accent);
  font-weight: 800;
}

.cal-day-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.cal-day-amount {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.cal-pos { color: var(--success); }
.cal-neg { color: var(--danger); }

/* ============================================================
   ESTADISTICA
   ============================================================ */

/* Nav bar (mes/año) */
.stats-nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

/* KPI grid */
.stats-kpis {
  margin-bottom: 16px;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stats-kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.stats-kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stats-kpi-val {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2px;
}
.stats-kpi-val.positive { color: var(--success); }
.stats-kpi-val.negative { color: var(--danger, #e05555); }

.stats-kpi-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Comparación vs mes anterior */
.stats-vs {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 5px;
  text-transform: none;
}
.stats-vs-up      { background: rgba(224,85,85,0.15); color: #e05555; }
.stats-vs-down    { background: rgba(60,180,100,0.15); color: var(--success); }
.stats-vs-neutral { background: var(--surface-2); color: var(--text-2); }

/* Category list */
.stats-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  padding: 20px;
}

.cat-item-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-bottom: 6px;
}

/* ============================================================
   BILLETERA
   ============================================================ */
.wallet-dashboard {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 10px;
}

.billetera-top {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 0;
}

.wallet-total {
  margin-bottom: 0;
}

.wallet-total-card {
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.wallet-total-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.wallet-hide-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-2);
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  border-radius: 6px;
}
.wallet-hide-btn:hover { opacity: 1; color: var(--accent); }
.wallet-hide-btn svg { width: 18px; height: 18px; }

.balance-mask {
  letter-spacing: 0.15em;
  font-style: normal;
}

.wallet-total-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.wallet-total-amount {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 6px;
}

.wallet-total-amount.positive { color: var(--success); }
.wallet-total-amount.negative { color: var(--danger); }
.wallet-total-amount.neutral { color: var(--accent); }

.wallet-total-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.acc-item.is-excluded {
  opacity: 0.45;
}

.acc-card.is-excluded {
  opacity: 0.45;
}

.acc-excluded-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--line);
  vertical-align: middle;
}

.excl-btn {
  font-size: 0.68rem;
  min-width: 42px;
  color: var(--text-muted);
  border-color: var(--line);
}

.excl-btn.is-excluded {
  color: var(--accent);
  border-color: var(--accent);
}

/* Botón colapsar cuentas — solo en desktop */
.acc-collapse-btn {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

/* Por defecto (expandido): flecha apunta arriba */
.acc-collapse-btn .wsec-arrow::before {
  transform: translateY(-50%) rotate(-45deg);
}
.acc-collapse-btn .wsec-arrow::after {
  transform: translateY(-50%) rotate(45deg);
}
/* Colapsado: flecha apunta abajo */
.gs-accounts-card.is-collapsed .acc-collapse-btn .wsec-arrow::before {
  transform: translateY(-50%) rotate(45deg);
}
.gs-accounts-card.is-collapsed .acc-collapse-btn .wsec-arrow::after {
  transform: translateY(-50%) rotate(-45deg);
}

.gs-accounts-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* legacy alias */
.wallet-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 0;
  min-width: 0;
}

/* ============================================================
   WALLET SECTIONS — acordeón
   ============================================================ */
.wallet-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0;
}

.wsec {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  overflow: hidden;
  transition: border-color var(--ease);
}

.wsec.is-open {
  border-color: var(--line-strong);
}

.wsec-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: background var(--ease);
}

.wsec-head:hover {
  background: var(--surface-soft);
}

.wsec-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wsec-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.wsec-title {
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.wsec-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.wsec-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
}

.wsec-arrow::before,
.wsec-arrow::after {
  content: "";
  position: absolute;
  top: 50%;
  background: var(--text-muted);
  border-radius: 2px;
  height: 2px;
  width: 6px;
  transition: transform var(--ease);
}

.wsec-arrow::before {
  left: 3px;
  transform: translateY(-50%) rotate(45deg);
}

.wsec-arrow::after {
  right: 3px;
  transform: translateY(-50%) rotate(-45deg);
}

.wsec.is-open .wsec-arrow::before {
  transform: translateY(-50%) rotate(-45deg);
}

.wsec.is-open .wsec-arrow::after {
  transform: translateY(-50%) rotate(45deg);
}

.wsec-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

.wsec-empty {
  padding: 20px 0;
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- wsec list items ---- */
.wsec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding-top: 8px;
}

.wsec-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

/* ---- wsec progress item ---- */
.wsec-item-prog {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 14px;
}

.wsec-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wsec-item-head .wsec-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wsec-item-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.wsec-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wsec-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* progress bar */
.wsec-bar-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.wsec-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s var(--ease-fn);
}

.bar-ok     { background: var(--success); }
.bar-warn   { background: #e8b020; }
.bar-danger { background: var(--danger); }
.bar-goal   { background: var(--info); }
.bar-debt   { background: var(--accent); }
.bar-fin    { background: var(--info); }
.bar-done   { background: var(--success); }

/* progress meta */
.wsec-prog-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  gap: 8px;
}

.wsec-prog-meta strong {
  color: var(--text-soft);
}

.prog-left { color: var(--text-muted); }
.prog-over { color: var(--danger); font-weight: 600; }
.prog-done { color: var(--success); font-weight: 600; }

/* ---- edit button ---- */
.wsec-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
  transition: color var(--ease), background var(--ease);
}

.wsec-edit-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---- inline edit item ---- */
.wsec-item-edit {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px;
  border-color: var(--accent);
}

.wsec-edit-actions {
  display: flex;
  gap: 8px;
}

.wsec-btn-ghost {
  flex: 1;
  padding: 8px;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease);
}

.wsec-btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.wsec-edit-actions .wsec-submit {
  flex: 2;
}

.wsec-pagos-row {
  margin-top: 6px;
}

.wsec-pagos-btn {
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

.wsec-pagos-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---- pagos summary bar ---- */
.pagos-summary-bar {
  padding: 14px 20px 12px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

.pagos-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pagos-summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pagos-summary-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pagos-summary-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

/* ---- currency tag on account items ---- */
.acc-currency-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--info);
  background: rgba(77, 132, 255, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
}

.acc-currency-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: 4px;
}

/* ---- "Saldar deuda" button ---- */
.wsec-pagar-btn {
  margin-top: 6px;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--success);
  border-radius: var(--radius-xs);
  color: var(--success);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.wsec-pagar-btn:hover {
  background: rgba(40, 183, 119, 0.12);
}

/* ---- Paid debts section ---- */
.wsec-pagadas-section {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.wsec-pagadas-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 4px;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
.wsec-pagadas-header:hover { background: var(--surface-2); color: var(--text-2); }

.wsec-pagadas-count {
  font-weight: 500;
  opacity: 0.7;
}

.wsec-pagadas-chevron {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform 0.15s;
}
.wsec-status-tag {
  font-size: 0.75rem;
  color: var(--success);
  background: rgba(40, 183, 119, 0.12);
  border-radius: 20px;
  padding: 2px 8px;
}
.wsec-item-done {
  opacity: 0.8;
}
.prog-done-tag {
  color: var(--success);
  font-size: 0.8rem;
}

/* ---- exchange rate field hint ---- */
.field-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  display: block;
  margin-top: 2px;
  line-height: 1.4;
}

.pagos-summary-due {
  margin-top: 6px;
  font-size: 0.76rem;
}

.pago-account-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Config modal ── */
/* ── Modal Configuración — lista de ajustes ── */

.cfg-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 4px;
}

.cfg-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.cfg-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.cfg-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cfg-subtabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 10px;
}

.cfg-subtab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.cfg-subtab.active {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface-2));
  border-color: var(--accent);
  color: var(--text);
}

.mp-classifier-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mp-classifier-rule {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.mp-classifier-rule:first-child {
  border-top: 0;
}

.mp-classifier-main {
  min-width: 0;
}

.mp-classifier-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-classifier-meta {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.mp-classifier-rule[data-status="conflicto"] .mp-classifier-title {
  color: var(--danger);
}

.mp-iframe-test {
  margin: 12px 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.mp-iframe-test iframe {
  display: block;
  width: 100%;
  height: min(70vh, 560px);
  border: 0;
  background: #fff;
}

.mp-sync-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0 14px;
}

.mp-sync-step {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.mp-sync-step[data-status="ok"] {
  color: var(--success);
}

.mp-sync-step[data-status="error"] {
  color: var(--danger);
}

.mp-sync-step[data-status="pending"] {
  color: var(--accent);
}

.mp-auto-eval {
  display: grid;
  gap: 8px;
}

.mp-auto-eval-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mp-auto-eval-row strong {
  color: var(--text);
  font-size: 0.8rem;
}

.mp-auto-eval-row[data-score="best"] strong {
  color: var(--success);
}

@media (max-width: 767px) {
  .mp-auto-eval-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .mp-classifier-rule {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.cfg-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 4px 6px;
}

.cfg-section-title:first-child {
  padding-top: 4px;
}

.cfg-card {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 0 16px;
  overflow: hidden;
}

.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
}

.cfg-row-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.cfg-row-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.cfg-row-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.cfg-divider {
  height: 1px;
  background: var(--line);
  margin: 0 -16px;
}

.cfg-select {
  min-width: 130px;
  max-width: 160px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.84rem;
  flex-shrink: 0;
  cursor: pointer;
}

.cfg-select-wide {
  width: 100%;
  max-width: none;
}

.cfg-select:disabled {
  opacity: 0.5;
}

.cfg-rate-input {
  width: 120px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  text-align: right;
  outline: none;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.cfg-rate-input:focus {
  border-color: var(--accent);
}

.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 0;
}

.cfg-text-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.cfg-text-input:focus {
  border-color: var(--accent);
}

.cfg-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
  resize: vertical;
  outline: none;
}

.cfg-textarea:focus {
  border-color: var(--accent);
}

.cfg-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0;
}

.cfg-status[data-status="ok"] {
  color: var(--success);
}

.cfg-status[data-status="error"] {
  color: var(--danger);
}

.cfg-status[data-status="pending"] {
  color: var(--accent);
}

.cfg-rate-input--disabled,
.cfg-rate-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cfg-action-btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.cfg-action-btn:hover {
  background: rgba(232, 112, 32, 0.1);
}

.cfg-action-btn[data-state="installed"],
.cfg-action-btn[data-state="unavailable"] {
  opacity: 0.45;
  border-color: var(--border);
  color: var(--text-muted);
  pointer-events: none;
}

@media (max-width: 520px) {
  .cfg-list {
    gap: 8px;
  }

  .cfg-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-height: 52px;
    padding: 8px 0 12px;
    overflow: visible;
  }

  .cfg-subtabs {
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
  }

  .cfg-tabs::-webkit-scrollbar,
  .cfg-subtabs::-webkit-scrollbar {
    display: none;
  }

  .cfg-tab {
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .cfg-subtab {
    flex: 0 0 auto;
  }

  .cfg-card {
    padding: 0 14px;
    border-radius: 12px;
  }

  .cfg-row {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 14px 0;
  }

  .cfg-row-label {
    width: 100%;
    min-width: 0;
  }

  .cfg-row-name {
    font-size: 0.88rem;
    line-height: 1.3;
  }

  .cfg-row-hint {
    font-size: 0.76rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .cfg-actions-row {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 8px;
    padding: 10px 0 14px;
  }

  .cfg-row > .cfg-actions-row {
    padding: 0;
  }

  .cfg-action-btn {
    flex: 1 1 140px;
    min-width: 0;
    height: auto;
    min-height: 38px;
    padding: 8px 12px;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
  }

  .cfg-select,
  .cfg-rate-input {
    width: 100%;
    max-width: none;
  }

  .cfg-divider {
    margin: 0 -14px;
  }

  .mp-sync-detail {
    padding: 8px 0 12px;
  }

  .mp-sync-step {
    font-size: 0.76rem;
    overflow-wrap: anywhere;
  }
}

.cfg-hint-inline {
  margin: -10px 0 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.4;
  min-height: 0;
}

.cfg-about {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.cfg-about-logo {
  height: 36px;
  display: block;
  flex-shrink: 0;
}

.cfg-about-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cfg-about-meta span:first-child {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
}

.cfg-about-meta span:last-child {
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* Theme toggle — mantiene estilos existentes */
.theme-segmented {
  display: flex;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  flex-shrink: 0;
}

.theme-seg-btn {
  flex: 1;
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  white-space: nowrap;
}

.theme-seg-btn + .theme-seg-btn {
  border-left: 1px solid var(--line-strong);
}

.theme-seg-btn.active {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 360px) {
  .pagos-summary-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.wsec-item-main {
  flex: 1;
  min-width: 0;
}

.wsec-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wsec-item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wsec-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wsec-item-amount {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.wsec-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
  transition: color var(--ease), background var(--ease);
}

.wsec-del:hover {
  color: var(--danger);
  background: rgba(217, 83, 79, 0.1);
}

/* ---- wsec form ---- */
.wsec-add-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.wsec-add-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.wsec-add-toggle.is-open {
  color: var(--text-muted);
  border-style: solid;
  border-color: var(--line);
}

.wsec-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

.wsec-form-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.wsec-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.wsec-form-grid .wsec-span2 {
  grid-column: 1 / -1;
}

.wsec-form-grid select,
.wsec-form-grid input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.84rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.wsec-form-grid select:focus,
.wsec-form-grid input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.wsec-computed {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.wsec-submit {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), opacity var(--ease);
}

.wsec-submit:hover {
  background: var(--accent-strong);
}

@media (max-width: 420px) {
  .wsec-form-grid {
    grid-template-columns: 1fr;
  }

  .wsec-form-grid .wsec-span2 {
    grid-column: 1;
  }
}

/* ============================================================
   ICONOS NAV — nuevas vistas
   ============================================================ */
.nav-tab[data-view="calendario"] .tab-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--line-strong);
  background:
    linear-gradient(var(--line-strong) 0 0) left top / 100% 4px no-repeat;
}

.nav-tab[data-view="estadistica"] .tab-icon {
  width: 18px;
  height: 18px;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-tab[data-view="estadistica"] .tab-icon svg {
  width: 18px;
  height: 18px;
  color: var(--line-strong);
}

.nav-tab[data-view="billetera"] .tab-icon {
  width: 18px;
  height: 13px;
  border-radius: 4px;
  border: 2px solid var(--line-strong);
}

.nav-tab.active[data-view="calendario"] .tab-icon {
  border-color: var(--accent);
  background:
    linear-gradient(var(--accent) 0 0) left top / 100% 4px no-repeat;
}

.nav-tab.active[data-view="estadistica"] .tab-icon svg {
  color: var(--accent);
}

.nav-tab.active[data-view="billetera"] .tab-icon {
  border-color: var(--accent);
}

/* Responsive calendario */
@media (min-width: 640px) {
  .cal-day {
    min-height: 62px;
    padding: 6px 4px 5px;
  }

  .cal-day-num {
    font-size: 0.84rem;
  }

  .cal-day-amount {
    font-size: 0.68rem;
  }

  .cal-sum-amount {
    font-size: clamp(0.8rem, 2vw, 1.05rem);
  }
}

@media (min-width: 1024px) {
  /* Billetera top: total + cuentas lado a lado, misma altura */
  .billetera-top {
    flex-direction: row;
    align-items: stretch;
    gap: 20px;
  }

  #wallet-total {
    flex: 0 0 340px;
  }

  .wallet-total-card {
    height: 100%;
    box-sizing: border-box;
  }

  /* Alineación: anular el margin-top que desplazaba el panel */
  .wallet-grid {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    margin-top: 0;
  }

  /* El panel de cuentas llena la altura del contenedor */
  .wallet-grid .res-section,
  .wallet-grid .gs-accounts-card {
    height: 100%;
    box-sizing: border-box;
  }

  /* Mostrar botón colapsar solo en desktop */
  .acc-collapse-btn {
    display: flex;
  }

  /* Panel colapsado: mantiene las cuentas visibles en formato compacto */
  .wallet-grid .gs-accounts-card.is-collapsed {
    height: auto;
    gap: 10px;
  }

  .gs-accounts-card.is-collapsed #accounts-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
  }

  .gs-accounts-card.is-collapsed #accounts-summary .acc-card {
    flex: 0 1 220px;
    width: auto;
    min-height: 84px;
    padding: 10px 12px;
    gap: 6px;
    align-items: flex-start;
    text-align: left;
    border-radius: 16px;
  }

  .gs-accounts-card.is-collapsed #accounts-summary .acc-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 16px;
  }

  .gs-accounts-card.is-collapsed #accounts-summary .acc-card-name {
    font-size: 0.82rem;
  }

  .gs-accounts-card.is-collapsed #accounts-summary .acc-card-bal {
    margin-top: 0;
    font-size: 0.94rem;
  }

  .gs-accounts-card.is-collapsed #accounts-summary .acc-card-converted {
    display: none;
  }

  /* Secciones en grilla 2 columnas */
  .wallet-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 10px;
    margin-top: 0;
  }

  .stats-panel {
    max-width: 700px;
  }

  .calendar-summary {
    max-width: 560px;
  }

  .cal-day {
    min-height: 68px;
  }
}

/* ============================================================
   CALCULADORA
   ============================================================ */

.modal-calculator {
  width: 340px;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
}

.calc-display {
  background: var(--surface-2);
  padding: 20px 24px 20px;
  text-align: right;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.calc-expr {
  font-size: 14px;
  color: var(--text-muted);
  min-height: 20px;
  margin-bottom: 4px;
}

.calc-result {
  font-size: 52px;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
  word-break: break-all;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
}

.calc-btn {
  border: none;
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-size: 22px;
  font-weight: 400;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.calc-btn:active {
  background: var(--surface-3);
}

.calc-accent {
  color: var(--accent, #e87020);
}

.calc-confirm {
  background: var(--accent, #e87020);
  color: #fff;
  font-size: 26px;
}

/* Toggle switch for config rows */
.cfg-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.cfg-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.cfg-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-4, #3a3a4e);
  border-radius: 13px;
  transition: background 0.2s;
  cursor: pointer;
}

.cfg-toggle-track::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.cfg-toggle input:checked + .cfg-toggle-track {
  background: var(--accent, #e87020);
}

.cfg-toggle input:checked + .cfg-toggle-track::after {
  transform: translateX(18px);
}

/* Full-screen calculator on small screens */
@media (max-width: 600px) {
  .modal-calculator {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .modal-calculator.open {
    display: flex;
    flex-direction: column;
  }

  .modal-category-picker {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .calc-display {
    flex: 1;
    padding: 32px 28px 20px;
    justify-content: flex-end;
  }

  .calc-result {
    font-size: 64px;
  }

  .calc-btn {
    height: 80px;
    font-size: 26px;
  }

  .calc-confirm {
    font-size: 30px;
  }
}

/* ============================================================
   CRYPTO (MODULO)
   ============================================================ */

/* Modal full-screen */
.modal-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Guard rail: los modales solo se muestran con `.open` */
.modal:not(.open) { display: none !important; }
.modal.open { display: flex !important; }

/* Crypto header */
.crypto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.crypto-header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* Tabs */
.crypto-tabs {
  display: flex;
  gap: 0;
  padding: 14px 20px 0;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.crypto-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.crypto-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Body scroll area */
.crypto-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty state */
.crypto-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* Notice banner */
.crypto-notice {
  background: rgba(232,112,32,0.1);
  border: 1px solid rgba(232,112,32,0.25);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--accent);
}

/* Summary row (Posiciones tab) */
.crypto-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.crypto-summary-card {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
}

.crypto-summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.crypto-summary-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Positions list */
.crypto-pos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crypto-pos-card {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 14px 16px;
}

.crypto-pos-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.crypto-pos-asset {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crypto-pos-symbol {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.crypto-pos-name {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.crypto-pos-right {
  text-align: right;
}

.crypto-pos-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.crypto-pos-pnl {
  font-size: 0.8rem;
  margin-top: 2px;
}

.crypto-pos-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.crypto-pos-account {
  margin-left: auto;
  font-style: italic;
}

/* Form elements (Operar + Cuentas tabs) */
.crypto-form-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crypto-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.crypto-input-full,
.crypto-select-full {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.crypto-input-full:focus,
.crypto-select-full:focus {
  border-color: var(--accent);
}

.crypto-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.crypto-search-row {
  display: flex;
  gap: 8px;
}

.crypto-search-row .crypto-input-full {
  flex: 1;
}

.crypto-search-btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.crypto-asset-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(232,112,32,0.1);
  border: 1px solid rgba(232,112,32,0.3);
  border-radius: 12px;
}

.crypto-asset-sym {
  font-weight: 800;
  color: var(--accent);
}

.crypto-asset-nm {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.crypto-calc-tip {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.crypto-submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.crypto-submit-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.crypto-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Accounts list (Cuentas tab) */
.crypto-acc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crypto-acc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 12px;
}

.crypto-acc-name {
  font-weight: 500;
  color: var(--text);
}

.crypto-acc-currency {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.crypto-new-acc-row {
  display: flex;
  gap: 8px;
}

.crypto-new-acc-row .crypto-select-full {
  flex: 1;
}

.crypto-new-acc-row .crypto-submit-btn {
  width: auto;
  padding: 12px 18px;
  white-space: nowrap;
}

/* Search results */
.crypto-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.crypto-search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crypto-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: border-color 0.15s;
}

.crypto-search-item:hover {
  border-color: var(--line-strong);
}

.csi-symbol {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  min-width: 44px;
}

.csi-name {
  flex: 1;
  font-size: 0.83rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csi-rank {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.csi-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.csi-btn:hover {
  filter: brightness(1.1);
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  animation: fadeIn 140ms ease;
}

.confirm-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2001;
  background: var(--surface-2);
  border-radius: 18px;
  padding: 24px 24px 18px;
  width: min(360px, 90vw);
  box-shadow: var(--shadow-lg);
  animation: modalIn 160ms var(--ease-fn) both;
}

.confirm-dialog-msg {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 20px;
  word-break: break-word;
  text-align: center;
}

.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-btn-cancel {
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.confirm-btn-cancel:hover {
  background: var(--surface-3);
}

.confirm-btn-ok {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: #c0392b;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.confirm-btn-ok:hover {
  filter: brightness(1.15);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ============================================================
   FLUJO — Cash Flow
   ============================================================ */
.flujo-pos { color: var(--success); }
.flujo-neg { color: var(--danger); }

/* KPI grid */
.flujo-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.flujo-kpi {
  background: var(--card-alt, rgba(255,255,255,0.04));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.flujo-kpi-net {
  grid-column: 1 / -1;
}
.flujo-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.flujo-kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flujo-kpi-val {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}
.flujo-kpi-net .flujo-kpi-val {
  font-size: 1.6rem;
}
.flujo-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Selector */
.flujo-sel {
  font-size: 0.72rem;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  cursor: pointer;
}

/* Obligaciones detail */
.flujo-oblig-list {
  background: var(--card-alt, rgba(255,255,255,0.03));
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}
.flujo-oblig-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.flujo-oblig-row:last-child { border-bottom: none; }
.flujo-oblig-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flujo-oblig-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.flujo-oblig-amount {
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
}

/* Table bar */
.flujo-table-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.flujo-table-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Projection table */
.flujo-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.flujo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}
.flujo-table thead tr {
  background: var(--card-alt, rgba(255,255,255,0.04));
}
.flujo-table th {
  padding: 9px 12px;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
}
.flujo-table th:first-child { text-align: left; }
.flujo-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.flujo-table tr:last-child td { border-bottom: none; }
.flujo-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
}
.flujo-td-acum {
  font-weight: 700;
}
