/* ============================================================
   PilatesGestion - Diseno optimizado iPad + Mobile
   ============================================================ */
:root {
  --rose:        #e8a0b0;
  --rose-dark:   #c97a8e;
  --rose-light:  #f5d0da;
  --rose-bg:     #fdf2f5;
  --gray-900:    #1e1e24;
  --gray-800:    #2d2d35;
  --gray-700:    #3e3e4a;
  --gray-500:    #7a7a8c;
  --gray-300:    #c8c8d4;
  --gray-100:    #f0eff4;
  --success:     #3a9e6e;
  --danger:      #d94f4f;
  --warning:     #d48c2a;
  --info:        #4a7fc1;
  --sidebar-w:   260px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   22px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.16);
  --nav-h:       68px; /* altura barra nav inferior movil */
  /* tema claro */
  --bg:          #f7f5f8;
  --surface:     #ffffff;
  --text:        #1e1e24;
  --text-muted:  #7a7a8c;
  --border:      #dddde8;
  --sidebar-bg:  #1c1c22;
  --sidebar-txt: #c8c8d8;
  --nav-section: #6e6e82;
}
[data-theme="dark"] {
  --bg:         #13131a;
  --surface:    #1c1c24;
  --text:       #e8e8f0;
  --text-muted: #8888a0;
  --border:     #32323e;
  --rose-bg:    #1e1520;
  --sidebar-bg: #0f0f14;
  --gray-100:   #25252f;
}

/* ?? RESET ??????????????????????????????????????????????????? */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:15px;-webkit-text-size-adjust:100%}
body{
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  background:var(--bg);color:var(--text);
  line-height:1.6;-webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
}

/* ?? UTILS ??????????????????????????????????????????????????? */
.hidden{display:none!important}
.text-muted{color:var(--text-muted)}
.text-rose{color:var(--rose-dark)}
.text-success{color:var(--success)}
.text-danger{color:var(--danger)}
.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}
.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}
.flex{display:flex}.flex-col{flex-direction:column}
.gap-1{gap:.5rem}.gap-2{gap:1rem}
.items-center{align-items:center}
.justify-between{justify-content:space-between}
.w-full{width:100%}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:1rem}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:1rem}

/* ?? LOGIN ??????????????????????????????????????????????????? */
.login-screen{
  min-height:100vh;min-height:100dvh;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(145deg,#1c1c22 0%,#2a1f28 50%,#1c1c22 100%);
  padding:1.5rem;
}
.login-card{
  background:var(--surface);border-radius:var(--radius-xl);
  padding:2.5rem 2rem;width:100%;max-width:420px;
  box-shadow:0 24px 64px rgba(0,0,0,.45);
}
.login-brand{text-align:center;margin-bottom:2rem}
.login-brand .brand-icon{font-size:2.2rem;color:var(--rose-dark);display:block;margin-bottom:.5rem}
.login-brand h1{
  font-family:'Playfair Display',serif;font-size:1.8rem;
  color:var(--text);margin:.25rem 0;
}
.login-brand p{color:var(--text-muted);font-size:.9rem}

/* ?? APP LAYOUT ??????????????????????????????????????????????? */
.app{display:flex;min-height:100vh;min-height:100dvh}

/* ?? SIDEBAR (desktop) ???????????????????????????????????????? */
.sidebar{
  width:var(--sidebar-w);background:var(--sidebar-bg);
  color:var(--sidebar-txt);display:flex;flex-direction:column;
  flex-shrink:0;height:100vh;position:sticky;top:0;
  overflow-y:auto;z-index:200;
  transition:transform .28s cubic-bezier(.4,0,.2,1);
  scrollbar-width:none;
}
.sidebar::-webkit-scrollbar{display:none}
.sidebar-brand{
  display:flex;align-items:center;gap:.75rem;
  padding:1.5rem 1.25rem 1rem;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.sidebar-brand .brand-icon{font-size:1.5rem;color:var(--rose);flex-shrink:0}
.brand-name{font-weight:600;font-size:.95rem;color:#fff;line-height:1.2}
.brand-sub{font-size:.7rem;color:var(--nav-section);margin-top:.1rem}
.sidebar-search{position:relative;margin:.75rem .75rem .5rem}
.sidebar-search i{
  position:absolute;left:.75rem;top:50%;transform:translateY(-50%);
  color:var(--nav-section);font-size:.88rem;pointer-events:none;
}
.sidebar-search input{
  width:100%;padding:.55rem .75rem .55rem 2.2rem;
  background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.1);
  border-radius:var(--radius);color:var(--sidebar-txt);
  font-size:.85rem;outline:none;transition:border-color .2s;
  -webkit-appearance:none;
}
.sidebar-search input:focus{border-color:var(--rose)}
.sidebar-search input::placeholder{color:var(--nav-section)}
.search-dropdown{
  position:absolute;top:calc(100% + 4px);left:0;right:0;
  background:var(--gray-800);border:1px solid var(--gray-700);
  border-radius:var(--radius);overflow:hidden;z-index:300;
  box-shadow:var(--shadow-lg);
}
.search-result-item{
  padding:.6rem 1rem;cursor:pointer;font-size:.84rem;
  transition:background .15s;display:flex;align-items:center;gap:.5rem;
}
.search-result-item:hover{background:rgba(232,160,176,.15)}
.search-result-item .sr-tipo{
  font-size:.69rem;background:rgba(232,160,176,.2);
  color:var(--rose-light);padding:1px 6px;border-radius:4px;margin-left:auto;
}
.sidebar-nav{flex:1;padding:.5rem 0}
.nav-section{
  font-size:.67rem;font-weight:600;letter-spacing:.08em;
  text-transform:uppercase;color:var(--nav-section);
  padding:.8rem 1.25rem .3rem;
}
.nav-item{
  display:flex;align-items:center;gap:.7rem;
  padding:.62rem 1.25rem;color:var(--sidebar-txt);
  text-decoration:none;font-size:.875rem;
  transition:background .15s,color .15s;position:relative;
  -webkit-tap-highlight-color:transparent;
}
.nav-item i{font-size:1rem;width:1.1rem;text-align:center;flex-shrink:0}
.nav-item:hover{background:rgba(255,255,255,.06);color:#fff}
.nav-item.active{background:rgba(232,160,176,.15);color:var(--rose-light)}
.nav-item.active::before{
  content:'';position:absolute;left:0;top:0;bottom:0;
  width:3px;background:var(--rose);border-radius:0 2px 2px 0;
}
.badge-alert{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;height:18px;padding:0 5px;
  background:var(--danger);color:#fff;
  border-radius:9px;font-size:.68rem;font-weight:600;margin-left:auto;
}
.sidebar-footer{
  padding:1rem;border-top:1px solid rgba(255,255,255,.06);
  display:flex;align-items:center;gap:.75rem;
}
.user-info{display:flex;align-items:center;gap:.6rem;flex:1;min-width:0}
.user-avatar{
  width:36px;height:36px;border-radius:50%;
  background:var(--rose-dark);color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-size:.8rem;font-weight:600;flex-shrink:0;
}
.user-name{font-size:.82rem;color:#fff;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* ?? MAIN CONTENT ????????????????????????????????????????????? */
.main-content{flex:1;min-width:0;padding:1.75rem;overflow-y:auto}

/* ?? PAGE HEADER ?????????????????????????????????????????????? */
.page-header{
  display:flex;align-items:flex-start;justify-content:space-between;
  margin-bottom:1.5rem;flex-wrap:wrap;gap:.75rem;
}
.page-title{font-family:'Playfair Display',serif;font-size:1.55rem;line-height:1.2}
.page-subtitle{color:var(--text-muted);font-size:.87rem;margin-top:.15rem}
.page-actions{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center}

/* ?? CARDS ???????????????????????????????????????????????????? */
.card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);padding:1.25rem;box-shadow:var(--shadow);
}
.card-title{font-weight:600;font-size:.95rem;margin-bottom:1rem}

/* ?? KPIs ????????????????????????????????????????????????????? */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:1rem;margin-bottom:1.5rem}
.kpi-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);padding:1.1rem 1.25rem;
  display:flex;flex-direction:column;gap:.2rem;
}
.kpi-card.rose{border-left:3px solid var(--rose)}
.kpi-card.danger{border-left:3px solid var(--danger)}
.kpi-card.success{border-left:3px solid var(--success)}
.kpi-card.info{border-left:3px solid var(--info)}
.kpi-label{font-size:.73rem;color:var(--text-muted);font-weight:500;text-transform:uppercase;letter-spacing:.04em}
.kpi-value{font-size:1.75rem;font-weight:600;line-height:1}
.kpi-sub{font-size:.76rem;color:var(--text-muted)}

/* ?? TABLE ???????????????????????????????????????????????????? */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;font-size:.875rem}
thead th{
  text-align:left;padding:.6rem .75rem;
  border-bottom:2px solid var(--border);
  font-size:.71rem;font-weight:600;color:var(--text-muted);
  text-transform:uppercase;letter-spacing:.05em;white-space:nowrap;
}
tbody tr{border-bottom:1px solid var(--border);transition:background .15s}
tbody tr:hover{background:var(--rose-bg)}
tbody td{padding:.7rem .75rem;vertical-align:middle}
.table-actions{display:flex;gap:.35rem}

/* ?? FORMS ???????????????????????????????????????????????????? */
.field{margin-bottom:.9rem}
.field label{display:block;font-size:.82rem;font-weight:500;margin-bottom:.35rem}
.field input,.field select,.field textarea{
  width:100%;padding:.65rem .85rem;
  background:var(--surface);color:var(--text);
  border:1.5px solid var(--border);border-radius:var(--radius);
  font-size:.9rem;font-family:inherit;outline:none;
  transition:border-color .2s,box-shadow .2s;
  -webkit-appearance:none;
  /* Touch: minimo 44px de alto */
  min-height:44px;
}
.field input:focus,.field select:focus,.field textarea:focus{
  border-color:var(--rose);box-shadow:0 0 0 3px rgba(232,160,176,.2);
}
.field textarea{resize:vertical;min-height:90px}
.field-hint{font-size:.76rem;color:var(--text-muted);margin-top:.25rem}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:1rem}

/* ?? BUTTONS ?????????????????????????????????????????????????? */
.btn-primary{
  background:var(--rose-dark);color:#fff;border:none;
  border-radius:var(--radius);padding:.7rem 1.2rem;
  font-size:.88rem;font-weight:500;cursor:pointer;
  transition:background .2s,transform .1s;
  display:inline-flex;align-items:center;gap:.4rem;
  min-height:44px;-webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
.btn-primary:hover{background:#b5697d}
.btn-primary:active{transform:scale(.97)}
.btn-full{width:100%;justify-content:center}
.btn-secondary{
  background:transparent;color:var(--text);
  border:1.5px solid var(--border);border-radius:var(--radius);
  padding:.65rem 1rem;font-size:.88rem;font-weight:500;cursor:pointer;
  transition:background .2s,border-color .2s;
  display:inline-flex;align-items:center;gap:.4rem;
  min-height:44px;-webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
.btn-secondary:hover{background:var(--rose-bg);border-color:var(--rose)}
.btn-icon{
  background:none;border:none;cursor:pointer;
  padding:.5rem;color:var(--text-muted);border-radius:var(--radius);
  display:inline-flex;align-items:center;justify-content:center;
  transition:background .15s,color .15s;
  min-width:40px;min-height:40px;
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.btn-icon:hover{background:var(--rose-bg);color:var(--rose-dark)}
.btn-link{
  background:none;border:none;cursor:pointer;
  color:var(--text-muted);font-size:.8rem;text-decoration:underline;padding:0;
}
.btn-link:hover{color:var(--rose-dark)}
.btn-danger{
  background:var(--danger);color:#fff;border:none;
  border-radius:var(--radius);padding:.65rem 1rem;font-size:.88rem;
  cursor:pointer;min-height:44px;touch-action:manipulation;
}
.btn-success{
  background:var(--success);color:#fff;border:none;
  border-radius:var(--radius);padding:.55rem .9rem;font-size:.84rem;
  cursor:pointer;min-height:40px;
}

/* ?? BADGES ??????????????????????????????????????????????????? */
.badge{
  display:inline-flex;align-items:center;
  padding:3px 10px;border-radius:20px;
  font-size:.73rem;font-weight:500;
}
.badge-rose{background:var(--rose-light);color:var(--rose-dark)}
.badge-gray{background:var(--gray-100);color:var(--gray-700)}
.badge-success{background:#d4edda;color:#1a6e3e}
.badge-danger{background:#fde8e8;color:#a03030}
.badge-warning{background:#fff3cd;color:#856404}
.badge-info{background:#d1ecf1;color:#1a5a6e}
.seg-pilates{background:#fde8f3;color:#a0336e}
.seg-kinesiologia{background:#e8f0fd;color:#3358a0}
.seg-presoterapia{background:#e8fdf0;color:#1a6e3e}

/* ?? ALERTS ??????????????????????????????????????????????????? */
.alert{padding:.8rem 1rem;border-radius:var(--radius);font-size:.875rem;margin-bottom:.75rem}
.alert-danger{background:#fde8e8;color:#a03030;border:1px solid #f5c6c6}
.alert-success{background:#d4edda;color:#1a6e3e;border:1px solid #b8dfc7}
.alert-warning{background:#fff8e1;color:#856404;border:1px solid #ffe082}
.alert-info{background:#e3f0fb;color:#174880;border:1px solid #b3d4f0}

/* ?? MODAL ???????????????????????????????????????????????????? */
.modal-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.55);
  display:flex;align-items:flex-end;justify-content:center;
  z-index:1000;padding:0;
  backdrop-filter:blur(2px);
}
.modal-box{
  background:var(--surface);
  border-radius:var(--radius-xl) var(--radius-xl) 0 0;
  width:100%;max-width:680px;
  max-height:92vh;max-height:92dvh;
  overflow-y:auto;box-shadow:var(--shadow-lg);
  -webkit-overflow-scrolling:touch;
}
.modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:1.1rem 1.5rem;border-bottom:1px solid var(--border);
  position:sticky;top:0;background:var(--surface);z-index:1;
}
.modal-header h3{font-size:1.05rem;font-weight:600}
.modal-body{padding:1.5rem;padding-bottom:2rem}

/* ?? TOAST ???????????????????????????????????????????????????? */
#toast-container{
  position:fixed;bottom:calc(var(--nav-h) + 1rem);right:1rem;
  display:flex;flex-direction:column;gap:.5rem;z-index:2000;
}
.toast{
  background:var(--gray-900);color:#fff;
  padding:.75rem 1rem;border-radius:var(--radius);
  font-size:.875rem;box-shadow:var(--shadow-lg);
  display:flex;align-items:center;gap:.6rem;
  animation:slideUp .2s ease;max-width:300px;
}
.toast.success{border-left:3px solid var(--success)}
.toast.error{border-left:3px solid var(--danger)}
.toast.info{border-left:3px solid var(--rose)}
@keyframes slideUp{from{transform:translateY(8px);opacity:0}to{transform:translateY(0);opacity:1}}

/* ?? SPINNER ?????????????????????????????????????????????????? */
.spin{animation:rotate .7s linear infinite;display:inline-block}
@keyframes rotate{to{transform:rotate(360deg)}}

/* ?? TABS ????????????????????????????????????????????????????? */
.tabs{display:flex;border-bottom:2px solid var(--border);margin-bottom:1.5rem;overflow-x:auto;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tab-btn{
  padding:.65rem 1.1rem;font-size:.875rem;font-weight:500;
  background:none;border:none;cursor:pointer;color:var(--text-muted);
  border-bottom:2px solid transparent;margin-bottom:-2px;
  transition:color .2s,border-color .2s;white-space:nowrap;
  min-height:44px;
}
.tab-btn.active{color:var(--rose-dark);border-color:var(--rose-dark)}

/* ?? CALENDAR ????????????????????????????????????????????????? */
.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}
.cal-header{
  text-align:center;font-size:.7rem;font-weight:600;
  color:var(--text-muted);padding:.4rem 0;text-transform:uppercase;
}
.cal-day{
  min-height:70px;padding:.35rem;
  background:var(--surface);border:1px solid var(--border);
  border-radius:6px;cursor:pointer;transition:background .15s;
}
.cal-day:hover,.cal-day:active{background:var(--rose-bg)}
.cal-day.today{border-color:var(--rose)}
.day-num{font-size:.78rem;font-weight:600;margin-bottom:.2rem}
.cal-day.today .day-num{
  background:var(--rose-dark);color:#fff;border-radius:50%;
  width:20px;height:20px;display:flex;align-items:center;justify-content:center;font-size:.72rem;
}
.cal-event{
  font-size:.65rem;background:var(--rose-light);color:var(--rose-dark);
  border-radius:3px;padding:1px 3px;margin-bottom:2px;
  overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
}
.cal-event.kine{background:#dde8fd;color:#2a4eb0}
.cal-event.presos{background:#d4f5e5;color:#1a6e3e}

/* ?? CHART ???????????????????????????????????????????????????? */
.chart-wrap{position:relative;height:200px}

/* ?? PROGRESS ????????????????????????????????????????????????? */
.progress-bar{height:8px;background:var(--gray-100);border-radius:4px;overflow:hidden}
.progress-fill{height:100%;background:var(--rose-dark);border-radius:4px;transition:width .4s}

/* ?? FICHAS ??????????????????????????????????????????????????? */
.sesion-item{
  border-left:3px solid var(--rose);padding:.75rem 1rem;
  margin-bottom:.6rem;background:var(--rose-bg);
  border-radius:0 var(--radius) var(--radius) 0;
}
.sesion-header{display:flex;justify-content:space-between;margin-bottom:.25rem}
.sesion-num{font-size:.76rem;font-weight:600;color:var(--rose-dark)}
.sesion-fecha{font-size:.76rem;color:var(--text-muted)}
.dolor-dots{display:flex;gap:3px;margin-top:.35rem}
.dolor-dot{width:14px;height:14px;border-radius:50%;background:var(--gray-100);border:1px solid var(--border)}
.dolor-dot.active{background:var(--rose-dark);border-color:var(--rose-dark)}
.dolor-dot.alta{background:var(--danger);border-color:var(--danger)}

/* ?? HORARIO CARD ????????????????????????????????????????????? */
.horario-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden}
.horario-card-header{background:var(--rose-dark);color:#fff;padding:.75rem 1rem;display:flex;justify-content:space-between;align-items:center}
.horario-card-body{padding:1rem}
.horario-alumna{
  display:flex;align-items:center;gap:.5rem;padding:.4rem .6rem;
  border-radius:6px;font-size:.82rem;background:var(--rose-bg);margin-bottom:.3rem;
}

/* ?? EMPTY STATE ?????????????????????????????????????????????? */
.empty-state{text-align:center;padding:2.5rem 1rem;color:var(--text-muted)}
.empty-state i{font-size:2.5rem;color:var(--gray-300);margin-bottom:.75rem;display:block}
.empty-state p{font-size:.9rem}

/* ?? HAMBURGER (solo se usa en pantallas muy pequenas) ???????? */
.hamburger{
  display:none;position:fixed;top:1rem;left:1rem;z-index:150;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:.5rem .65rem;
  font-size:1.15rem;cursor:pointer;box-shadow:var(--shadow);
  min-width:44px;min-height:44px;align-items:center;justify-content:center;
}

/* ??????????????????????????????????????????????????????????????
   TABLET - iPad (768px - 1024px)
   Layout: sidebar colapsado con iconos, contenido amplio
   ?????????????????????????????????????????????????????????????? */
@media (min-width:768px) and (max-width:1024px) {
  :root { --sidebar-w: 64px; }

  .sidebar{
    width:var(--sidebar-w);
    overflow:visible;
  }
  /* Ocultar textos, mostrar solo iconos */
  .brand-name,.brand-sub,.sidebar-search,
  .nav-section,.nav-item span,
  .user-name,.btn-link,
  .sidebar-footer .btn-icon ~ *{ display:none }

  .sidebar-brand{
    padding:1.2rem .8rem;justify-content:center;
  }
  .sidebar-brand .brand-icon{font-size:1.6rem;margin:0}

  .nav-item{
    padding:.8rem;justify-content:center;
    border-radius:0;
  }
  .nav-item i{width:auto;font-size:1.15rem}
  /* Tooltip al hover en tablet */
  .nav-item{position:relative}
  .nav-item::after{
    content:attr(data-label);
    position:absolute;left:calc(100% + 8px);top:50%;
    transform:translateY(-50%);
    background:var(--gray-800);color:#fff;
    padding:.35rem .7rem;border-radius:6px;
    font-size:.78rem;white-space:nowrap;
    opacity:0;pointer-events:none;
    transition:opacity .15s;z-index:500;
  }
  .nav-item:hover::after{opacity:1}

  .sidebar-footer{padding:.75rem;justify-content:center}
  .user-info{justify-content:center}

  .main-content{padding:1.25rem}
  .grid-3{grid-template-columns:1fr 1fr}
  .kpi-grid{grid-template-columns:repeat(2,1fr)}

  /* Modal centrado en tablet */
  .modal-overlay{align-items:center;padding:1.5rem}
  .modal-box{border-radius:var(--radius-xl);max-height:88vh}

  /* Toast mas arriba (sin nav inferior) */
  #toast-container{bottom:1.5rem}
}

/* ?? Sidebar expandido en tablet al tocar hamburger ??????????? */
@media (min-width:768px) and (max-width:1024px) {
  .sidebar.open{
    width:var(--sidebar-w);
  }
  .sidebar.expanded{
    width:260px;
  }
  .sidebar.expanded .brand-name,
  .sidebar.expanded .brand-sub,
  .sidebar.expanded .sidebar-search,
  .sidebar.expanded .nav-section,
  .sidebar.expanded .user-name,
  .sidebar.expanded .btn-link{ display:block }
  .sidebar.expanded .nav-item{padding:.62rem 1.25rem;justify-content:flex-start}
  .sidebar.expanded .nav-item i{width:1.1rem;font-size:1rem}
  .sidebar.expanded .sidebar-brand{padding:1.5rem 1.25rem 1rem;justify-content:flex-start}
  .sidebar.expanded .sidebar-footer{padding:1rem}
  .sidebar.expanded .user-info{justify-content:flex-start}
}

/* ??????????????????????????????????????????????????????????????
   MOBILE - Telefono (< 768px)
   Layout: navegacion inferior fija, sin sidebar
   ?????????????????????????????????????????????????????????????? */
@media (max-width:767px) {
  :root{ --sidebar-w:280px }

  /* Sidebar como drawer deslizante */
  .sidebar{
    position:fixed;left:0;top:0;bottom:0;
    transform:translateX(-100%);
    box-shadow:var(--shadow-lg);
    z-index:300;
  }
  .sidebar.open{transform:translateX(0)}

  /* Overlay oscuro cuando sidebar abierto */
  .sidebar-overlay{
    position:fixed;inset:0;background:rgba(0,0,0,.5);
    z-index:299;display:none;
  }
  .sidebar-overlay.visible{display:block}

  .main-content{
    padding:.85rem;padding-top:.85rem;
    padding-bottom:calc(var(--nav-h) + 1rem);
  }

  /* Barra de navegacion inferior */
  .bottom-nav{
    position:fixed;bottom:0;left:0;right:0;
    height:var(--nav-h);
    background:var(--surface);
    border-top:1px solid var(--border);
    display:flex;align-items:stretch;
    z-index:250;
    padding-bottom:env(safe-area-inset-bottom);
    box-shadow:0 -2px 12px rgba(0,0,0,.08);
  }
  .bottom-nav-item{
    flex:1;display:flex;flex-direction:column;
    align-items:center;justify-content:center;gap:.18rem;
    text-decoration:none;color:var(--text-muted);
    font-size:.65rem;font-weight:500;
    -webkit-tap-highlight-color:transparent;
    touch-action:manipulation;transition:color .15s;
    padding:.3rem .2rem;
  }
  .bottom-nav-item i{font-size:1.35rem;line-height:1}
  .bottom-nav-item.active{color:var(--rose-dark)}
  .bottom-nav-item .bn-badge{
    position:absolute;top:.35rem;
    background:var(--danger);color:#fff;
    border-radius:8px;font-size:.6rem;
    padding:0 4px;min-width:14px;height:14px;
    display:flex;align-items:center;justify-content:center;
  }
  .bottom-nav-item{position:relative}

  /* Boton menu (mas) */
  .bottom-nav-more{
    flex:1;display:flex;flex-direction:column;
    align-items:center;justify-content:center;gap:.18rem;
    color:var(--text-muted);font-size:.65rem;font-weight:500;
    background:none;border:none;cursor:pointer;
    -webkit-tap-highlight-color:transparent;padding:.3rem .2rem;
  }
  .bottom-nav-more i{font-size:1.35rem;line-height:1}

  /* Ocultar sidebar desktop en mobile */
  .app > .sidebar{display:flex} /* se controla con transform */

  /* Hamburger no se usa en mobile, usamos bottom nav */
  .hamburger{display:none}

  /* Grids en mobile */
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr}
  .form-row{grid-template-columns:1fr}
  .kpi-grid{grid-template-columns:1fr 1fr}

  /* Modal como sheet que sube desde abajo */
  .modal-overlay{align-items:flex-end;padding:0}
  .modal-box{
    border-radius:var(--radius-xl) var(--radius-xl) 0 0;
    max-height:94vh;max-height:94dvh;
    width:100%;
  }
  /* Drag handle visual */
  .modal-header::before{
    content:'';display:block;position:absolute;
    top:.5rem;left:50%;transform:translateX(-50%);
    width:36px;height:4px;background:var(--border);border-radius:2px;
  }
  .modal-header{position:relative;padding-top:1.25rem}

  /* Tablas en mobile: scroll horizontal */
  .table-wrap{margin:0 -.85rem;padding:0 .85rem}

  /* Toast arriba del nav */
  #toast-container{
    bottom:calc(var(--nav-h) + .75rem);
    right:.75rem;left:.75rem;
  }
  .toast{max-width:100%}

  /* Textos mas grandes para touch */
  .page-title{font-size:1.35rem}
  table{font-size:.82rem}
  thead th{font-size:.68rem;padding:.5rem .6rem}
  tbody td{padding:.6rem .6rem}

  /* Calendario mas pequeno en mobile */
  .cal-day{min-height:52px;padding:.25rem}
  .cal-event{display:none} /* solo puntos en mobile */
  .cal-day.has-events::after{
    content:'';display:block;width:5px;height:5px;
    background:var(--rose-dark);border-radius:50%;margin:.1rem auto 0;
  }

  /* Login en mobile */
  .login-card{padding:2rem 1.5rem;border-radius:var(--radius-xl)}
}

/* ?? Safe area para iPhone X+ ????????????????????????????????? */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav{
    padding-bottom:env(safe-area-inset-bottom);
    height:calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .main-content{
    padding-bottom:calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem);
  }
}


/* == DESKTOP: ocultar bottom nav == */
@media (min-width: 1025px) {
  .bottom-nav { display: none !important; }
  #toast-container { bottom: 1.5rem !important; }
  .main-content { padding-bottom: 1.75rem !important; }
}
