/* ==========================================================================
   Archibald · experiencia nativa en el móvil (≤ 860 px)
   Inspirada en iOS: barras translúcidas, títulos grandes, listas agrupadas,
   hojas inferiores y gestos. Todo funciona en tema claro y oscuro.
   ========================================================================== */
.m-avatar, .m-title, .m-head, .m-grab, .m-head-btn { display: none; }

/* Piezas solo del móvil: fuera del móvil no se muestran (el indicador de «tirar para actualizar» quedaba suelto abajo a la izquierda) */
.m-pull { display: none; }

@media (max-width: 860px) {
  :root {
    --m-bg: #f2f1ec; --m-group: #ffffff; --m-sep: rgba(60, 60, 67, .14); --m-label: #8a8780; --m-press: #ebe8e1;
    --m-bar: rgba(242, 241, 236, .78); --m-tab: rgba(249, 248, 245, .82); --m-gold: #a88a52; --m-gold-ink: #7d6234;
    --m-safe-t: env(safe-area-inset-top, 0px); --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-ease: cubic-bezier(.32, .72, 0, 1);
  }
  [data-theme="dark"] {
    --m-bg: #0d0c0b; --m-group: #1b1a18; --m-sep: rgba(235, 235, 245, .12); --m-label: #8f897d; --m-press: #26241f;
    --m-bar: rgba(13, 12, 11, .76); --m-tab: rgba(22, 21, 19, .84); --m-gold: #d8c39a; --m-gold-ink: #d8c39a;
  }
  html { -webkit-tap-highlight-color: transparent; }
  body { background: var(--m-bg); font-size: 15.5px; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
  body.m-locked { position: fixed; left: 0; right: 0; overflow: hidden; }
  button, a { -webkit-touch-callout: none; }

  /* ---------- barra superior translúcida ---------- */
  .layout { display: block; }
  .main { min-height: 100vh; }
  .topbar {
    position: fixed; left: 0; right: 0; top: 0; z-index: 30;
    height: calc(52px + var(--m-safe-t)); padding: var(--m-safe-t) 12px 0 14px; gap: 6px;
    background: transparent; box-shadow: none; border: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    transition: background .25s, box-shadow .25s;
  }
  html.m-scrolled .topbar { background: var(--m-bar); -webkit-backdrop-filter: saturate(1.8) blur(22px); backdrop-filter: saturate(1.8) blur(22px); box-shadow: 0 .5px 0 var(--m-sep); }
  .topbar .menu-btn, .topbar .topbar-title { display: none !important; }
  .m-avatar {
    display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer;
    border: 0; background: linear-gradient(145deg, #2b2a27, #121212); color: #efe3c4;
    font: 600 12.5px/1 var(--font); letter-spacing: .02em; box-shadow: 0 0 0 1.5px var(--m-bg), 0 0 0 2.5px var(--m-gold);
  }
  .m-avatar.lg { width: 56px; height: 56px; font-size: 19px; box-shadow: 0 0 0 2px var(--m-group), 0 0 0 3.5px var(--m-gold); }
  .m-title {
    display: block; position: absolute; left: 72px; right: 104px; bottom: 0; height: 52px; line-height: 52px; text-align: center;
    font: 600 17px/52px var(--font); letter-spacing: -.02em; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .25s; pointer-events: none;
  }
  html.m-titled .m-title { opacity: 1; transform: none; }
  .topbar .spacer { flex: 1; }
  .topbar .search-btn, .topbar .privacy-btn {
    width: 36px; height: 36px; min-width: 0; padding: 0; border-radius: 50%; justify-content: center;
    background: var(--m-group); border: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); color: var(--ink);
  }
  [data-theme="dark"] .topbar .search-btn, [data-theme="dark"] .topbar .privacy-btn { background: #24221f; }
  .topbar .privacy-btn span { display: none; }
  .topbar .privacy-btn[aria-pressed="true"] { background: var(--ink); color: var(--m-gold); }
  [data-theme="dark"] .topbar .privacy-btn[aria-pressed="true"] { background: var(--m-gold); color: #121110; }
  .app-banner { margin-top: calc(52px + var(--m-safe-t)); border-radius: 0; }

  /* ---------- título grande ---------- */
  .m-head { display: block; padding: calc(60px + var(--m-safe-t)) 20px 6px; }
  .app-banner + .topbar + .m-head, .app-banner ~ .m-head { padding-top: 14px; }
  .m-head small { display: block; font: 650 12px/1.3 var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--m-gold-ink); min-height: 16px; }
  .m-head small:empty { visibility: hidden; }
  .m-head h1 {
    font-family: var(--serif, Georgia, serif); font-weight: 400; font-size: 36px; line-height: 1.04; letter-spacing: -.028em; color: var(--ink);
    font-variation-settings: "SOFT" 100, "opsz" 144; margin-top: 4px;
  }
  .m-head h1 em { font-style: italic; color: var(--m-gold-ink); font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144; }

  /* ---------- página ---------- */
  .page { padding: 14px 16px calc(112px + var(--m-safe-b)); gap: 18px; max-width: none; grid-template-columns: minmax(0, 1fr); }
  .page > * { min-width: 0; }
  .page.enter { animation: m-enter .42s var(--m-ease) both; }
  @keyframes m-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  .card, .kpi:not(.kpi-hero), .acc-card, .mini-stat { border: 0; border-radius: 18px; box-shadow: none; background: var(--m-group); }
  .kpi-hero { border-radius: 22px; }
  .card { padding: 18px 16px; }
  .card.flush { padding: 0; }
  .card-head > b, .card-head h3 { font-size: 17px; letter-spacing: -.015em; }
  h2 { font-size: 22px; }
  .page-head { gap: 12px; }

  /* tipografía y campos: 16 px mínimo para que iOS no haga zoom */
  input, select, textarea { font-size: 16px !important; }
  .field input, .field select, .field textarea, .modal input:not([type=checkbox]):not([type=radio]), .modal select, .modal textarea { min-height: 46px; border-radius: 12px; }
  .btn { min-height: 44px; border-radius: 12px; font-size: 15.5px; }
  .btn-sm { min-height: 38px; }
  .btn:active, .m-row:active, .bottom-nav a:active, .bottom-nav button:active, .m-big button:active { transform: scale(.97); transition: transform .08s; }
  .icon-btn { width: 40px; height: 40px; }

  /* ---------- indicadores ---------- */
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 16px; gap: 4px; }
  .kpi-label { font-size: 13px; }
  .kpi-value { font-size: 22px; letter-spacing: -.03em; }
  .kpi-hero { grid-column: 1 / -1; padding: 22px 20px; border-radius: 22px; position: relative; overflow: hidden; }
  .kpi-hero .kpi-value { font-size: 34px; font-family: var(--serif, Georgia, serif); font-weight: 400; letter-spacing: -.03em; font-variation-settings: "SOFT" 100, "opsz" 144; }

  /* ---------- pestañas → control segmentado ---------- */
  .tabs-line { gap: 4px; border: 0; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .tabs-line::-webkit-scrollbar { display: none; }
  .tabs-line a { padding: 8px 15px; border: 0; border-radius: 999px; background: var(--m-group); color: var(--muted); font-weight: 600; font-size: 14.5px; margin: 0; }
  .tabs-line a.active { background: var(--ink); color: var(--bg); }
  .seg, .view-toggle { display: flex; width: 100%; background: rgba(118, 118, 128, .12); border-radius: 10px; padding: 2px; }
  .seg label, .view-toggle button { flex: 1; }
  .seg span, .view-toggle button { text-align: center; justify-content: center; padding: 7px 6px; font-size: 14px; border-radius: 8px; }
  .seg input:checked + span, .view-toggle button.active { background: var(--m-group); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
  [data-theme="dark"] .seg input:checked + span, [data-theme="dark"] .view-toggle button.active { background: #3a3835; }

  /* ---------- barra de pestañas inferior ---------- */
  .bottom-nav {
    grid-template-columns: repeat(5, 1fr); align-items: start; z-index: 40;
    padding: 7px 6px calc(2px + var(--m-safe-b)); height: calc(56px + var(--m-safe-b));
    background: var(--m-tab); -webkit-backdrop-filter: saturate(1.8) blur(24px); backdrop-filter: saturate(1.8) blur(24px);
    border-top: .5px solid var(--m-sep);
  }
  .bottom-nav a, .bottom-nav button { gap: 3px; font: 550 10.5px/1.1 var(--font); color: #8e8b84; letter-spacing: .01em; transition: color .15s; }
  .bottom-nav .ic { width: 25px; height: 25px; stroke-width: 1.6; }
  .bottom-nav a.active { color: var(--ink); }
  .bottom-nav a.active .ic { color: var(--m-gold-ink); stroke-width: 2; }
  .bottom-nav .bn-new {
    width: 50px; height: 50px; border-radius: 50%; margin-top: -14px; padding: 0;
    background: radial-gradient(circle at 30% 25%, #3a3835, #121212 70%); color: #efe3c4;
    box-shadow: 0 0 0 4px var(--m-bg), 0 10px 24px -8px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(216, 195, 154, .35);
  }
  .bottom-nav .bn-new .ic { width: 24px; height: 24px; stroke-width: 2; color: #e9d6a6; }
  [data-theme="dark"] .bottom-nav .bn-new { background: radial-gradient(circle at 30% 25%, #e9d6a6, #a88a52 75%); color: #121110; box-shadow: 0 0 0 4px var(--m-bg), 0 10px 24px -8px rgba(0, 0, 0, .8); }
  [data-theme="dark"] .bottom-nav .bn-new .ic { color: #121110; }
  .sidebar, .nav-backdrop { display: none !important; }

  /* ---------- avisos: cápsula arriba ---------- */
  #toasts { left: 12px; right: 12px; top: calc(8px + var(--m-safe-t)); bottom: auto; justify-items: center; z-index: 90; }
  .toast {
    max-width: 100%; border-radius: 22px; padding: 12px 16px; font-size: 14.5px; font-weight: 550;
    background: rgba(28, 27, 25, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    box-shadow: 0 12px 34px -10px rgba(0, 0, 0, .5); animation: m-toast .45s var(--m-ease);
  }
  .toast.out { transform: translateY(-14px); opacity: 0; }
  @keyframes m-toast { from { transform: translateY(-120%); } to { transform: none; } }

  /* ---------- hojas inferiores (formularios) ---------- */
  .modal-overlay { place-items: end stretch; padding: 0; background: rgba(0, 0, 0, .36); backdrop-filter: none; animation: m-fade .3s; }
  .modal-overlay.out { animation: m-fade-out .3s forwards; }
  .modal, .modal-wide {
    width: 100%; max-height: calc(100vh - var(--m-safe-t) - 18px); border-radius: 14px 14px 0 0; background: var(--m-bg);
    animation: m-up .48s var(--m-ease); transition: transform .35s var(--m-ease); padding-bottom: var(--m-safe-b); box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
  }
  .modal-overlay.out .modal { transform: translateY(100%); }
  .modal .m-grab { display: block; }
  .modal-head { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 2px 8px 10px; border-bottom: .5px solid var(--m-sep); }
  .modal-head .modal-x { display: none; }
  .modal-title { text-align: center; min-width: 0; grid-column: 2; }
  .modal-title h3 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
  .modal-title p { display: none; }
  .m-head-btn { display: block; background: none; border: 0; font: 500 16.5px var(--font); color: var(--m-gold-ink); padding: 10px 8px; cursor: pointer; min-width: 0; }
  .m-head-cancel { justify-self: start; grid-column: 1; grid-row: 1; }
  .m-head-done { justify-self: end; font-weight: 700; grid-column: 3; grid-row: 1; }
  .m-head-done.danger { color: var(--neg); }
  .m-head-btn:disabled { opacity: .45; }
  .modal-foot { display: none; }
  .modal-body { padding: 18px 16px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .modal-body .form-grid, .modal-body .form-grid.four { grid-template-columns: 1fr; gap: 14px; }
  .modal-body .span-2 { grid-column: auto; }
  .modal-error { margin: 0 16px 14px; }
  .modal-subtitle-m { display: block; }
  @keyframes m-up { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes m-fade-out { to { opacity: 0; } }

  /* ---------- hojas propias: acciones, nuevo, más ---------- */
  .m-sheet-ov { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; transition: background .3s; }
  .m-sheet-ov.in { background: rgba(0, 0, 0, .36); }
  .m-sheet-ov.out { background: rgba(0, 0, 0, 0); }
  .m-sheet {
    position: relative; width: 100%; max-height: calc(100vh - var(--m-safe-t) - 18px); display: flex; flex-direction: column;
    background: var(--m-bg); border-radius: 14px 14px 0 0; padding-bottom: calc(14px + var(--m-safe-b));
    transform: translateY(100%); transition: transform .48s var(--m-ease); box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
  }
  .m-sheet-ov.in .m-sheet { transform: none; }
  .m-sheet-ov.out .m-sheet { transform: translateY(100%); transition-duration: .3s; }
  .m-grab { display: block; width: 38px; height: 5px; border-radius: 3px; background: rgba(120, 120, 128, .35); margin: 7px auto 6px; flex: none; }
  .m-scroll { overflow-y: auto; padding: 4px 16px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .m-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 16px 12px; }
  .m-sheet-head b { font-size: 21px; font-weight: 700; letter-spacing: -.025em; color: var(--ink); }
  .m-x { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(118, 118, 128, .16); color: var(--m-label); display: grid; place-items: center; cursor: pointer; }
  .m-gtitle { margin: 24px 16px 7px; font: 500 13px var(--font); text-transform: uppercase; letter-spacing: .04em; color: var(--m-label); }
  .m-group { background: var(--m-group); border-radius: 14px; overflow: hidden; }
  .m-row {
    position: relative; display: flex; align-items: center; gap: 13px; width: 100%; min-height: 52px; padding: 9px 14px; text-align: left;
    background: none; border: 0; font: inherit; color: var(--ink); text-decoration: none !important; cursor: pointer;
  }
  .m-row + .m-row::before { content: ""; position: absolute; top: 0; right: 0; left: 59px; height: .5px; background: var(--m-sep); }
  .m-row:not(:has(.m-tile)) + .m-row::before, .m-row:not(:has(.m-tile))::before { left: 16px; }
  .m-row:active { background: var(--m-press); }
  .m-row.cur .m-row-t b { color: var(--m-gold-ink); }
  .m-row-t { flex: 1; min-width: 0; display: grid; gap: 1px; }
  .m-row-t b { font-weight: 500; font-size: 16.5px; letter-spacing: -.01em; }
  .m-row-t small { color: var(--m-label); font-size: 13.5px; line-height: 1.3; }
  .m-row .chev { color: #c4c4c7; width: 15px; height: 15px; stroke-width: 2.4; flex: none; }
  .m-row.danger .m-row-t b { color: var(--neg); }
  .m-row.center { justify-content: center; text-align: center; }
  .m-row.center .m-row-t { flex: none; }
  .m-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--neg); color: #fff; font: 700 12.5px/22px var(--font); text-align: center; }
  .m-tile { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: #3a3835; }
  .m-tile .ic { width: 18px; height: 18px; stroke-width: 1.9; }
  .m-tile.ink { background: #1c1b19; color: #e9d6a6; }
  .m-tile.gold { background: #a88a52; }
  .m-tile.green { background: #2f7d62; }
  .m-tile.blue { background: #3d6fa8; }
  .m-tile.plum { background: #6e5a7e; }
  .m-tile.rose { background: #b8655c; }
  .m-tile.grey { background: #8e8b84; }
  [data-theme="dark"] .m-tile.ink { background: #34322e; }
  .m-tile.lg { width: 52px; height: 52px; border-radius: 15px; }
  .m-tile.lg .ic { width: 24px; height: 24px; }
  .m-user { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--m-group); border-radius: 14px; color: var(--ink); text-decoration: none !important; margin-top: 4px; }
  .m-user .m-row-t b { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
  .m-user .chev { color: #c4c4c7; }
  .m-foot { display: grid; justify-items: center; gap: 6px; margin: 28px 0 8px; color: var(--m-label); font-size: 12.5px; }
  .m-foot svg { color: var(--m-label); }
  .m-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
  .m-big button { display: grid; justify-items: center; gap: 9px; padding: 18px 6px 14px; border: 0; border-radius: 18px; background: var(--m-group); color: var(--ink); font: 600 13.5px/1.2 var(--font); cursor: pointer; transition: transform .1s; }
  .m-actions { background: transparent; box-shadow: none; padding: 0 8px calc(8px + var(--m-safe-b)); }
  .m-actions .m-grab { display: none; }
  .m-actions .m-scroll { padding: 0; background: var(--m-group); border-radius: 0 0 14px 14px; max-height: 60vh; }
  .m-actions .m-group { border-radius: 0; }
  .m-actions .m-act-head + .m-scroll { border-top: .5px solid var(--m-sep); }
  .m-actions .m-scroll:first-child { border-radius: 14px; }
  .m-act-head { background: var(--m-group); border-radius: 14px 14px 0 0; padding: 16px 20px 14px; text-align: center; }
  .m-act-head > b { display: block; font-size: 14px; color: var(--m-label); font-weight: 600; }
  .m-act-head p { margin: 4px 0 0; font-size: 13.5px; color: var(--m-label); }
  .m-actions .m-row { justify-content: center; min-height: 56px; }
  .m-actions .m-row:has(.m-tile) { justify-content: flex-start; }
  .m-actions .m-row .m-row-t { flex: initial; text-align: center; }
  .m-actions .m-row:has(.m-tile) .m-row-t { flex: 1; text-align: left; }
  .m-actions .m-row .m-row-t b { font-size: 19px; font-weight: 400; color: var(--m-gold-ink); }
  :root:not([data-theme="dark"]) .m-actions .m-row .m-row-t b { color: #1c1b19; }
  .m-actions .m-row.danger .m-row-t b { color: var(--neg) !important; }
  .m-actions .m-row:has(.m-tile) .m-row-t b { font-size: 16.5px; font-weight: 500; }
  .m-cancel { display: block; width: 100%; margin-top: 8px; min-height: 56px; border: 0; border-radius: 14px; background: var(--m-group); font: 650 19px var(--font); color: var(--ink); cursor: pointer; }
  .m-cancel:active { background: var(--m-press); }

  /* ---------- tirar para actualizar ---------- */
  .m-pull { position: fixed; top: calc(var(--m-safe-t) - 44px); left: 50%; margin-left: -20px; z-index: 25; width: 40px; height: 40px; border-radius: 50%; background: var(--m-group); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .35); display: grid; place-items: center; opacity: 0; transition: opacity .2s, transform .3s var(--m-ease); pointer-events: none; }
  .m-pull.on { opacity: 1; transition: opacity .2s; }
  .m-pull.ready { box-shadow: 0 0 0 2px var(--m-gold), 0 6px 18px -6px rgba(0, 0, 0, .35); }
  .m-pull.spin .m-pull-in { animation: m-spin .9s linear infinite; }
  .m-pull-in { display: grid; }
  @keyframes m-spin { to { transform: rotate(360deg); } }

  /* ---------- buscador a pantalla completa ---------- */
  .palette-overlay { padding: 0; align-items: stretch; background: var(--m-bg); }
  .palette { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0; box-shadow: none; background: var(--m-bg); padding-top: var(--m-safe-t); animation: m-fade .2s; }
  .palette-input { margin: 10px 14px; padding: 0 12px; height: 42px; border-radius: 12px; background: rgba(118, 118, 128, .14); border: 0; }
  .palette-input kbd { display: none; }
  .palette-foot { display: none; }
  .palette-list { max-height: none; flex: 1; padding: 0 14px calc(20px + var(--m-safe-b)); }
  .palette-item { min-height: 52px; border-radius: 12px; }

  /* menús desplegables de escritorio: nunca en móvil */
  .dropdown { display: none !important; }

  /* ---------- movimientos: lista nativa ---------- */
  .filter-bar { display: flex; gap: 8px; margin: 0; padding: 0; align-items: center; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .month-switch { flex: 0 0 100%; order: -2; }
  .filter-bar .search-input { flex: 0 0 100%; order: -1; }
  .filter-bar { flex-wrap: wrap; overflow: visible; }
  .table-wrap:has(.tx-table) { overflow: visible; }
  .filter-bar > select { flex: 1 1 0 !important; min-width: 0; height: 38px; min-height: 38px; border-radius: 19px; padding: 0 30px 0 14px; font-size: 14.5px !important; font-weight: 550; background-color: var(--m-group); border: 0; }
  .filter-bar #type-seg { flex: 0 0 100%; margin: 0; }
  .month-switch { background: var(--m-group); border: 0; border-radius: 14px; height: 46px; }
  .month-switch select { font-weight: 650; text-align: center; text-align-last: center; }
  .search-input { background: rgba(118, 118, 128, .12); border: 0; border-radius: 11px; height: 40px; }
  .search-input input { background: transparent; }
  .summary-row { display: block; }
  .summary-row .row-btns { display: none; }
  .summary-cards, #tx-summary { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; flex-wrap: nowrap; }
  .summary-cards::-webkit-scrollbar { display: none; }
  .mini-stat { flex: none; min-width: 124px; padding: 12px 14px; border-radius: 14px; }
  .bulk-bar { display: none !important; }
  .tx-table thead, .tx-table .sel-cell, .tx-table td:nth-child(3), .tx-table td.row-btns { display: none !important; }
  .tx-table, .tx-table tbody { display: block; }
  .tx-table tr { display: flex; align-items: center; position: relative; overflow: hidden; background: var(--m-group); }
  .tx-table tr[data-id] { min-height: 64px; cursor: pointer; }
  .tx-table tr[data-id] > td { border: 0; padding: 10px 16px; background: var(--m-group); transform: translateX(var(--sx, 0)); }
  .tx-table tr.m-anim > td { transition: transform .3s var(--m-ease); }
  .tx-table tr[data-id] > td:nth-child(2) { flex: 1; min-width: 0; padding-right: 6px; }
  .tx-table tr[data-id] > td.num { padding-left: 0; font-size: 16px; font-weight: 600; }
  .tx-table tr[data-id] + tr[data-id]::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; height: .5px; background: var(--m-sep); z-index: 1; }
  .tx-table tr[data-id]:active > td { background: var(--m-press); }
  .tx-table .tile { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
  .tx-table .desc { font-weight: 550; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tx-table .desc .tag, .tx-table .receipt-tag { font-size: 11px; }
  .tx-table .tx-meta { font-size: 13px; color: var(--m-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tx-table .tx-cell { gap: 12px; }
  .tx-table tr.day-row { position: sticky; top: calc(52px + var(--m-safe-t)); z-index: 3; background: var(--m-bg); }
  .tx-table tr.day-row td { display: flex; justify-content: space-between; width: 100%; padding: 16px 4px 7px; border: 0; background: var(--m-bg); font: 600 13px var(--font); text-transform: uppercase; letter-spacing: .04em; color: var(--m-label); }
  .tx-table tr.day-row .day-total .amount { font-size: 13px; }
  section.card.flush:has(.tx-table) { background: transparent; overflow: visible; border-radius: 0; }
  .tx-table tr.day-row + tr[data-id] { border-radius: 14px 14px 0 0; }
  .tx-table tr[data-id]:has(+ tr.day-row), .tx-table tr[data-id]:last-child { border-radius: 0 0 14px 14px; }
  .tx-table tr.day-row + tr[data-id]:has(+ tr.day-row), .tx-table tr.day-row + tr[data-id]:last-child { border-radius: 14px; }
  .load-more { border: 0; flex-direction: column; gap: 6px; }

  /* deslizar para acciones */
  .m-swipe-tray { position: absolute; top: 0; right: 0; bottom: 0; display: flex; z-index: 0; }
  .m-swipe-tray button { width: 84px; border: 0; display: grid; place-items: center; align-content: center; gap: 4px; color: #fff; font: 600 12.5px var(--font); cursor: pointer; }
  .m-swipe-tray .grey { background: #8e8b84; }
  .m-swipe-tray .red { background: #d64b3c; }
  .m-swipe-tray .blue { background: #3d6fa8; }
  .tx-table tr.m-swipe > td { position: relative; z-index: 1; }

  /* ---------- tablas anchas: desplazamiento horizontal cómodo ---------- */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* ---------- formularios de la app ---------- */
  .form-grid { gap: 14px; }
  .field > span { font-size: 13.5px; font-weight: 600; color: var(--muted); }
  .check { font-size: 15px; }

  /* ---------- tema oscuro: ajustes finos ---------- */
  [data-theme="dark"] .card, [data-theme="dark"] .kpi:not(.kpi-hero), [data-theme="dark"] .mini-stat, [data-theme="dark"] .acc-card { background: var(--m-group); }
}

/* iPhone instalado: deja aire bajo la barra de estado */
@media (max-width: 860px) and (display-mode: standalone) { .m-head { padding-top: calc(64px + var(--m-safe-t)); } }
@media (prefers-reduced-motion: reduce) { .page.enter, .m-sheet, .modal, .toast { animation: none !important; transition: none !important; } }
@media (max-width: 860px) {
  .tx-table .tx-cell, .tx-table .tx-cell > .grow, .tx-table .desc, .tx-table .tx-meta { min-width: 0; }
  .tx-table .tx-cell > .grow { overflow: hidden; }
  .tx-table tr[data-id] > td:nth-child(2) { overflow: hidden; }
  .tx-table .receipt-tag:not(.pending) { display: none; }
  .tx-table .receipt-tag.pending { font-size: 0; padding: 2px 5px; vertical-align: 2px; }
  .tx-table .receipt-tag.pending .ic { width: 12px; height: 12px; }
  .tx-table .desc .tag { display: none; }
}
@media (max-width: 860px) {
  .tx-table tr[data-id] { align-items: stretch; }
  .tx-table tr[data-id] > td { display: flex; align-items: center; }
  .m-swipe:not(.m-sw) .m-swipe-tray { visibility: hidden; }
}
/* deudores y acreedores: tabla → tarjetas de lista */
@media (max-width: 860px) {
  .table.clickable thead { display: none; }
  .table.clickable, .table.clickable tbody { display: block; }
  .table.clickable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name bal" "meta meta" "prog prog"; gap: 6px 12px; padding: 14px 16px; position: relative; }
  .table.clickable tr + tr::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--m-sep); }
  .table.clickable td { border: 0; padding: 0; }
  .table.clickable td:nth-child(1) { grid-area: name; }
  .table.clickable td:nth-child(7) { grid-area: bal; align-self: center; font-size: 16px; }
  .table.clickable td:nth-child(2) { grid-area: meta; padding-left: 52px; display: flex; gap: 10px; align-items: center; }
  .table.clickable td:nth-child(3) { grid-area: meta; justify-self: end; align-self: center; color: var(--m-label); font-size: 13.5px; }
  .table.clickable td:nth-child(4), .table.clickable td:nth-child(5) { display: none; }
  .table.clickable td:nth-child(6) { grid-area: prog; padding-left: 52px; }
  .table.clickable .cell-main small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .table.clickable .cell-main > div { min-width: 0; }
  .table.clickable tr:active { background: var(--m-press); }
  .m-head h1 { overflow-wrap: anywhere; }
}
@media (max-width: 860px) {
  .palette-input { gap: 8px; }
  .palette-cancel { display: block !important; background: none; border: 0; font: 500 16.5px var(--font); color: var(--m-gold-ink); padding: 0 0 0 6px; margin-right: -4px; cursor: pointer; white-space: nowrap; }
  .palette-input:has(.palette-cancel) { margin-right: 14px; }
}
.palette-cancel { display: none; }
/* acceso y registro: la tarjeta sube sobre la cabecera oscura como una hoja */
@media (max-width: 860px) {
  .auth { min-height: 100svh; display: flex; flex-direction: column; background: #121212; }
  .auth-side { padding: calc(24px + var(--m-safe-t)) 24px 60px; }
  .auth-main { flex: 1; position: relative; z-index: 1; margin-top: -32px; border-radius: 28px 28px 0 0; padding: 32px 22px calc(28px + var(--m-safe-b)); place-items: start center; box-shadow: 0 -16px 40px -20px rgba(0, 0, 0, .6); }
  .auth-main::before { content: ""; position: absolute; top: 9px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: rgba(120, 120, 128, .25); }
  .auth-card h1, .auth-card h2 { font-family: var(--serif, Georgia, serif); font-weight: 400; letter-spacing: -.025em; font-variation-settings: "SOFT" 100, "opsz" 144; }
  .auth-card .btn-primary { min-height: 52px; border-radius: 14px; font-size: 16.5px; }
}
@media (max-width: 860px) {
  .card table.table:not(.tx-table):not(.clickable), .page > table.table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card { max-width: 100%; }
  .card > *, .panel-block > * { min-width: 0; }
  .row-btns { flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .kv-list li { flex-wrap: wrap; }
  .kv-list li > b { white-space: normal; text-align: right; min-width: 0; margin-left: auto; }
  .span-2 { grid-column: auto !important; }
}
@media (max-width: 860px) {
  [data-theme="dark"] .seg, [data-theme="dark"] .view-toggle, [data-theme="dark"] .search-input, [data-theme="dark"] .palette-input { background: rgba(255, 255, 255, .07); }
}

/* ==========================================================================
   Ajustes finos de reparto de espacio (v1.0.10)
   ========================================================================== */
@media (max-width: 860px) {
  /* indicadores: sin huecos y en lista cuando el texto no cabe */
  .kpis > .kpi.m-span { grid-column: 1 / -1; }
  .kpis.m-rows { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kpis.m-rows > .kpi-hero { margin-bottom: 12px; }
  .kpis.m-rows > .kpi-hero ~ .kpi-hero { margin-top: 12px; }
  .kpis.m-rows > .kpi:not(.kpi-hero) {
    border-radius: 0; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start;
    gap: 3px; padding: 14px 16px; position: relative;
  }
  .kpis.m-rows > .kpi:not(.kpi-hero):not(.m-first)::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--m-sep); }
  .kpis.m-rows > .kpi.m-first { border-top-left-radius: 18px; border-top-right-radius: 18px; }
  .kpis.m-rows > .kpi.m-last { border-bottom-left-radius: 18px; border-bottom-right-radius: 18px; }
  .kpis.m-rows > .kpi-hero { margin-top: 12px; }
  .kpis.m-rows > .kpi-hero:first-child { margin-top: 0; }
  .kpis.m-rows > .kpi:not(.kpi-hero) .kpi-label { font-size: 13.5px; color: var(--m-label); font-weight: 550; }
  .kpis.m-rows > .kpi:not(.kpi-hero) .kpi-foot { font-size: 13px; color: var(--m-label); }
  .kpis.m-rows > .kpi:not(.kpi-hero) .kpi-value { font-size: 21px; }
  .kpis.m-rows > .kpi > :not(.kpi-label):not(.kpi-value):not(.kpi-foot) { grid-column: 1 / -1; }

  /* barras de herramientas: los botones se reparten todo el ancho */
  .toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
  .toolbar > .spacer { display: none; }
  .toolbar > .btn, .toolbar > a.btn { flex: 1 1 auto; justify-content: center; white-space: nowrap; }
  .toolbar > .stat-inline, .toolbar > .year-nav, .toolbar > .month-switch, .toolbar > .view-toggle, .toolbar > .seg, .toolbar > p, .toolbar > .kpis, .toolbar > .grow { flex: 1 1 100%; }
  .toolbar > .year-nav { justify-content: space-between; background: var(--m-group); border: 0; border-radius: 14px; height: 46px; }
  .stat-inline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--m-group); border-radius: 16px; }
  .stat-inline b { font-size: 22px; letter-spacing: -.02em; }

  .row-actions, .conn-actions, .card-foot, .page-head > .row-btns { display: flex; flex-wrap: wrap; gap: 10px; }
  .row-actions > .btn, .conn-actions > .btn, .page-head > .row-btns > .btn, .card-foot > .btn:not(.icon-btn) { flex: 1 1 auto; justify-content: center; white-space: nowrap; }
  .row-actions.end { justify-content: stretch; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .row-btns { width: 100%; }

  /* cabeceras de tarjeta: el botón no aprieta al título */
  .card-head { flex-wrap: wrap; row-gap: 10px; }
  .card-head > div:first-child { flex: 1 1 200px; min-width: 0; }
  .card-head > .btn, .card-head > .row-btns, .card-head > a { margin-left: auto; white-space: nowrap; }
  .card-head .legend { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; order: 3; }
  .card-head h3 { text-wrap: balance; }

  /* filas con acciones: se tocan para abrir la hoja de acciones */
  .m-hide { display: none !important; }
  .m-tap { cursor: pointer; -webkit-user-select: none; user-select: none; }
  .m-tap:active { background: var(--m-press); }
  .m-ico { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: rgba(118, 118, 128, .12); color: var(--ink); font-size: 17px; }
  .m-ico svg { width: 18px; height: 18px; }
  .m-actions .m-row:has(.m-ico) { justify-content: flex-start; }
  .m-actions .m-row:has(.m-ico) .m-row-t { flex: 1; text-align: left; }
  .m-actions .m-row:has(.m-ico) .m-row-t b { font-size: 16.5px; font-weight: 500; }
  .m-actions .m-row.danger .m-ico { background: rgba(214, 75, 60, .12); color: var(--neg); }

  /* presupuesto: fila compacta (nombre e importes arriba, barra debajo) */
  .budget-row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cat amt" "bar bar"; gap: 10px 12px; padding: 14px 16px !important; }
  .budget-row .br-cat { grid-area: cat; min-width: 0; }
  .budget-row .br-amt { grid-area: amt; text-align: right; }
  .budget-row .br-bar { grid-area: bar; }

  /* cuentas: totales por tipo en rejilla */
  .section-title { display: grid; gap: 10px; }
  .type-totals { width: 100%; display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .type-totals > span { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--m-group); font-size: 12.5px; color: var(--m-label); }
  .type-totals > span b { font-size: 15.5px; color: var(--ink); }
  .conn { grid-template-columns: 44px minmax(0, 1fr) !important; }
  .conn-actions { grid-column: 1 / -1; }

  /* categorías y reglas */
  .rows.dense li { min-height: 50px; }
  .rule-list li { flex-wrap: wrap; row-gap: 6px; }
  .inline-form { display: grid !important; grid-template-columns: 1fr; gap: 10px; }
  .inline-form .btn { width: 100%; }

  /* tickets: preferencias del buzón apiladas */
  .rc-settings summary { flex-direction: column; align-items: flex-start; gap: 4px; }

  /* resumen: últimos movimientos sin columna de fecha (va en el detalle) */
  .dash-tx .tx-date, .recent .tx-date { display: none; }
  .dash-bar { margin-bottom: -6px; }
}
/* tablas de movimientos → fichas */
@media (max-width: 860px) {
  table.m-stack { display: block !important; overflow: visible !important; }
  table.m-stack thead { display: none; }
  table.m-stack tbody { display: block; }
  table.m-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 16px; position: relative; }
  table.m-stack tr + tr::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--m-sep); }
  table.m-stack td { display: flex; gap: 8px; align-items: baseline; border: 0 !important; padding: 0 !important; font-size: 13.5px; color: var(--m-label); min-width: 0; grid-column: 1; white-space: normal !important; }
  table.m-stack td[data-label]::before { content: attr(data-label); flex: none; color: var(--m-label); opacity: .8; font-size: 12.5px; }
  table.m-stack td[data-label] { color: var(--text); }
  table.m-stack td.m-main { grid-column: 1; grid-row: 1; font-size: 15.5px; font-weight: 550; color: var(--ink); line-height: 1.3; }
  table.m-stack td.m-amt { grid-column: 2; grid-row: 1; justify-content: flex-end; font-size: 15.5px; font-weight: 600; color: var(--ink); white-space: nowrap !important; }
  table.m-stack td.m-empty { display: none; }
  table.m-stack td.row-btns, table.m-stack td:has(> .icon-btn) { grid-column: 2; grid-row: 2 / span 3; align-self: center; justify-content: flex-end; }
  table.m-stack td:has(select) select { min-height: 34px; height: 34px; font-size: 14px !important; padding: 0 28px 0 10px; }
}
@media (max-width: 860px) {
  table.m-stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  table.m-stack td { grid-column: auto; order: 2; flex: none; font-size: 13px; }
  table.m-stack td[data-label]::before { display: none; }
  table.m-stack td.m-main { order: 0; flex: 1 1 calc(100% - 120px); min-width: 0; font-size: 15px; }
  table.m-stack td.m-amt { order: 1; flex: none; margin-left: auto; }
  table.m-stack td.m-main ~ td:not(.m-amt) { color: var(--m-label); }
  table.m-stack td .pill { font-size: 11.5px; padding: 1px 8px; }
  table.m-stack td.row-btns, table.m-stack td:has(> .icon-btn) { order: 3; margin-left: auto; }
}
@media (max-width: 860px) {
  table.m-stack td.m-main { flex: 1 0 calc(100% - 130px); }
  table.m-stack td.m-lab::before { display: inline !important; content: attr(data-label) " "; }
  table.m-stack td.m-lab { color: var(--text) !important; }
  .card-head > .row-btns:has(> .btn + .btn) { flex: 1 1 100%; margin-left: 0; display: flex; flex-wrap: wrap; gap: 8px; }
  .card-head > .row-btns:has(> .btn + .btn) > .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 860px) {
  table.m-stack td.m-main { display: block; }
  table.m-stack td.m-main small, table.m-stack td.m-main .muted { display: block; font-weight: 400; font-size: 13px; color: var(--m-label); margin-top: 1px; }
  table.m-stack tr::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
}
@media (max-width: 860px) {
  table.m-stack td { max-width: 100%; }
  table.m-stack .linked { white-space: normal; }
  table.m-stack td.m-main .linked { display: block; font-size: 14.5px; font-weight: 550; }
  table.m-stack td.m-main .linked .ic { display: inline; vertical-align: -2px; }
}
@media (max-width: 860px) {
  .title-row { align-items: flex-start; }
  .title-row h3 { display: block; line-height: 1.3; }
  .title-row h3 .pill { display: inline-flex; margin: 4px 0 0; vertical-align: 1px; }
  .card-head > .row-btns:has(> .btn) { flex: 1 1 100%; margin-left: 0; display: flex; gap: 8px; align-items: center; }
  .card-head > .row-btns:has(> .btn) > .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 860px) {
  .ap-options { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; }
  .ap-options:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ap-card { padding: 8px !important; font-size: 13px; }
  .rule-list li { display: grid !important; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 4px 10px; padding: 12px 4px; }
  .rule-list li .idx { grid-row: 1 / span 2; align-self: center; }
  .rule-list li code { justify-self: start; }
  .rule-list li .arrow, .rule-list li .spacer { display: none; }
  .rule-list li .cat-badge { grid-column: 2; justify-self: start; }
}
@media (max-width: 860px) {
  .ap-options { display: grid !important; }
  .ap-card { width: auto !important; }
  .rule-list { max-height: none; overflow: visible; }
}
@media (max-width: 860px) {
  .kv-list li { flex-wrap: nowrap !important; }
  .kv-list li > span { flex: 1 1 45%; min-width: 0; }
  .kv-list li > b { flex: 0 1 auto; }
  .kv-list li > b { text-align: right; }
  .session .pill, .sessions .pill, li .pill { justify-self: start; width: auto; }
  table.m-stack td:has(> .icon-btn.m-hide):not(:has(> :not(.m-hide))) { display: none; }
}
@media (max-width: 860px) {
  .modal-head { grid-template-columns: auto minmax(0, 1fr) auto; }
  .modal-head .m-head-cancel, .modal-head .m-head-done { min-width: 72px; }
  .modal-head .m-head-done { text-align: right; }
  .modal-title h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
  [data-theme="dark"] input[type=checkbox] { accent-color: var(--m-gold); }
  label.check { display: flex; align-items: flex-start; gap: 10px; line-height: 1.4; }
  label.check input { margin-top: 1px; }
}
@media (max-width: 860px) {
  .modal, .modal-wide { width: 100vw !important; max-width: 100vw; min-width: 0; }
  .modal-body { overflow-x: hidden; }
  .modal-body .table-wrap, .modal-body table { max-width: 100%; }
  .modal-body table { font-size: 13.5px; }
  .modal-body table th, .modal-body table td { padding-left: 6px; padding-right: 6px; }
  .modal-body table input:not([type=checkbox]):not([type=radio]) { width: 78px; min-height: 40px !important; padding: 0 8px; }
  .modal-body table td:first-child, .modal-body table th:first-child { width: 34px; padding-left: 0; }
  .modal-body table { width: 100%; }
}
@media (max-width: 860px) {
  .section .section-title, .section-title { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; }
  .section-title .type-totals { width: 100% !important; margin: 0 !important; }
  .section-title .type-totals > span { margin: 0 !important; }
}
@media (max-width: 860px) { .type-totals b { margin-left: 0 !important; } }
@media (max-width: 860px) { table.m-stack td:not(.m-main) .linked { display: inline; } table.m-stack td:not(.m-main) .linked small { display: inline; } }

/* Asistentes IA en el móvil */
@media (max-width: 860px) {
  .ai-hero { padding: 20px; gap: 22px; }
  .ai-chat { font-size: 13px; }
  .ai-seg { width: auto; margin-left: -2px; margin-right: -2px; }
  .ai-steps > li { padding-left: 38px; }
  .ai-steps .addr-row, .ai-steps .ai-code { margin-left: -38px; }
  .ai-prompt-grid { grid-template-columns: 1fr; gap: 10px; }
  .ai-prompt-q { font-size: 15px; }
  .ai-log { max-height: none; overflow: visible; }
  .ai-conn, .ai-log-row { padding: 12px 16px; align-items: flex-start; }
  .ai-log-row b { -webkit-line-clamp: 3; }
  .ai-log-row [data-undo] { padding: 6px 10px; font-size: 13px; }
  .ai-conn [data-revoke] { padding: 6px 10px; }
  .ai-activity .card-head { flex-wrap: wrap; }
  .ai-code { padding-left: 12px; }
}
input[type=checkbox].switch { width: 44px; height: 26px; accent-color: initial; }
