:root {
  --bg-header: rgba(33, 71, 116, 0.94);
  --bg-footer: #214774;
  --bg-main: linear-gradient(90deg, #000000 0%, #120e4e 44%, #25238e 74%, #3a36d1 100%);
  --panel: rgba(7, 12, 38, 0.72);
  --panel-border: rgba(255, 160, 175, 0.58);
  --text-main: #eef3ff;
  --text-soft: #c8d3f1;
  --text-muted: #a5b3d9;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --card-income: #7dd351;
  --card-expense: #ff5757;
  --card-balance: #07c25f;
  --card-saving: #24b7d4;
  --button: #ff8fa3;
  --button-hover: #ff7b92;
  --input-bg: rgba(255, 255, 255, 0.08);
  --surface: rgba(16, 23, 62, 0.55);
  --border-soft: rgba(255, 255, 255, 0.12);
  --danger: #ff7a8e;
  --success: #6ce2a0;
  --warning: #ffd877;
  --overlay: rgba(5, 8, 20, 0.68);
  --table-head: rgba(33, 71, 116, 0.78);
  --icon: currentColor;
  --header-height: 104px;
}

:root[data-theme="light"] {
  --bg-header: rgba(220, 232, 247, 0.92);
  --bg-footer: #dce8f7;
  --bg-main: linear-gradient(90deg, #eef5ff 0%, #e6ecff 52%, #dfe5ff 100%);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(230, 143, 165, 0.62);
  --text-main: #193155;
  --text-soft: #375076;
  --text-muted: #58759e;
  --shadow: 0 18px 35px rgba(42, 70, 120, 0.12);
  --input-bg: rgba(42, 70, 120, 0.05);
  --surface: rgba(255, 255, 255, 0.88);
  --border-soft: rgba(42, 70, 120, 0.12);
  --overlay: rgba(30, 45, 82, 0.28);
  --table-head: rgba(33, 71, 116, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  background: #0f1630;
  color: var(--text-main);
}
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.screen { display: none; min-height: 100vh; }
.screen--active { display: block; }
textarea { resize: vertical; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(76, 212, 255, 0.18), transparent 25%),
    radial-gradient(circle at bottom right, rgba(255, 143, 163, 0.18), transparent 24%),
    linear-gradient(135deg, #101631 0%, #161b5f 50%, #2228a0 100%);
}

.login-card,
.filters-panel,
.table-card,
.modal-card {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  border-radius: 26px;
}

.login-brand, .brand, .filters-title, .header-actions, .profile-box {
  display: flex;
  align-items: center;
}

.login-brand { gap: 16px; margin-bottom: 28px; }
.login-brand h1, .brand-copy h2 { margin: 0; font-size: clamp(1.55rem, 2vw, 1.9rem); }
.login-brand p, .brand-copy p, .filters-title p, .table-toolbar p, .modal-head p, .modal-note, .login-help, .form-message, .stat-mini, .profile-label, .exchange-note, .row-meta {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}
.login-logo, .brand-logo, .profile-image {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px rgba(76, 212, 255, 0.16);
}
.profile-image { width: 48px; height: 48px; }

.login-form, .filters-form, .record-form { display: grid; gap: 16px; }
.login-form label, .filters-form label, .record-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: var(--text-soft);
  font-size: 0.94rem;
}

input, select, textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 13px 14px;
  outline: none;
  transition: border-color .25s ease, transform .2s ease, background .25s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { border-color: rgba(76,212,255,.7); transform: translateY(-1px); }

.primary-button, .secondary-button, .icon-button, .fab, .filters-fab, .header-icon-button, .profile-image-button, .logout-button {
  transition: transform .2s ease, box-shadow .25s ease, background .25s ease;
}
.primary-button {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--button);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(255, 143, 163, 0.22);
}
.primary-button:hover { background: var(--button-hover); transform: translateY(-1px); }
.secondary-button, .header-icon-button, .logout-button, .profile-image-button, .icon-button {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}
.secondary-button:hover, .icon-button:hover, .filters-fab:hover, .header-icon-button:hover, .logout-button:hover, .profile-image-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.16);
}
.icon-button--small { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
.form-message { min-height: 18px; }
.form-message--error { color: var(--danger); }
.form-message--success { color: var(--success); }
.login-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.app-header, .app-footer {
  background: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(18px, 3vw, 36px);
}
.app-header {
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { gap: 14px; }
.header-actions { gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.profile-box {
  gap: 12px;
  padding: 8px 10px 8px 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.profile-image-button {
  padding: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
}
.profile-copy { display: grid; gap: 2px; min-width: 120px; }
.profile-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
#profileName { font-size: .96rem; line-height: 1.1; }
.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  padding-inline: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  color: var(--text-main);
  border: 1px solid rgba(255,255,255,.16);
}
.toggle-track {
  position: relative;
  width: 62px;
  height: 30px;
  border-radius: 999px;
  background: rgba(5,8,20,.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.toggle-thumb {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .26s ease;
  box-shadow: 0 5px 14px rgba(0,0,0,.18);
}
:root[data-theme="light"] .toggle-thumb { transform: translateX(32px); }
.toggle-icon, .filters-icon, .stat-icon, .header-icon-button, .logout-button svg, .filters-fab svg { display: grid; place-items: center; }
.toggle-icon svg, .filters-icon svg, .icon-button svg, .actions svg, .filters-fab svg, .header-icon-button svg, .logout-button svg, .stat-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--icon);
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.header-icon-button { width: 48px; height: 48px; padding: 0; border-radius: 14px; }
.header-icon-button svg { width: 20px; height: 20px; }
.logout-button svg, .icon-button svg { width: 18px; height: 18px; }

.dashboard-shell {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - var(--header-height));
  padding: 20px;
  background: var(--bg-main);
}
.filters-panel {
  border-radius: 28px;
  padding: 22px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-height) + 20px);
}
.filters-head { margin-bottom: 20px; }
.filters-title { gap: 14px; }
.filters-title h3, .table-toolbar h3, .modal-head h3 { margin: 0; font-size: 1.15rem; }
.filters-icon, .stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--text-main);
  background: rgba(255,255,255,.08);
}
.filters-actions, .actions, .modal-actions, .toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.content-panel { display: grid; gap: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  min-height: 168px;
  border-radius: 28px;
  padding: 18px;
  display: grid;
  gap: 18px;
  color: #0f1837;
  box-shadow: 0 16px 26px rgba(0,0,0,.16);
}
.stat-card--income { background: var(--card-income); }
.stat-card--expense { background: var(--card-expense); }
.stat-card--balance { background: var(--card-balance); }
.stat-card--saving { background: var(--card-saving); }
.stat-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.stat-label { font-weight: 800; font-size: 1rem; display: block; }
.stat-mini { color: rgba(15,24,55,.75); font-size: .8rem; }
.stat-icon { flex: 0 0 auto; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-currencies { display: grid; gap: 10px; }
.currency-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(15,24,55,.18);
}
.currency-line--stacked { display: grid; gap: 8px; }
.currency-line-main { display: flex; justify-content: space-between; gap: 12px; }
.currency-label { font-size: .82rem; font-weight: 800; letter-spacing: .08em; }
.stat-value { font-size: 1.24rem; font-weight: 800; }
.stat-value--secondary { font-size: 1.14rem; }
.exchange-note { color: rgba(15,24,55,.8); font-size: .8rem; }

.table-card {
  border-radius: 28px;
  padding: 20px;
}
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.table-wrap { overflow: auto; }
.records-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}
.records-table th,
.records-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.records-table thead th {
  position: sticky;
  top: 0;
  background: var(--table-head);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.records-table tbody tr:hover { background: rgba(255,255,255,.03); }
.empty-state { text-align: center; color: var(--text-soft); padding: 32px 14px; }
.accounts-flow { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.accounts-flow span { opacity: .7; }

.sub-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.sub-tag--ingreso { background: rgba(125, 211, 81, .18); color: #234912; }
.sub-tag--egreso { background: rgba(255, 87, 87, .18); color: #6d1010; }
.sub-tag--transferencia { background: rgba(76, 212, 255, .18); color: #0f4050; }
.sub-tag--ajuste { background: rgba(255, 216, 119, .22); color: #5a3f00; }

.filters-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--button);
  color: #fff;
  box-shadow: 0 12px 24px rgba(0,0,0,.22);
  z-index: 60;
}
.filters-fab svg { width: 24px; height: 24px; stroke: currentColor; }

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 70;
}
.modal-card {
  width: min(100%, 860px);
  border-radius: 28px;
  padding: 22px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.form-grid { display: grid; gap: 16px; }
.form-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

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

@media (max-width: 1080px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .filters-panel {
    position: fixed;
    inset: calc(var(--header-height) + 10px) 14px auto 14px;
    top: calc(var(--header-height) + 10px);
    z-index: 55;
    transform: translateY(-140%);
    transition: transform .25s ease;
  }
  body.filters-open .filters-panel { transform: translateY(0); }
  .filters-fab { display: grid; }
}

@media (max-width: 840px) {
  .app-header { align-items: flex-start; flex-direction: column; gap: 16px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .stats-grid, .form-grid--two, .form-grid--three { grid-template-columns: 1fr; }
  .profile-copy { min-width: 0; }
}

@media (max-width: 560px) {
  .login-card, .table-card, .modal-card, .filters-panel { padding: 18px; border-radius: 22px; }
  .profile-box { width: 100%; justify-content: space-between; }
  .logout-button span { display: none; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1 1 auto; }
}
