/* ==========================================================================
   Agenda — sistema visual
   Base neutra y cálida, un solo acento, mucho aire. Claro y oscuro.
   ========================================================================== */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --border: #e8e8e4;
  --border-strong: #d9d9d4;
  --text: #17171a;
  --text-2: #6e6e6b;
  --text-3: #a0a09c;
  --accent: #5b54e8;
  --accent-ink: #ffffff;
  --accent-soft: #efeefe;
  --pos: #0f7f57;
  --pos-soft: #e6f5ee;
  --neg: #c3384a;
  --neg-soft: #fcecee;
  --shadow-1: 0 1px 2px rgba(20, 20, 25, 0.05);
  --shadow-2: 0 4px 16px rgba(20, 20, 25, 0.08);
  --shadow-3: 0 16px 48px rgba(20, 20, 25, 0.16);

  --r-xs: 6px;
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --nav-w: 232px;
  --tab-h: 60px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111214;
    --surface: #17181b;
    --surface-2: #1f2126;
    --border: #272930;
    --border-strong: #363940;
    --text: #ededeb;
    --text-2: #9b9b99;
    --text-3: #6b6b69;
    --accent: #8f89ff;
    --accent-ink: #14121f;
    --accent-soft: #211f38;
    --pos: #45d195;
    --pos-soft: #14312a;
    --neg: #ff6f81;
    --neg-soft: #351f26;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-3: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme='dark'] {
  --bg: #111214;
  --surface: #17181b;
  --surface-2: #1f2126;
  --border: #272930;
  --border-strong: #363940;
  --text: #ededeb;
  --text-2: #9b9b99;
  --text-3: #6b6b69;
  --accent: #8f89ff;
  --accent-ink: #14121f;
  --accent-soft: #211f38;
  --pos: #45d195;
  --pos-soft: #14312a;
  --neg: #ff6f81;
  --neg-soft: #351f26;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, 0.6);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

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

button {
  background: none;
  border: 0;
  cursor: pointer;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

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

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.main {
  /* El hueco de abajo deja pasar la barra de pestañas Y el botón flotante,
     para que nunca tapen la última fila de la lista. */
  padding: 24px 20px calc(var(--tab-h) + env(safe-area-inset-bottom) + 92px);
  outline: none;
}

.view {
  max-width: 760px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--nav-w) 1fr;
  }
  .main {
    padding: 40px 40px 80px;
  }
}

/* ==========================================================================
   Navegación
   ========================================================================== */

.nav__brand {
  display: none;
}

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav__items {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: var(--tab-h);
}

.nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.nav__item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
}

.nav__item[aria-current='page'] {
  color: var(--accent);
}

@media (min-width: 900px) {
  .nav {
    position: sticky;
    top: 0;
    height: 100dvh;
    border-top: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    backdrop-filter: none;
    padding: 32px 14px;
    display: flex;
    flex-direction: column;
    gap: 28px;
  }
  .nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
  }
  .nav__mark {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--text);
    position: relative;
    flex: none;
  }
  .nav__mark::after {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    border: 1.5px solid var(--bg);
    border-top-color: transparent;
  }
  .nav__name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .nav__items {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    height: auto;
    gap: 2px;
  }
  .nav__item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
  }
  .nav__item svg {
    width: 18px;
    height: 18px;
  }
  .nav__item:hover {
    background: var(--surface-2);
    color: var(--text);
  }
  .nav__item[aria-current='page'] {
    background: var(--accent-soft);
    color: var(--accent);
  }
}

/* ==========================================================================
   Cabecera de vista
   ========================================================================== */

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.head__title {
  font-size: 26px;
  font-weight: 640;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.head__sub {
  color: var(--text-3);
  font-size: 13px;
  margin-top: 3px;
}

@media (min-width: 900px) {
  .head__title {
    font-size: 30px;
  }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    opacity 0.15s var(--ease), transform 0.08s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
  flex: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover {
  opacity: 0.88;
}

.btn--soft {
  background: var(--surface-2);
  color: var(--text);
}
.btn--soft:hover {
  background: var(--border);
}

.btn--outline {
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn--outline:hover {
  background: var(--surface-2);
}

.btn--ghost {
  color: var(--text-2);
}
.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  color: var(--neg);
}
.btn--danger:hover {
  background: var(--neg-soft);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
  color: var(--text-2);
}
.btn--icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

/* Botón flotante (sólo móvil) */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px);
  z-index: 35;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-2);
  transition: transform 0.12s var(--ease);
}
.fab:active {
  transform: scale(0.93);
}
.fab svg {
  width: 23px;
  height: 23px;
  stroke-width: 2;
}

@media (min-width: 900px) {
  .fab {
    display: none;
  }
}

/* En móvil las acciones de cabecera viven en el botón flotante. */
.head__actions {
  display: none;
}
@media (min-width: 900px) {
  .head__actions {
    display: flex;
    gap: 6px;
  }
}

/* ==========================================================================
   Superficies
   ========================================================================== */

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

.section-title {
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 28px 0 10px;
}

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-3);
}
.empty__icon {
  font-size: 26px;
  opacity: 0.5;
  margin-bottom: 10px;
}
.empty__title {
  color: var(--text-2);
  font-weight: 550;
  font-size: 14px;
}
.empty__text {
  font-size: 13px;
  margin-top: 3px;
}

/* ==========================================================================
   Calendario
   ========================================================================== */

.cal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
}

.cal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px;
}

.cal__month {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cal__nav {
  display: flex;
  gap: 2px;
}

.cal__dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.cal__dow span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 0;
}

.cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal__day {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: background 0.12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.cal__day:hover {
  background: var(--surface-2);
}

.cal__day--pad {
  color: var(--text-3);
  opacity: 0.45;
}

.cal__day--today {
  color: var(--accent);
  font-weight: 700;
}

.cal__day--sel {
  background: var(--text);
  color: var(--bg);
}
.cal__day--sel:hover {
  background: var(--text);
}

/* En pantallas anchas la celda cuadrada se vuelve enorme: fijamos alto. */
@media (min-width: 640px) {
  .cal__day {
    aspect-ratio: auto;
    height: 60px;
  }
}

.cal__dots {
  display: flex;
  gap: 3px;
  height: 4px;
}

.cal__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.cal__day--sel .cal__dot {
  background: var(--bg);
}

.cal__dot--done {
  background: var(--text-3);
}

/* ==========================================================================
   Listas / filas
   ========================================================================== */

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s var(--ease);
}

.row:last-child {
  border-bottom: 0;
}

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

.row__main {
  flex: 1;
  min-width: 0;
}

.row__title {
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__meta {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__amount {
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.row--done .row__title {
  text-decoration: line-through;
  color: var(--text-3);
}

.row__time {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  width: 42px;
  flex: none;
}

.row__icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 15px;
  flex: none;
}

.check {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  transition: all 0.15s var(--ease);
}
.check:hover {
  border-color: var(--accent);
}
.check svg {
  width: 12px;
  height: 12px;
  stroke-width: 3;
  opacity: 0;
  color: var(--accent-ink);
}
.check[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}
.check[aria-checked='true'] svg {
  opacity: 1;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.01em;
}

/* ==========================================================================
   Notas
   ========================================================================== */

.notes {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@media (min-width: 620px) {
  .notes {
    grid-template-columns: 1fr 1fr;
  }
}

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  text-align: left;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.note:hover {
  border-color: var(--border-strong);
}
.note:active {
  transform: scale(0.99);
}

.note__title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note__body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.note__meta {
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.note--draw {
  gap: 8px;
}

.note__thumbwrap {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  height: 104px;
  overflow: hidden;
}

.note__thumb {
  width: 100%;
  height: 100%;
  display: block;
}

.note--draw .note__meta {
  color: var(--text-3);
}

.note--draw .note__meta svg {
  width: 11px;
  height: 11px;
  stroke-width: 2;
}

.search {
  position: relative;
  margin-bottom: 14px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  stroke-width: 1.8;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}

.search input::placeholder {
  color: var(--text-3);
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ==========================================================================
   Finanzas
   ========================================================================== */

.balance {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.balance__label {
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.balance__value {
  font-size: 34px;
  font-weight: 660;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  line-height: 1.1;
}

.balance__split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.stat__label {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat__label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.stat--in .stat__label {
  color: var(--pos);
}
.stat--out .stat__label {
  color: var(--neg);
}

.stat__value {
  font-size: 17px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  margin-top: 2px;
  color: var(--text);
}

.monthbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
}

.monthbar__label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 132px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}

.bar__name {
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
}

.bar__value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}

.bar__pct {
  color: var(--text-3);
  font-size: 12px;
  margin-left: 5px;
}

.bar__track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s var(--ease);
}

/* Avisos / recordatorios */
.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 14px;
  border-radius: var(--r);
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.notice__icon {
  font-size: 15px;
  line-height: 1.3;
  flex: none;
}

.notice strong {
  font-weight: 620;
}

.notice--info {
  background: var(--accent-soft);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}
.notice--warn {
  background: var(--neg-soft);
  color: var(--text);
  border-color: color-mix(in srgb, var(--neg) 22%, transparent);
}
.notice--ok {
  background: var(--pos-soft);
  color: var(--text);
  border-color: color-mix(in srgb, var(--pos) 22%, transparent);
}

.notice__close {
  margin-left: auto;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--r-xs);
  flex: none;
}
.notice__close:hover {
  color: var(--text);
}

/* ==========================================================================
   Hoja modal (bottom sheet en móvil, diálogo en escritorio)
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 15, 20, 0.4);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.18s var(--ease);
}

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

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

.sheet {
  background: var(--surface);
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3);
  animation: rise 0.24s var(--ease);
  -webkit-overflow-scrolling: touch;
}

.sheet__grab {
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 6px auto 14px;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.sheet__title {
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.sheet__actions {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

.sheet__actions .btn {
  flex: 1;
  height: 44px;
}

@media (min-width: 700px) {
  .scrim {
    align-items: center;
    padding: 24px;
  }
  .sheet {
    max-width: 460px;
    border-radius: var(--r-xl);
    padding: 22px 24px 24px;
    max-height: 86dvh;
  }
  .sheet__grab {
    display: none;
  }
}

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

.field {
  margin-bottom: 14px;
}

.field__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 15px; /* >=16px evita zoom en iOS; ver .input en móvil */
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

@media (max-width: 699px) {
  /* Safari iOS hace zoom si la fuente del campo es menor a 16px. */
  .input,
  .textarea,
  .select,
  .search input {
    font-size: 16px;
  }
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  font-family: inherit;
}

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

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.amount-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
}

.amount-input:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.amount-input__cur {
  color: var(--text-3);
  font-size: 15px;
  font-weight: 600;
}

.amount-input input {
  flex: 1;
  border: 0;
  background: none;
  font-size: 24px;
  font-weight: 620;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
  min-width: 0;
}

.amount-input input:focus {
  outline: none;
}

/* Control segmentado */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 3px;
}

.seg__opt {
  height: 32px;
  border-radius: var(--r-xs);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  transition: all 0.15s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.seg__opt[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.seg__opt[aria-pressed='true'][data-tone='in'] {
  color: var(--pos);
}
.seg__opt[aria-pressed='true'][data-tone='out'] {
  color: var(--neg);
}

/* Grilla de categorías */
.cats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 4px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.2;
  text-align: center;
  transition: all 0.14s var(--ease);
}

.cat__icon {
  font-size: 16px;
}

.cat[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Interruptor */
.switch {
  position: relative;
  width: 42px;
  height: 25px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.2s var(--ease);
  flex: none;
}

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

.switch[aria-checked='true'] {
  background: var(--accent);
}

.switch[aria-checked='true']::after {
  transform: translateX(17px);
}

.setting {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
}

.setting:last-child {
  border-bottom: 0;
}

.setting__main {
  flex: 1;
  min-width: 0;
}

.setting__title {
  font-size: 14.5px;
  font-weight: 500;
}

.setting__desc {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.4;
}

.setting .select {
  width: auto;
  min-width: 116px;
  padding: 7px 32px 7px 10px;
  font-size: 13.5px;
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
}

/* ==========================================================================
   Nota libre (lienzo infinito)
   ========================================================================== */

.draw {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.draw__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.draw__title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 8px;
  border-radius: var(--r-xs);
}

.draw__title:focus {
  outline: none;
  background: var(--surface-2);
}

.draw__title::placeholder {
  color: var(--text-3);
  font-weight: 500;
}

.draw__zoom {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
}

.draw__canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  cursor: crosshair;
  /* Clave: sin esto el navegador se queda el gesto para hacer scroll/zoom
     y el lápiz no llega a dibujar. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.draw__canvas--erase {
  cursor: cell;
}

.draw__tools {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}

.draw__tools::-webkit-scrollbar {
  display: none;
}

.tool {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.tool:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tool[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool[disabled] {
  opacity: 0.3;
  pointer-events: none;
}

.tool__sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex: none;
  margin: 0 2px;
}

.swatches,
.sizes {
  display: flex;
  align-items: center;
  gap: 3px;
}

.swatch {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  position: relative;
  transition: transform 0.14s var(--ease);
}

.swatch::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--c);
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch[aria-pressed='true'] {
  box-shadow: inset 0 0 0 2px var(--c);
}

.swatch[aria-pressed='true']::after {
  inset: 5px;
}

.sizebtn {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.sizebtn span {
  border-radius: 50%;
  background: var(--text-2);
  display: block;
}

.sizebtn:hover span {
  background: var(--text);
}

.sizebtn[aria-pressed='true'] {
  background: var(--accent-soft);
}

.sizebtn[aria-pressed='true'] span {
  background: var(--accent);
}

/* ==========================================================================
   Pantalla de bloqueo (PIN)
   ========================================================================== */

.lock {
  position: fixed;
  inset: 0;
  z-index: 100; /* por encima de todo, incluido el lienzo */
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.lock__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 300px;
}

.lock__mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--text);
  position: relative;
  flex: none;
}

.lock__mark::after {
  content: '';
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  border: 2.5px solid var(--bg);
  border-top-color: transparent;
}

.lock__title {
  font-size: 21px;
  font-weight: 640;
  letter-spacing: -0.02em;
  margin-top: 14px;
}

.lock__hint {
  font-size: 13.5px;
  color: var(--text-3);
  margin-top: 5px;
  min-height: 20px;
  text-align: center;
}

.lock__dots {
  display: flex;
  gap: 14px;
  margin: 26px 0 30px;
}

.lock__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease),
    transform 0.12s var(--ease);
}

.lock__dot--on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}

.lock__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}

.lock__key {
  aspect-ratio: 1;
  max-height: 68px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 23px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: background 0.1s var(--ease), transform 0.08s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.lock__key:hover {
  background: var(--border);
}

.lock__key:active {
  transform: scale(0.92);
  background: var(--border-strong);
}

.lock__key--fn {
  background: none;
  font-size: 19px;
  color: var(--text-2);
}

.lock__key--fn:hover {
  background: var(--surface-2);
}

.lock__pad--shake {
  animation: shake 0.36s var(--ease);
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-7px);
  }
  40%,
  60% {
    transform: translateX(7px);
  }
}

.lock__forgot {
  margin-top: 22px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-xs);
}

.lock__forgot:hover {
  color: var(--accent);
}

/* ==========================================================================
   Avisos flotantes
   ========================================================================== */

.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: min(92vw, 420px);
}

@media (min-width: 900px) {
  .toasts {
    bottom: 24px;
  }
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: rise 0.2s var(--ease);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.toast button {
  color: var(--accent);
  font-weight: 620;
  font-size: 13.5px;
}

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