/* Cuentas Claras — estilos. Fuentes del sistema, claro/oscuro, acento #0A6B63. */

:root {
  --accent: #0A6B63;
  --accent-strong: #08564F;
  --accent-soft: #E3F1EF;
  --bg: #F4F7F7;
  --surface: #FFFFFF;
  --surface-2: #F7FAFA;
  --text: #11201F;
  --muted: #5B6B6A;
  --line: #E2E9E8;
  --good: #15803D;
  --good-soft: #E8F6EC;
  --bad: #C2410C;
  --bad-soft: #FDEEE6;
  --warn: #B45309;
  --warn-soft: #FEF5E2;
  --info: #0E6FA8;
  --info-soft: #E5F2FA;
  --shadow: 0 1px 2px rgba(16, 40, 38, .05), 0 6px 20px rgba(16, 40, 38, .06);
  --radius: 16px;
  --nav-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #3CC2B4;
    --accent-strong: #5FD3C6;
    --accent-soft: #123532;
    --bg: #0C1413;
    --surface: #141F1E;
    --surface-2: #1A2726;
    --text: #E6EFEE;
    --muted: #97A9A7;
    --line: #253534;
    --good: #4ADE80;
    --good-soft: #14301F;
    --bad: #FB923C;
    --bad-soft: #3A2014;
    --warn: #FBBF24;
    --warn-soft: #362A10;
    --info: #60B8EA;
    --info-soft: #11283A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #3CC2B4;
  --accent-strong: #5FD3C6;
  --accent-soft: #123532;
  --bg: #0C1413;
  --surface: #141F1E;
  --surface-2: #1A2726;
  --text: #E6EFEE;
  --muted: #97A9A7;
  --line: #253534;
  --good: #4ADE80;
  --good-soft: #14301F;
  --bad: #FB923C;
  --bad-soft: #3A2014;
  --warn: #FBBF24;
  --warn-soft: #362A10;
  --info: #60B8EA;
  --info-soft: #11283A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------- Arranque y login ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; padding: 16px; text-align: center; }
/* Si la app no arranca en 6 s (sin señal o abierta como archivo), se muestra la ayuda. */
.boot-help { max-width: 340px; color: var(--muted); font-size: 14px; opacity: 0; animation: show-help .3s ease 6s forwards; }
@keyframes show-help { to { opacity: 1; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 700; font-size: 17px; line-height: 1.1; }
.brand-name span { display: block; color: var(--accent); font-weight: 600; font-size: 13px; }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 4px; }
.login-card form { margin-top: 18px; display: grid; gap: 12px; }

/* ---------- Formularios ---------- */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; font-weight: 400;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #06201D; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #06201D; } }
.btn-primary:active { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }

.alert { padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-ok { background: var(--good-soft); color: var(--good); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Estructura ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { padding: 14px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-top: env(safe-area-inset-top); }
.topbar h1 { flex: 1; min-width: 0; }
.month-pick { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
.month-pick button { border: 0; background: transparent; width: 34px; height: 36px; border-radius: 10px; font-size: 18px; color: var(--muted); }
.month-pick span { font-weight: 600; font-size: 14px; min-width: 86px; text-align: center; text-transform: capitalize; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.nav-item { border: 0; background: transparent; display: grid; justify-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 6px 0; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item[aria-current="page"] { color: var(--accent); font-weight: 600; }
.fab {
  justify-self: center; width: 56px; height: 56px; border-radius: 50%; border: 0; margin-top: -26px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(10, 107, 99, .35);
}
.fab svg { width: 26px; height: 26px; }

/* Tablet y computadora: menú lateral en lugar de la barra inferior.
   600–1099 px (tablet vertical u horizontal): riel compacto de íconos con etiqueta.
   1100 px o más: menú lateral completo. */
@media (min-width: 600px) {
  .shell { display: grid; grid-template-columns: 88px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) 8px 14px; background: var(--surface); border-right: 1px solid var(--line);
    overflow-y: auto; scrollbar-width: none;
  }
  .sidebar .brand { justify-content: center; padding: 0 0 14px; }
  .sidebar .brand-name { display: none; }
  .side-item {
    display: grid; justify-items: center; gap: 3px; border: 0; background: transparent; padding: 9px 2px; border-radius: 14px;
    color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.15; text-align: center; min-height: 56px;
  }
  .side-item svg { width: 22px; height: 22px; flex: none; }
  .side-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
  .sidebar .btn-primary { margin: 0 auto 12px; width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 18px; box-shadow: 0 8px 20px rgba(10, 107, 99, .3); }
  .sidebar .btn-primary span { display: none; }
  .sidebar .btn-primary svg { width: 26px; height: 26px; }
  .sidebar .side-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: center; }
  .sidebar .sync { font-size: 0; gap: 0; }
  .sidebar .sync i { width: 10px; height: 10px; }
  .bottom-nav { display: none; }
  .main { padding: calc(20px + env(safe-area-inset-top)) 24px 32px; width: 100%; }
  #toast { bottom: 24px; }
}
@media (min-width: 1100px) {
  .shell { grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar { padding: 20px 14px; gap: 4px; }
  .sidebar .brand { justify-content: flex-start; padding: 0 8px 18px; }
  .sidebar .brand-name { display: block; }
  .side-item { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 12px; font-size: 15px; min-height: 0; }
  .side-item svg { width: 20px; height: 20px; }
  .side-item:hover { background: var(--surface-2); }
  .sidebar .btn-primary { margin: 8px 0 14px; width: auto; height: auto; min-height: 46px; padding: 0 18px; border-radius: 12px; box-shadow: none; }
  .sidebar .btn-primary span { display: inline; }
  .sidebar .btn-primary svg { width: 18px; height: 18px; }
  .sidebar .side-foot { justify-content: flex-start; padding-left: 8px; }
  .sidebar .sync { font-size: 12px; gap: 6px; }
  .main { padding: 24px 28px 40px; }
}
@media (hover: hover) { .side-item:hover { color: var(--text); } }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr) 300px; }
  .kpi { padding: 16px 18px; }
  .kpi-value { font-size: 26px; }
}
@media (min-width: 1300px) { .grid-side { grid-template-columns: minmax(0, 1fr) 360px; } }
@media (max-width: 599px) { .hide-sm { display: none; } }
/* En celular "Más" es el menú; desde tablet el riel lateral ya muestra todo. */
.show-lg { display: none; }
@media (min-width: 600px) { .hide-lg { display: none !important; } .show-lg { display: inline; } }
.side-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-long { display: none; }
@media (min-width: 1100px) { .side-short { display: none; } .side-long { display: inline; } }

.topbar-sub { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.topbar-sub::first-letter { text-transform: uppercase; }
.search { background: var(--surface); }
.sum-rows { display: grid; gap: 8px; margin-top: 10px; }
.sum-rows div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.sum-rows b { font-variant-numeric: tabular-nums; }
.cat-btn { border: 0; background: transparent; padding: 4px; margin: -4px; border-radius: 12px; text-align: left; width: calc(100% + 8px); }
.cat-btn:active { background: var(--surface-2); }
/* Tablet horizontal: con poca altura, el contenido no necesita tanto aire. */
@media (min-width: 600px) and (max-width: 1099px) and (max-height: 820px) {
  .sidebar .brand { padding-bottom: 8px; }
  .sidebar .btn-primary { margin-bottom: 8px; width: 50px; height: 50px; min-height: 50px; }
  .side-item { min-height: 50px; padding: 6px 2px; }
}

/* ---------- Tarjetas de contenido ---------- */
.stack { display: grid; gap: 14px; align-content: start; }
.grid { display: grid; gap: 14px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head .btn { margin: -6px -8px -6px 0; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { border-radius: var(--radius); padding: 12px; min-width: 0; }
.kpi-label { font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.kpi-value { font-size: 18px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi-in { background: var(--good-soft); color: var(--good); }
.kpi-out { background: var(--bad-soft); color: var(--bad); }
.kpi-net { background: var(--info-soft); color: var(--info); }
.kpi svg { width: 16px; height: 16px; flex: none; }
@media (min-width: 600px) { .kpi { padding: 16px; } .kpi-value { font-size: 24px; } .kpi-label { font-size: 13px; } }

/* Tarjeta de crédito */
.cc { border-radius: var(--radius); padding: 16px; color: #fff; background: linear-gradient(135deg, #0A6B63, #0B4F7A); box-shadow: var(--shadow); }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc-name { font-weight: 700; font-size: 16px; }
.cc-sub { font-size: 12px; opacity: .8; }
.cc-amount { font-size: 26px; font-weight: 700; margin: 12px 0 2px; font-variant-numeric: tabular-nums; }
.cc-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .25); overflow: hidden; margin: 10px 0 12px; }
.cc-bar i { display: block; height: 100%; background: #fff; border-radius: 6px; }
.cc-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cc-date { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 8px 10px; }
.cc-date b { display: block; font-size: 15px; }
.cc-date span { font-size: 12px; opacity: .85; }
.cc-due { margin-top: 10px; background: rgba(255, 255, 255, .95); color: #0B302D; border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cc-due b { font-size: 17px; font-variant-numeric: tabular-nums; }
.cc-due .btn { min-height: 34px; background: #0A6B63; border-color: #0A6B63; color: #fff; }
.cards-row { display: grid; gap: 12px; }
@media (min-width: 700px) { .cards-row { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }

/* Barras de progreso */
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 8px; background: var(--accent); }
.bar.over i { background: var(--bad); }
.bar.near i { background: var(--warn); }

.budget-total { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.budget-total b { font-size: 24px; font-variant-numeric: tabular-nums; }
.cat-list { display: grid; gap: 12px; margin-top: 14px; }
.cat { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; }
.cat-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--surface-2); }
.cat-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 5px; }
.cat-top span:first-child { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gráficas */
.donut-wrap { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: center; }
.donut { width: 140px; height: 140px; }
.legend { display: grid; gap: 6px; font-size: 13px; }
.legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 50%; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chart-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: currentColor; }
.chart-legend .in { color: var(--good); }
.chart-legend .out { color: var(--bad); }
@media (max-width: 380px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .legend { width: 100%; } }

/* Coach */
.tips { display: grid; gap: 10px; }
.tip { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.tip-ico { font-size: 20px; line-height: 1.2; }
.tip b { display: block; margin-bottom: 2px; }
.tip.t-bad { background: var(--bad-soft); }
.tip.t-warn { background: var(--warn-soft); }
.tip.t-good { background: var(--good-soft); }
.chat { display: grid; gap: 10px; margin: 12px 0; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; }
.msg.me { justify-self: end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { justify-self: start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Listas */
.list { display: grid; }
.item { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--surface-2); }
.item-main { min-width: 0; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-end { text-align: right; display: grid; justify-items: end; gap: 2px; }
.item-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-del { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 0; }
.day-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 14px 0 2px; }
.day-head:first-child { padding-top: 0; }
.pending-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-left: 6px; vertical-align: 1px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.filters .chip { flex: none; }

.goal { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.goal:last-child { border-bottom: 0; }
.goal-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.settings-list { display: grid; gap: 8px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); }

/* ---------- Hoja inferior (formularios) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 15, 14, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.sheet form { display: grid; gap: 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 9px; min-height: 38px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.amount-input { font-size: 30px; font-weight: 700; text-align: center; min-height: 62px; font-variant-numeric: tabular-nums; }
.cat-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-pick button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 8px 4px; display: grid; justify-items: center; gap: 2px; font-size: 11px; line-height: 1.2; min-height: 62px; }
.cat-pick button span:first-child { font-size: 20px; }
.cat-pick button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.scan-btn { border-style: dashed; color: var(--accent); }
.scan-note { font-size: 13px; }

/* ---------- Aviso flotante ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #11201F; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
@media (min-width: 900px) { #toast { bottom: 24px; } }

.sync { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.sync.pending i { background: var(--warn); }
.sync.offline i { background: var(--bad); }

/* ---------- setup.php ---------- */
.setup { padding: 24px 16px; }
.setup-card { max-width: 480px; margin: 0 auto; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.setup-card form { display: grid; gap: 14px; }

/* Campana de avisos */
.bell { position: relative; flex: none; color: var(--text); }
.bell .badge {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
  border: 2px solid var(--bg);
}
.rem-intro { margin: -6px 0 12px; }
.rem { grid-template-columns: 28px 1fr auto; align-items: center; }
.rem-btn { background: var(--surface); white-space: nowrap; }
.rem-actions { grid-template-columns: auto 1fr; margin-top: 14px; }
@media (max-width: 420px) {
  .rem { grid-template-columns: 28px 1fr; }
  .rem-btn { grid-column: 2; justify-self: start; }
}
/* Celular angosto: el saludo, el mes y la campana caben en una línea. */
@media (max-width: 420px) {
  .topbar { gap: 8px; }
  .topbar h1 { font-size: 19px; }
  .month-pick span { min-width: 0; font-size: 13px; padding: 0 2px; }
  .month-pick button { width: 28px; }
}
/* ---------- Gastos de la empresa ---------- */
.kpi-warn { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
button.tag { cursor: pointer; }
.tag-photo { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.emp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.emp-item { align-items: start; }
.emp-item.is-sel { background: var(--accent-soft); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 12px; }
.emp-check { width: 38px; height: 38px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: #fff; font-weight: 700; font-size: 18px; }
.emp-check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.emp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); position: sticky; top: 8px; z-index: 5; }
.emp-bar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.emp-home .budget-total { margin: 0; align-items: center; }
.emp-home b { font-size: 22px; }

.toggle-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; text-align: left; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.toggle-row > span:first-child { font-size: 20px; }
.toggle-row[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.switch { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.toggle-row[aria-pressed="true"] .switch { background: var(--accent); }
.toggle-row[aria-pressed="true"] .switch::after { left: 21px; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); font-weight: 500; min-height: 46px; align-self: end; }
label.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.photo-box { display: grid; gap: 8px; }
.photo-box img { max-width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); justify-self: start; }
.photo-full img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 12px; background: var(--surface-2); }
.photo-full + p { margin: 10px 0; }

/* Reporte */
.report-preview { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; max-height: 46vh; overflow: auto; background: var(--surface-2); }
.rep-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: 14px; }
.rep-table { overflow-x: auto; }
.rep-table table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 560px; }
.rep-table th, .rep-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rep-table th { font-weight: 700; color: var(--muted); }
.rep-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep-table tfoot td { font-weight: 700; border-bottom: 0; }
.rep-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.rep-photos figure { margin: 0; break-inside: avoid; }
.rep-photos img { width: 100%; max-height: 420px; object-fit: contain; border: 1px solid #ccc; }
.rep-photos figcaption { font-size: 11px; margin-top: 4px; }
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-root { display: block; color: #000; font: 12px/1.4 system-ui, sans-serif; }
  #print-root .rep-table table { min-width: 0; }
  #print-root th, #print-root td { border-bottom: 1px solid #bbb; color: #000; }
  @page { margin: 14mm; }
}