/* ============================================================
   OmniPost Finance — Tema negro y plateado
   ============================================================ */

:root {
  --bg: #05060a;
  --bg-soft: #080a0f;
  --surface: #0c0e14;
  --surface-2: #11141b;
  --surface-3: #171b23;

  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.16);
  --line-glow: rgba(214, 222, 232, 0.28);

  --text: #e9edf3;
  --text-dim: #b6bdc8;
  --muted: #838b98;
  --muted-2: #656d79;

  --silver: linear-gradient(135deg, #ffffff 0%, #a7b0bb 38%, #eef2f7 62%, #7c8592 100%);
  --silver-soft: linear-gradient(135deg, #dfe4ea 0%, #9aa3ae 60%, #cfd6df 100%);
  --metal-line: linear-gradient(90deg, transparent, rgba(233, 237, 243, 0.45), transparent);

  --pos: #8fe3bf;
  --neg: #f09292;
  --warn: #e8c274;
  --info: #9dbbdd;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.4);

  --sidebar-w: 250px;
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(150, 162, 178, 0.14), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(120, 132, 148, 0.1), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}

body.is-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

::selection { background: rgba(216, 224, 234, 0.28); }

/* ===================== Estructura ===================== */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

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

/* ===================== Sidebar ===================== */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  background: linear-gradient(180deg, rgba(20, 23, 30, 0.94), rgba(7, 8, 12, 0.97));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.brand::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  height: 1px;
  background: var(--metal-line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, #23262e, #0a0b0f);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), var(--shadow-sm);
  flex: none;
}

.brand-mark svg { width: 22px; height: 22px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }

.brand-text strong {
  font-size: 16px;
  letter-spacing: 0.01em;
  background: var(--silver);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text small {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.16s, background 0.16s, border-color 0.16s;
}

.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.045); }

.nav-item.is-active {
  color: #0a0b0f;
  background: var(--silver-soft);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 16px rgba(0, 0, 0, 0.45);
  font-weight: 650;
}

.nav-item .i { width: 18px; height: 18px; flex: none; }

.sidebar-foot { padding-top: 4px; }

.net-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
}

.net-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-2); }
.net-value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.net-sub { font-size: 11.5px; color: var(--muted-2); }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 35;
}

.backdrop[hidden] { display: none; }

[hidden] { display: none !important; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 26px;
  background: linear-gradient(180deg, rgba(8, 9, 13, 0.94), rgba(8, 9, 13, 0.7));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.page-head { flex: 1; min-width: 0; }
.page-head h1 { font-size: 21px; }
.page-head p { font-size: 13px; color: var(--muted); }

.period {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  flex: none;
}

.period-label {
  min-width: 138px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.period-label:hover { background: rgba(255, 255, 255, 0.07); }

.period-label.is-current {
  background: var(--silver-soft);
  color: #0a0b0f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.view { padding: 24px 26px 8px; flex: 1; min-width: 0; }
.view:focus { outline: none; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 26px 26px;
  font-size: 12px;
  color: var(--muted-2);
  flex-wrap: wrap;
}

/* ===================== Botones ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, opacity 0.15s;
}

.btn:hover { border-color: var(--line-glow); background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }

.btn--primary {
  background: var(--silver);
  color: #08090d;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 20px rgba(0, 0, 0, 0.45);
}

.btn--primary:hover { filter: brightness(1.07); background: var(--silver); }

.btn--danger {
  background: linear-gradient(165deg, rgba(240, 146, 146, 0.22), rgba(240, 146, 146, 0.08));
  border-color: rgba(240, 146, 146, 0.45);
  color: #ffd9d9;
}

.btn--danger:hover { background: rgba(240, 146, 146, 0.28); }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.btn--sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex: none;
}

.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); border-color: var(--line-strong); }
.icon-btn .i { width: 17px; height: 17px; }
.icon-btn--sm { width: 29px; height: 29px; border-radius: 8px; }
.icon-btn--sm .i { width: 15px; height: 15px; }
.icon-btn--danger:hover { color: #ffcfcf; border-color: rgba(240, 146, 146, 0.5); background: rgba(240, 146, 146, 0.14); }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dashed var(--line-strong);
}

.link-btn:hover { color: #fff; border-color: var(--line-glow); }

.only-mobile { display: none; }

/* ===================== Tarjetas y paneles ===================== */

.stack { display: flex; flex-direction: column; gap: 18px; }

.card {
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(158deg, rgba(28, 32, 40, 0.85), rgba(10, 12, 16, 0.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--metal-line);
  opacity: 0.7;
}

/* Evita que la cabecera fija tape el contenido al desplazarse a un elemento */
.card, .budget-item, .goal-item, .quick-bar { scroll-margin-top: 96px; }

.grid { display: grid; gap: 18px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-head h2 { font-size: 15.5px; }
.panel-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 16px 20px 20px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.pill .i { width: 14px; height: 14px; }
.pill--good { color: var(--pos); border-color: rgba(143, 227, 191, 0.35); }
.pill--warn { color: var(--warn); border-color: rgba(232, 194, 116, 0.35); }
.pill--bad { color: var(--neg); border-color: rgba(240, 146, 146, 0.35); }

/* ===================== KPI ===================== */

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.kpi header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.kpi-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.kpi-icon .i { width: 15px; height: 15px; }

.kpi-value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: var(--silver);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.kpi footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-sub { font-size: 12px; color: var(--muted-2); }

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.kpi-trend.is-good { color: var(--pos); background: rgba(143, 227, 191, 0.12); }
.kpi-trend.is-bad { color: var(--neg); background: rgba(240, 146, 146, 0.12); }

.tri { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; flex: none; }
.tri--up { border-bottom: 6px solid currentColor; }
.tri--down { border-top: 6px solid currentColor; }

.kpi--income::after,
.kpi--expense::after,
.kpi--good::after,
.kpi--bad::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
}

.kpi--income::after { background: linear-gradient(180deg, #ffffff, #9aa3ae); }
.kpi--expense::after { background: linear-gradient(180deg, #6d7681, #3a3f47); }
.kpi--good::after { background: linear-gradient(180deg, var(--pos), rgba(143, 227, 191, 0.2)); }
.kpi--bad::after { background: linear-gradient(180deg, var(--neg), rgba(240, 146, 146, 0.2)); }

/* ===================== Barra rápida ===================== */

.quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.quick-info { display: flex; flex-direction: column; }
.quick-month { font-size: 16px; font-weight: 650; }
.quick-count { font-size: 12px; color: var(--muted); }
.quick-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ===================== Alertas ===================== */

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

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.alert .i { width: 16px; height: 16px; flex: none; }
.alert--warn { border-color: rgba(232, 194, 116, 0.32); color: #f2dfb4; background: rgba(232, 194, 116, 0.08); }
.alert--error { border-color: rgba(240, 146, 146, 0.32); color: #f8cfcf; background: rgba(240, 146, 146, 0.08); }

.note {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
}

.note .i { width: 15px; height: 15px; }
.note-plain { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ===================== Tablas ===================== */

.table-wrap { overflow-x: auto; margin: 0 -4px; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }

.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-2);
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table tbody td { padding: 11px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.13s; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.035); }

.ta-right { text-align: right; }
.ta-center { text-align: center; }

.cell-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-main strong { font-weight: 600; font-size: 13.5px; }
.cell-main small { font-size: 11.5px; color: var(--muted-2); }

.row-actions { white-space: nowrap; }
.row-actions .icon-btn { margin-left: 4px; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-pos { color: var(--pos); }
.is-neg { color: var(--neg); }

.table-empty { text-align: center; padding: 26px 10px; color: var(--muted-2); font-size: 13px; }

.table-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.table-total strong { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
}

.tag--silver { background: var(--silver-soft); color: #0a0b0f; border-color: rgba(255, 255, 255, 0.5); }
.tag--dark { background: rgba(255, 255, 255, 0.035); color: var(--muted); }
.tag--good { color: var(--pos); border-color: rgba(143, 227, 191, 0.35); background: rgba(143, 227, 191, 0.1); }
.tag--warn { color: var(--warn); border-color: rgba(232, 194, 116, 0.35); background: rgba(232, 194, 116, 0.1); }
.tag--bad { color: var(--neg); border-color: rgba(240, 146, 146, 0.35); background: rgba(240, 146, 146, 0.1); }
.tag--blue { color: var(--info); border-color: rgba(157, 187, 221, 0.35); background: rgba(157, 187, 221, 0.1); }

/* ===================== Toolbar y filtros ===================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar-spacer { flex: 1; min-width: 0; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 190px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.search .i { width: 16px; height: 16px; flex: none; }

.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}

.search input::placeholder { color: var(--muted-2); }
.search:focus-within { border-color: var(--line-glow); background: rgba(255, 255, 255, 0.06); }

.select-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }

/* ===================== Formularios ===================== */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field > label em { color: var(--neg); font-style: normal; }
.field--actions { flex-direction: row; justify-content: flex-end; }

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--line-glow);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(214, 222, 232, 0.09);
}

.input--sm { padding: 7px 9px; font-size: 12.5px; border-radius: 9px; width: auto; }

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

select.input option { background: #10131a; color: var(--text); }

textarea.input { resize: vertical; }

input[type='date'].input { color-scheme: dark; }

.input-money { position: relative; display: flex; align-items: center; }
.input-money > span { position: absolute; left: 12px; color: var(--muted); font-size: 13px; pointer-events: none; }
.input-money .input { padding-left: 28px; font-variant-numeric: tabular-nums; }

.field--check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  flex-wrap: wrap;
}

.field--check input { width: 17px; height: 17px; accent-color: #d8dee7; flex: none; }
.field--check span { font-size: 13px; color: var(--text-dim); }
.hint { font-size: 11.5px; color: var(--muted-2); }
.field--check .hint { flex-basis: 100%; }

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #f8cfcf;
  background: rgba(240, 146, 146, 0.1);
  border: 1px solid rgba(240, 146, 146, 0.32);
}

.calc-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line-strong);
}

.calc-strip span { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }

.calc-strip strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  background: var(--silver);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ===================== Modal ===================== */

.modal-root { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal-root[hidden] { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(2, 3, 5, 0.72); backdrop-filter: blur(4px); }

.modal {
  position: relative;
  width: min(100%, 480px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(165deg, #1b1f27, #0a0c11);
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.7);
  animation: pop 0.18s ease-out;
}

.modal--wide { width: min(100%, 660px); }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { font-size: 17px; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
}

.confirm-text { font-size: 14px; color: var(--text-dim); line-height: 1.55; }

/* ===================== Toasts ===================== */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
  background: linear-gradient(160deg, #212630, #0c0e13);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.24s, transform 0.24s;
  max-width: 340px;
}

.toast.is-in { opacity: 1; transform: none; }
.toast .i { width: 16px; height: 16px; flex: none; }
.toast--ok .i { color: var(--pos); }
.toast--warn .i { color: var(--warn); }
.toast--error .i { color: var(--neg); }

/* ===================== Gráficas ===================== */

.chart-box { display: flex; flex-direction: column; gap: 10px; }
.chart { width: 100%; height: auto; display: block; }

.chart .chart-grid { stroke: rgba(255, 255, 255, 0.065); stroke-width: 1; }
.chart .axis { fill: var(--muted-2); font-size: 11px; font-family: var(--font); }
.chart .bar-income { fill: #e4e9ef; }
.chart .bar-expense { fill: #5f6873; }
.chart .bar-income:hover { fill: #ffffff; }
.chart .bar-expense:hover { fill: #7b848f; }
.chart .line-balance { fill: none; stroke: #8fe3bf; stroke-width: 2; stroke-linejoin: round; opacity: 0.9; }
.chart .dot-balance { fill: #8fe3bf; stroke: #0a0c11; stroke-width: 1.4; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 7px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.sw--income { background: #e4e9ef; }
.sw--expense { background: #5f6873; }
.sw--balance { background: #8fe3bf; }

.donut-box { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { position: relative; width: 180px; max-width: 100%; }
.donut svg { width: 100%; height: auto; display: block; }
.donut-seg { transition: opacity 0.15s; }
.donut-seg:hover { opacity: 0.82; }

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2px;
  pointer-events: none;
}

.donut-center span { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-2); }
.donut-center strong { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

.legend--list { flex-direction: column; gap: 8px; width: 100%; }

.legend--list li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  gap: 9px;
  align-items: center;
  font-size: 12.5px;
}

.lg-label { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-value { color: var(--text); font-variant-numeric: tabular-nums; }
.lg-share { color: var(--muted-2); font-size: 11.5px; min-width: 42px; text-align: right; }

.spark { width: 100%; height: auto; display: block; }
.spark-line { fill: none; stroke: #dfe5ec; stroke-width: 1.8; }
.spark-area { fill: rgba(223, 229, 236, 0.1); stroke: none; }

.hbars { display: flex; flex-direction: column; gap: 13px; }
.hbars-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.hbars-top strong { font-variant-numeric: tabular-nums; }
.hbars li small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted-2); }

.hbars-track {
  margin-top: 6px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.hbars-track span { display: block; height: 100%; border-radius: 999px; transition: width 0.4s ease; }

/* ===================== Barras de progreso ===================== */

.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bar span { display: block; height: 100%; border-radius: 999px; transition: width 0.45s ease; }
.bar--ok span { background: linear-gradient(90deg, #cfd6df, #ffffff); }
.bar--warn span { background: linear-gradient(90deg, #d9b877, #f0d79b); }
.bar--over span { background: linear-gradient(90deg, #c97b7b, #f0a1a1); }

/* ===================== Presupuestos y metas ===================== */

.budget-mini { display: flex; flex-direction: column; gap: 15px; }
.bm-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 6px; }
.bm-top strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.bm-top strong small { color: var(--muted-2); font-weight: 500; }
.bm-foot { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted-2); }

.budget-list, .goal-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 14px; }

.budget-item, .goal-item {
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-item--warn { border-color: rgba(232, 194, 116, 0.3); }
.budget-item--over { border-color: rgba(240, 146, 146, 0.34); }
.goal-item--done { border-color: rgba(143, 227, 191, 0.32); }

.bi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.bi-head h3 { font-size: 14.5px; }
.bi-head small { font-size: 11.5px; color: var(--muted-2); }
.bi-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.bi-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 10px; }
.bi-numbers span { display: flex; flex-direction: column; gap: 1px; }
.bi-numbers small { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); }
.bi-numbers strong { font-size: 13.5px; font-variant-numeric: tabular-nums; }

.split-block { display: flex; flex-direction: column; gap: 8px; }
.split-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.split-row strong { font-variant-numeric: tabular-nums; }

.split-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  flex-wrap: wrap;
}

.split-foot strong { font-variant-numeric: tabular-nums; }

/* ===================== Tendencia ===================== */

.trend-list { display: flex; flex-direction: column; gap: 14px; }
.trend-list--tight { margin-top: 16px; gap: 10px; }
.mini-list { display: flex; flex-direction: column; gap: 2px; }

.mini-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}

.mini-row:hover { background: rgba(255, 255, 255, 0.055); color: var(--text); }
.mini-row--static { cursor: default; }
.mini-row--static:hover { background: none; }
.mini-row strong { font-variant-numeric: tabular-nums; }

/* ===================== Estado vacío ===================== */

.empty { text-align: center; padding: 46px 20px 34px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(160deg, #23262e, #0b0d11);
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.empty-icon .i { width: 24px; height: 24px; }
.empty h3 { font-size: 18px; }
.empty p { font-size: 13.5px; color: var(--muted); max-width: 460px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===================== Acerca de ===================== */

.about-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }

.about-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font-size: 13px;
}

.about-list span { color: var(--muted); }

/* ===================== Responsive ===================== */

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

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

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

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

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 264px;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open { transform: none; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 13px 16px; gap: 12px; flex-wrap: wrap; }
  .page-head h1 { font-size: 18px; }
  .period { order: 3; width: 100%; justify-content: space-between; }
  .period-label { flex: 1; }
  .view { padding: 18px 16px 4px; }
  .foot { padding: 16px; }
  .donut-box { flex-direction: column; }
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .hide-md { display: none; }
  .kpi-value { font-size: 22px; }
  .budget-list, .goal-list { grid-template-columns: minmax(0, 1fr); }
  .toasts { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
}

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .table { min-width: 0; }
  .quick-actions { width: 100%; }
  .quick-actions .btn { flex: 1; }
  .panel-head { padding: 14px 15px 11px; }
  .panel-body { padding: 14px 15px 17px; }
  .modal-root { padding: 12px; }
}

@media (min-width: 981px) {
  .donut-box { align-items: stretch; }
  .donut { align-self: center; width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }


/* ============================================================
   Sesión: tarjeta de cuenta y pantallas de acceso
   ============================================================ */

.account { margin-top: 10px; }

.account-cta {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.account-cta:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--line-glow); color: var(--text); }
.account-cta .i { width: 19px; height: 19px; flex: none; }
.account-cta span { display: flex; flex-direction: column; min-width: 0; }
.account-cta strong { font-size: 13px; font-weight: 650; }
.account-cta small { font-size: 11px; color: var(--muted-2); }

.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015));
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: var(--silver-soft);
  color: #0a0b0f;
  font-weight: 700;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.account-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-info strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sync { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted-2); }
.sync .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); flex: none; }
.sync--idle .dot, .sync--saved .dot { background: var(--pos); }
.sync--saving .dot, .sync--loading .dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.sync--error { color: var(--neg); }
.sync--error .dot { background: var(--neg); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.account-actions { display: flex; gap: 4px; flex: none; }

/* ===================== Pantalla de acceso ===================== */

.auth-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-root[hidden] { display: none; }

.auth-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 5, 0.82);
  backdrop-filter: blur(6px);
}

.auth-card {
  position: relative;
  width: min(100%, 430px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 20px;
  background: linear-gradient(168deg, #1c2029, #08090d);
  border: 1px solid var(--line-strong);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.75);
  animation: pop 0.2s ease-out;
}

.auth-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.auth-head > div { flex: 1; min-width: 0; }

.auth-head h2 {
  font-size: 18px;
  background: var(--silver);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.auth-body { padding: 18px 22px 8px; }
.auth-body .field { margin-bottom: 13px; }

.auth-foot {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 22px 20px;
  flex-wrap: wrap;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.auth-tabs button {
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tabs button:hover { color: var(--text); }

.auth-tabs button.is-active {
  background: var(--silver-soft);
  color: #0a0b0f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

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

.btn--google {
  width: 100%;
  background: #ffffff;
  color: #1f2328;
  border-color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.btn--google:hover { background: #f1f3f6; }

.auth-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  font-size: 11.5px;
  color: var(--muted-2);
}

.auth-sep::before, .auth-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}

.auth-links { display: flex; justify-content: center; padding: 14px 0 4px; }
.auth-links .link-btn { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.auth-links .link-btn:hover { color: var(--text); }

.auth-message { font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }

.auth-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #cdeade;
  background: rgba(143, 227, 191, 0.1);
  border: 1px solid rgba(143, 227, 191, 0.3);
}

.auth-notice .i { width: 15px; height: 15px; flex: none; }
.auth-body .form-error { margin-top: 0; margin-bottom: 13px; }

@media (max-width: 560px) {
  .auth-root { padding: 12px; }
  .auth-head { padding: 18px 16px 14px; }
  .auth-body { padding: 16px 16px 6px; }
  .auth-foot { padding: 6px 16px 16px; }
}


/* ============================================================
   Publicidad
   ============================================================ */

/* Sin anuncio no ocupa nada: el atributo hidden manda y no se reserva
   espacio, así que no hay salto de maquetación al cargar o al fallar. */
.ad-slot {
  display: block;
  margin: 4px 26px 0;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  overflow: hidden;
}

.ad-slot[hidden] { display: none; }

.ad-slot.is-filled {
  padding: 10px 12px 12px;
  border-color: var(--line);
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
}

.ad-label {
  display: none;
  margin-bottom: 7px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ad-slot.is-filled .ad-label { display: block; }

.ad-slot ins { display: block; width: 100%; }

.foot-links { display: inline-flex; align-items: center; gap: 14px; }
.foot-links a { color: var(--muted); border-bottom: 1px solid transparent; }
.foot-links a:hover { color: var(--text); border-color: var(--line-strong); }

@media (max-width: 900px) {
  .ad-slot { margin: 4px 16px 0; }
}

/* ============================================================
   Página de privacidad
   ============================================================ */

.doc {
  max-width: 780px;
  margin: 0 auto;
  padding: 46px 22px 70px;
}

.doc-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 20px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.doc h1 {
  font-size: 26px;
  background: var(--silver);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.doc-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.doc h2 { font-size: 17px; margin: 30px 0 10px; }
.doc p, .doc li { font-size: 14.5px; color: var(--text-dim); line-height: 1.65; }
.doc p { margin-bottom: 12px; }
.doc ul { margin: 0 0 14px; padding-left: 20px; list-style: disc; }
.doc li { margin-bottom: 7px; }
.doc a { color: #cfd6df; border-bottom: 1px solid var(--line-strong); }
.doc a:hover { color: #fff; }
.doc code { font-size: 13px; padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.07); }

.doc-note {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(232, 194, 116, 0.07);
  color: #f0e2c2;
  font-size: 13.5px;
  margin-bottom: 20px;
}

.doc-back { display: inline-flex; align-items: center; gap: 8px; margin-top: 34px; }
