/* ══════════════════════════════════════════════════════════
   Gastos — Design System (handoff v2026.04)
   Outfit · dark default · indigo accent · Chart.js-compatible
   ══════════════════════════════════════════════════════════ */

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

html[data-dark] {
  --bg: #0c0c18;
  --surface: #14142a;
  --surf2: #1c1c38;
  --border: #26264a;
  --text: #e8e8f5;
  --muted: #8888aa;
  --muted2: #55557a;
  --accent: #818cf8;
  --accent-text: #a5b4fc;
  --accent-light: rgba(129, 140, 248, 0.16);
  --green: #34d399;
  --greenl: rgba(52, 211, 153, 0.15);
  --red: #f87171;
  --redl: rgba(248, 113, 113, 0.15);
  --amber: #fbbf24;
  --amberl: rgba(251, 191, 36, 0.15);
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.5);
}

html[data-light] {
  --bg: #f3f3f8;
  --surface: #ffffff;
  --surf2: #ededf5;
  --border: #e0e0ea;
  --text: #16162c;
  --muted: #70708a;
  --muted2: #b0b0c8;
  --accent: #6366f1;
  --accent-text: #4f46e5;
  --accent-light: #eef2ff;
  --green: #059669;
  --greenl: #ecfdf5;
  --red: #dc2626;
  --redl: #fef2f2;
  --amber: #d97706;
  --amberl: #fffbeb;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 6px 24px rgba(0, 0, 0, 0.12);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.25);
}

html, body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
}
input, select, textarea { font-family: inherit; outline: none; }
a { color: inherit; text-decoration: none; }

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

/* ─── HEADER ─────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 54px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 22px;
  flex-shrink: 0;
}
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand span {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.03em;
}
.desk-nav {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: 1;
  overflow: hidden;
}
.desk-nav button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.15s;
}
.desk-nav button:hover {
  background: var(--surf2);
  color: var(--text);
}
.desk-nav button.active {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
}
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-nuevo {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
.btn-nuevo:hover { opacity: 0.85; }
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surf2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--text); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

/* ─── MAIN ───────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 20px 24px;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.page-head {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.page-head h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.view { display: none; }
.view.active { display: block; }

/* ─── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s;
}
.card.no-pad { padding: 0; overflow: hidden; }
.card-clickable { cursor: pointer; }
.card-clickable:hover { box-shadow: var(--shadow-card-hover); }
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title-sm {
  font-size: 13px;
  font-weight: 600;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

/* ─── DASHBOARD: KPIs ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 10px;
}
.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-card .kpi-note { font-size: 12px; color: var(--muted); }
.kpi-card .kpi-note.pos { color: var(--green); }
.kpi-card .kpi-note.neg { color: var(--red); }

/* Chart row */
.chart-row {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}
.chart-row > .card:first-child { flex: 1; min-width: 0; }
.chart-side {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.chart-box {
  height: 210px;
  position: relative;
}

/* Alerts */
.alerts-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--redl);
  color: var(--red);
  border-radius: 99px;
  padding: 2px 8px;
}
.alert-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-body { flex: 1; min-width: 0; }
.alert-name { font-size: 13px; font-weight: 500; text-transform: capitalize; }
.alert-meta { font-size: 11px; margin-top: 1px; }

/* Two col */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* Goal row */
.goal-row { margin-bottom: 14px; }
.goal-row:last-child { margin-bottom: 0; }
.goal-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}
.goal-name { font-weight: 500; }
.goal-pct { color: var(--accent-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-bar {
  background: var(--surf2);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.goal-meta { font-size: 11px; color: var(--muted); }

/* ─── TRANSACTION ROW (shared) ───────────────────────────── */
.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  position: relative;
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: var(--surf2); }
.tx-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tx-icon-dot { width: 11px; height: 11px; border-radius: 50%; }
.tx-icon-sm { width: 32px; height: 32px; border-radius: 9px; }
.tx-icon-sm .tx-icon-dot { width: 8px; height: 8px; }
.tx-body { flex: 1; min-width: 0; }
.tx-desc {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: capitalize;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.tx-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.tx-amount {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.tx-amount.pos { color: var(--green); }
.tx-date { font-size: 12px; color: var(--muted); }
.tx-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surf2);
  color: var(--muted);
  font-size: 11px;
  opacity: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tx-row:hover .tx-del { opacity: 1; }
.tx-del:hover { background: var(--redl); color: var(--red); }

.pago-chip, .tag-chip {
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  background: var(--surf2);
  color: var(--muted);
}
.tag-chip { background: var(--accent-light); color: var(--accent-text); }
.foto-chip {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

/* ─── TRANSACTIONS PAGE ──────────────────────────────────── */
.tx-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tx-filters input,
.tx-filters select {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 13px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s;
}
.tx-filters input:focus,
.tx-filters select:focus { border-color: var(--accent); }
.tx-filters input { flex: 1 1 160px; min-width: 0; }
.tx-filters select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8.5L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── BUDGETS ────────────────────────────────────────────── */
.budget-overall {
  margin-bottom: 16px;
}
.budget-overall .bo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.budget-overall .bo-title {
  font-size: 14px;
  font-weight: 600;
}
.budget-overall .bo-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.pct-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--greenl);
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.pct-badge.warn { background: var(--amberl); color: var(--amber); }
.pct-badge.over { background: var(--redl); color: var(--red); }
.pct-badge.sm { font-size: 11px; padding: 3px 10px; }
.pct-badge.neutral { background: var(--surf2); color: var(--muted); }
.progress-bar.thick { height: 8px; }
.progress-bar.thick-7 { height: 7px; }

.budget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.budget-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.budget-card-name {
  font-size: 15px;
  font-weight: 600;
  text-transform: capitalize;
}
.budget-card-limit {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}
.budget-card-foot {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.budget-card-foot .spent { font-weight: 700; }
.budget-card-foot .spent.over { color: var(--red); }
.budget-card-foot .rest { color: var(--muted); }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 8px 0 14px;
}
.goal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.link-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--accent-light);
  transition: opacity 0.15s;
}
.link-btn:hover { opacity: 0.8; }
.empty-mini {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ─── CHAT ───────────────────────────────────────────────── */
.chat-view.view.active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 54px - 20px - 40px);
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot {
  align-self: flex-start;
  background: var(--surf2);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.msg.bot.egreso { border-left: 3px solid var(--red); }
.msg.bot.ingreso { border-left: 3px solid var(--green); }
.msg.bot.fijo { border-left: 3px solid var(--accent); }
.msg.bot.consulta { border-left: 3px solid var(--accent-text); }
.msg.bot.error { background: var(--redl); color: var(--red); }
.msg strong { font-weight: 700; }
.msg code {
  background: rgba(0, 0, 0, 0.18);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
html[data-light] .msg code { background: rgba(0, 0, 0, 0.06); }
.msg.user code { background: rgba(255, 255, 255, 0.22); }
.msg .hint { display: block; font-size: 12px; color: var(--muted); margin: 6px 0; }
.sugerencias { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sugerencia {
  font-size: 12px;
  padding: 5px 11px;
  background: var(--surface);
  color: var(--text);
  border-radius: 99px;
  cursor: pointer;
  border: 1px solid var(--border);
  font-weight: 500;
}
.sugerencia:hover { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent-light); }
.msg.typing { display: flex; gap: 4px; align-items: center; padding: 13px 16px; }
.msg.typing span {
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.input-bar {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  align-items: center;
  background: var(--surface);
}
.input-bar button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surf2);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: all 0.15s;
}
.input-bar button:hover { color: var(--text); background: var(--border); }
.input-bar button#send-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  border-radius: 9px;
}
.input-bar button#send-btn:hover { opacity: 0.85; }
.input-bar button#send-btn:disabled { opacity: 0.5; }
.input-bar button#mic-btn.recording {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  animation: pulse 1.3s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}
.input-bar input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surf2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 14px;
  min-width: 0;
  transition: border-color 0.15s;
}
.input-bar input:focus { border-color: var(--accent); }
.input-bar input::placeholder { color: var(--muted2); }

/* ─── REPORTS ────────────────────────────────────────────── */
.rep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.rep-chart-box { height: 280px; position: relative; }
.rep-table-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.rep-table-row:last-child { border-bottom: none; }
.rep-table-row .rt-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rep-table-row .rt-name { flex: 1; font-size: 14px; font-weight: 500; text-transform: capitalize; }
.rep-table-row .rt-bar { width: 130px; background: var(--surf2); border-radius: 99px; height: 5px; overflow: hidden; }
.rep-table-row .rt-bar-fill { height: 100%; border-radius: 99px; }
.rep-table-row .rt-pct { width: 38px; text-align: right; font-size: 13px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.rep-table-row .rt-amount { width: 110px; text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ─── BOTTOM NAV (mobile) ────────────────────────────────── */
.bot-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.bot-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  padding: 4px 0;
  font-size: 9px;
  font-weight: 400;
}
.bot-nav button.active {
  color: var(--accent);
  font-weight: 700;
}

/* ─── TOAST ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 300;
  box-shadow: var(--shadow-card-hover);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── MODALS ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
.modal.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8.5L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surf2);
  padding: 4px;
  border-radius: 99px;
  border: 1px solid var(--border);
}
.type-toggle button {
  padding: 8px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
}
.type-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.foto-row { display: flex; gap: 10px; align-items: center; }
.foto-preview {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.foto-preview img { width: 100%; height: 100%; object-fit: cover; }
.foto-preview .remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn-primary, .btn-secondary {
  flex: 1;
  padding: 11px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: 0.85; }
.btn-secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}
.btn-secondary:hover { color: var(--text); background: var(--surf2); }
.btn-sm { padding: 7px 14px; flex: 0 0 auto; }

/* Foto viewer */
.modal-foto-viewer.open {
  background: rgba(0, 0, 0, 0.88);
  padding: 24px;
}
.foto-viewer-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}
.foto-viewer-inner img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
}
.close-btn-floating {
  position: absolute;
  top: -40px;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  backdrop-filter: blur(8px);
  font-size: 14px;
  line-height: 1;
}

/* ─── EMPTY STATES ───────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
}
.empty .emoji {
  display: block;
  font-size: 38px;
  margin-bottom: 10px;
  opacity: 0.7;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .desk-nav { display: none !important; }
  .bot-nav { display: flex !important; }
  main {
    padding: 14px 14px 80px !important;
    max-width: 100%;
  }
  .brand { margin-right: 0; }
  .header-actions .btn-nuevo span { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .chart-row { flex-direction: column; }
  .chart-side { width: 100%; }
  .two-col, .rep-grid, .goal-grid { grid-template-columns: 1fr; }
  .budget-grid { grid-template-columns: 1fr; }
  .rep-table-row .rt-bar { width: 80px; }
  .rep-table-row .rt-amount { width: 90px; font-size: 13px; }
  .chat-view.view.active {
    height: calc(100dvh - 54px - 80px - 28px);
    border-radius: 12px;
  }
  .page-head h1 { font-size: 20px; }
}

@media (max-width: 420px) {
  .kpi-card .kpi-value { font-size: 20px; }
  main { padding: 12px 12px 80px !important; }
}

/* ══════════════════════════════════════════════════════════
   Mobile refinements — cubre iPhone SE hasta tablets
   ══════════════════════════════════════════════════════════ */

@media (max-width: 680px) {
  /* Evitar zoom automático en iOS al enfocar inputs */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Header más compacto */
  header {
    padding: 10px 14px !important;
    gap: 8px;
  }
  .header-actions { gap: 6px; }
  .brand span { font-size: 15px; }

  /* Safe-area (iPhones con notch) */
  .bot-nav {
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
  main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }

  /* Modales full-height en móvil */
  .modal { align-items: flex-end !important; padding: 0 !important; }
  .modal-card, .modal-card-wide {
    max-width: 100% !important;
    width: 100%;
    border-radius: 18px 18px 0 0 !important;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom)) !important;
  }
  .modal-title { font-size: 17px; margin-bottom: 12px; }
  .modal-actions {
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: var(--surf);
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
  }
  .modal-actions button { flex: 1 1 140px; min-height: 44px; }

  /* Foto viewer fullscreen sin bordes */
  .modal-foto-viewer .foto-viewer-inner { max-height: 100dvh; }

  /* Tablas horizontales con scroll táctil */
  .import-preview, .tx-filters {
    -webkit-overflow-scrolling: touch;
  }
  .import-preview { max-height: 45dvh; }
  .import-preview table {
    font-size: 12.5px;
  }
  .import-preview th, .import-preview td {
    padding: 6px 8px !important;
    white-space: nowrap;
  }

  /* Auth lobby: apilar nombre + usuario en móvil */
  .auth-card {
    padding: 22px 18px !important;
    max-height: 100dvh;
    border-radius: 16px;
  }
  .auth-lobby { padding: 12px; align-items: flex-start; padding-top: 28px; }
  .form-row { flex-direction: column; gap: 10px; }
  .auth-tabs { margin-bottom: 14px; }
  .auth-tab { padding: 10px 8px !important; font-size: 13.5px; }
  .auth-title { font-size: 22px; }
  .auth-subtitle { font-size: 12.5px; }

  /* Botones con altura mínima táctil */
  .btn-primary, .btn-secondary {
    min-height: 42px;
  }
  .btn-primary.btn-block { min-height: 46px; }

  /* Dropdown usuario: ancho casi total */
  .user-dropdown {
    right: -8px !important;
    min-width: calc(100vw - 28px) !important;
    max-width: 320px;
  }
  .user-action { min-height: 44px; font-size: 14px; }

  /* Transacciones: descripción completa sin truncar raro */
  .tx-body { font-size: 14px; }
  .tx-amount { font-size: 15px !important; }
  .tx-filters { gap: 8px; }
  .tx-filters input, .tx-filters select { flex: 1 1 100%; }

  /* Chat input accesible */
  #chat-input {
    font-size: 16px !important;
    padding: 12px 14px !important;
  }

  /* Verify code: agrandar */
  #verify-code {
    font-size: 26px !important;
    letter-spacing: 0.3em;
    padding: 14px !important;
  }

  /* Help text import */
  .import-help { font-size: 12.5px; padding: 10px 12px; }
  .import-help code { font-size: 11.5px; }

  /* Dashboard KPIs — más espacio */
  .kpi-grid { gap: 10px; }
  .kpi-card { padding: 12px 14px; }

  /* Quitar outline exagerado en focus mobile */
  button:focus-visible { outline-offset: 2px; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auth-title { font-size: 20px; }
  .modal-title { font-size: 16px; }
}

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

/* ══════════════════════════════════════════════════════════
   Auth Lobby
   ══════════════════════════════════════════════════════════ */

.auth-lobby {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow-modal);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-logo-lg {
  width: 40px !important;
  height: 40px !important;
  border-radius: 11px !important;
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 3px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surf2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

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

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

.auth-error {
  font-size: 12.5px;
  color: var(--red);
  background: var(--redl);
  border-radius: 8px;
  padding: 8px 11px;
  min-height: 0;
  display: none;
}

.auth-error.visible { display: block; }

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 11px 16px !important;
  font-size: 14px !important;
  margin-top: 4px;
}

.auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted2);
  line-height: 1.5;
}

.auth-verify-info {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 14px;
}
.auth-verify-info strong { color: var(--text); }

#verify-code {
  font-size: 22px !important;
  letter-spacing: 0.35em;
  text-align: center;
  font-family: 'SF Mono', 'Menlo', monospace;
  padding: 13px 16px !important;
}

.auth-verify-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 12.5px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 2px;
  font-size: inherit;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   User menu (avatar dropdown)
   ══════════════════════════════════════════════════════════ */

.user-menu {
  position: relative;
}

.user-menu .avatar {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s;
}

.user-menu .avatar:hover { transform: scale(1.05); }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card-hover);
  padding: 6px;
  z-index: 500;
  display: none;
}

.user-dropdown.open { display: block; }

.user-info {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.user-nombre {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  word-break: break-all;
}

.user-action {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}

.user-action:hover { background: var(--surf2); }
.user-action svg { color: var(--muted); flex-shrink: 0; }

.user-action-danger { color: var(--red); }
.user-action-danger:hover { background: var(--redl); }
.user-action-danger svg { color: var(--red); }

@media (max-width: 680px) {
  .user-dropdown {
    right: 0;
    min-width: 220px;
  }
}

/* ══════════════════════════════════════════════════════════
   Import Excel modal
   ══════════════════════════════════════════════════════════ */

.modal-card-wide { max-width: 640px !important; }

.import-help {
  background: var(--surf2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}
.import-help code {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--accent-text);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11.5px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.import-help small { display: block; margin-top: 6px; color: var(--muted2); font-size: 11.5px; }

.import-preview {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 12px;
  display: none;
}
.import-preview.visible { display: block; }
.import-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.import-preview th, .import-preview td {
  padding: 6px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.import-preview th {
  background: var(--surf2);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .05em;
  position: sticky; top: 0;
}
.import-preview tr:last-child td { border-bottom: 0; }
.import-preview td.amt-in { color: var(--green); font-weight: 600; }
.import-preview td.amt-out { color: var(--red); font-weight: 600; }

.import-summary {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}
.import-summary .ok { color: var(--green); font-weight: 600; }
.import-summary .err { color: var(--red); font-weight: 600; }

/* ═══════════════ QUICK BAR DASHBOARD ═══════════════ */
.quick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.quick-bar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 8px 6px;
  outline: none;
  min-width: 0;
}
.quick-bar button {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surf2);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .12s, background .12s;
}
.quick-bar button:hover { background: var(--surf3, var(--surf2)); }
.quick-bar button:active { transform: scale(.95); }
.quick-bar button.recording {
  background: var(--red, #e53935);
  color: #fff;
  border-color: transparent;
  animation: pulse-rec 1.1s ease-in-out infinite;
}
#quick-send { background: var(--accent, #4f46e5); color: #fff; border-color: transparent; }
@keyframes pulse-rec { 0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,.45);} 50% { box-shadow: 0 0 0 7px rgba(229,57,53,0);} }

.quick-feedback {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: var(--surf);
  animation: qf-in .2s ease-out;
}
.quick-feedback strong { font-weight: 600; }
.quick-feedback.pending { color: var(--muted); }
.quick-feedback.ingreso { border-color: rgba(46,160,67,.4); background: rgba(46,160,67,.08); }
.quick-feedback.egreso { border-color: rgba(229,57,53,.4); background: rgba(229,57,53,.08); }
.quick-feedback.fijo { border-color: rgba(79,70,229,.4); background: rgba(79,70,229,.08); }
.quick-feedback.warn { border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.08); }
.qf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; animation: qf-dot 1s infinite; }
@keyframes qf-dot { 0%,100% { opacity: .3 } 50% { opacity: 1 } }
@keyframes qf-in { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: none;} }

/* ═══════════════ AVISOS (dashboard) ═══════════════ */
.avisos-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.aviso {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surf);
  font-size: 13px;
  line-height: 1.4;
}
.aviso-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.aviso-body { flex: 1; min-width: 0; }
.aviso-title { font-weight: 600; color: var(--text); }
.aviso-desc { color: var(--muted); margin-top: 2px; font-size: 12.5px; }
.aviso-actions { display: flex; gap: 6px; flex-shrink: 0; }
.aviso-actions button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surf2);
  color: var(--text);
  cursor: pointer;
}
.aviso-actions button.primary { background: var(--accent, #4f46e5); color: #fff; border-color: transparent; }
.aviso-warn { border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.06); }
.aviso-accent { border-color: rgba(79,70,229,.4); background: rgba(79,70,229,.06); }
.aviso-info { border-color: rgba(46,160,67,.3); background: rgba(46,160,67,.05); }
.aviso-muted { opacity: .85; }
.aviso-sub { color: var(--muted); margin-top: 2px; font-size: 12.5px; }
.btn-sm { padding: 5px 10px !important; font-size: 12px !important; border-radius: 8px !important; }

/* ═══════════════ AJUSTES / SETTINGS ═══════════════ */
.settings-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  padding: 8px 14px;
  font-size: 13px;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { background: var(--accent, #4f46e5); color: #fff; font-weight: 600; }

.settings-body { display: flex; flex-direction: column; gap: 14px; }
.settings-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.settings-h2 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.settings-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }

.badge-auto {
  display: inline-block;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 5px;
  background: rgba(79,70,229,.15);
  color: var(--accent, #4f46e5);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: 6px;
}

.tx-edit {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}
.tx-edit:hover { background: var(--surf2); color: var(--text); }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
  cursor: pointer;
  padding: 6px 0;
}
.check-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent, #4f46e5); }

@media (max-width: 680px) {
  .quick-bar { padding: 8px 10px; border-radius: 12px; }
  .quick-bar input { font-size: 16px; }
  .quick-bar button { width: 38px; height: 38px; }
  .aviso { font-size: 12.5px; flex-wrap: wrap; }
  .aviso-actions { width: 100%; margin-top: 4px; }
  .settings-tab { padding: 7px 12px; font-size: 12.5px; }
}
