/* Financheck — sistema visual.
   Fondos neutros, un color de acento, tipografía del sistema y jerarquía clara.
   Bootstrap aporta grilla, formularios y modales; aquí se refinan. */

:root {
  color-scheme: light;
  --fc-bg: #f2f2f5;
  --fc-surface: #ffffff;
  --fc-surface-2: #f7f7f9;
  --fc-fill: rgba(118, 118, 128, 0.12);
  --fc-fill-strong: rgba(118, 118, 128, 0.2);
  --fc-segment-on: #ffffff; /* opción elegida de un control segmentado */
  --fc-brand-ink: #15212a; /* texto del logotipo (azul noche de la marca) */
  /* Gráfico de gastos: paleta categórica validada (orden fijo; daltonismo y contraste revisados)
     y un gris neutro para "Otras". */
  --fc-series-1: #2a78d6;
  --fc-series-2: #eb6834;
  --fc-series-3: #1baf7a;
  --fc-series-4: #eda100;
  --fc-series-5: #e87ba4;
  --fc-series-other: #aeaeb2;
  --fc-separator: rgba(60, 60, 67, 0.14);
  --fc-text: #0b0b0c;
  --fc-text-2: #55555c;
  --fc-text-3: #8a8a91;
  --fc-accent: #2a78d6;
  --fc-accent-strong: #1f63b5;
  --fc-accent-soft: rgba(42, 120, 214, 0.12);
  --fc-on-accent: #ffffff;
  --fc-income: #0f7a3a;
  --fc-expense: #0b0b0c;
  --fc-danger: #c62f2f;
  --fc-warning: #9a6200;
  --fc-focus: 0 0 0 3px rgba(42, 120, 214, 0.45);
  --fc-radius: 14px;
  --fc-radius-sm: 10px;
  --fc-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --fc-tabbar-h: 64px;
  --fc-safe-bottom: env(safe-area-inset-bottom, 0px);
  --fc-safe-top: env(safe-area-inset-top, 0px);
  --fc-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bs-body-font-family: var(--fc-font);
  --bs-body-bg: var(--fc-bg);
  --bs-body-color: var(--fc-text);
  --bs-border-color: var(--fc-separator);
  --bs-primary: var(--fc-accent);
  --bs-primary-rgb: 42, 120, 214;
  --bs-link-color: var(--fc-accent);
  --bs-link-color-rgb: 42, 120, 214;
  --bs-link-hover-color: var(--fc-accent-strong);
  --bs-secondary-color: var(--fc-text-2);
  --bs-tertiary-bg: var(--fc-surface-2);
}

/* Oscuro: automático (sistema) salvo que se elija Claro, o elegido a mano en Ajustes → Aspecto.
   Los valores se declaran dos veces a propósito: la elección manual gana en ambos sentidos. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fc-bg: #000000;
    --fc-surface: #1c1c1e;
    --fc-surface-2: #2c2c2e;
    --fc-fill: rgba(118, 118, 128, 0.24);
    --fc-fill-strong: rgba(118, 118, 128, 0.36);
    /* En oscuro, la superficie casi no se distingue del fondo del control: se usa un gris más claro. */
    --fc-segment-on: #636366;
    --fc-brand-ink: #f2f2f4;
    --fc-series-1: #3987e5;
    --fc-series-2: #d95926;
    --fc-series-3: #199e70;
    --fc-series-4: #c98500;
    --fc-series-5: #d55181;
    --fc-series-other: #636366;
    --fc-separator: rgba(84, 84, 88, 0.6);
    --fc-text: #f2f2f4;
    --fc-text-2: #b8b8bf;
    --fc-text-3: #8d8d94;
    --fc-accent: #3987e5;
    --fc-accent-strong: #5598e7;
    --fc-accent-soft: rgba(57, 135, 229, 0.2);
    --fc-income: #3fbf6f;
    --fc-expense: #f2f2f4;
    --fc-danger: #ff6b6b;
    --fc-warning: #f2b544;
    --fc-focus: 0 0 0 3px rgba(57, 135, 229, 0.6);
    --fc-shadow: none;
    --bs-primary-rgb: 57, 135, 229;
    --bs-link-color-rgb: 57, 135, 229;
    --bs-emphasis-color: #fff;
    --bs-body-bg: var(--fc-bg);
    --bs-secondary-bg: var(--fc-surface-2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fc-bg: #000000;
  --fc-surface: #1c1c1e;
  --fc-surface-2: #2c2c2e;
  --fc-fill: rgba(118, 118, 128, 0.24);
  --fc-fill-strong: rgba(118, 118, 128, 0.36);
  /* En oscuro, la superficie casi no se distingue del fondo del control: se usa un gris más claro. */
  --fc-segment-on: #636366;
  --fc-brand-ink: #f2f2f4;
  --fc-series-1: #3987e5;
  --fc-series-2: #d95926;
  --fc-series-3: #199e70;
  --fc-series-4: #c98500;
  --fc-series-5: #d55181;
  --fc-series-other: #636366;
  --fc-separator: rgba(84, 84, 88, 0.6);
  --fc-text: #f2f2f4;
  --fc-text-2: #b8b8bf;
  --fc-text-3: #8d8d94;
  --fc-accent: #3987e5;
  --fc-accent-strong: #5598e7;
  --fc-accent-soft: rgba(57, 135, 229, 0.2);
  --fc-income: #3fbf6f;
  --fc-expense: #f2f2f4;
  --fc-danger: #ff6b6b;
  --fc-warning: #f2b544;
  --fc-focus: 0 0 0 3px rgba(57, 135, 229, 0.6);
  --fc-shadow: none;
  --bs-primary-rgb: 57, 135, 229;
  --bs-link-color-rgb: 57, 135, 229;
  --bs-emphasis-color: #fff;
  --bs-body-bg: var(--fc-bg);
  --bs-secondary-bg: var(--fc-surface-2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-select {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b8b8bf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  }
  :root:not([data-theme="light"]) .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
}
:root[data-theme="dark"] .form-select {
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b8b8bf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

* { -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }
body {
  background: var(--fc-bg);
  color: var(--fc-text);
  font-family: var(--fc-font);
  -webkit-font-smoothing: antialiased;
  font-size: 1rem;
  line-height: 1.4;
}

:focus-visible { outline: none; box-shadow: var(--fc-focus) !important; border-radius: 8px; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 2000;
  background: var(--fc-surface); padding: 8px 12px; border-radius: 8px; color: var(--fc-text);
}
.skip-link:focus { top: calc(8px + var(--fc-safe-top)); }

.boot { min-height: 100vh; display: grid; place-items: center; }

/* ---------- Marca ---------- */

/* Logotipo como texto: FINAN fino + CHECK grueso, con la tipografía del sistema (SF en Apple).
   Al ser texto, toma el color del aspecto (azul noche en claro, blanco en oscuro). */
.wordmark { color: var(--fc-brand-ink); letter-spacing: 0.06em; line-height: 1; white-space: nowrap; text-transform: uppercase; }
.wordmark .w-light { font-weight: 300; }
.wordmark .w-bold { font-weight: 800; }

/* ---------- Estructura ---------- */

.app { min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }
.main {
  flex: 1;
  min-width: 0;
  padding: calc(12px + var(--fc-safe-top)) 16px calc(var(--fc-tabbar-h) + var(--fc-safe-bottom) + 24px);
}
.page { max-width: 720px; margin: 0 auto; }
.page-wide { max-width: 960px; margin: 0 auto; }

.page-header {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; margin-bottom: 12px;
}
.page-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; flex: 1; }
.page-back {
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--fc-accent); text-decoration: none; font-size: 1rem; min-height: 44px; padding-right: 8px;
}

.section-title {
  font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--fc-text-3); margin: 24px 4px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.section-title a, .section-title button { text-transform: none; letter-spacing: 0; font-size: 0.9375rem; font-weight: 500; }

/* ---------- Superficies ---------- */

.card-fc {
  background: var(--fc-surface);
  border-radius: var(--fc-radius);
  box-shadow: var(--fc-shadow);
  padding: 16px;
}
.card-fc + .card-fc { margin-top: 12px; }

.list-fc {
  background: var(--fc-surface);
  border-radius: var(--fc-radius);
  box-shadow: var(--fc-shadow);
  overflow: hidden;
  list-style: none;
  padding: 0;
  margin: 0;
}
.list-fc > li + li > .row-fc,
.list-fc > li + li > .row-static { border-top: 1px solid var(--fc-separator); }
.list-fc > li + li { position: relative; }

.row-fc, .row-static {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 10px 16px;
  color: inherit; text-decoration: none; width: 100%;
  background: none; border: 0; text-align: left;
}
.row-fc { cursor: pointer; transition: background-color 0.12s ease; }
.row-fc:hover { background: var(--fc-surface-2); }
.row-fc:active { background: var(--fc-fill); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.8125rem; color: var(--fc-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; flex-shrink: 0; }
.chevron { color: var(--fc-text-3); flex-shrink: 0; }

.icon-badge {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--fc-fill); color: var(--fc-text-2);
}
.icon-badge.is-income { background: rgba(15, 122, 58, 0.12); color: var(--fc-income); }
.icon-badge.is-accent { background: var(--fc-accent-soft); color: var(--fc-accent); }
.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Montos ---------- */

.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amount.is-income { color: var(--fc-income); }
.amount.is-expense { color: var(--fc-expense); }
.amount-hero { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* ---------- Barra superior de inicio ---------- */

.topbar { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 8px; }
.topbar .dropdown { flex: 1 1 auto; min-width: 0; }
.account-switch {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em;
  background: none; border: 0; padding: 0; color: var(--fc-text);
}
.account-switch .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-switch .icon { color: var(--fc-accent); }
.topbar .spacer { flex: 1; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 500; color: var(--fc-text-2);
  background: var(--fc-fill); border-radius: 999px; padding: 4px 10px; white-space: nowrap;
  text-decoration: none;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
@media (max-width: 575.98px) {
  .account-switch { font-size: 1.5rem; }
  /* En pantallas angostas el indicador muestra solo el ícono; el texto queda para lectores de pantalla. */
  .status-pill { padding: 6px 8px; }
  .status-pill .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.status-pill.is-offline { color: var(--fc-warning); }
button.status-pill { border: 0; cursor: pointer; }
.install-pill { color: var(--fc-accent); margin-right: 6px; }
/* El texto "Instalar" se ve siempre (un ícono de flecha solo se confundiría con "exportar"). */
.install-pill .pill-text { position: static !important; width: auto !important; height: auto !important; clip: auto !important; overflow: visible !important; font-weight: 600; }
/* En escritorio el botón vive en la barra lateral. */
@media (min-width: 992px) { .install-pill { display: none; } }
.side-install { width: 100%; background: none; border: 0; text-align: left; }

.install-guide { text-align: left; }
.install-guide .install-icon { display: block; width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 14px; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12); }
.install-guide p { color: var(--fc-text-2); margin-bottom: 14px; }
.install-steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 12px; }
.install-steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; line-height: 1.45; }
.install-steps li::before {
  content: counter(step); width: 28px; height: 28px; border-radius: 50%;
  background: var(--fc-accent-soft); color: var(--fc-accent); font-weight: 700; font-size: 0.875rem;
  display: grid; place-items: center;
}
.step-icon { display: inline-flex; vertical-align: -3px; color: var(--fc-accent); }
.status-pill.is-pending { color: var(--fc-accent); }

.shared-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; color: var(--fc-text-2); font-weight: 500;
}

/* ---------- Selector de período ---------- */

/* Nombre de la pantalla encima de la cuenta activa (Movimientos, Resumen). */
.screen-label {
  margin: 0 0 2px; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fc-text-2);
}
/* En el celular ocupa todo el ancho, como el período; en pantallas grandes, solo lo necesario. */
.period-kind { width: 100%; }
@media (min-width: 768px) { .period-kind { max-width: 320px; } }

.period {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fc-surface); border-radius: var(--fc-radius); box-shadow: var(--fc-shadow);
  padding: 4px; margin-bottom: 12px;
}
.period .label { font-weight: 600; }

/* Filtro por persona de Inicio: etiqueta y selector en una fila, a todo el ancho en el celular. */
.person-filter { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; }
.person-filter .form-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--fc-text-2); }
.person-filter .form-select { flex: 1; }
@media (min-width: 768px) { .person-filter .form-select { flex: 0 1 260px; } }
/* Quién registró el movimiento: discreto, junto a la fecha. */
/* Debajo del importe, discreto: fecha (en Inicio) e iniciales de quién es el movimiento. */
.tx-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px;
  font-size: 0.6875rem; line-height: 1; color: var(--fc-text-2); white-space: nowrap;
}
.tx-meta .sep { color: var(--fc-text-3); }
.who-tag { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; letter-spacing: 0.04em; }
.who-tag .icon { width: 11px; height: 11px; }
/* Movimiento de un período ya compensado que no entró en la compensación. */
.missed-tag { display: inline-flex; vertical-align: -2px; margin-right: 5px; color: var(--fc-warning); }
.missed-tag .icon { width: 15px; height: 15px; }
.period .label::first-letter { text-transform: uppercase; }
.btn-icon {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; background: none; color: var(--fc-accent); border-radius: 10px;
}
.btn-icon:hover { background: var(--fc-fill); }
.btn-icon:disabled { color: var(--fc-text-3); background: none; }

/* ---------- Resumen ---------- */

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary .card-fc { margin: 0; min-width: 0; }
.summary .balance { grid-column: 1 / -1; }
/* Egresos e Ingresos de Inicio: tocar la tarjeta registra un movimiento de ese tipo. */
.stat-link { display: block; color: inherit; text-decoration: none; transition: background-color 0.15s; }
.stat-link:hover { background: var(--fc-surface-2); color: inherit; }
.stat-link:focus-visible { box-shadow: var(--fc-focus); outline: 0; }
.stat-link:active { transform: scale(0.99); }
.stat-add { margin-left: auto; color: var(--fc-accent); display: inline-flex; }
.stat-label { font-size: 0.8125rem; color: var(--fc-text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: clamp(1.0625rem, 4.4vw, 1.375rem); overflow-wrap: anywhere; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }

/* ---------- Gráfico ---------- */

.chart-wrap { position: relative; width: 100%; }
/* Anillo de gastos: el total va en el centro, como HTML (nítido y con el color del aspecto). */
.donut-wrap { position: relative; width: min(240px, 72%); aspect-ratio: 1; margin: 4px auto 8px; }
/* El lienzo no debe dar tamaño a su contenedor (Chart.js lo agranda en bucle): ocupa el cuadrado. */
.donut-wrap canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center; padding: 0 22%;
}
.donut-center .donut-label { font-size: 0.8125rem; color: var(--fc-text-2); }
.donut-center .donut-total { font-size: clamp(1.05rem, 4.6vw, 1.375rem); font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); flex-shrink: 0; }
.cat-item.is-active { background: var(--fc-surface-2); }
.cat-list { list-style: none; padding: 0; margin: 8px 0 0; }
.cat-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  width: 100%; padding: 10px 4px; background: none; border: 0; text-align: left; color: inherit;
  border-top: 1px solid var(--fc-separator); border-radius: 0;
}
.cat-item:first-child { border-top: 0; }
.cat-item:hover { background: var(--fc-surface-2); }
.cat-item .cat-name { font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-item .cat-pct { font-size: 0.8125rem; color: var(--fc-text-2); font-variant-numeric: tabular-nums; }
.cat-bar { grid-column: 1 / -1; height: 6px; background: var(--fc-fill); border-radius: 3px; overflow: hidden; }
.cat-bar > span { display: block; height: 100%; background: var(--dot, var(--fc-accent)); border-radius: 3px; }
.cat-item .cat-end { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.cat-item .cat-chevron { color: var(--fc-text-3); }
/* Desglose de una categoría: volver, nombre y registrar en ella. */
.drill-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin: -4px -4px 4px; }
.drill-head .btn { min-height: 36px; display: inline-flex; align-items: center; gap: 2px; }
.drill-title { font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; }

/* ---------- Controles segmentados y chips ---------- */

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--fc-fill); border-radius: 10px; padding: 2px; gap: 2px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  text-align: center; padding: 7px 10px; border-radius: 8px; font-weight: 500; font-size: 0.9375rem;
  cursor: pointer; user-select: none; color: var(--fc-text); min-height: 36px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented input:checked + label { background: var(--fc-segment-on); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
.segmented input:focus-visible + label { box-shadow: var(--fc-focus); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  min-height: 36px; padding: 6px 12px; border-radius: 999px;
  background: var(--fc-surface); border: 1px solid var(--fc-separator); color: var(--fc-text);
  font-size: 0.9375rem; font-weight: 500; cursor: pointer;
}
.chip:hover { background: var(--fc-surface-2); }
.chip[aria-pressed='true'], .chip[aria-checked='true'], .chip.is-active {
  background: var(--fc-accent); border-color: var(--fc-accent); color: var(--fc-on-accent);
}
.chip .icon { width: 18px; height: 18px; }
/* Acción dentro de una fila de chips (crear categoría): borde punteado para no confundirla con una opción. */
.chip-add { border-style: dashed; color: var(--fc-accent); background: transparent; }
.chip-add:hover { background: var(--fc-accent-soft); }

/* ---------- Formularios ---------- */

.form-fc .form-label { font-size: 0.8125rem; font-weight: 600; color: var(--fc-text-2); margin-bottom: 6px; }
.form-control, .form-select {
  background-color: var(--fc-surface); border-color: var(--fc-separator); color: var(--fc-text);
  border-radius: var(--fc-radius-sm); min-height: 44px; font-size: 1rem;
}
.form-control:focus, .form-select:focus { border-color: var(--fc-accent); box-shadow: var(--fc-focus); background-color: var(--fc-surface); color: var(--fc-text); }
.form-control::placeholder { color: var(--fc-text-3); }
.form-control:disabled, .form-select:disabled { background-color: var(--fc-surface-2); color: var(--fc-text-2); }
.form-text { color: var(--fc-text-2); }
.invalid-feedback { color: var(--fc-danger); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--fc-danger); }

.amount-field {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--fc-surface); border-radius: var(--fc-radius); padding: 14px 16px;
  border: 1px solid transparent; box-shadow: var(--fc-shadow);
}
.amount-field:focus-within { border-color: var(--fc-accent); box-shadow: var(--fc-focus); }
.amount-field.is-invalid { border-color: var(--fc-danger); }
.amount-field .currency { font-size: 1.25rem; font-weight: 600; color: var(--fc-text-2); }
.amount-field input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fc-text);
  font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.amount-field input:focus-visible { box-shadow: none !important; }

.btn { border-radius: 12px; min-height: 44px; font-weight: 600; padding-inline: 18px; }
.btn-primary { --bs-btn-bg: var(--fc-accent); --bs-btn-border-color: var(--fc-accent); --bs-btn-hover-bg: var(--fc-accent-strong); --bs-btn-hover-border-color: var(--fc-accent-strong); --bs-btn-active-bg: var(--fc-accent-strong); --bs-btn-disabled-bg: var(--fc-accent); --bs-btn-disabled-border-color: var(--fc-accent); }
.btn-tinted { background: var(--fc-accent-soft); color: var(--fc-accent); border: 0; }
.btn-tinted:hover { background: var(--fc-accent-soft); color: var(--fc-accent-strong); filter: brightness(0.97); }
.btn-plain { background: none; border: 0; color: var(--fc-accent); }
.btn-plain:hover { color: var(--fc-accent-strong); background: var(--fc-fill); }
.btn-danger-plain { background: none; border: 0; color: var(--fc-danger); }
.btn-danger-plain:hover { background: rgba(198, 47, 47, 0.08); color: var(--fc-danger); }
.btn-gray { background: var(--fc-fill); color: var(--fc-text); border: 0; }
.btn-gray:hover { background: var(--fc-fill-strong); color: var(--fc-text); }

.form-actions {
  position: sticky; bottom: calc(var(--fc-tabbar-h) + var(--fc-safe-bottom) + 8px);
  display: flex; gap: 12px; margin-top: 20px; padding-top: 8px;
  background: linear-gradient(to bottom, transparent, var(--fc-bg) 30%);
}
.form-actions .btn { flex: 1; }

/* ---------- Barra de pestañas / navegación lateral ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  height: calc(var(--fc-tabbar-h) + var(--fc-safe-bottom));
  padding-bottom: var(--fc-safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--fc-surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--fc-separator);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; color: var(--fc-text-3); text-decoration: none; font-size: 0.6875rem; font-weight: 500;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current='page'] { color: var(--fc-accent); }
.tab-add { display: grid; place-items: center; }
.tab-add a {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fc-accent); color: var(--fc-on-accent);
  box-shadow: 0 4px 14px rgba(42, 120, 214, 0.35);
}
.tab-add a:hover { background: var(--fc-accent-strong); }
.tab-add .icon { width: 26px; height: 26px; }

.sidebar { display: none; }

@media (min-width: 992px) {
  .tabbar { display: none; }
  .main { padding: 32px 40px 48px; }
  .form-actions { bottom: 16px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    width: 248px; flex-shrink: 0; padding: 28px 16px;
    position: sticky; top: 0; height: 100vh;
    border-right: 1px solid var(--fc-separator); background: var(--fc-surface-2);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 8px; padding: 2px 10px 22px; color: inherit; text-decoration: none; }
  .sidebar .brand img { width: 38px; height: auto; }
  .sidebar .brand .wordmark { font-size: 1.0625rem; }
  .side-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
    color: var(--fc-text); text-decoration: none; font-weight: 500; min-height: 40px;
  }
  .side-link .icon { color: var(--fc-accent); }
  .side-link:hover { background: var(--fc-fill); }
  .side-link[aria-current='page'] { background: var(--fc-accent); color: var(--fc-on-accent); }
  .side-link[aria-current='page'] .icon { color: var(--fc-on-accent); }
  .sidebar .side-cta { margin-bottom: 12px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .sidebar .side-foot { margin-top: auto; font-size: 0.75rem; color: var(--fc-text-3); padding: 0 10px; }
}

@media (min-width: 768px) {
  .summary { grid-template-columns: 1fr 1fr 1fr; }
  .summary .balance { grid-column: auto; }
}

/* Dos columnas solo con ancho útil suficiente (sin barra lateral, o pantallas grandes). */
@media (min-width: 768px) and (max-width: 991.98px), (min-width: 1200px) {
  .home-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
}

/* ---------- Estados ---------- */

.empty {
  text-align: center; padding: 32px 16px; color: var(--fc-text-2);
}
.empty .icon { width: 40px; height: 40px; color: var(--fc-text-3); margin-bottom: 8px; }
.empty h2 { font-size: 1.0625rem; font-weight: 600; color: var(--fc-text); margin-bottom: 4px; }
.empty p { margin-bottom: 12px; font-size: 0.9375rem; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--fc-accent-soft); color: var(--fc-text); border-radius: var(--fc-radius-sm);
  padding: 12px 14px; font-size: 0.875rem;
}
.notice .icon { color: var(--fc-accent); margin-top: 1px; }
.notice.is-warning { background: rgba(242, 181, 68, 0.16); }
.notice.is-warning .icon { color: var(--fc-warning); }
.notice.is-success .icon { color: var(--fc-income); }

/* Tabla del resumen de la cuenta compartida. */
.table-fc { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table-fc th, .table-fc td { padding: 12px 14px; text-align: left; vertical-align: top; border-top: 1px solid var(--fc-separator); }
.table-fc thead th { border-top: 0; font-size: 0.75rem; font-weight: 600; color: var(--fc-text-2); text-transform: uppercase; letter-spacing: 0.02em; }
.table-fc tbody th { font-weight: 600; }
.table-fc .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-fc .row-sub { font-weight: 400; white-space: normal; }
.amount-field-sm { padding: 8px 12px; box-shadow: none; border-color: var(--bs-border-color); }
.amount-field-sm input { font-size: 1.25rem; }
.amount-field-sm .currency { font-size: 1rem; }
/* Tarjeta de Inicio con el resumen de la cuenta compartida. */
.settle-card { display: block; color: inherit; text-decoration: none; }
.settle-card:hover { background: var(--fc-surface-2); }
.settle-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.settle-head .chevron { color: var(--fc-text-3); }
.settle-line { display: flex; gap: 8px; align-items: baseline; font-size: 0.9375rem; padding: 4px 0; }
.settle-line .icon { color: var(--fc-warning); flex: none; position: relative; top: 2px; }
.settle-line.is-done .icon { color: var(--fc-income); }
/* Cuenta compartida en el formulario de movimiento. */
.payer-block { border-top: 1px solid var(--fc-separator); padding-top: 12px; }

.badge-fc {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 600; border-radius: 6px; padding: 2px 8px;
  background: var(--fc-fill); color: var(--fc-text-2);
}
.badge-fc.is-accent { background: var(--fc-accent-soft); color: var(--fc-accent); }
.badge-fc.is-warning { background: rgba(242, 181, 68, 0.18); color: var(--fc-warning); }
.badge-fc.is-danger { background: rgba(198, 47, 47, 0.1); color: var(--fc-danger); }

.skeleton { background: var(--fc-fill); border-radius: 8px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------- Avisos (toasts) ---------- */

.toast-stack {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 2000;
  bottom: calc(var(--fc-tabbar-h) + var(--fc-safe-bottom) + 12px);
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 992px) { .toast-stack { bottom: 24px; } }
.toast-fc {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--fc-text) 92%, transparent); color: var(--fc-bg);
  padding: 12px 14px; border-radius: 14px; font-size: 0.9375rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.2s ease-out;
}
.toast-fc .icon { flex-shrink: 0; }
.toast-fc .toast-msg { flex: 1; }
.toast-fc button { background: none; border: 0; color: inherit; font-weight: 700; padding: 4px 6px; border-radius: 6px; }
.toast-fc.is-error { background: var(--fc-danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Modales ---------- */

.modal-content {
  background: var(--fc-surface); color: var(--fc-text);
  border: 0; border-radius: 18px;
}
.modal-header, .modal-footer { border-color: var(--fc-separator); }
.modal-title { font-weight: 600; font-size: 1.0625rem; }
.modal-backdrop.show { opacity: 0.35; }
@media (max-width: 575.98px) {
  .modal-dialog.sheet { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; min-height: 0; display: block; }
  .modal-dialog.sheet .modal-content { border-radius: 18px 18px 0 0; padding-bottom: var(--fc-safe-bottom); }
  .modal.fade .modal-dialog.sheet { transform: translateY(40px); }
  .modal.show .modal-dialog.sheet { transform: none; }
}
.sheet-actions { display: grid; gap: 8px; }
.sheet-actions .btn { width: 100%; }

.dropdown-menu {
  background: var(--fc-surface); border: 1px solid var(--fc-separator); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14); padding: 6px; min-width: 260px;
  --bs-dropdown-link-color: var(--fc-text);
  --bs-dropdown-link-hover-bg: var(--fc-fill);
  --bs-dropdown-link-hover-color: var(--fc-text);
  --bs-dropdown-link-active-bg: var(--fc-accent);
  --bs-dropdown-divider-bg: var(--fc-separator);
  --bs-dropdown-header-color: var(--fc-text-3);
}
.dropdown-item { border-radius: 8px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }

/* ---------- Ingreso ---------- */

.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.login-card { width: min(400px, 100%); text-align: center; }
.login-card .logo { width: 132px; height: auto; margin-bottom: 18px; }
.login-card .wordmark { display: block; font-size: 1.875rem; margin-bottom: 8px; }
.login-card .lead { color: var(--fc-text-2); font-size: 1rem; margin-bottom: 28px; }
.legal-links { color: var(--fc-text-3); }
.legal-links a { color: var(--fc-text-2); text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }
.gsi-slot { display: flex; justify-content: center; min-height: 44px; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--fc-text-3); font-size: 0.8125rem; margin: 20px 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--fc-separator); }

/* ---------- Accesibilidad y movimiento ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .chip[aria-pressed='true'], .chip[aria-checked='true'] { border: 2px solid CanvasText; }
  .cat-bar > span { background: CanvasText; }
}

/* ---------- Planes ---------- */

.notice.is-danger { background: rgba(198, 47, 47, 0.1); }
.notice.is-danger .icon { color: var(--fc-danger); }
.badge-fc.is-premium { background: rgba(242, 181, 68, 0.2); color: var(--fc-warning); }
.icon.icon-xs { width: 12px; height: 12px; }
.plan-card { height: 100%; display: flex; flex-direction: column; }
.plan-card.is-premium { border: 2px solid var(--fc-accent); }
.plan-card.is-current { box-shadow: 0 0 0 2px var(--fc-accent-soft); }
.plan-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.plan-head h2 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.plan-tagline { color: var(--fc-text-2); font-size: 0.9375rem; margin-bottom: 12px; }
.plan-features { list-style: none; padding: 0; margin: 0 0 16px; flex-grow: 1; }
.plan-features li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 0.9375rem; border-top: 1px solid var(--fc-separator); }
.plan-features li:first-child { border-top: 0; }
.plan-features .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--fc-income); }
.plan-features .is-limit .icon { color: var(--fc-warning); }
.plan-features .is-no { color: var(--fc-text-3); }
.plan-features .is-no .icon { color: var(--fc-text-3); }
.plan-features .is-soon .icon { color: var(--fc-text-3); }
.plan-subtitle { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--fc-text-2); margin: 8px 0 4px; }
.notice.is-accent-strong { background: var(--fc-accent-soft); border: 1px solid var(--fc-accent); }
