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

:root {
  /* ═══ COLORES PRINCIPALES — cambiá estas variables para cambiar el tema ═══ */
  /* Sidebar: slate profundo con gradient para contrastar con el navy del logo */
  --sidebar-bg-1:   #0f172a;
  --sidebar-bg-2:   #1e293b;
  --sidebar-hover:  rgba(255,255,255,.08);
  --sidebar-active: rgba(46,134,222,.18);
  --sidebar-active-bar: #2E86DE;
  --accent:         #2E86DE;
  --accent-dark:    #1a6abf;
  --navy:           #1A2B5E;  /* color del logo - usado en botones primarios */
  --verde:          #0F6E56;
  --rojo:           #C0392B;
  --amarillo:       #E67E22;
  /* ══════════════════════════════════════════════════════════════════════════ */
  --gris:     #6B7280;
  --gris-cl:  #F3F4F6;
  --borde:    #E5E7EB;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);

  /* ═══ SOMBRAS FLOTANTES ═══ */
  --sh-sm:  0 1px 3px rgba(20,30,60,.04), 0 1px 2px rgba(20,30,60,.03);
  --sh-md:  0 4px 12px rgba(20,30,60,.06), 0 2px 4px rgba(20,30,60,.04);
  --sh-lg:  0 10px 28px rgba(20,30,60,.08), 0 4px 10px rgba(20,30,60,.05);
  --sh-xl:  0 20px 40px rgba(20,30,60,.12), 0 8px 16px rgba(20,30,60,.06);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; color: #1f2937;
  background: #cbcbcb;
  background-image:
    radial-gradient(circle at 20% 0%,  rgba(46,134,222,.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(26,43,94,.05)  0%, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── LOGIN ── */
.login-screen {
  display: none; position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1A2B5E 100%);
  align-items: center; justify-content: center; z-index: 9999;
  padding: 20px;
  padding-top:    calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
.login-screen.show { display: flex; }
.login-box {
  background: #fff; border-radius: 18px; padding: 40px 36px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
  margin-bottom: 24px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 20px;
  display: inline-block;
}
.login-logo img { height: 80px; display: block; }
.login-box h2 { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.login-box p  { font-size: 13px; color: #6B7280; margin-bottom: 24px; }
.login-box input {
  width: 100%; padding: 13px 14px; border: 1.5px solid #E5E7EB;
  border-radius: 9px; font-size: 16px; margin-bottom: 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.login-box input:focus { border-color: #2E86DE; box-shadow: 0 0 0 3px rgba(46,134,222,.15); }
.login-btn {
  width: 100%; padding: 14px; background: var(--navy); color: #fff;
  border: none; border-radius: 9px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, box-shadow .15s; margin-top: 4px;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
.login-btn:hover { background: #2E4A8A; box-shadow: 0 6px 18px rgba(26,43,94,.35); }
.login-error { color: #C0392B; font-size: 12px; margin-top: 8px; display: none; }
.login-error.show { display: block; }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg-1) 0%, var(--sidebar-bg-2) 100%);
  display: flex; flex-direction: column;
  z-index: 200; transition: transform .25s ease;
  box-shadow: 4px 0 24px rgba(20,30,60,.15);
  padding-top:    var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar-logo {
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
}
/* Cajita BLANCA detrás del logo para que se vea tal cual fue diseñado */
.sidebar-logo-box {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.9);
}
.sidebar-logo-box img {
  width: 100%;
  max-width: 170px;
  height: auto;
  max-height: 66px;
  object-fit: contain;
  display: block;
}
.sidebar-sep { height: 1px; background: rgba(255,255,255,.06); margin: 6px 0; }
.nav-links { list-style: none; padding: 10px 10px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; color: rgba(255,255,255,.72); text-decoration: none;
  font-size: 14px; border-radius: 10px; margin-bottom: 3px;
  transition: background .15s, color .15s;
  position: relative;
  min-height: 44px;
}
.nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-active-bar);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-link.active svg, .nav-link:hover svg { opacity: 1; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06);
  font-size: 11px; color: rgba(255,255,255,.4); text-align: center;
}
.btn-logout {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 11px 14px; color: rgba(255,255,255,.6); background: none;
  border: none; border-radius: 8px; font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s; margin-bottom: 6px;
  min-height: 44px;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }

/* ── TOPBAR mobile ── */
.topbar {
  display: none; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 14px;
  background: #fff; border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(20,30,60,.05);
  padding-top: var(--safe-top);
  height: calc(var(--topbar-h) + var(--safe-top));
}
.topbar-title { flex: 1; font-weight: 600; font-size: 16px; }
.hamburger {
  background: none; border: none; cursor: pointer;
  color: var(--navy); padding: 8px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  transition: background .15s;
}
.hamburger:hover { background: var(--gris-cl); }
.hamburger:active { background: #E5E7EB; }
.hamburger svg { width: 22px; height: 22px; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 190; backdrop-filter: blur(2px); }

/* ── PÁGINAS ── */
.page { display: none; padding: 24px; }
.page.active { display: block; }

/* ── CARDS FLOTANTES ── */
.card {
  background: #fff;
  border: none;
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--sh-md);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover { box-shadow: var(--sh-lg); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; color: #111827; }

/* ── STATS (tarjetas flotantes) ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #fff;
  border: none;
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: var(--sh-md);
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sh-lg); }
.stat-label { font-size: 11px; color: var(--gris); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 24px; font-weight: 700; word-break: break-word; }
.stat-value.green  { color: var(--verde); }
.stat-value.red    { color: var(--rojo); }
.stat-value.blue   { color: var(--accent); }
.stat-value.orange { color: var(--amarillo); }

/* ── TABLA (dentro de card ya tiene sombra heredada) ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  margin: 0 -4px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
th {
  text-align: left; font-weight: 600; font-size: 11px; color: var(--gris);
  padding: 10px 12px; border-bottom: 2px solid var(--borde);
  text-transform: uppercase; letter-spacing: .5px;
  background: #FAFBFD;
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid #F1F3F7; vertical-align: middle; transition: background .12s; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #EFF5FF; cursor: default; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-activo    { background: #D1FAE5; color: #065F46; }
.badge-aldia     { background: #D1FAE5; color: #065F46; }
.badge-al\ dia   { background: #D1FAE5; color: #065F46; }
.badge-pendiente { background: #FEF3C7; color: #92400E; }
.badge-moroso    { background: #FEE2E2; color: #991B1B; }
.badge-pagado    { background: #D1FAE5; color: #065F46; }
.badge-enviado   { background: #DBEAFE; color: #1E40AF; }
.badge-aceptado  { background: #D1FAE5; color: #065F46; }
.badge-rechazado { background: #FEE2E2; color: #991B1B; }
.badge-gasto     { background: #FEE2E2; color: #991B1B; }
.badge-ingreso   { background: #D1FAE5; color: #065F46; }

/* ── BOTONES (con sombra suave) ── */
.btn {
  border: 1px solid var(--borde); background: #fff; border-radius: 9px;
  padding: 9px 16px; font-size: 13px; cursor: pointer; color: #374151;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  box-shadow: var(--sh-sm);
  min-height: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}
.btn:hover { background: #EFF5FF; border-color: #93C5FD; box-shadow: var(--sh-md); }
.btn:active { transform: scale(.97); box-shadow: var(--sh-sm); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: 0 2px 6px rgba(26,43,94,.25); }
.btn-primary:hover { background: #2040A0; border-color: #2040A0; box-shadow: 0 4px 12px rgba(26,43,94,.35); }
.btn-green { background: var(--verde); color: #fff; border-color: var(--verde); box-shadow: 0 2px 6px rgba(15,110,86,.25); }
.btn-green:hover { background: #0a5240; border-color: #0a5240; box-shadow: 0 4px 12px rgba(15,110,86,.35); }
.btn-red { color: var(--rojo); border-color: #FECACA; }
.btn-red:hover { background: #FEE2E2; border-color: var(--rojo); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 6px rgba(46,134,222,.25); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 4px 12px rgba(46,134,222,.35); }
.btn-wa {
  background: #25D366; color: #fff; border-color: #25D366;
  box-shadow: 0 2px 6px rgba(37,211,102,.25);
}
.btn-wa:hover { background: #1da851; border-color: #1da851; box-shadow: 0 4px 12px rgba(37,211,102,.35); }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }
.btn-xs { padding: 4px 9px; font-size: 11px; border-radius: 7px; min-height: 26px; }

/* ── FORMULARIOS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: #374151; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--borde);
  border-radius: 9px; font-size: 14px; color: #111827; background: #fff;
  outline: none; transition: border-color .18s, box-shadow .18s, background .15s;
  box-shadow: var(--sh-sm);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236B7280' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input:hover, select:hover, textarea:hover { border-color: #93C5FD; background: #FAFCFF; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,134,222,.15), var(--sh-sm);
  background: #fff;
}
textarea { resize: vertical; min-height: 70px; font-family: inherit; }

/* ── MODAL ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 560px;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0; margin-bottom: 16px;
  position: sticky; top: 0; background: #fff; z-index: 2;
  padding-top: 18px; padding-bottom: 12px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gris);
  padding: 4px 10px; border-radius: 8px;
  min-width: 36px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gris-cl); }
#modal-body { padding: 0 22px 22px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--borde); flex-wrap: wrap; }

/* ── PRESUPUESTO ítems ── */
.item-row { display: grid; grid-template-columns: 1fr 70px 100px 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row input { margin: 0; }

/* ── AVATAR ── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  color: #1E40AF; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.5), 0 1px 3px rgba(30,64,175,.15);
}
.row-flex { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-flex .nombre { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1f2937; color: #fff;
  padding: 11px 24px; border-radius: 11px; font-size: 13px;
  opacity: 0; transition: all .3s; z-index: 999; pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── FILTROS ── */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros select, .filtros input { width: auto; flex: 1; min-width: 140px; }

/* ── FAB mobile ── */
.fab {
  display: none; position: fixed; right: 20px;
  bottom: calc(24px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 28px;
  border: none; cursor: pointer; z-index: 150;
  align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(26,43,94,.4);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }

/* ── GASTOS ── */
.gasto-row-ingreso td { background: #F0FDF4; }
.gasto-row-gasto   td { background: #FFF7F7; }
.gasto-row-ingreso:hover td { background: #DCFCE7 !important; }
.gasto-row-gasto:hover   td { background: #FEE2E2 !important; }

/* ═══ VENCIMIENTOS (dashboard) ═══ */
.alert-card {
  background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  border-left: 4px solid var(--amarillo);
  border-radius: 14px; padding: 16px 20px; margin-bottom: 16px;
  box-shadow: var(--sh-md);
}
.alert-card.red { background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%); border-left-color: var(--rojo); }
.alert-card h4 { font-size: 13px; font-weight: 700; color: #92400E; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }
.alert-card.red h4 { color: #991B1B; }
.alert-list { list-style: none; }
.alert-list li {
  padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.alert-list li:last-child { border-bottom: none; }
.alert-list .nombre { font-weight: 600; color: #1f2937; }
.alert-list .detalle { font-size: 12px; color: #6B7280; }
.alert-list .acciones { display: flex; gap: 6px; flex-shrink: 0; }

/* ═══ BITÁCORA ═══ */
.bitacora-wrap {
  display: flex; flex-direction: column; gap: 12px;
  height: calc(100vh - 100px);
  max-height: calc(100vh - 100px);
}
.bitacora-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.bitacora-info {
  font-size: 12px; color: var(--gris);
  display: flex; align-items: center; gap: 8px;
}
.bitacora-info .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #9CA3AF;
  display: inline-block; transition: background .3s;
}
.bitacora-info .dot.saving  { background: var(--amarillo); animation: pulse 1s infinite; }
.bitacora-info .dot.saved   { background: var(--verde); }
@keyframes pulse { 50% { opacity: .4; } }
.bitacora-textarea {
  flex: 1; width: 100%;
  background: #FFFCF5;
  border: none;
  border-radius: 16px;
  padding: 24px 28px;
  font-size: 14.5px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  line-height: 1.7;
  color: #2d3748;
  resize: none;
  box-shadow: var(--sh-lg);
  background-image: linear-gradient(to bottom, transparent 0, transparent calc(1.7em - 1px), rgba(229, 231, 235, .5) calc(1.7em - 1px), rgba(229, 231, 235, .5) 1.7em, transparent 1.7em);
  background-size: 100% 1.7em;
  background-attachment: local;
  min-height: 300px;
  -webkit-appearance: none;
  appearance: none;
}
.bitacora-textarea:focus {
  outline: none;
  background-color: #FFFCF5;
  box-shadow: var(--sh-xl), 0 0 0 3px rgba(46,134,222,.12);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile-first enhancements
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet landscape y abajo */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 20px; }
}

/* Tablet y mobile (sidebar desliza) */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .overlay.open { display: block; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .page { padding: 14px 12px; padding-bottom: calc(90px + var(--safe-bottom)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 16px 14px; border-radius: 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }
  .card { padding: 16px 14px; border-radius: 14px; margin-bottom: 14px; }
  .card-header { margin-bottom: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .fab { display: flex; }
  .hide-mobile { display: none !important; }
  .bitacora-wrap { height: calc(100dvh - 120px); }
  .bitacora-textarea { padding: 18px 20px; font-size: 14px; }

  /* Modal ocupa más pantalla en mobile */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 92dvh;
    animation: slideUp .25s ease;
    padding-bottom: var(--safe-bottom);
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-header { padding: 16px 18px 0; }
  #modal-body { padding: 0 18px 18px; }
  .modal-footer { position: sticky; bottom: 0; background: #fff; padding-bottom: 14px; }

  /* Alertas de dashboard: botones grandes y apilables */
  .alert-list li { padding: 12px 0; }
  .alert-list .acciones { width: 100%; justify-content: flex-end; }

  /* Item row (presupuestos) se adapta */
  .item-row { grid-template-columns: 1fr 60px 90px 32px; gap: 6px; }

  /* Filtros full-width */
  .filtros { gap: 8px; }
  .filtros select, .filtros input { min-width: 0; width: 100%; flex: 1 1 calc(50% - 4px); }

  /* Tablas con scroll más evidente */
  .table-wrap { margin: 0 -14px; border-radius: 0; }
  .card > .table-wrap { margin: 0 -14px; }
  table { font-size: 12.5px; }
  th, td { padding: 9px 10px; }
}

/* Mobile chico */
@media (max-width: 480px) {
  :root { --topbar-h: 52px; }
  body { font-size: 13.5px; }
  .page { padding: 12px 10px; padding-bottom: calc(90px + var(--safe-bottom)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 18px; }
  .card { padding: 14px 12px; }
  .card-title { font-size: 14px; }
  .bitacora-textarea { padding: 14px 16px; font-size: 13.5px; }
  .topbar-title { font-size: 15px; }
  .login-box { padding: 32px 24px; }
  .login-logo img { height: 64px; }

  /* Botones de acción más compactos */
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .btn-sm { padding: 6px 10px; font-size: 11.5px; }

  /* Item row más compacto */
  .item-row { grid-template-columns: 1fr 50px 80px 28px; gap: 5px; }
  .item-row input { padding: 8px 10px; font-size: 13px; }
}

/* Mobile muy chico (iPhone SE etc.) */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
}

/* Landscape de mobile: sidebar más angosto */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  :root { --sidebar-w: 220px; --topbar-h: 48px; }
  .bitacora-wrap { height: calc(100dvh - 80px); }
}