/* Mis Cuentas — estética editorial: blanco y negro, un solo acento rosa, titulares condensados en mayúscula,
   formas rectas sin sombras. Fuentes del sistema (la app no carga nada externo). */
:root {
  --bg: #ffffff; --card: #ffffff; --raised: #f3f3f3; --text: #141414; --muted: #6a6a6a; --faint: #b4b4b4; --line: #e2e2e2;
  --brand: #ff3399; --brand-ink: #141414;
  --income: #141414; --expense: #ff3399; --danger: #ff3399; --warn: #141414;
  --display: "HelveticaNeue-CondensedBlack", "Helvetica Neue Condensed Black", Impact, Haettenschweiler, "Arial Narrow Bold", "Roboto Condensed", sans-serif-condensed, sans-serif;
  --body: "Helvetica Neue", Helvetica, Arial, "Segoe UI", Roboto, sans-serif;
  --tabbar: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141414; --card: #141414; --raised: #222222; --text: #ffffff; --muted: #a4a4a4; --faint: #5e5e5e; --line: #303030; --income: #ffffff; --warn: #ffffff; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 16px/1.35 var(--body); letter-spacing: -.012em; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  padding: 0 env(safe-area-inset-right) calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
button, input, select { font: inherit; letter-spacing: inherit; color: inherit; border-radius: 0; }
button {
  border: 1.5px solid var(--text); background: transparent; padding: 10px 16px; min-height: 44px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; cursor: pointer; touch-action: manipulation;
  transition: background-color .18s ease, color .18s ease, transform .12s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
button.primary { background: var(--text); color: var(--bg); }
button.danger { border-color: var(--brand); }
button:disabled { opacity: .45; }
button.small { min-height: 34px; padding: 5px 11px; font-size: 11.5px; }
a { color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; text-underline-offset: 3px; }
p { margin: 0 0 10px; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
b, strong { font-weight: 700; }

/* Encabezado */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px; max-width: 720px; margin: 0 auto; background: var(--bg);
}
h1 { font-family: var(--display); font-size: clamp(38px, 11.5vw, 60px); line-height: .86; font-weight: 400; text-transform: uppercase; letter-spacing: -.01em; margin: 0; }
h2 { font-family: var(--display); font-size: 28px; line-height: .92; font-weight: 400; text-transform: uppercase; letter-spacing: 0; margin: 0 0 16px; }
#syncBtn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px 8px 10px; min-height: 40px; flex: none; }
#syncBtn svg { width: 16px; height: 16px; }
#syncBtn:disabled svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
main { padding: 8px 16px 16px; max-width: 720px; margin: 0 auto; }
main.enter > * { animation: rise .34s cubic-bezier(.2, .8, .2, 1) both; }
main.enter > *:nth-child(2) { animation-delay: .04s; }
main.enter > *:nth-child(3) { animation-delay: .08s; }
main.enter > *:nth-child(n+4) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Secciones: sin caja, separadas por una regla gruesa */
.card { border-top: 3px solid var(--text); padding: 14px 0 6px; margin-bottom: 30px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.note { margin: -14px 0 30px; font-size: 13px; }

.progress { padding: 0 16px 10px; max-width: 720px; margin: 0 auto; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.bar { height: 4px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }

/* Navegación de mes */
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.monthnav strong { font-family: var(--display); font-size: 24px; font-weight: 400; text-transform: uppercase; line-height: 1; }
.monthnav button { width: 42px; min-height: 42px; padding: 0; font-size: 20px; line-height: 1; }

/* Bloque de balance: color pleno de borde a borde */
.balance { background: var(--brand); color: #141414; margin: 0 -16px 30px; padding: 20px 16px 18px; }
.balance span { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.balance .total { display: block; font-family: var(--display); font-weight: 400; font-size: clamp(50px, 16.5vw, 104px); line-height: .88; letter-spacing: -.01em; margin: 8px 0 20px; overflow-wrap: anywhere; }
.balance .split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.balance .split div { border-top: 2px solid #141414; padding-top: 8px; min-width: 0; }
.balance .split b { display: block; font-family: var(--display); font-weight: 400; font-size: clamp(22px, 7vw, 30px); line-height: 1; margin-top: 4px; overflow-wrap: anywhere; }
.balance .split i { font-style: normal; margin-right: 5px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin-bottom: 30px; }
.kpi { border-top: 3px solid var(--text); padding-top: 8px; min-width: 0; }
.kpi.wide { grid-column: 1 / -1; }
.kpi span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.kpi b { display: block; font-family: var(--display); font-weight: 400; font-size: clamp(26px, 8vw, 34px); line-height: .95; overflow-wrap: anywhere; }
.kpi small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.income { color: var(--income); } .expense { color: var(--expense); }
.hero { display: block; font-family: var(--display); font-weight: 400; font-size: clamp(44px, 14vw, 64px); line-height: .9; margin-bottom: 16px; }

/* Barras por categoría y comercio */
.cat { margin-bottom: 14px; }
.cat:last-child { margin-bottom: 8px; }
.cat .line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; }
.cat .line span { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.cat .line small { font-size: 12px; font-weight: 400; color: var(--muted); }
.cat .line b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat .track { height: 5px; background: var(--raised); margin-top: 6px; overflow: hidden; }
.cat .track i { display: block; height: 100%; background: var(--text); }
.trend { width: 100%; height: auto; display: block; }
.trend text { font-size: 9px; font-weight: 700; text-transform: uppercase; fill: var(--muted); }
.trend .axis { stroke: var(--text); stroke-width: 1.5; }
.trend g:hover rect:nth-child(2) { opacity: .7; }
.legend { display: flex; gap: 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; }

/* Formularios */
input, select { border: 1.5px solid var(--text); background: var(--bg); padding: 11px 12px; width: 100%; min-height: 46px; font-size: 16px; -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%); background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus { outline: 3px solid var(--brand); outline-offset: 0; }
input::placeholder { color: var(--faint); }
input[readonly] { color: var(--muted); border-color: var(--line); }
.field { display: block; margin-bottom: 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.field input, .field select { margin-top: 6px; color: var(--text); font-weight: 400; text-transform: none; letter-spacing: -.012em; }
.filters { display: flex; gap: 8px; margin-bottom: 10px; }
.filters input { flex: 1; min-width: 0; }
.filters select { width: auto; max-width: 44%; }
.add { width: 100%; }
.copy { display: flex; gap: 8px; }
.copy input { font-size: 13px; }
.copy button { margin-top: 6px; }
label.check { display: flex; gap: 10px; align-items: center; font-size: 14.5px; min-height: 36px; text-transform: none; letter-spacing: -.012em; font-weight: 400; color: var(--text); }
label.check input, .seg input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; flex: none; }
label.check input { -webkit-appearance: none; appearance: none; border: 1.5px solid var(--text); background: var(--bg); }
label.check input:checked { background: var(--brand); box-shadow: inset 0 0 0 3px var(--bg); }

/* Listas de movimientos */
.day { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 26px 0 0; padding-top: 8px; border-top: 3px solid var(--text); }
.list { margin-bottom: 4px; }
.tx { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 0; min-height: 62px; font-size: 16px; font-weight: 400; text-transform: none; letter-spacing: -.012em; }
.list .tx:first-child { border-top: 0; }
.tx:active { transform: none; background: var(--raised); }
.avatar { flex: none; width: 40px; height: 40px; display: grid; place-items: center; background: var(--text); color: var(--bg); font-family: var(--display); font-size: 22px; line-height: 1; text-transform: uppercase; }
.avatar.in { background: var(--brand); color: #141414; }
.tx .info { flex: 1; min-width: 0; }
.tx .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.tx .info span { font-size: 13px; color: var(--muted); }
.tx .amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.tx .amt.income, .tx .amt.expense { color: var(--text); }
.tx.ignored { opacity: .4; }
.tx.ignored .amt { text-decoration: line-through; }
.flag { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--muted); padding: 0 4px; margin-left: 6px; }

.rule { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rule span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status { display: inline-block; width: 10px; height: 10px; background: var(--faint); margin-right: 8px; }
.status.on { background: var(--brand); }

/* Barra inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; background: var(--bg); border-top: 3px solid var(--text); padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); }
.tabs button { position: relative; flex: 1; max-width: 130px; min-width: 0; height: var(--tabbar); min-height: 0; border: 0; padding: 7px 0 5px; color: var(--muted); font-size: 9.5px; letter-spacing: .02em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.tabs button svg { width: 23px; height: 23px; }
.tabs button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabs button.active { color: var(--text); }
.tabs button.active::before { content: ""; position: absolute; top: -3px; left: 0; right: 0; height: 5px; background: var(--brand); }

/* Pestañas de sección: texto subrayado */
.segs { display: flex; gap: 20px; border-bottom: 1.5px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.segs::-webkit-scrollbar { display: none; }
.segs button { flex: none; min-height: 40px; border: 0; padding: 8px 0; font-size: 12.5px; white-space: nowrap; color: var(--muted); }
.segs button.on { color: var(--text); box-shadow: inset 0 -4px 0 var(--brand); }

/* Análisis, por pagar y planeación */
.meter { position: relative; height: 12px; background: var(--raised); margin-bottom: 12px; }
.meter i { position: absolute; left: 0; top: 0; height: 100%; background: var(--brand); }
.meter i.rest { opacity: .3; }
.meter u { position: absolute; top: -5px; bottom: -5px; width: 2.5px; background: var(--text); }
.spark { width: 64px; height: 22px; display: block; }
.spark polyline { fill: none; stroke: var(--text); stroke-width: 1.5; }
.spark circle { fill: var(--brand); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
table.data th { text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 0 8px; }
table.data td { padding: 10px 0; border-top: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
table.data td + td, table.data th + th { padding-left: 10px; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td small { display: block; font-size: 12px; color: var(--muted); }
.item { padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; padding-top: 0; }
.item .line { display: flex; gap: 12px; align-items: baseline; }
.item .info { flex: 1; min-width: 0; }
.item .info b { display: block; overflow-wrap: anywhere; font-size: 17px; }
.item .info span { font-size: 13px; color: var(--muted); }
.item .amt { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; white-space: nowrap; }
.item .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.item .title { display: block; margin-top: 10px; font-size: 18px; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; }
.item p { margin: 5px 0 0; }
/* "Ver más" como enlace con flecha */
.item ~ button { border: 0; padding: 0; min-height: 44px; margin-top: 4px; font-size: 15px; text-transform: none; letter-spacing: -.012em; text-align: left; }
.item ~ button::before { content: "⟶"; margin-right: 10px; }
.item ~ button:hover { color: var(--brand); }
.saving { font-size: 13px; font-weight: 700; }
.badge { display: inline-block; font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 6px; color: var(--muted); border: 1.5px solid var(--line); white-space: nowrap; }
.badge.bad { color: #141414; background: var(--brand); border-color: var(--brand); }
.badge.warn { color: var(--text); border-color: var(--text); }
.badge.good { color: var(--bg); background: var(--text); border-color: var(--text); }
.tip { position: fixed; z-index: 30; max-width: 260px; background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.35; padding: 7px 10px; pointer-events: none; }

/* Editor: hoja inferior en el teléfono, diálogo centrado en pantallas anchas */
dialog { border: 3px solid var(--text); border-radius: 0; background: var(--bg); color: var(--text); width: min(92vw, 480px); padding: 22px; max-height: 88dvh; overflow: auto; }
dialog::backdrop { background: rgba(20, 20, 20, .6); }
dialog h2 { font-size: 34px; margin-bottom: 18px; }
dialog label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 14px; }
dialog label input, dialog label select { margin-top: 6px; color: var(--text); font-weight: 400; text-transform: none; letter-spacing: -.012em; }
dialog label.check { margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--text); margin-bottom: 16px; }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 42px; margin: 0; color: var(--text); font-size: 13px; position: relative; cursor: pointer; }
.seg label input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; }
.seg label:has(input:checked) { background: var(--text); color: var(--bg); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--brand); }
.pair { display: grid; grid-template-columns: 1fr 96px; gap: 10px; }
.pair label { min-width: 0; }
.source { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; position: sticky; bottom: -22px; background: var(--bg); padding: 12px 0 22px; margin-bottom: -22px; }
@media (max-width: 560px) {
  dialog { margin: auto 0 0; width: 100%; max-width: 100%; border-width: 5px 0 0; border-color: var(--brand); padding: 22px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92dvh; }
  dialog[open] { animation: sheet .3s cubic-bezier(.2, .8, .2, 1); }
  .actions { bottom: calc(-18px - env(safe-area-inset-bottom)); padding-bottom: calc(18px + env(safe-area-inset-bottom)); margin-bottom: calc(-18px - env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(100%); } }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); border-left: 6px solid var(--brand); padding: 12px 14px; z-index: 20; font-size: 14px; font-weight: 700; max-width: 480px; margin: 0 auto; animation: rise .25s ease both; }
ol.steps { padding-left: 20px; margin: 8px 0 14px; font-size: 15px; }
ol.steps li { margin-bottom: 8px; }
ol.steps li::marker { font-weight: 700; }

/* Teléfono: el botón de sincronizar queda solo con su ícono para dejarle el ancho al título */
@media (max-width: 520px) {
  #syncBtn span { display: none; }
  #syncBtn { padding: 0; width: 44px; min-height: 44px; justify-content: center; }
  #syncBtn svg { width: 19px; height: 19px; }
  .top { align-items: center; }
  h1 { min-width: 0; overflow-wrap: anywhere; }
}
/* Teléfonos angostos */
@media (max-width: 359px) {
  main, .top { padding-left: 12px; padding-right: 12px; }
  .balance { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  table.data .hide-xs { display: none; }
}
/* Tableta */
@media (min-width: 680px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpis:has(> :nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
  .balance { margin-left: 0; margin-right: 0; padding: 26px 24px 22px; }
  .balance .total { font-size: 96px; }
}
/* Escritorio: navegación lateral tipográfica y tablero en dos columnas */
@media (min-width: 1000px) {
  :root { --side: 260px; }
  body { padding: 0 0 60px var(--side); }
  .tabs { right: auto; top: 0; width: var(--side); flex-direction: column; justify-content: flex-start; gap: 2px; padding: 34px 28px; border-top: 0; border-right: 3px solid var(--text); }
  .tabs::before { content: "Mis\A Cuentas"; white-space: pre; font-family: var(--display); font-size: 46px; line-height: .86; text-transform: uppercase; padding-bottom: 14px; margin-bottom: 30px; border-bottom: 5px solid var(--brand); }
  .tabs button { flex: none; max-width: none; width: 100%; height: auto; min-height: 44px; flex-direction: row; justify-content: flex-start; padding: 0; font-family: var(--display); font-size: 32px; font-weight: 400; line-height: 1; letter-spacing: 0; color: var(--text); }
  .tabs button svg { display: none; }
  .tabs button.active::before { display: none; }
  .tabs button:hover, .tabs button.active { color: var(--brand); }
  .top, main, .progress { max-width: 1180px; padding-left: 44px; padding-right: 44px; margin-left: 0; }
  .top { padding-top: 34px; padding-bottom: 22px; }
  h1 { font-size: 92px; }
  h2 { font-size: 32px; }
  button:hover:not(:disabled) { background: var(--text); color: var(--bg); }
  button.primary:hover:not(:disabled) { background: var(--brand); color: #141414; border-color: var(--brand); }
  .tabs button:hover:not(:disabled), .segs button:hover:not(:disabled), .item ~ button:hover:not(:disabled) { background: none; }
  .tabs button:hover:not(:disabled) { color: var(--brand); }
  .segs button:hover:not(:disabled) { color: var(--text); }
  .item ~ button:hover:not(:disabled) { color: var(--brand); }
  .tx:hover:not(:disabled) { background: var(--raised); color: var(--text); }
  .toast { left: calc(var(--side) + 44px); right: auto; bottom: 28px; margin: 0; }

  main[data-view="resumen"], main[data-view="analisis"], main[data-view="ajustes"] { columns: 2; column-gap: 44px; }
  main > * { break-inside: avoid; }
  main > .monthnav, main > .segs, main > .kpis, main > .note, main > .field, main > .card:has(.meter) { column-span: all; }
  main > .monthnav { max-width: 380px; }
  main > .field { max-width: 240px; }
  main > .card:has(.meter) { max-width: 640px; }
  main[data-view="plan"] { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 44px; align-items: start; }
  main[data-view="plan"] > .card { position: sticky; top: 150px; }
  main[data-view="movimientos"] { max-width: 880px; }
  main[data-view="movimientos"] .filters select { max-width: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
