/* ---------- Fuentes ---------- */

/* Outfit (Google Fonts, licencia libre OFL). Se guarda en /fonts para que ande offline. */
@font-face {
  font-family: 'Outfit';
  src: url('../fonts/outfit-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark;
  /* Oscuro fijo. El color aparece solo donde informa: categorías, montos y barras de presupuesto. */
  --bg: #070a0f;
  --surface: #10151d;
  --surface-2: #171e29;
  --surface-3: #202938;
  --border: #222b39;
  --text: #eef2f7;
  --muted: #8593a6;
  --accent: #1fbf8f; /* verde de los botones principales */
  --accent-strong: #17a67c;
  --on-accent: #03140e;
  --accent-soft: rgba(31, 191, 143, 0.14);
  --pos: #34d399;
  --neg: #f87171;
  --warn: #f5b942;
  --danger: #ff6b6b;
  --card-grad: linear-gradient(150deg, #1d9c8a 0%, #127066 60%, #0e5a55 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  --font-brand: 'Outfit', var(--font-fallback);
  --font-fallback: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Vidrio estilo Liquid Glass (iOS 26): barra de abajo, pastilla del mes y botón Anotar. */
  --glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04) 45%, rgba(255, 255, 255, 0.06));
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-blur: blur(18px) saturate(180%);
  --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 1px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: inherit;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
}

input::placeholder,
textarea::placeholder {
  color: #5b6879;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238593a6' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 34px;
}

input[type='checkbox'] {
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 6px;
}

code.block {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  word-break: break-all;
  line-height: 1.5;
}

code i {
  color: var(--accent);
  font-style: normal;
}

/* ---------- Layout ---------- */

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

.content {
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 120px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-screen .content {
  padding-bottom: 24px;
  flex: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar.main {
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
  justify-content: space-between;
}

.topbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-title svg {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  min-width: 40px;
  justify-content: flex-end;
}

.brand-title {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.2px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background 0.15s;
}

.icon-btn:active {
  background: var(--surface-2);
}

.icon-btn.sm {
  width: 32px;
  height: 32px;
  color: var(--muted);
}

.icon-btn.sm svg {
  width: 18px;
  height: 18px;
}

.icon-btn.danger {
  color: var(--danger);
}

/* ---------- Botones ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 600;
  width: 100%;
  text-align: center;
  transition: transform 0.12s var(--ease), background 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.primary:active:not(:disabled) {
  background: var(--accent-strong);
}

.btn.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.btn.link {
  min-height: 40px;
  color: var(--muted);
  font-weight: 500;
}

.btn.link.danger {
  color: var(--danger);
}

.btn.sm {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 11px;
  width: auto;
}

.btn.sm svg {
  width: 16px;
  height: 16px;
}

.btn.ghost {
  color: var(--muted);
}

.banner .btn.sm {
  background: var(--surface-3);
}

.link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.link svg {
  width: 16px;
  height: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.pill svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

/* ---------- Tarjetas y filas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card.pad {
  padding: 16px;
}

.card.list {
  overflow: hidden;
}

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.sec-head h2 {
  font-size: 15px;
  font-weight: 600;
}

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 2px -4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Adentro de una tarjeta, el título necesita aire arriba y abajo. */
.card .label {
  margin: 14px 2px 10px;
}

.card .sec-head + .label {
  margin-top: 4px;
}

.label svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.muted-sm {
  color: var(--muted);
  font-size: 13px;
}

.center {
  text-align: center;
  justify-content: center;
}

.pos {
  color: var(--pos);
}

.neg {
  color: var(--neg);
}

.warn-text {
  color: var(--warn) !important;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.cat-ico {
  --c: #94a3b8;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
}

.cat-ico.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.cat-ico.sm svg {
  width: 16px;
  height: 16px;
}

.cat-ico.xs {
  width: 22px;
  height: 22px;
  border-radius: 7px;
}

.cat-ico.xs svg {
  width: 13px;
  height: 13px;
}

.mov,
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  transition: background 0.15s;
}

.mov + .mov,
.row + .row,
.fx-row + .fx-row {
  border-top: 1px solid var(--border);
}

.mov:active,
button.row:active {
  background: var(--surface-2);
}

.row > svg:last-child {
  color: var(--muted);
  width: 18px;
  height: 18px;
}

.row-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.row-ico svg {
  width: 18px;
  height: 18px;
}

.mov-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mov-main b {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mov-main small {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}

.mov-amt {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mov-amt.ingreso {
  color: var(--pos);
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

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

/* La fecha queda pegada arriba mientras se ven los gastos de ese día (--sticky-top lo pone mount()). */
.day-head {
  position: sticky;
  top: var(--sticky-top, 0px);
  z-index: 5;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 4px 6px;
  margin: -4px 0 -4px;
  background: var(--bg);
}

.day-head span:first-child::first-letter {
  text-transform: uppercase;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}

.empty svg {
  width: 34px;
  height: 34px;
  color: #3c4757;
  margin-bottom: 4px;
}

.empty p {
  color: var(--text);
  font-weight: 600;
}

.empty .btn {
  margin-top: 12px;
  width: auto;
}

/* ---------- Barras ---------- */

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  animation: grow 0.7s var(--ease);
}

.bar.warn i {
  background: var(--warn);
}

.bar.over i {
  background: var(--danger);
}

.t-ok {
  color: var(--accent);
}

.t-warn {
  color: var(--warn);
}

.t-over {
  color: var(--danger);
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

.budget-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.budget-box p {
  font-size: 13px;
  color: var(--muted);
}

.budget-box p b {
  color: var(--text);
}

.bb-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.bb-tag {
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
}

.budget-box.warn .bb-tag {
  color: var(--warn);
}

.budget-box.over .bb-tag {
  color: var(--danger);
}

/* ---------- Inicio ---------- */

.spent {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 18px 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent) 0%, transparent 60%),
    var(--surface);
}

.spent-label {
  color: var(--muted);
  font-size: 14px;
}

.spent-amount {
  font-family: var(--font-brand);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  animation: rise 0.35s var(--ease);
}

.spent small {
  color: var(--muted);
  font-size: 13px;
}

.spent.small .spent-amount {
  font-size: 36px;
}

.spent .compare {
  padding: 4px 0 0;
}

.sec-title {
  font-size: 15px;
  font-weight: 600;
}

.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  border: 1px solid var(--border);
}

/* Selector de mes: pastilla con el mes completo y flechas a los costados. */
.month-pill {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 36px;
  padding: 0 2px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 1px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  font-weight: 600;
}

.month-pill span {
  min-width: 74px;
  padding: 0 2px;
  text-align: center;
  white-space: nowrap;
}

.month-pill button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.month-pill button:active {
  background: var(--surface-3);
  color: var(--text);
}

.month-pill svg {
  width: 16px;
  height: 16px;
}

.spent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -6px -8px -4px 0;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  animation: rise 0.35s var(--ease);
}

.banner > svg:first-child {
  color: var(--muted);
}

.banner > svg:last-child {
  color: var(--muted);
  width: 18px;
  height: 18px;
}

.banner > span:not(.cat-ico) {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.banner small {
  color: var(--muted);
  font-size: 13px;
}

.banner.accent {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.banner.accent > svg:first-child {
  color: var(--accent);
}

.banner.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.banner.danger > svg:first-child {
  color: var(--danger);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.row-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0;
}

/* ---------- Barra de pestañas y botón + ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  width: min(528px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 28px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  z-index: 20;
}

.tab {
  height: 50px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #c7d0dc;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.tab svg {
  width: 20px;
  height: 20px;
}

.tab span {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* La pestaña activa es una "burbuja" de vidrio dentro de la barra. */
.tab.on {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
  color: #7ff0d0;
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - 264px));
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  height: 56px;
  min-width: 56px;
  padding: 0 16px;
  border-radius: 28px;
  /* Vidrio verde: deja ver lo que pasa por detrás, con brillo arriba. */
  background: linear-gradient(180deg, rgba(31, 191, 143, 0.62), rgba(31, 191, 143, 0.32));
  border: 1px solid rgba(180, 255, 230, 0.38);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #f2fffa;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 1px rgba(0, 0, 0, 0.2), 0 10px 28px rgba(31, 191, 143, 0.3);
  z-index: 21;
  overflow: hidden;
  white-space: nowrap;
  transition: transform 0.15s var(--ease), padding 0.25s var(--ease), gap 0.25s var(--ease);
}

.fab svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.6;
}

.fab:active {
  transform: scale(0.94);
}

.fab.wide {
  padding: 0 20px 0 16px;
}

.fab span {
  max-width: 80px;
  transition: max-width 0.25s var(--ease), opacity 0.2s;
}

/* Al bajar en la lista queda solo el "+" (ver syncFab en app.js). */
.fab.wide.small {
  padding: 0 16px;
  gap: 0;
}

.fab.wide.small span {
  max-width: 0;
  opacity: 0;
}

/* ---------- Anotar (una sola pantalla) ---------- */

.quick-form .content {
  gap: 16px;
}

.topbar-title.center {
  justify-content: center;
}

/* Anotar: otras formas de cargar (QR del ticket, lote), arriba del monto. */
.entry-modes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.entry-modes .pill-btn {
  align-self: auto;
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 2px 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 12px;
  color: #c7d0dc;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.12s var(--ease);
}

.cat-tile > span:not(.cat-ico) {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-tile:active {
  transform: scale(0.95);
}

.cat-tile.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.cat-tile.add {
  color: var(--muted);
}

.cat-tile.add > svg {
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
}

.desc-input {
  background: var(--surface);
}

.foot-hint {
  text-align: center;
  font-size: 13px;
}

.foot-hint:empty {
  display: none;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  transition: background 0.2s, color 0.2s;
}

.seg-btn.on {
  background: var(--accent);
  color: var(--on-accent);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 12px;
}

.search svg {
  color: var(--muted);
  width: 18px;
  height: 18px;
}

.search input {
  border: 0;
  background: transparent;
  padding: 11px 0;
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chip-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}

.chip-cat > span:not(.cat-ico) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chip-cat > svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.chip-cat.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip-cat.sm {
  padding: 5px 10px 5px 5px;
  font-size: 13px;
  border-radius: 999px;
}

.cat-list {
  display: flex;
  flex-direction: column;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-radius: 12px;
  width: 100%;
}

.cat-item > span:not(.cat-ico) {
  flex: 1;
}

.cat-item > svg:last-child {
  color: var(--accent);
}

.cat-item.on {
  background: var(--accent-soft);
}

.cat-item.add {
  color: var(--accent);
  font-weight: 600;
}

.cat-item.add svg {
  width: 40px;
}

/* ---------- Formulario del movimiento ---------- */

/* Recuadro suave del monto: se ilumina en verde mientras se escribe. */
.hero-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-amount:focus-within {
  border-color: rgba(31, 191, 143, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 4px var(--accent-soft), 0 8px 24px rgba(0, 0, 0, 0.25);
}

.hero-amount span {
  font-size: 34px;
  font-weight: 300;
  color: var(--muted);
}

.hero-amount input {
  border: 0;
  outline: none;
  background: transparent;
  font-size: 46px;
  font-weight: 600;
  text-align: center;
  padding: 4px 0;
  width: 70%;
  font-variant-numeric: tabular-nums;
}

.hero-amount.ingreso input {
  color: var(--pos);
}

.date-chip {
  position: relative;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  color: #c7d0dc;
}

.date-chip svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}


.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field-label em {
  font-weight: 400;
  font-style: normal;
  opacity: 0.8;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.field-row .field-label {
  width: 78px;
}

.field-val {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-row > svg:last-child {
  color: var(--muted);
  width: 18px;
  height: 18px;
}

@keyframes pop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}

.pill-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 14px;
  color: #c7d0dc;
}

.pill-btn svg {
  width: 16px;
  height: 16px;
}

.pill-btn.on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.rec-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: rise 0.25s var(--ease);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #c7d0dc;
}

.note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.note svg {
  width: 16px;
  height: 16px;
}

.form-foot {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  font-size: 15px;
  color: #c7d0dc;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch {
  width: 46px;
  height: 28px;
  border-radius: 99px;
  background: var(--surface-3);
  position: relative;
  transition: background 0.2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}

.switch-row input:checked + .switch {
  background: var(--accent);
}

.switch-row input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.amount-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.amount-inline span {
  color: var(--muted);
  font-weight: 600;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.two .btn.sm {
  width: 100%;
}

/* ---------- Historial ---------- */

.filters {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

.filters select {
  background-color: var(--surface);
  font-size: 14px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.summary-line {
  font-size: 13px;
  color: var(--muted);
  padding: 0 4px;
}

/* ---------- Análisis ---------- */

.stack {
  display: flex;
  gap: 2px;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
  transform-origin: left;
  animation: grow 0.7s var(--ease);
}

.stack-seg {
  min-width: 4px;
  height: 100%;
  flex-basis: 0;
  transition: opacity 0.15s;
}

.stack:has(.hl) .stack-seg:not(.hl) {
  opacity: 0.35;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
  transition: background 0.15s;
}

.legend-row + .legend-row {
  border-top: 1px solid var(--border);
}

/* Análisis: gasto por semana (una barrita por semana) y promedio por categoría. */
.week-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.week-lbl {
  display: flex;
  flex-direction: column;
  color: var(--muted);
}

.week-lbl small {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.week-row.on .week-lbl {
  color: var(--text);
}

.week-bar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.week-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

.week-row.on .week-bar i {
  background: var(--accent);
}

.week-row b {
  font-variant-numeric: tabular-nums;
  min-width: 76px;
  text-align: right;
}

.avg-total {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 4px;
}

.avg-total b {
  color: var(--text);
}

.legend-row.hl {
  background: var(--surface-2);
}

.legend-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.legend-name small,
.legend-val small {
  font-size: 12px;
}

.legend-val {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.legend-val small {
  color: var(--muted);
}

.compare {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 0 4px;
}

.compare svg {
  width: 16px;
  height: 16px;
}

.proj {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.proj div {
  display: flex;
  flex-direction: column;
}

.proj small {
  color: var(--muted);
  font-size: 12px;
}

.proj b {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.proj + .bar + .muted-sm,
.proj + .muted-sm {
  margin-top: 8px;
}

.bud-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0 4px;
}

.bud-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.bud-del {
  width: 30px;
  height: 30px;
  margin-right: -6px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}

.bud-del svg {
  width: 16px;
  height: 16px;
}

.bud-del:active {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.bud-row + .bud-row {
  border-top: 1px solid var(--border);
}

.bud-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bud-top b {
  flex: 1;
  font-weight: 600;
}

.bud-top span {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.bud-top small {
  color: var(--muted);
}

.bud-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Gastos por mes ---------- */

.mchart {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 170px;
}

.mbar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mbar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.mbar-track i {
  width: 100%;
  max-width: 24px;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--accent) 35%, var(--surface-3));
  transform-origin: bottom;
  animation: grow-y 0.6s var(--ease);
  transition: background 0.2s;
}

.mbar.on .mbar-track i {
  background: var(--accent);
}

.mbar-lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
}

.mbar.on .mbar-lbl {
  color: var(--text);
  font-weight: 600;
}

.mchart.still .mbar-track i {
  animation: none;
}

@keyframes grow-y {
  from {
    transform: scaleY(0);
  }
}

.month-row small {
  display: flex;
  align-items: center;
  gap: 2px;
}

.month-row small.neg {
  color: var(--neg);
}

.month-row small.pos {
  color: var(--pos);
}

.month-row small svg {
  width: 13px;
  height: 13px;
}

.month-row.on {
  background: var(--surface-2);
}

/* ---------- Carga en lote ---------- */

.batch-text {
  min-height: 220px;
  resize: vertical;
  font-size: 16px;
  line-height: 1.6;
  background: var(--surface);
}

.processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 0 6px;
  color: var(--muted);
  animation: rise 0.2s var(--ease);
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.proc-bar {
  width: 70%;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.proc-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  animation: fill 0.7s ease-in-out forwards;
}

/* Barra que sigue el avance real (lectura de la foto). */
.proc-bar i.live {
  width: 0;
  animation: none;
  transition: width 0.3s ease;
}

/* Carga en lote: botón para sacar foto de una lista o ticket. */
.photo-btn {
  align-self: stretch;
  justify-content: center;
  padding: 11px 14px;
  cursor: pointer;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.photo-btn.busy {
  opacity: 0.5;
  pointer-events: none;
}

@keyframes fill {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

.batch-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.batch-total small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.batch-total b {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.batch-total span {
  font-size: 13px;
}

.batch-total .t-ok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.batch-total .t-ok svg {
  width: 14px;
  height: 14px;
}

/* Escáner: el botón de foto se destaca cuando hace falta (TIQUE sin monto en el QR, o sin cámara). */
.sheet-btn.pulse {
  background: var(--accent);
  color: var(--on-accent);
  animation: pulse 1.4s ease-in-out 2;
}

@keyframes pulse {
  50% {
    transform: scale(1.03);
  }
}

.info-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-top: -4px;
}

.info-line svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.warn-card {
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.warn-card b {
  color: var(--warn);
  font-size: 14px;
}

#bitems {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.batch-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: rise 0.3s var(--ease) backwards;
}

.batch-item:nth-child(2) {
  animation-delay: 0.04s;
}

.batch-item:nth-child(3) {
  animation-delay: 0.08s;
}

.batch-item:nth-child(n + 4) {
  animation-delay: 0.12s;
}

.batch-item.unclassified {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.bi-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.bi-desc {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  border-radius: 0;
  background: transparent;
  font-weight: 600;
}

.bi-desc:focus {
  border-bottom-color: var(--border);
}

.bi-cat {
  --c: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.unclassified .bi-cat {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

.bi-cat svg {
  width: 14px;
  height: 14px;
}

.bi-date {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.bi-date svg {
  width: 13px;
  height: 13px;
}

.bi-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
}

.bi-amt {
  display: flex;
  align-items: center;
  gap: 2px;
}

.bi-sign {
  width: 24px;
  height: 30px;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
  background: var(--surface-2);
}

.bi-amt.ingreso .bi-sign,
.bi-amt.ingreso input {
  color: var(--pos);
}

.bi-amount {
  width: 104px;
  padding: 5px 6px;
  text-align: right;
  font-weight: 600;
  border: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
}

/* ---------- Fijos y pendientes ---------- */

.fx-row {
  display: flex;
  align-items: center;
  padding-right: 8px;
}

.fx-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 12px 8px 12px 14px;
  text-align: left;
}

.fx-row.paused .fx-main {
  opacity: 0.5;
}

.up-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  padding: 6px 0;
}

.up-row span:nth-child(2) {
  flex: 1;
}

.up-date {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 13px;
}

.pend {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.3s var(--ease);
}

.pend-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pend-amount {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 600;
}

.pend-amount span {
  color: var(--muted);
}

.pend-amount input {
  font-size: 20px;
  font-weight: 600;
  padding: 8px 12px;
}

.pend-amount.ingreso input {
  color: var(--pos);
}

.pend-actions {
  display: flex;
  gap: 8px;
}

.pend-actions .btn:first-child {
  flex: 1;
}

/* ---------- Sin clasificar ---------- */

.unc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.25s, transform 0.25s var(--ease);
}

.unc.leaving {
  opacity: 0;
  transform: translateX(30px);
}

.unc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-row .chip-cat > span:not(.cat-ico) {
  flex: none;
}

/* ---------- Hojas (dialog) ---------- */

.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet[open] {
  animation: sheet-up 0.28s var(--ease);
}

@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.sheet-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 88dvh;
  overflow-y: auto;
}

.sheet-body.tall {
  min-height: 60dvh;
}

.sheet-title {
  font-weight: 700;
  font-size: 17px;
  text-align: center;
  margin-bottom: 4px;
}

.sheet-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: -4px;
}

.sheet-message {
  text-align: center;
  color: #c7d0dc;
  padding: 6px 6px 10px;
}

.sheet-input {
  font-size: 18px;
  padding: 14px;
}

.sheet-input.amount {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
}

.sheet-btn {
  min-height: 50px;
  border-radius: 14px;
  background: var(--surface-2);
  font-weight: 600;
  text-align: center;
  width: 100%;
}

label.sheet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.sheet-btn svg {
  width: 18px;
  height: 18px;
}

/* Escáner de QR: la imagen de la cámara con un marco en el medio. */
.scan-view {
  position: relative;
  aspect-ratio: 1;
  max-height: 46dvh;
  margin: 0 auto 4px;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

.scan-view {
  touch-action: none;
}

.scan-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.1s linear;
}

.scan-zoom {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}

.scan-zoom[hidden],
.sheet-btn[hidden] {
  display: none;
}

.scan-zoom button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 30px;
  text-align: center;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.scan-zoom button.on {
  background: rgba(255, 255, 255, 0.22);
  color: var(--accent);
}

.scan-frame {
  position: absolute;
  inset: 18%;
  border: 3px solid var(--accent);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}

.scan-msg {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.scan-msg[hidden] {
  display: none;
}

.sheet-btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.sheet-btn.danger {
  color: var(--danger);
}

.sheet-btn.cancel {
  background: transparent;
  color: var(--muted);
}

.sheet .picker {
  overflow-y: auto;
}

/* Tarjeta centrada de "Gasto rápido" */
.sheet.center {
  margin: auto;
  width: calc(100% - 32px);
  max-width: 420px;
}

.sheet.center[open] {
  animation: card-in 0.32s var(--ease);
}

@keyframes card-in {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
}

.qcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.qcard:focus {
  outline: none;
}

.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
}

.q-head span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.q-head span svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.q-cat {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.q-cat > span:not(.cat-ico) {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.q-cat b {
  font-size: 17px;
}

.q-cat small {
  color: var(--muted);
  font-size: 13px;
}

.q-cat > svg:last-child {
  color: var(--muted);
  width: 16px;
  height: 16px;
}

.q-amount {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.q-amount.ingreso {
  color: var(--pos);
}

/* ---------- Calendario propio ---------- */

.cal {
  gap: 12px;
}

.cal-quick {
  display: flex;
  gap: 8px;
}

.cal-quick button {
  flex: 1;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600;
  text-align: center;
}

.cal-quick button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.cal-head b {
  font-family: var(--font-brand);
  font-size: 19px;
}

.cal-head button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.cal-head button:active {
  background: var(--surface-3);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  justify-items: center;
}

.cal-wd {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 4px;
}

.cal-day {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s;
}

.cal-day:active {
  background: var(--surface-3);
}

.cal-day.future {
  color: var(--muted);
}

.cal-day.today {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.cal-day.sel {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: none;
}

/* ---------- Avisos y animación al guardar ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 150px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s var(--ease);
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Barra "Deshacer" después de guardar (por encima del cartel de guardado). */
.undo-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 156px); /* arriba del botón Anotar */
  transform: translate(-50%, 20px);
  width: min(360px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.25s var(--ease);
  z-index: 75;
}

.undo-bar.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.undo-bar button {
  padding: 8px 14px;
  border-radius: 12px;
  color: var(--accent);
  font-weight: 700;
}

.undo-bar button:active {
  background: var(--accent-soft);
}

.celebrate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 10, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 70;
  pointer-events: none;
  animation: fade-in 0.18s ease;
  transition: opacity 0.3s;
}

.celebrate.out {
  opacity: 0;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.celebrate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 26px;
  max-width: 300px;
  text-align: center;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: card-in 0.35s var(--ease);
}

.celebrate-card b {
  font-size: 18px;
}

.celebrate-card p {
  font-size: 14px;
  font-weight: 600;
}

.alert-warn {
  color: var(--warn);
}

.alert-over {
  color: var(--danger);
}

.check-anim {
  width: 64px;
  height: 64px;
  stroke-width: 3;
}

.check-anim circle {
  stroke: var(--accent);
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
  animation: draw 0.5s var(--ease) forwards;
}

.check-anim path {
  stroke: var(--accent);
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw 0.35s 0.35s var(--ease) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}
