:root {
  color-scheme: light;
  --bg:      #eef3f8;
  --surface: #ffffff;
  --surface2:#f2f6fb;
  --border:  #cdd8e3;
  --accent:  #1f9e6e;
  --accent2: #1e7dc4;
  --accent3: #d97c2a;
  --accent4: #d44444;
  --accent5: #7153a8;
  /* Color de marca (isotipo FUXI ONE) para acciones primarias y navegación activa.
     Separado de --accent (verde) a propósito: --accent sigue significando "éxito"
     en badges, alertas y estados (no se toca), esto es solo la identidad visual. */
  --brand:          #111111;
  --brand-hover:    #2c2c2c;
  --brand-contrast: #ffffff;
  --brand-tint:     rgba(17,17,17,.06);
  --text:    #1a2535;
  --text2:   #556070;
  --text3:   #9aaab8;
  --radius:  10px;
  /* Alias usados por vistas de ABM (Mascotas/Tutores): sin estos, esas vistas
     quedaban con fallback fijo claro (#fff/#222) y no seguían el modo oscuro,
     produciendo texto claro sobre fondo blanco = ilegible en dark mode. */
  --card-bg:    var(--surface);
  --input-bg:   var(--surface2);
  --text-muted: var(--text2);
  --bg2:        var(--surface2);
}
* { margin:0; padding:0; box-sizing:border-box; }
img { max-width:100%; height:auto; }
body { font-family:'DM Sans',sans-serif; background:var(--bg); color:var(--text); height:100vh; display:flex; overflow:hidden; }

/* SIDEBAR */
.sidebar { width:220px; min-width:220px; background:var(--surface); border-right:1px solid var(--border); display:flex; flex-direction:column; padding:24px 0; gap:4px; overflow-y:auto; }
.sidebar-logo { padding:0 20px 24px; border-bottom:1px solid var(--border); margin-bottom:8px; }
.sidebar-logo h1 { font-family:'DM Serif Display',serif; font-size:22px; color:var(--text); }
.sidebar-logo span { font-size:11px; color:var(--text2); text-transform:uppercase; letter-spacing:1px; }
.sidebar-logo .logo-mark { height:28px; width:auto; display:block; margin-bottom:6px; }
/* El isotipo es negro sobre transparente: en modo oscuro el sidebar pasa a fondo
   oscuro, así que se invierte a blanco en vez de mantener un asset aparte. */
[data-theme="dark"] .sidebar-logo .logo-mark { filter:invert(1); }
/* Nombre + isologo de la clínica (tenant), debajo del isologo de FUXI ONE. */
.sidebar-clinica { display:flex; align-items:center; gap:8px; margin-top:12px; padding-top:12px; border-top:1px solid var(--border); }
.sidebar-clinica-logo { width:26px; height:26px; border-radius:6px; object-fit:cover; flex-shrink:0; background:var(--surface2); }
.sidebar-clinica-inicial { width:26px; height:26px; border-radius:6px; background:var(--brand-tint); color:var(--brand); font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.sidebar-clinica-nombre { font-size:13px; font-weight:600; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-section { padding:6px 12px 2px; font-size:10px; color:var(--text3); text-transform:uppercase; letter-spacing:1.2px; font-weight:600; margin-top:8px; }
.nav-item { display:flex; align-items:center; gap:10px; padding:9px 20px; cursor:pointer; color:var(--text2); font-size:14px; border-left:3px solid transparent; text-decoration:none; transition:all .15s; }
.nav-item:hover { background:var(--surface2); color:var(--text); }
.nav-item.active { color:var(--brand); border-left-color:var(--brand); background:var(--brand-tint); }
.nav-item svg { width:16px; height:16px; flex-shrink:0; }
.sidebar-footer { margin-top:auto; padding:16px 20px; border-top:1px solid var(--border); }
.vet-card { display:flex; align-items:center; gap:10px; }
.vet-avatar { width:34px; height:34px; border-radius:50%; background:linear-gradient(135deg,#3fb950,#58a6ff); display:flex; align-items:center; justify-content:center; font-weight:600; font-size:13px; color:#fff; flex-shrink:0; }
.vet-info .name { font-size:13px; font-weight:500; }
.vet-info .role { font-size:11px; color:var(--text2); }

/* MAIN */
.main { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.topbar { background:var(--surface); border-bottom:1px solid var(--border); padding:14px 28px; display:flex; align-items:center; justify-content:space-between; gap:16px; }
.topbar-title { font-family:'DM Serif Display',serif; font-size:20px; }
.topbar-date { font-size:13px; color:var(--text2); }
.topbar-actions { display:flex; align-items:center; gap:10px; }
.content { flex:1; overflow-y:auto; padding:24px 28px; min-height:0; }

/* BUTTONS */
.btn { padding:8px 16px; border-radius:6px; border:none; cursor:pointer; font-size:13px; font-family:'DM Sans',sans-serif; font-weight:500; display:inline-flex; align-items:center; gap:6px; transition:all .15s; text-decoration:none; }
.btn-primary { background:var(--brand); color:var(--brand-contrast); }
.btn-primary:hover { background:var(--brand-hover); }
.btn-ghost { background:transparent; color:var(--text2); border:1px solid var(--border); }
.btn-ghost:hover { background:var(--surface2); color:var(--text); }
.btn-sm { padding:5px 12px; font-size:12px; }
.btn-danger { background:rgba(255,123,114,.15); color:var(--accent4); border:1px solid rgba(255,123,114,.3); }
.btn-info { background:rgba(88,166,255,.12); color:var(--accent2); border:1px solid rgba(88,166,255,.25); }
.btn-info:hover { background:rgba(88,166,255,.2); }
.btn-success { background:rgba(63,185,80,.12); color:var(--accent); border:1px solid rgba(63,185,80,.25); }
.btn-success:hover { background:rgba(63,185,80,.2); }

/* STATS */
.stats-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:24px; }
.stat-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; }
.stat-label { font-size:11px; color:var(--text2); text-transform:uppercase; letter-spacing:.8px; margin-bottom:8px; }
.stat-value { font-size:28px; font-family:'DM Serif Display',serif; letter-spacing:-1px; }
.stat-sub { font-size:12px; color:var(--text2); margin-top:4px; }
.stat-card.blue .stat-value { color:var(--accent2); }
.stat-card.orange .stat-value { color:var(--accent3); }
.stat-card.purple .stat-value { color:var(--accent5); }
.stat-card.green .stat-value { color:var(--accent); }

/* ALERT ROW */
.alert-row { display:flex; gap:12px; margin-bottom:20px; }
.alert-card { flex:1; padding:14px 16px; border-radius:10px; display:flex; align-items:center; gap:12px; border:1px solid; cursor:pointer; transition:all .15s; text-decoration:none; }
.alert-card:hover { filter:brightness(1.1); }
.alert-card.orange { background:rgba(240,136,62,.08); border-color:rgba(240,136,62,.3); }
.alert-card.red    { background:rgba(255,123,114,.08); border-color:rgba(255,123,114,.3); }
.alert-card.green  { background:rgba(63,185,80,.08);   border-color:rgba(63,185,80,.3); }
.a-icon { font-size:24px; }
.a-num  { font-size:22px; font-family:'DM Serif Display',serif; }
.a-label { font-size:11px; color:var(--text2); }
.alert-card.orange .a-num { color:var(--accent3); }
.alert-card.red    .a-num { color:var(--accent4); }
.alert-card.green  .a-num { color:var(--accent); }

/* SECTION */
.section-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.section-title  { font-size:15px; font-weight:600; }
.section-sub    { font-size:12px; color:var(--text2); margin-top:2px; }

/* FILTERS */
.filters { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.filter-btn { padding:5px 13px; border-radius:20px; border:1px solid var(--border); background:transparent; color:var(--text2); font-size:12px; cursor:pointer; font-family:'DM Sans',sans-serif; transition:all .15s; text-decoration:none; }
.filter-btn:hover, .filter-btn.active { background:var(--brand); color:var(--brand-contrast); border-color:var(--brand); font-weight:500; }

/* TABLE */
.turnos-table { width:100%; border-collapse:collapse; background:var(--surface); border-radius:var(--radius); overflow:hidden; border:1px solid var(--border); }
.turnos-table th { padding:11px 16px; text-align:left; font-size:11px; color:var(--text2); font-weight:600; text-transform:uppercase; letter-spacing:.7px; background:var(--surface2); border-bottom:1px solid var(--border); }
.turnos-table td { padding:13px 16px; font-size:13px; border-bottom:1px solid rgba(48,54,61,.5); vertical-align:middle; }
.turnos-table tr:last-child td { border-bottom:none; }
.turnos-table tbody tr:hover { background:rgba(0,0,0,.03); }
.pet-cell { display:flex; align-items:center; gap:10px; }
.pet-avatar { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:16px; background:var(--surface2); flex-shrink:0; }
.pet-name  { font-weight:500; }
.pet-breed { font-size:11px; color:var(--text2); }
.time-cell { font-family:'DM Serif Display',serif; font-size:16px; }
.motivo-cell { color:var(--text2); font-size:12px; max-width:160px; }
.actions-cell { display:flex; gap:6px; }

/* BADGES */
.badge { display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:500; white-space:nowrap; }
.badge-dot { width:5px; height:5px; border-radius:50%; }
.badge-scheduled { background:rgba(88,166,255,.1);   color:var(--accent2); } .badge-scheduled .badge-dot { background:var(--accent2); }
.badge-checkin   { background:rgba(240,136,62,.12);  color:var(--accent3); } .badge-checkin   .badge-dot { background:var(--accent3); }
.badge-attention { background:rgba(210,168,255,.1);  color:var(--accent5); } .badge-attention .badge-dot { background:var(--accent5); }
.badge-checkout  { background:rgba(63,185,80,.1);    color:var(--accent);  } .badge-checkout  .badge-dot { background:var(--accent);  }
.badge-done      { background:rgba(139,148,158,.1);  color:var(--text2);   } .badge-done      .badge-dot { background:var(--text2);   }
.badge-urgent    { background:rgba(255,123,114,.12); color:var(--accent4); } .badge-urgent    .badge-dot { background:var(--accent4); }

/* CHECKIN FLOW */
.checkin-flow { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text2); margin-bottom:20px; padding:10px 14px; background:var(--surface2); border-radius:8px; border:1px solid var(--border); flex-wrap:wrap; }
.flow-step-pill { padding:3px 10px; border-radius:12px; font-weight:500; }
.blue-pill   { background:rgba(88,166,255,.15);  color:var(--accent2); }
.orange-pill { background:rgba(240,136,62,.12);  color:var(--accent3); }
.purple-pill { background:rgba(210,168,255,.1);  color:var(--accent5); }
.green-pill  { background:rgba(63,185,80,.1);    color:var(--accent); }
.flow-arrow  { color:var(--text3); }

/* PATIENT */
.patient-hero { display:flex; align-items:center; gap:16px; padding:16px; background:var(--surface2); border-radius:10px; margin-bottom:20px; border:1px solid var(--border); }
.patient-emoji { font-size:40px; }
.patient-name  { font-size:18px; font-weight:600; }
.patient-meta  { font-size:12px; color:var(--text2); display:flex; gap:12px; margin-top:4px; flex-wrap:wrap; }
.patient-meta span::before { content:'•'; margin-right:6px; color:var(--text3); }
.patient-meta span:first-child::before { display:none; }

/* INFO GRID */
.info-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:16px; }
.info-item { background:var(--surface2); border:1px solid var(--border); border-radius:8px; padding:12px 14px; }
.info-item label { font-size:10px; color:var(--text2); text-transform:uppercase; letter-spacing:.7px; display:block; margin-bottom:4px; }
.info-item value { font-size:14px; font-weight:500; display:block; }

/* HISTORY */
.history-list { display:flex; flex-direction:column; gap:10px; }
.history-item { padding:12px 14px; background:var(--surface2); border-radius:8px; border:1px solid var(--border); display:flex; gap:12px; align-items:flex-start; }
.history-date { font-size:11px; color:var(--text2); white-space:nowrap; }
.history-type { font-size:11px; color:var(--accent2); margin-bottom:2px; font-weight:500; }
.history-text { font-size:13px; }

/* WIZARD */
.wizard-section { background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:20px; margin-bottom:16px; }
.wizard-section-title { font-size:14px; font-weight:600; margin-bottom:16px; display:flex; align-items:center; gap:10px; }
.wizard-num { width:24px; height:24px; border-radius:50%; background:var(--accent2); color:#000; font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; }

/* FORM */
.form-group { margin-bottom:16px; }
.form-label { font-size:12px; color:var(--text2); margin-bottom:6px; display:block; font-weight:500; text-transform:uppercase; letter-spacing:.5px; }
.form-input, .form-textarea, .form-select { width:100%; background:var(--surface2); border:1px solid var(--border); border-radius:8px; padding:10px 12px; color:var(--text); font-family:'DM Sans',sans-serif; font-size:14px; outline:none; transition:border-color .15s; }
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color:var(--accent2); }
.form-textarea { resize:vertical; min-height:80px; }
.form-select { cursor:pointer; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* SUMMARY */
.summary-table { width:100%; border-collapse:collapse; }
.summary-table td { padding:8px 0; font-size:13px; border-bottom:1px solid rgba(48,54,61,.5); }
.summary-table td:last-child { text-align:right; font-weight:500; }
.summary-table tr:last-child td { border:none; font-size:15px; font-weight:700; color:var(--accent); }

/* EMPTY STATE */
.empty-state { text-align:center; padding:48px 20px; color:var(--text2); }
.empty-state-icon { font-size:40px; margin-bottom:12px; }
.empty-state h3 { font-size:15px; color:var(--text); margin-bottom:6px; }

/* ALERT */
.alert-success { background:rgba(63,185,80,.1); border:1px solid rgba(63,185,80,.3); border-radius:8px; padding:12px 16px; margin-bottom:16px; font-size:13px; color:var(--accent); }

/* ──────────── DARK MODE ──────────── */
[data-theme="dark"] {
  /* Sin esto, selects/inputs de fecha/hora nativos en mobile siguen el tema
     del sistema operativo en vez del tema de la app: si el celular está en
     claro y la app en oscuro (o viceversa), el navegador puede pintar texto
     oscuro sobre fondo oscuro (o claro sobre claro) en esos controles nativos. */
  color-scheme: dark;
  --bg:      #0d1117;
  --surface: #161b22;
  --surface2:#1c2330;
  --border:  #30363d;
  --accent:  #3fb950;
  --accent2: #58a6ff;
  --accent3: #f0883e;
  --brand:          #ffffff;
  --brand-hover:    #d0d0d0;
  --brand-contrast: #111111;
  --brand-tint:     rgba(255,255,255,.08);
  --accent4: #ff7b72;
  --accent5: #d2a8ff;
  --text:    #e6edf3;
  --text2:   #8b949e;
  --text3:   #484f58;
}
[data-theme="dark"] .turnos-table tbody tr:hover { background: rgba(255,255,255,.02); }

/* THEME TOGGLE BUTTON */
.btn-theme {
  width: 34px; height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-theme:hover { background: var(--border); color: var(--text); }
.btn-theme svg { width: 16px; height: 16px; }
/* Mostrar icono correcto según tema */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* SCROLLBAR */
::-webkit-scrollbar { width:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

/* ──────────── HAMBURGER BUTTON ──────────── */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .22s ease, opacity .22s ease;
  transform-origin: center;
}

/* Hamburguesa → X cuando sidebar está abierto */
body.sidebar-open .sidebar-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sidebar-open .sidebar-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.sidebar-open .sidebar-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Checkin cards */
.checkin-card { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:14px 18px; display:flex; align-items:center; gap:16px; }
.checkin-card-emoji { font-size:36px; flex-shrink:0; }
.checkin-card-info { flex:1; min-width:0; }
.checkin-card-actions { display:flex; gap:8px; flex-shrink:0; }
.topbar-left { display: flex; align-items: center; gap: 12px; }

/* ──────────── SIDEBAR OVERLAY ──────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ──────────── MOBILE BOTTOM NAV (oculto en desktop) ──────────── */
.mobile-bottom-nav { display: none; }

/* ──────────── RESPONSIVE — MOBILE Y TABLET (≤ 900px) ────────────
   900px en vez de 768px a propósito: una tablet de 10" en vertical mide
   ~800-834px de ancho lógico (iPad ~810-834px, Android ~800px) y con 768px
   quedaba justo afuera del breakpoint mobile, renderizando el layout de
   escritorio completo (sidebar fijo + grillas de 2 columnas) apretado en
   poco ancho — eso era lo que hacía que el scroll no llegara a mostrar los
   últimos campos (ej. próximo turno). Con 900px, tablets en vertical entran
   al layout mobile (sidebar en drawer, grillas a 1 columna) y tablets en
   horizontal (~1024px+) siguen con el layout de escritorio, que ahí sí tiene
   ancho de sobra. */
@media (max-width: 900px) {
  /* Scroll natural de página en mobile */
  body {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100vh;
  }

  /* Sidebar como drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
    min-width: 260px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,.5); }
  body.sidebar-open { overflow: hidden; }

  /* Nav items más grandes para dedos */
  .nav-item { padding: 14px 20px; font-size: 15px; }
  .nav-item svg { width: 20px; height: 20px; }
  .sidebar-section { padding: 10px 12px 4px; font-size: 11px; }

  /* Toggle visible en mobile, más grande */
  .sidebar-toggle { display: flex; width: 44px; height: 44px; }
  .btn-theme { width: 44px; height: 44px; }

  /* Topbar pegado arriba */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 12px 16px;
    background: var(--surface);
  }
  .topbar-title { font-size: 17px; }
  .topbar-date { font-size: 11px; }

  /* Main y content fluyen con el contenido */
  .main { display: flex; flex-direction: column; min-height: 100vh; width: 100%; overflow: visible; }
  /* Espacio para la bottom nav */
  .content { flex: none; overflow: visible; padding: 16px; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* ─── BOTONES GRANDES — mínimo 44px para toque cómodo ─── */
  .btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 8px;
  }
  .btn-sm {
    min-height: 42px;
    padding: 9px 16px;
    font-size: 13px;
  }
  .filter-btn {
    min-height: 40px;
    padding: 9px 18px;
    font-size: 13px;
  }

  /* ─── INPUTS GRANDES — 16px evita el zoom automático de iOS ─── */
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px;
    padding: 13px 14px;
    min-height: 50px;
  }

  /* Stats: 2 columnas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 22px; }

  /* Alert row: vertical */
  .alert-row { flex-direction: column; gap: 8px; }
  .alert-card { padding: 16px 18px; }
  .a-num { font-size: 26px; }

  /* ─── TABLA → CARDS ─── */
  .turnos-table {
    display: block !important;
    overflow-x: visible !important;
    white-space: normal !important;
    border: none;
    background: transparent;
  }
  .turnos-table thead { display: none; }
  .turnos-table tbody { display: flex; flex-direction: column; gap: 12px; }
  .turnos-table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--surface);
    white-space: normal;
  }
  .turnos-table td {
    display: block;
    padding: 2px 0;
    border: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .turnos-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .7px;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 2px;
  }
  .turnos-table td.time-cell {
    font-size: 24px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
  }
  .turnos-table td.time-cell::before { margin-top: 0; }
  /* Ocultar columna veterinario en mobile (info secundaria) */
  .turnos-table td[data-label="Veterinario"] { display: none; }
  .motivo-cell { max-width: none; overflow: visible; white-space: normal; }
  .turnos-table td.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
  }
  /* Botones de acción a todo el ancho disponible */
  .turnos-table td.actions-cell .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }

  /* Wizard */
  .wizard-section { padding: 14px; }

  /* Checkin flow wrap */
  .checkin-flow { gap: 6px; }

  /* Patient hero */
  .patient-hero { flex-wrap: wrap; }
  .patient-emoji { font-size: 36px; }
  .patient-name { font-size: 16px; }

  /* Cobro layout — el action-bar antes quedaba en bottom:0, tapado detrás
     de la bottom nav (también fija, con más z-index): la última sección
     (cuenta corriente) quedaba inalcanzable aunque se hiciera scroll.
     Importante: en mobile .cobro-side (Resumen) queda DEBAJO de .cobro-main
     (una sola columna), así que el padding de despeje para el action-bar
     fijo tiene que ir en .cobro-side (lo último que se ve), no en
     .cobro-main — si no, quedaba un hueco enorme en el medio de la página
     entre "Cuenta corriente" y "Resumen". */
  .cobro-layout { grid-template-columns: 1fr !important; }
  .cobro-side { position: static !important; padding-bottom: 160px !important; }
  .cobro-main { padding-bottom: 16px !important; }
  .action-bar {
    left: 0 !important;
    right: 0 !important;
    bottom: calc(58px + env(safe-area-inset-bottom)) !important;
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    flex-wrap: wrap !important;
  }
  .action-bar .btn { flex: 1; justify-content: center; min-width: 100px; }

  /* Checkin cards */
  .checkin-card { flex-wrap: wrap; gap: 12px; padding: 16px 18px; }
  .checkin-card-emoji { font-size: 42px; }
  .checkin-card-actions {
    width: 100%;
    display: flex;
    gap: 10px;
  }
  .checkin-card-actions .btn { flex: 1; justify-content: center; }

  /* ─── BOTTOM NAV BAR ─── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 95;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 8px;
    color: var(--text3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .3px;
    gap: 4px;
    transition: color .15s;
    min-height: 58px;
  }
  .mbn-item svg { width: 22px; height: 22px; }
  .mbn-item.active { color: var(--brand); }
  .mbn-item:not(.active) { color: var(--text3); }
}

/* ──────────── RESPONSIVE — SMALL MOBILE (≤ 480px) ──────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 20px; }
  .topbar-date { display: none; }
  .content { padding: 12px; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* Botones siguen siendo grandes en pantallas pequeñas */
  .btn { font-size: 14px; padding: 10px 14px; }
  .btn-sm { font-size: 13px; padding: 9px 14px; }
  .actions-cell { flex-wrap: wrap; gap: 6px; }
  .section-header { flex-wrap: wrap; gap: 8px; }
  .filters { gap: 6px; }
}

/* ──────────── UPGRADE BANNER / PLAN GATE ──────────── */
.upgrade-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 18, 30, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.upgrade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 44px;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  animation: upgradeIn .22s ease;
}
@keyframes upgradeIn {
  from { opacity:0; transform: scale(.94) translateY(12px); }
  to   { opacity:1; transform: scale(1)  translateY(0); }
}
.upgrade-lock {
  width: 64px;
  height: 64px;
  background: rgba(31,158,110,.12);
  border: 2px solid rgba(31,158,110,.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--accent);
}
.upgrade-lock svg { width: 28px; height: 28px; }
.upgrade-plan-badge {
  display: inline-block;
  background: rgba(88,166,255,.12);
  color: var(--accent2);
  border: 1px solid rgba(88,166,255,.25);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 3px 12px;
  margin-bottom: 14px;
}
.upgrade-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}
.upgrade-desc {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 28px;
}
.upgrade-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.upgrade-btn-main {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
}
.upgrade-btn-dismiss {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text2);
}
.upgrade-btn-dismiss:hover { color: var(--text); }

/* Indicador de lock en sidebar */
.nav-item .nav-lock {
  margin-left: auto;
  opacity: .45;
  flex-shrink: 0;
}
.nav-item .nav-lock svg { width: 13px; height: 13px; }
.nav-item:hover .nav-lock { opacity: .7; }

/* Plan badge en sidebar footer */
.plan-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  background: rgba(31,158,110,.12);
  color: var(--accent);
  border: 1px solid rgba(31,158,110,.25);
}
.plan-badge.plan-medium {
  background: rgba(88,166,255,.12);
  color: var(--accent2);
  border-color: rgba(88,166,255,.25);
}
.plan-badge.plan-full {
  background: rgba(113,83,168,.12);
  color: var(--accent5);
  border-color: rgba(113,83,168,.25);
}

/* Dark mode */
[data-theme="dark"] .upgrade-overlay { background: rgba(0,0,0,.8); }
[data-theme="dark"] .upgrade-card { background: #161b22; border-color: #30363d; }

/* ── Modo solo lectura (plan insuficiente, usuario eligió "Ver de todas formas") ── */
.plan-readonly-bar {
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(88,166,255,.10);
  border: 1px solid rgba(88,166,255,.28);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--accent2);
  margin-bottom: 16px;
}
.plan-readonly-bar svg { flex-shrink: 0; width: 15px; height: 15px; }
body.plan-view-only .plan-readonly-bar { display: flex; }

/* Deshabilita visualmente todos los controles interactivos dentro del contenido */
body.plan-view-only .content button,
body.plan-view-only .content input,
body.plan-view-only .content select,
body.plan-view-only .content textarea,
body.plan-view-only .content a.btn,
body.plan-view-only .content .btn,
body.plan-view-only .content .filter-btn,
body.plan-view-only .content .orden-actions,
body.plan-view-only .content form {
  pointer-events: none !important;
  opacity: 0.38 !important;
  cursor: not-allowed !important;
}

@media (max-width: 480px) {
  .upgrade-card { padding: 28px 20px; }
  .upgrade-title { font-size: 18px; }
  .upgrade-actions { flex-direction: column; }
  .upgrade-btn-main, .upgrade-btn-dismiss { width: 100%; justify-content: center; }
}

/* ──────────── MODAL DE CONFIRMACIÓN / AVISO (reemplaza confirm()/alert() nativos) ──────────── */
/* Los diálogos nativos muestran la URL de la página ("miapp.com dice:") y en
   algunos navegadores/webviews móviles pueden no aparecer, dejando la acción
   "colgada" sin botones visibles para continuar. Este modal vive siempre en
   el DOM y no depende del navegador. */
.app-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.app-modal-overlay.on { display: flex; }
.app-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.app-modal-msg {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-line;
  margin-bottom: 20px;
}
.app-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
@media (max-width: 480px) {
  .app-modal-box { padding: 20px; }
  .app-modal-actions { flex-direction: column-reverse; }
  .app-modal-actions .btn { width: 100%; justify-content: center; }
}

/* ──────────── BARRA DE ACCIONES FIJA (wizards / formularios largos) ──────────── */
.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .wizard-actions {
    position: fixed;
    left: 0;
    right: 0;
    /* Por encima de la bottom nav (58px + safe-area), si no queda tapada */
    bottom: calc(58px + env(safe-area-inset-bottom));
    background: var(--bg);
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    z-index: 60;
    margin-top: 0;
  }
  .wizard-actions .btn { flex: 1; justify-content: center; }
  /* Deja lugar para que la barra fija no tape el último campo del formulario */
  .wizard-actions-spacer { display: block; height: 140px; }
}
