/* =============================================================================
   miagenda-mobile.css — Responsive layer for /miagenda (v8 — clean rebuild)
   ---------------------------------------------------------------------------
   DESIGN (user-blessed):
   - Minimalist top bar (56px): hamburger + title + overflow "⋯" + clock + logo
   - Main area: "HOY" + "MAÑANA" + "PRÓXIMAS" sections with Apple-style cards
   - Right rail: 5 circular action buttons always visible
   - Drawer: ONLY nav links (no Gestión, no Acciones)
   - Overflow "⋯" sheet: Gestión + switch to full Día/Semana/Mes view
   - Calendar (day/week/month) is HIDDEN by default. User can open it via the
     overflow menu ("Vista completa") if they need the full grid.
   - Desktop (>=768px) UNTOUCHED.
   ========================================================================== */

@media (max-width: 1099px) {

  /* ===== Base ============================================================= */
  html, body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  }
  body { overflow-x: hidden !important; background: #F2F2F7 !important; }
  .gradient-orb { display: none !important; }  /* distracting on mobile */

  body > div.flex.h-screen {
    display: block !important;
    height: auto !important;
    min-height: 100dvh;
    position: relative;
    background: #F2F2F7 !important;
  }

  /* Hide the legacy floating hamburger from components/sidebar.html
     (green circle, bottom-4 right-4, fa-bars). We already have our own
     hamburger in the top bar so this duplicates/overlaps our FAB. */
  button.fixed.bottom-4.right-4,
  button[onclick="toggleSidebar()"].fixed {
    display: none !important;
  }

  /* ===== Hamburger — back as drawer trigger (white over navy) ========== */
  #mobile-hamburger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    background: transparent;
    border: none;
    color: #ffffff;
    flex-shrink: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    border-radius: 8px;
  }
  #mobile-hamburger:active { background: rgba(255,255,255,0.12); }
  #mobile-hamburger i { font-size: 20px; pointer-events: none; }

  /* Overlay behind drawer when it's open */
  #sidebar-mobile-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  #sidebar-mobile-overlay.active { opacity: 1; pointer-events: auto; }

  /* ===== Sidebar — off-canvas drawer (navy like desktop) =============== */
  #sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -110% !important;
    width: 84vw !important;
    max-width: 320px !important;
    min-width: 0 !important;
    height: 100dvh !important;
    z-index: 1001 !important;
    background: #0b0044 !important;          /* navy — matches top bar + desktop */
    box-shadow: 2px 0 28px rgba(0,0,0,0.32);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    border-right: none !important;
  }
  #sidebar.mobile-open { left: 0 !important; }

  /* Hide the Google Calendar indicator (green/red dot next to "MI AGENDA")
     on mobile. Desktop users still see it and can click it for the modal. */
  #google-calendar-indicator {
    display: none !important;
  }

  /* Close (X) button at the top-left of the mobile drawer */
  #sidebar #mobile-drawer-close {
    position: absolute !important;
    top: calc(10px + env(safe-area-inset-top)) !important;
    left: 12px !important;
    right: auto !important;
    z-index: 10 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    transition: background 0.15s ease, border-color 0.15s ease !important;
  }
  #sidebar #mobile-drawer-close:hover,
  #sidebar #mobile-drawer-close:active {
    background: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  #sidebar #mobile-drawer-close i { font-size: 14px !important; }

  #sidebar > div.h-full {
    min-height: 100%;
    background: transparent !important;
    display: flex !important;
    flex-direction: column;
    padding: 0 !important;
  }
  #sidebar nav.flex-1 {
    /* Top padding leaves room for the close (X) button so nav items start below it */
    padding: calc(64px + env(safe-area-inset-top)) 0 10px 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  /* Nav items in drawer: icon + label, white on navy */
  #sidebar nav a.nav-link,
  #sidebar nav a.nav-link:link,
  #sidebar nav a.nav-link:visited {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    width: 100% !important;
    min-height: 46px !important;
    padding: 10px 20px !important;
    margin: 0 !important;
    color: rgba(255,255,255,0.85) !important;
    background: transparent !important;
    border-radius: 0 !important;
    border-left: 3px solid transparent !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    box-sizing: border-box;
    overflow: visible !important;
    white-space: nowrap;
    letter-spacing: -0.01em;
  }
  #sidebar nav a.nav-link:active { background: rgba(255,255,255,0.08) !important; }
  #sidebar nav a.nav-link.active {
    color: #ffffff !important;
    background: #3c75f0 !important;            /* desktop active blue */
    border-left: 3px solid #6b9aff !important;
    font-weight: 600 !important;
  }
  #sidebar nav a.nav-link .nav-icon {
    width: 22px !important;
    font-size: 16px !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    color: inherit !important;
  }
  /* Kill desktop hover tooltip pseudo-elements */
  #sidebar nav a.nav-link::after,
  #sidebar nav a.nav-link::before,
  #sidebar nav a.nav-link:hover::after,
  #sidebar nav a.nav-link:hover::before {
    content: none !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
  /* Page label inside the drawer nav — small text, icons keep their size.
     Single consolidated rule (a previous duplicate further down was bumping
     the font back to 15px). */
  #sidebar nav a.nav-link .nav-mobile-label {
    display: inline-block !important;
    color: inherit !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    line-height: 1.2;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #sidebar .drawer-mobile-extras,
  #sidebar .drawer-section-title,
  #sidebar .drawer-action-btn { display: none !important; }

  /* User section footer (truly centered over navy) =====================
     Neutralising every possible thing that could shift layout:
     - Full width + box-sizing border-box
     - 0 horizontal padding (symmetric)
     - Eliminate text-nodes from whitespace with font-size:0, then reset on children
     - Explicit margin reset on anchor (browsers apply default margin to <a>)
  */
  #sidebar .user-section {
    padding: 18px 0 !important;
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 24px !important;
    background: rgba(0,0,0,0.18) !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    font-size: 0 !important;  /* kills whitespace text-nodes between items */
    text-align: center !important;
  }
  #sidebar .user-section > * {
    font-size: 15px;  /* reset so children still render text normally */
    margin: 0 !important;
  }

  /* Help icon — same translucent style as desktop (not blue) */
  #sidebar .help-icon {
    width: 44px !important; height: 44px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    color: white !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle;
    transition: background 0.2s ease !important;
  }
  #sidebar .help-icon:hover,
  #sidebar .help-icon:active {
    background: rgba(255, 255, 255, 0.2) !important;
  }
  #sidebar .help-icon i { font-size: 16px !important; }

  #sidebar .user-profile-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    margin: 0 !important;
    vertical-align: middle;
  }
  #sidebar .user-profile-link #user-avatar-container {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    margin: 0 !important;
  }
  /* Any text inside the user section: white */
  #sidebar .user-section,
  #sidebar .user-section * {
    color: rgba(255,255,255,0.9);
  }
  #sidebar .user-section a { color: #6b9aff !important; }

  /* ===== Sidebar overlay ================================================ */
  #sidebar-mobile-overlay {
    display: block !important;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
  }
  #sidebar-mobile-overlay.active { opacity: 1; pointer-events: auto; }

  /* ===== Main — full width (drawer is off-canvas, not fixed) =========== */
  main.flex-1 {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    overflow-x: hidden !important;
    background: #F2F2F7 !important;
  }
  /* Lock body scroll when drawer is open */
  body.sidebar-open {
    overflow: hidden !important;
    touch-action: none;
  }
  main [style*="margin-top: -60px"] { margin-top: 0 !important; }
  main [style*="margin-top: -80px"] { margin-top: 0 !important; }
  main [style*="margin-top: 80px"]  { margin-top: 0 !important; }

  /* ===== App bar — Apple-clean ========================================== */
  main > div[style*="height: 60px"] {
    height: 52px !important;
    padding-left: 6px !important;
    padding-right: 8px !important;
    padding-top: env(safe-area-inset-top);
    gap: 4px !important;
    background: #0b0044 !important;      /* same navy as desktop sidebar */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
  }
  /* Ensure status-bar area (safe-area-inset-top) also tints navy on iPhone */
  main > div[style*="height: 60px"]::before {
    content: '';
    position: absolute;
    top: calc(-1 * env(safe-area-inset-top));
    left: 0; right: 0;
    height: env(safe-area-inset-top);
    background: #0b0044;
  }
  main > div[style*="height: 60px"] > div:first-child {
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden;
  }
  #page-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #ffffff !important;              /* white on navy */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48vw;
    margin: 0 !important;
    letter-spacing: -0.01em;
  }
  #page-description { display: none !important; }
  #google-calendar-indicator > button {
    padding: 5px !important; width: 28px; height: 28px; justify-content: center;
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
  }
  #google-calendar-indicator > button:active {
    background: rgba(255,255,255,0.25) !important;
  }
  #google-calendar-indicator > button svg { display: none !important; }
  #google-dropdown {
    left: auto !important; right: 0 !important;
    margin-top: 6px !important;
    min-width: 200px; max-width: 90vw;
    padding: 8px 12px !important; font-size: 12px;
  }
  #topbar-right-area {
    gap: 4px !important;
    flex-shrink: 0;
    align-items: center;
  }
  #current-date-timezone { display: none !important; }
  #current-time {
    font-size: 16px !important;
    font-weight: 700;
    color: #ffffff !important;
    letter-spacing: 0.2px;
  }
  #topbar-right-area img { height: 20px !important; }

  /* Overflow button retired — user preferred the inline sections */
  #mobile-overflow-btn,
  #mobile-overflow-sheet { display: none !important; }

  /* ===== HIDE the full calendar (user prefers Today view) =============== */
  body.mobile-today-active #main-agenda-content,
  body.mobile-today-active #onboarding-container {
    display: none !important;
  }
  /* Also hide pre-calendar helpers */
  main .mb-2.grid.lg\:grid-cols-4 { display: none !important; }
  main .space-y-6 { display: none !important; }

  /* ===== Mobile Today view (primary on mobile) =========================
     IMPORTANT !important so the desktop-default rule below can't win. */
  #mobile-today-view {
    display: block !important;
    width: 100% !important;
    padding: 6px 0 100px !important;  /* bottom padding clears the FAB */
    background: #F2F2F7 !important;
    min-height: calc(100dvh - 52px) !important;
    box-sizing: border-box;
  }
  /* Also force the overflow sheet to use flex when active on mobile */
  #mobile-overflow-sheet {
    display: flex !important;
  }
  #mobile-overflow-sheet:not(.active) {
    /* keep it in layout but hidden until JS activates it */
    pointer-events: none;
  }

  /* ---- Section ---- */
  .today-section {
    padding: 4px 14px 16px;
  }
  .today-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 2px 8px;
  }
  .today-section-header-text {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .today-section-label {
    font-size: 11px;
    font-weight: 700;
    color: #0078b6;
    letter-spacing: 0.08em;
    flex-shrink: 0;
  }
  .today-section-date {
    font-size: 13px;
    color: #6B7280;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .today-section-count {
    font-size: 11px;
    color: #9CA3AF;
    font-weight: 600;
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
    padding: 2px 8px;
    flex-shrink: 0;
  }

  /* Day navigation — arrows + "Hoy" pill beside the section title */
  .today-day-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
  }
  .today-day-arrow {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
    color: #6B7280;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  }
  .today-day-arrow:hover { color: #3d75ef; background: rgba(61,117,239,0.08); }
  .today-day-arrow:active { color: #3d75ef; transform: scale(0.9); }
  .today-day-arrow i { font-size: 14px; }

  /* "Hoy" button sits on its own row above the section header */
  .today-day-topbar {
    display: flex;
    justify-content: flex-end;
    padding: 10px 2px 0;
  }
  .today-day-today {
    background: #3d75ef;
    color: #ffffff;
    border: none;
    border-radius: 14px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  }
  .today-day-today:hover  { background: #2a62de; }
  .today-day-today:active { transform: scale(0.95); }
  /* "Already on today" — rendered but visually disabled */
  .today-day-today.is-inactive,
  .today-day-today:disabled {
    background: #E5E7EB !important;
    color: #9CA3AF !important;
    cursor: default !important;
    transform: none !important;
    opacity: 1;
  }
  .today-day-today.is-inactive:hover,
  .today-day-today:disabled:hover {
    background: #E5E7EB !important;
  }

  /* ---- Empty state per section ---- */
  .today-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    background: #F3F4F6;          /* muted gray instead of white */
    border-radius: 12px;
    color: #9CA3AF;
    font-size: 13px;
    font-style: italic;
    border: none;
  }
  .today-empty i { font-size: 16px; color: #9CA3AF; }

  /* Hidden cards (beyond the initial 2-per-group) — revealed by "Cargar más" */
  .today-card.is-hidden { display: none !important; }

  /* Skeleton placeholders — shown before the first fetch resolves to avoid
     the "Sin eventos" flicker on mobile page load. */
  .today-card-skeleton {
    background: linear-gradient(90deg,
      rgba(0, 0, 0, 0.04) 0%,
      rgba(0, 0, 0, 0.08) 50%,
      rgba(0, 0, 0, 0.04) 100%) !important;
    background-size: 200% 100% !important;
    animation: today-skeleton-shimmer 1.4s ease-in-out infinite !important;
    min-height: 56px;
    border-left: none !important;
    padding: 0 !important;
    cursor: default !important;
  }
  @keyframes today-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* "Cargar más" button */
  .today-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin: 8px 0 0 0;
    padding: 10px 12px;
    background: transparent;
    border: 1px dashed #D1D5DB;
    border-radius: 10px;
    color: #3d75ef;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .today-load-more:hover,
  .today-load-more:active {
    background: #F3F6FD;
    border-color: #3d75ef;
  }
  .today-load-more .today-load-more-count {
    color: #6B7280;
    font-weight: 500;
  }

  /* ---- Card — Apple Calendar-style pastel with colored stripe ---- */
  .today-card {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 6px 0;
    padding: 10px 12px 10px 0;
    background: rgba(0, 122, 255, 0.10);   /* default (overridden by data-accent) */
    border: none;
    border-radius: 12px;
    box-shadow: none;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, background 0.15s ease;
    min-height: 60px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", sans-serif;
  }
  .today-card:active {
    transform: scale(0.985);
  }
  .today-card-cancelled { opacity: 0.5; }
  .today-card-cancelled .today-card-title { text-decoration: line-through; }

  .today-card-stripe {
    flex: 0 0 3px;
    background: #007AFF;
    align-self: stretch;
    min-height: 44px;
  }

  .today-card-time {
    flex: 0 0 62px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 1px;
    padding-left: 10px;
  }
  .today-card-date {
    font-size: 10px;
    font-weight: 700;
    color: #6B7280;
    margin-bottom: 2px;
    letter-spacing: 0.03em;
  }
  .today-card-hour {
    font-size: 15px;
    font-weight: 700;
    color: #1F2937;
    line-height: 1.1;
    letter-spacing: -0.01em;
  }
  .today-card-duration {
    font-size: 10px;
    color: #9CA3AF;
    margin-top: 1px;
  }

  .today-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding-left: 2px;
  }
  .today-card-title {
    font-size: 15px;
    font-weight: 600;
    color: inherit;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
  }
  .today-card-sub {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .today-card-chev {
    align-self: center;
    font-size: 12px;
    color: #C7C7CC;
    flex-shrink: 0;
    margin-right: 4px;
  }

  /* Accent variants (Apple system colors) */
  .today-card[data-accent="blue"]    { background: rgba(0, 122, 255, 0.10);  color: #0056B3; }
  .today-card[data-accent="blue"]    .today-card-stripe { background: #007AFF; }
  .today-card[data-accent="red"]     { background: rgba(255, 59, 48, 0.10);  color: #B00E0E; }
  .today-card[data-accent="red"]     .today-card-stripe { background: #FF3B30; }
  .today-card[data-accent="green"]   { background: rgba(52, 199, 89, 0.10);  color: #0E6B2E; }
  .today-card[data-accent="green"]   .today-card-stripe { background: #34C759; }
  .today-card[data-accent="orange"]  { background: rgba(255, 149, 0, 0.10);  color: #9A4F00; }
  .today-card[data-accent="orange"]  .today-card-stripe { background: #FF9500; }
  .today-card[data-accent="purple"]  { background: rgba(175, 82, 222, 0.10); color: #6B1DA8; }
  .today-card[data-accent="purple"]  .today-card-stripe { background: #AF52DE; }
  .today-card[data-accent="gray"]    { background: rgba(142, 142, 147, 0.12);color: #4B5563; }
  .today-card[data-accent="gray"]    .today-card-stripe { background: #8E8E93; }

  /* ---- Zero state (no events at all) ---- */
  .today-zero {
    text-align: center;
    padding: 64px 20px 40px;
    color: #9CA3AF;
  }
  .today-zero i {
    font-size: 52px;
    color: #D1D5DB;
    margin-bottom: 18px;
  }
  .today-zero-title {
    font-size: 17px;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
  }
  .today-zero-sub {
    font-size: 14px;
    color: #9CA3AF;
  }
  .today-zero-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #0078b6;
    color: white;
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
    margin: 0 2px;
  }

  /* ===== Right rail RETIRED (confusing, overlapped content) ============= */
  #mobile-right-rail { display: none !important; }

  /* ===== FAB — single "Nueva cita" (Google-Calendar style) ============== */
  #mobile-fab {
    display: flex !important;
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(18px + env(safe-area-inset-right));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #3d75ef;                  /* match desktop appointments blue */
    color: white;
    align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(61, 117, 239, 0.45);
    border: none;
    z-index: 910;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-fab:active {
    transform: scale(0.94);
    box-shadow: 0 3px 10px rgba(0, 120, 182, 0.4);
  }
  #mobile-fab i { font-size: 22px; pointer-events: none; }
  body.sidebar-open #mobile-fab,
  body.overflow-sheet-open #mobile-fab { display: none !important; }

  /* ===== "Acciones" carousel inside Today view ========================= */
  /* 1-slide carousel: full-width card (same width as appointment cards)
     + navigation controls (arrows + dots) centered below the card. */
  .today-actions-carousel {
    display: block;
  }
  .today-actions-viewport {
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
  }
  .today-actions-track {
    display: flex;
    width: 100%;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  .today-action-slide {
    flex: 0 0 100%;
    width: 100%;
    min-height: 100px;
  }

  /* Arrows for the Acciones carousel use the SAME style as the day-nav
     arrows (.today-day-arrow) — defined above. No dots, no controls row. */

  /* Legacy grid layout — kept for any stale cached pages still rendering it */
  .today-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .today-action-card {
    display: flex;
    flex-direction: row;                    /* text on left, icon on right */
    align-items: center;
    justify-content: space-between;         /* push icon to the right edge */
    gap: 12px;
    padding: 14px 16px;
    background: #1f2a83;                    /* match desktop .carousel-item */
    border: 1.5px solid transparent;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
    min-height: 92px;
    box-shadow: 0 4px 14px rgba(31, 42, 131, 0.28);
  }
  .today-action-card:active {
    transform: scale(0.97);
    background: #2a3ba0;
    border-color: #1f2a83;
  }
  /* Left column: title stack */
  .today-action-card .today-action-title,
  .today-action-card .today-action-sub {
    flex: 0 1 auto;
    display: block;
  }
  .today-action-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;                         /* white text on blue */
    line-height: 1.25;
  }
  .today-action-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);        /* white 80% — matches desktop */
    line-height: 1.3;
    margin-top: 4px;
  }
  /* Wrap title+sub into a left column and push icon to the right */
  .today-action-card > .today-action-icon { order: 2; }
  .today-action-card > .today-action-title,
  .today-action-card > .today-action-sub { order: 1; }
  .today-action-card {
    /* grid layout keeps text left + icon pinned to right edge */
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
  }
  .today-action-card .today-action-icon {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .today-action-card .today-action-title { grid-column: 1; grid-row: 1; align-self: end; }
  .today-action-card .today-action-sub   { grid-column: 1; grid-row: 2; align-self: start; }

  /* Icon: bigger, pinned right. White-on-translucent to match desktop. */
  .today-action-card .today-action-icon,
  .today-action-card .today-action-icon[style] {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18) !important;  /* matches .carousel-item-icon */
    color: #ffffff !important;
    flex-shrink: 0;
  }
  .today-action-icon i { font-size: 22px; }

  /* ===== "Gestión" list inside Today view ================================ */
  .today-list {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
  }
  .today-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #F3F4F6;
    color: #1F2937;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .today-list-item:last-child { border-bottom: none; }
  .today-list-item:active { background: #F9FAFB; }
  .today-list-icon {
    width: 22px;
    font-size: 15px;
    color: #3d75ef;       /* match desktop primary blue */
    text-align: center;
    flex-shrink: 0;
  }
  .today-list-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .today-list-badge {
    background: #E8EEFC;
    color: #3d75ef;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
  }
  .today-list-chev {
    font-size: 11px;
    color: #C7C7CC;
    flex-shrink: 0;
  }

  /* ===== Overflow sheet (Gestión + Vista completa) ==================== */
  #mobile-overflow-sheet {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
  }
  #mobile-overflow-sheet .overflow-sheet-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    pointer-events: auto;
    transition: background 0.2s ease;
  }
  #mobile-overflow-sheet.active .overflow-sheet-scrim {
    background: rgba(0,0,0,0.35);
  }
  #mobile-overflow-sheet .overflow-sheet-panel {
    position: relative;
    width: 100vw;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    padding: 6px 0 calc(12px + env(safe-area-inset-bottom));
    max-height: 85vh;
    overflow-y: auto;
    pointer-events: auto;
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  }
  #mobile-overflow-sheet.active .overflow-sheet-panel {
    transform: translateY(0);
  }
  #mobile-overflow-sheet .overflow-sheet-handle {
    width: 38px; height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 8px auto 6px;
  }
  #mobile-overflow-sheet .overflow-sheet-title {
    font-size: 11px;
    font-weight: 700;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 20px 4px;
  }
  #mobile-overflow-sheet .overflow-sheet-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 20px;
  }
  #mobile-overflow-sheet .overflow-sheet-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 20px;
    background: transparent;
    border: none;
    color: #1F2937;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
  }
  #mobile-overflow-sheet .overflow-sheet-option:active { background: #F3F4F6; }
  #mobile-overflow-sheet .overflow-sheet-option i {
    width: 22px; font-size: 15px;
    color: #0078b6; text-align: center;
  }
  #mobile-overflow-sheet .overflow-sheet-option .count-badge {
    margin-left: auto;
    background: #EFF6FF; color: #0078b6;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px; font-weight: 600;
    min-width: 22px; text-align: center;
  }

  body.overflow-sheet-open { overflow: hidden !important; touch-action: none; }

  /* ===== Modales ======================================================= */
  div.modal {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 0 !important;
  }
  div.modal .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 14px !important;
    padding-top: calc(14px + env(safe-area-inset-top)) !important;
    padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    transform: none !important;
    transition: none !important;
  }
  div.modal.show .modal-content { transform: none !important; }
  div.modal .modal-content h2,
  div.modal .modal-content h3,
  div.modal .modal-content .text-xl,
  div.modal .modal-content .text-2xl {
    font-size: 17px !important;
    line-height: 1.3 !important;
  }
  div.modal .modal-content p { font-size: 13px !important; }
  div.modal .modal-content label {
    font-size: 13px !important; margin-bottom: 4px !important;
  }
  div.modal .modal-content .grid.grid-cols-2,
  div.modal .modal-content .grid.grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  #postponed-panel-modal,
  #special-schedules-panel-modal,
  #blocked-days-panel-modal {
    width: 100vw !important; height: 100dvh !important;
    max-width: 100vw !important; max-height: 100dvh !important;
    inset: 0 !important; border-radius: 0 !important;
  }
  #postponed-panel-modal > div,
  #special-schedules-panel-modal > div,
  #blocked-days-panel-modal > div {
    max-width: 100vw !important; max-height: 100dvh !important;
    border-radius: 0 !important; margin: 0 !important;
  }
  #quick-settings-modal {
    align-items: flex-end !important; padding: 0 !important;
  }
  #quick-settings-modal > div,
  #quick-settings-modal .modal-content {
    width: 100vw !important; max-width: 100vw !important;
    height: auto !important; max-height: 85dvh !important;
    border-radius: 16px 16px 0 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }

  /* ===== Form controls ================================================= */
  input[type="text"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="number"],
  input[type="tel"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  textarea { min-height: 88px !important; }
  .flatpickr-calendar {
    width: calc(100vw - 24px) !important;
    max-width: 360px !important;
  }
  .flatpickr-day {
    height: 38px !important; line-height: 38px !important;
    max-width: none !important;
  }
  div.modal .modal-content button[type="submit"],
  div.modal .modal-content .btn-primary { width: 100% !important; }

  /* ===== Toasts ========================================================
     Force the notifications.js container to the bottom-right. Previously
     it was pinned to the top, which moved toasts off-screen / centered
     depending on viewport width. Bottom-right matches the #toast element. */
  #toast-container, .toast-container {
    top: auto !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    left: auto !important;
    right: 16px !important;
    width: auto !important;
    max-width: calc(100vw - 32px) !important;
  }

  /* ===== Body scroll lock ============================================== */
  body.sidebar-open {
    overflow: hidden !important;
    touch-action: none;
    position: fixed; inset: 0; width: 100%;
  }

  /* =========================================================================
     "Nueva Cita" modal — mobile redesign (bottom-sheet style)
     -------------------------------------------------------------------------
     The desktop modal occupies a 750px-wide centered card. On mobile that
     looked like the entire viewport with no breathing room. We morph it into
     a bottom-sheet with a drag handle, compact header, dot-only step bar,
     larger touch targets, and a sticky footer with full-width primary action.
     ========================================================================= */

  /* Overlay: dim background, push sheet to the bottom edge */
  #appointment-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* Sheet container — FIXED height so the modal does not jump between steps.
     Body scrolls internally when a step has more content than the viewport. */
  #appointment-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  @keyframes slideUpModal {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1;   }
  }

  /* Drag-handle pill at the very top */
  #appointment-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header: compact title + close X */
  #appointment-modal .modal-header {
    padding: 10px 18px 12px !important;
    border-bottom: 1px solid #f1f3f5 !important;
    flex-shrink: 0 !important;
  }
  #appointment-modal .modal-header h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }
  #appointment-modal .close-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    background: #f3f4f6 !important;
  }
  #appointment-modal .close-btn:hover { background: #e5e7eb !important; }

  /* Wizard progress: replace 5 numbered circles + labels with a tiny dots row */
  #appointment-modal .wizard-progress {
    padding: 12px 18px !important;
    background: #f9fafb !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }
  #appointment-modal .wizard-progress .progress-label { display: none !important; }
  #appointment-modal .wizard-progress .progress-circle {
    width: 8px !important;
    height: 8px !important;
    font-size: 0 !important;       /* hide the digit */
    background: #d1d5db !important;
    color: transparent !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
  }
  #appointment-modal .wizard-progress .progress-step.active .progress-circle {
    background: #3d75ef !important;
    transform: scale(1.45);
  }
  #appointment-modal .wizard-progress .progress-step.completed .progress-circle {
    background: #68ecc0 !important;
  }
  #appointment-modal .wizard-progress .progress-line {
    width: 28px !important;
    height: 2px !important;
    margin-top: 0 !important;
    background: #e5e7eb !important;
  }
  #appointment-modal .wizard-progress .progress-step.completed ~ .progress-line {
    background: #68ecc0 !important;
  }

  /* Body — natural height, scroll, comfortable padding */
  #appointment-modal .modal-body {
    padding: 16px 18px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Each wizard step's inner title — promote to prominent header */
  #appointment-modal .step-title {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #111827 !important;
    margin-bottom: 14px !important;
  }

  /* Step containers no longer need a fixed min-height (eats screen) */
  #appointment-modal .wizard-step-fixed { min-height: 0 !important; }

  /* Touch-friendly form fields. 16px font keeps iOS from auto-zooming. */
  #appointment-modal .form-input,
  #appointment-modal .form-select,
  #appointment-modal input[type="text"],
  #appointment-modal input[type="email"],
  #appointment-modal input[type="tel"],
  #appointment-modal input[type="date"],
  #appointment-modal input[type="time"],
  #appointment-modal input[type="number"],
  #appointment-modal textarea,
  #appointment-modal select {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
  }
  #appointment-modal textarea { min-height: 80px !important; }

  /* Patient toggle — bigger, full-width pills */
  #appointment-modal .patient-toggle .toggle-btn {
    padding: 12px 14px !important;
    font-size: 14px !important;
  }

  /* New-patient form: stack everything on a single column */
  #appointment-modal .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  #appointment-modal .form-group.full-width { grid-column: span 1 !important; }

  /* Service option cards: tighter padding, full width */
  #appointment-modal .service-option-btn {
    padding: 14px !important;
    gap: 12px !important;
  }
  #appointment-modal .option-title  { font-size: 14px !important; }
  #appointment-modal .option-description { font-size: 12px !important; }

  /* Consultorio options spacing */
  #appointment-modal .consultorio-option {
    padding: 14px !important;
    gap: 12px !important;
  }
  #appointment-modal .consultorio-option-name    { font-size: 14px !important; }
  #appointment-modal .consultorio-option-address { font-size: 12px !important; }

  /* Time slots: bigger touch targets, smaller grid */
  #appointment-modal .slots-container {
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)) !important;
    gap: 6px !important;
  }
  #appointment-modal .slot-btn {
    padding: 10px 8px !important;
    font-size: 14px !important;
    min-height: 40px !important;
  }

  /* Patient search results: bigger items */
  #appointment-modal .search-result-item {
    padding: 14px 12px !important;
    gap: 12px !important;
  }
  #appointment-modal .patient-avatar {
    width: 42px !important;
    height: 42px !important;
  }

  /* Footer — sticky, prominent primary button, safe-area aware */
  #appointment-modal .modal-footer {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    gap: 8px !important;
    border-top: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 5 !important;
  }
  #appointment-modal .modal-footer .btn {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    justify-content: center !important;
  }
  /* Primary action takes the most space; secondary actions stay compact */
  #appointment-modal .modal-footer #btn-next,
  #appointment-modal .modal-footer #btn-save  { flex: 1 1 auto !important; }
  #appointment-modal .modal-footer #btn-cancel,
  #appointment-modal .modal-footer #btn-back  { flex: 0 0 auto !important; padding-left: 14px !important; padding-right: 14px !important; }

  /* Dark scrim + safer body lock when modal is open */
  body:has(#appointment-modal.show) {
    overflow: hidden !important;
  }

  /* =========================================================================
     "Crear Evento Personal" modal — same bottom-sheet treatment as Nueva Cita.
     Single-step form so we let height adapt to content (max 92vh, scroll if
     longer) instead of forcing a fixed height.
     ========================================================================= */

  #personal-event-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #personal-event-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    /* FIXED height — exactly matches the Nueva Cita sheet so the two modals
       feel like the same component. Body scrolls internally if needed. */
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  /* Drag handle */
  #personal-event-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }
  /* The desktop modal-content uses padding: 32px which is too much on phones.
     We zero it and add inner padding via spacing on the main blocks below.   */
  #personal-event-modal .modal-content > .flex.items-center.justify-between {
    /* Header row (title + close X) */
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #personal-event-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }
  /* Info-banner block (the "lightbulb" hint at top of the form) */
  #personal-event-modal .modal-content > .bg-blue-50 {
    margin: 14px 18px 0 !important;
  }
  /* Form body — scrolls if needed */
  #personal-event-modal .modal-content > .space-y-4 {
    padding: 14px 18px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }
  /* Footer buttons row at the very bottom of the modal */
  #personal-event-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
  }
  #personal-event-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
  }

  /* Inside the form: stack the date + time row and bigger touch targets */
  #personal-event-modal .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  #personal-event-modal input[type="text"],
  #personal-event-modal input[type="time"],
  #personal-event-modal input[type="date"],
  #personal-event-modal select,
  #personal-event-modal textarea {
    font-size: 16px !important;       /* iOS no-zoom */
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }
  #personal-event-modal textarea { min-height: 70px !important; }

  /* ----- Inner element polish for the Personal Event form ------------- */

  /* Section spacing: tighten the gap between form groups */
  #personal-event-modal .space-y-4 > * + * { margin-top: 16px !important; }

  /* Info banner — keep it readable but compact */
  #personal-event-modal .bg-blue-50 {
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #personal-event-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Labels: clean, consistent */
  #personal-event-modal label.block,
  #personal-event-modal label.text-sm {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Duration helper / error text */
  #personal-event-duration-hint,
  #personal-event-duration-error {
    font-size: 11.5px !important;
    line-height: 1.4 !important;
    margin-top: 6px !important;
  }

  /* Checkbox row "Bloquear disponibilidad" — bigger touch target,
     visually distinct as a switch-like row. */
  #personal-event-modal label.flex.items-center.cursor-pointer {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 12px 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    margin: 0 !important;
    cursor: pointer !important;
    min-height: 52px !important;
  }
  #personal-event-modal label.flex.items-center.cursor-pointer input[type="checkbox"] {
    width: 22px !important;
    height: 22px !important;
    accent-color: #3d75ef !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
  }
  #personal-event-modal label.flex.items-center.cursor-pointer span {
    margin-left: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1f2937 !important;
  }

  /* Footer buttons — Cancel secondary + Guardar primary, full width split */
  #personal-event-modal .modal-content > .flex.gap-3 {
    display: flex !important;
    gap: 10px !important;
  }
  #personal-event-modal .modal-content > .flex.gap-3 button {
    flex: 1 1 0 !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  /* Make the "Cancelar" button visually secondary; it's the second child? In
     this template it's the FIRST. Detect by background-color being gray. */
  #personal-event-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #personal-event-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  /* Tighten the body's first child top spacing (the info banner) */
  #personal-event-modal .modal-content > .bg-blue-50 {
    margin-top: 12px !important;
    margin-bottom: 0 !important;
  }

  body:has(#personal-event-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Horario Especial" modal — same bottom-sheet treatment as Nueva Cita.
     Single-step form with date / consultorio / opening + closing time / breaks.
     ========================================================================= */

  #special-schedule-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #special-schedule-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #special-schedule-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header (title + X) */
  #special-schedule-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #special-schedule-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Info banner */
  #special-schedule-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #special-schedule-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Form body — scrolls if content exceeds viewport */
  #special-schedule-modal .modal-content > .space-y-4 {
    padding: 14px 18px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }
  #special-schedule-modal .space-y-4 > * + * { margin-top: 16px !important; }

  /* Apertura + Cierre: stack vertically (was 2-column grid) */
  #special-schedule-modal .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Labels (consistent with the other mobile modals) */
  #special-schedule-modal label.block,
  #special-schedule-modal label.text-sm {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Inputs / select / time */
  #special-schedule-modal input[type="text"],
  #special-schedule-modal input[type="time"],
  #special-schedule-modal input[type="date"],
  #special-schedule-modal select {
    font-size: 16px !important;       /* iOS no-zoom */
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

  /* Helper text under date */
  #special-schedule-modal .text-xs.text-gray-500 {
    font-size: 11.5px !important;
    line-height: 1.4 !important;
    margin-top: 6px !important;
  }

  /* Breaks header row: stack the label above the "Agregar descanso" button so
     the button is full-width and finger-friendly. */
  #special-schedule-modal .flex.items-center.justify-between.mb-2 {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin-bottom: 10px !important;
  }
  #special-schedule-modal .flex.items-center.justify-between.mb-2 button {
    width: 100% !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    border-radius: 10px !important;
    min-height: 42px !important;
  }

  /* Each break row inside the container */
  #special-schedule-modal #special-schedule-breaks-container > * {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 10px !important;
  }
  #special-schedule-modal #special-schedule-breaks-container .grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Footer */
  #special-schedule-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    gap: 10px !important;
  }
  #special-schedule-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  /* Cancelar (gris, compacto) + Guardar (azul, principal) */
  #special-schedule-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #special-schedule-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#special-schedule-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Bloquear Día" modal — same bottom-sheet treatment.
     ========================================================================= */

  #block-day-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #block-day-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #block-day-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header */
  #block-day-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #block-day-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Info banner (blue) */
  #block-day-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #block-day-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Warning banner (yellow) — same compact treatment */
  #block-day-modal #block-warning-container {
    margin: 10px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #block-day-modal #block-warning-container .font-semibold { font-size: 12.5px !important; }
  #block-day-modal #block-warning-text { font-size: 12px !important; line-height: 1.45 !important; }

  /* Form body */
  #block-day-modal .modal-content > .space-y-4 {
    padding: 14px 18px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }
  #block-day-modal .space-y-4 > * + * { margin-top: 16px !important; }

  /* Labels */
  #block-day-modal label.block,
  #block-day-modal label.text-sm {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Inputs */
  #block-day-modal input[type="text"],
  #block-day-modal input[type="date"] {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

  /* Selected-date display card */
  #block-day-modal #selected-date-display-container {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 12px 14px !important;
  }
  #block-day-modal .selected-date-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #6b7280 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
  }
  #block-day-modal .selected-date-value {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #111827 !important;
  }

  /* Footer */
  #block-day-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    gap: 10px !important;
  }
  #block-day-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  #block-day-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #block-day-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#block-day-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Programar Vacaciones" modal — same bottom-sheet treatment.
     ========================================================================= */

  #vacation-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #vacation-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #vacation-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header */
  #vacation-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #vacation-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Info banner (blue) */
  #vacation-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #vacation-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Warning banner (yellow) */
  #vacation-modal .bg-yellow-50 {
    margin: 10px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #vacation-modal .bg-yellow-50 .font-semibold { font-size: 12.5px !important; }
  #vacation-modal .bg-yellow-50 .text-xs { font-size: 12px !important; line-height: 1.45 !important; }

  /* Form body */
  #vacation-modal .modal-content > .space-y-4 {
    padding: 14px 18px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }
  #vacation-modal .space-y-4 > * + * { margin-top: 16px !important; }

  /* Labels */
  #vacation-modal label.block,
  #vacation-modal label.text-sm {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Inputs */
  #vacation-modal input[type="text"],
  #vacation-modal input[type="date"] {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

  /* Helper text under date range */
  #vacation-modal .text-xs.text-gray-500 {
    font-size: 11.5px !important;
    line-height: 1.4 !important;
    margin-top: 6px !important;
  }

  /* Selected range display card (kept distinct: blue accent) */
  #vacation-modal #vacation-range-display .bg-blue-50 {
    margin: 0 !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  #vacation-modal #vacation-range-display .text-sm.font-semibold {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px !important;
  }
  #vacation-modal #vacation-range-value {
    font-size: 14px !important;
    font-weight: 600 !important;
  }

  /* Footer */
  #vacation-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    gap: 10px !important;
  }
  #vacation-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  #vacation-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #vacation-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#vacation-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Para Reprogramar" panel modal — bottom-sheet treatment.
     Different from the form modals: no footer, content is a scrollable list
     of postponed appointments rendered dynamically. We give it the same sheet
     chrome (drag handle, sticky header) and let the list take all the body.
     ========================================================================= */

  #postponed-panel-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #postponed-panel-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #postponed-panel-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header (title with icon + count badge + X) */
  #postponed-panel-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #postponed-panel-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  #postponed-panel-modal #postponed-count-badge {
    margin-left: 0 !important;
    font-size: 11px !important;
    padding: 2px 8px !important;
  }

  /* Info banner */
  #postponed-panel-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #postponed-panel-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* The scrollable appointments list — fills the remaining space */
  #postponed-panel-modal #postponed-appointments-list {
    padding: 12px 18px calc(16px + env(safe-area-inset-bottom)) !important;
    max-height: none !important;       /* override the desktop "60vh" cap */
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
  }

  /* Each postponed-appointment card */
  #postponed-panel-modal #postponed-appointments-list > * + * {
    margin-top: 10px !important;
  }
  #postponed-panel-modal #postponed-appointments-list .bg-white,
  #postponed-panel-modal #postponed-appointments-list [class*="border"] {
    border-radius: 12px !important;
  }

  /* Action buttons inside each card (Reprogramar / Eliminar). They're tiny on
     desktop; bump them on mobile for fingers. */
  #postponed-panel-modal #postponed-appointments-list button {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }

  /* Empty state */
  #postponed-panel-modal #postponed-empty {
    padding: 40px 18px !important;
    font-size: 14px !important;
  }
  #postponed-panel-modal #postponed-empty i {
    font-size: 36px !important;
    margin-bottom: 10px !important;
  }

  body:has(#postponed-panel-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Horarios Especiales" panel modal — same bottom-sheet treatment.
     Same pattern as the Para Reprogramar panel: list-only, no footer.
     ========================================================================= */

  #special-schedules-panel-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #special-schedules-panel-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #special-schedules-panel-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header (icon + title + count badge + X) */
  #special-schedules-panel-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #special-schedules-panel-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  #special-schedules-panel-modal #special-schedules-count {
    margin-left: 0 !important;
    font-size: 11px !important;
    padding: 2px 8px !important;
  }

  /* Info banner */
  #special-schedules-panel-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #special-schedules-panel-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Scrollable list — fills remaining space */
  #special-schedules-panel-modal #special-schedules-list {
    padding: 12px 18px calc(16px + env(safe-area-inset-bottom)) !important;
    max-height: none !important;     /* override desktop "60vh" cap */
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
  }
  #special-schedules-panel-modal #special-schedules-list > * + * {
    margin-top: 10px !important;
  }
  #special-schedules-panel-modal #special-schedules-list .bg-white,
  #special-schedules-panel-modal #special-schedules-list [class*="border"] {
    border-radius: 12px !important;
  }

  /* Action buttons inside each item (Editar / Eliminar) */
  #special-schedules-panel-modal #special-schedules-list button {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }

  /* Loading / empty state */
  #special-schedules-panel-modal #special-schedules-list .loading-state {
    padding: 40px 18px !important;
    font-size: 14px !important;
    text-align: center;
  }
  #special-schedules-panel-modal #special-schedules-list .loading-state i {
    font-size: 28px !important;
    margin-bottom: 10px !important;
  }

  body:has(#special-schedules-panel-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Días Bloqueados" panel modal — same bottom-sheet treatment.
     Same shape as Para Reprogramar / Horarios Especiales.
     ========================================================================= */

  #blocked-days-panel-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #blocked-days-panel-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #blocked-days-panel-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header */
  #blocked-days-panel-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #blocked-days-panel-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  #blocked-days-panel-modal #blocked-days-count {
    margin-left: 0 !important;
    font-size: 11px !important;
    padding: 2px 8px !important;
  }

  /* Info banner */
  #blocked-days-panel-modal .modal-content > .bg-blue-50 {
    margin: 12px 18px 0 !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #blocked-days-panel-modal .bg-blue-50 p {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Scrollable list — fills remaining space */
  #blocked-days-panel-modal #blocked-days-list {
    padding: 12px 18px calc(16px + env(safe-area-inset-bottom)) !important;
    max-height: none !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
  }
  #blocked-days-panel-modal #blocked-days-list > * + * {
    margin-top: 10px !important;
  }
  #blocked-days-panel-modal #blocked-days-list .bg-white,
  #blocked-days-panel-modal #blocked-days-list [class*="border"] {
    border-radius: 12px !important;
  }

  /* Action buttons inside each item */
  #blocked-days-panel-modal #blocked-days-list button {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }

  /* Loading / empty state */
  #blocked-days-panel-modal #blocked-days-list .loading-state {
    padding: 40px 18px !important;
    font-size: 14px !important;
    text-align: center;
  }
  #blocked-days-panel-modal #blocked-days-list .loading-state i {
    font-size: 28px !important;
    margin-bottom: 10px !important;
  }

  body:has(#blocked-days-panel-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Opciones de Cita" modal — mobile bottom-sheet treatment.
     Header + appointment info card + 3-4 action buttons (Reprogramar /
     Etiqueta / Postpone / Eliminar). Same sheet chrome as the rest.
     ========================================================================= */

  #appointment-options-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #appointment-options-modal .modal-content,
  #appointment-options-modal.appointment-options-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #appointment-options-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header row */
  #appointment-options-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #appointment-options-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Scrollable body wrapper — everything between header and the bottom of
     the sheet scrolls when there is overflow. We don't have a single
     ".modal-body", so we let the children flow inside a flex parent and
     give them inner padding. */
  #appointment-options-modal .modal-content > #package-warning,
  #appointment-options-modal .modal-content > #blocked-event-section,
  #appointment-options-modal .modal-content > #appointment-info-section,
  #appointment-options-modal .modal-content > #appointment-option-buttons {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #appointment-options-modal .modal-content > #package-warning {
    margin: 14px 18px 0 !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }

  /* Wrap the appointment info + actions in a scrollable region by giving
     the actions container `flex: 1; overflow-y: auto`. Easiest approach:
     make the whole body part of one scroll area. */
  #appointment-options-modal .modal-content > #appointment-info-section,
  #appointment-options-modal .modal-content > #appointment-option-buttons,
  #appointment-options-modal .modal-content > #blocked-event-section {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  /* Info card */
  #appointment-options-modal .appointment-info-card {
    margin-top: 14px !important;
    margin-bottom: 14px !important;
    padding: 16px !important;
    border-radius: 14px !important;
  }
  #appointment-options-modal .appointment-info-title {
    font-size: 16px !important;
  }
  #appointment-options-modal .appointment-info-detail {
    font-size: 13px !important;
    line-height: 1.45 !important;
  }

  /* Option buttons column — bigger touch targets, full-width */
  #appointment-options-modal #appointment-option-buttons {
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }
  #appointment-options-modal #appointment-option-buttons.option-buttons {
    gap: 10px !important;
  }
  #appointment-options-modal .option-button {
    padding: 14px 16px !important;
    min-height: 54px !important;
    font-size: 15px !important;
    border-radius: 12px !important;
  }
  #appointment-options-modal .option-button > i { font-size: 18px !important; }
  #appointment-options-modal .option-button:hover {
    transform: none !important;       /* avoid lift effect on touch */
  }

  /* Blocked-event section (alternative content) */
  #appointment-options-modal #blocked-event-section {
    padding-top: 14px !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
  }
  #appointment-options-modal #blocked-event-section .flex.gap-3 button {
    padding: 12px 14px !important;
    min-height: 48px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
  }
  #appointment-options-modal #blocked-event-warning {
    padding: 10px 12px !important;
    border-radius: 10px !important;
    border-left-width: 3px !important;
  }
  #appointment-options-modal #blocked-event-details {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  body:has(#appointment-options-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Etiqueta de Color" modal — same bottom-sheet treatment.
     Color grid + selected color preview + Cancelar/Guardar footer.
     ========================================================================= */

  #label-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #label-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    /* Override inline padding "40px 32px 50px 32px" set in the template */
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #label-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header — also overrides the inline `margin-bottom: 50px` */
  #label-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #label-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Color grid — override inline `margin-bottom: 50px` and `gap: 20px`.
     5 columns is preserved, just tighten the gap for narrow viewports.
     Children keep their JS-set natural circular size — DO NOT force width
     or aspect-ratio on them, that flattens them. `justify-items: center`
     (set inline on the grid) keeps each circle centered in its cell. */
  #label-modal #color-grid {
    margin: 18px 18px 0 !important;
    gap: 14px !important;
  }

  /* Selected-color section — overrides inline `margin-bottom: 50px` */
  #label-modal #selected-color-section {
    margin: 18px 18px 0 !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #label-modal #selected-color-section .flex.items-center.gap-3 {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  #label-modal #default-color-message {
    font-size: 13px !important;
  }
  #label-modal #color-name-input {
    font-size: 16px !important;       /* iOS no-zoom */
    min-height: 40px !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }

  /* Footer (Cancelar + Guardar) */
  #label-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    gap: 10px !important;
  }
  #label-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  #label-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #label-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#label-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Reprogramar Cita" modal — bottom-sheet treatment.
     This modal is nested above other modals (z-index 99999 in the desktop
     stylesheet); we keep that and just style the sheet shell.
     ========================================================================= */

  #reschedule-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #reschedule-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #reschedule-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header */
  #reschedule-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #reschedule-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Scrollable body — the .space-y-5 wraps everything except header/footer */
  #reschedule-modal .modal-content > .space-y-5 {
    padding: 14px 18px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }
  /* Tailwind's space-y-5 uses 1.25rem; tighten on mobile */
  #reschedule-modal .space-y-5 > * + * { margin-top: 14px !important; }

  /* Current appointment info card */
  #reschedule-modal .modal-content > .space-y-5 > .rounded-lg.p-4 {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  #reschedule-modal #current-appointment-info { font-size: 13px !important; line-height: 1.5 !important; }

  /* Package info collapsible */
  #reschedule-modal #package-info-reschedule {
    border-radius: 12px !important;
  }
  #reschedule-modal #package-info-reschedule #package-toggle-btn {
    padding: 10px 12px !important;
  }
  #reschedule-modal #package-summary-text { font-size: 13px !important; }

  /* Duration warning + notifications */
  #reschedule-modal #reschedule-duration-warning > *,
  #reschedule-modal #reschedule-notifications > * {
    border-radius: 10px !important;
    padding: 10px 12px !important;
    font-size: 12.5px !important;
    line-height: 1.45 !important;
  }

  /* Date input */
  #reschedule-modal #reschedule-date-input {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

  /* Labels */
  #reschedule-modal label.block {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Calendar legend */
  #reschedule-modal #calendar-legend {
    font-size: 11.5px !important;
    margin-top: 6px !important;
  }

  /* Available slots — bigger touch targets */
  #reschedule-modal #slots-container {
    max-height: none !important;
  }
  #reschedule-modal #slots-container button,
  #reschedule-modal #slots-container .slot-btn {
    min-height: 40px !important;
    padding: 10px 8px !important;
    font-size: 14px !important;
  }
  #reschedule-modal #no-availability-message {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  /* Footer */
  #reschedule-modal .modal-content > .flex.gap-3 {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    gap: 10px !important;
  }
  #reschedule-modal .modal-content > .flex.gap-3 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  #reschedule-modal .modal-content > .flex.gap-3 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #reschedule-modal .modal-content > .flex.gap-3 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#reschedule-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Reprogramar Evento" (personal event) — bottom-sheet treatment.
     Note: in this modal the action buttons live INSIDE .space-y-4 (last
     child), not as a separate footer container.
     ========================================================================= */

  #reschedule-personal-event-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #reschedule-personal-event-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #reschedule-personal-event-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header */
  #reschedule-personal-event-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
  }
  #reschedule-personal-event-modal .modal-content > .flex.items-center.justify-between h3 {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
  }

  /* Body — scrollable */
  #reschedule-personal-event-modal .modal-content > .space-y-4 {
    padding: 14px 18px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }
  #reschedule-personal-event-modal .space-y-4 > * + * { margin-top: 14px !important; }

  /* Event info card (blue gradient) */
  #reschedule-personal-event-modal .modal-content > .space-y-4 > .rounded-lg.p-4 {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  #reschedule-personal-event-modal #reschedule-event-title { font-size: 13.5px !important; }
  #reschedule-personal-event-modal #reschedule-event-time  { font-size: 12px !important; line-height: 1.4 !important; }
  #reschedule-personal-event-modal #reschedule-event-status-badge { font-size: 11.5px !important; padding: 6px 10px !important; }

  /* Date + Time: stack vertically */
  #reschedule-personal-event-modal .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Labels */
  #reschedule-personal-event-modal label.block,
  #reschedule-personal-event-modal label.text-sm {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 6px !important;
  }

  /* Inputs */
  #reschedule-personal-event-modal input[type="text"],
  #reschedule-personal-event-modal input[type="time"],
  #reschedule-personal-event-modal input[type="date"] {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

  /* Blocks-appointments banner with checkbox */
  #reschedule-personal-event-modal .bg-blue-50 {
    padding: 12px !important;
    border-radius: 12px !important;
    border-left-width: 3px !important;
  }
  #reschedule-personal-event-modal .bg-blue-50 label.flex {
    align-items: flex-start !important;
    gap: 12px !important;
  }
  #reschedule-personal-event-modal #reschedule-personal-event-blocks-appointments {
    width: 22px !important;
    height: 22px !important;
    margin-top: 1px !important;
    flex-shrink: 0 !important;
  }
  #reschedule-personal-event-modal .bg-blue-50 .text-sm.font-semibold { font-size: 13.5px !important; }
  #reschedule-personal-event-modal .bg-blue-50 .text-xs { font-size: 12px !important; line-height: 1.45 !important; margin-top: 4px !important; }

  /* Action buttons row (inside .space-y-4, last child) */
  #reschedule-personal-event-modal .flex.gap-3.mt-6 {
    margin-top: 6px !important;     /* let the .space-y-4 gap handle spacing */
    gap: 10px !important;
  }
  #reschedule-personal-event-modal .flex.gap-3.mt-6 button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
  }
  #reschedule-personal-event-modal .flex.gap-3.mt-6 button:first-child {
    background: #f3f4f6 !important;
    color: #374151 !important;
    flex: 0 0 38% !important;
  }
  #reschedule-personal-event-modal .flex.gap-3.mt-6 button:last-child {
    background: #3d75ef !important;
    color: #ffffff !important;
    flex: 1 1 auto !important;
  }

  body:has(#reschedule-personal-event-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     "Eliminar Evento / Cita" confirm modal — bottom-sheet treatment.
     This modal appears nested above Opciones de Cita; its z-index 99999 is
     defined elsewhere. Up to 3 footer buttons (Cancelar / Postpone / Delete).
     ========================================================================= */

  #delete-confirm-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #delete-confirm-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    height: 92vh !important;
    max-height: 92vh !important;
    min-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUpModal 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  #delete-confirm-modal .modal-content::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Header (icon + title + X) */
  #delete-confirm-modal .modal-content > .flex.items-center.justify-between {
    padding: 6px 18px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
    align-items: center !important;
  }
  #delete-confirm-modal #delete-confirm-icon {
    font-size: 1.5rem !important;
  }
  #delete-confirm-modal #delete-confirm-title {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
  }

  /* Body — message + warnings + details. The body is everything between
     header and footer; in this template the children sit as direct kids of
     the modal-content. We put them in a scroll wrapper via flex. */
  #delete-confirm-modal .modal-content > #delete-confirm-message,
  #delete-confirm-modal .modal-content > #delete-confirm-warning,
  #delete-confirm-modal .modal-content > #delete-confirm-recommendation,
  #delete-confirm-modal .modal-content > #delete-confirm-details {
    margin-left: 18px !important;
    margin-right: 18px !important;
  }
  #delete-confirm-modal #delete-confirm-message {
    margin-top: 14px !important;
    margin-bottom: 10px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: #374151 !important;
  }
  #delete-confirm-modal #delete-confirm-warning {
    margin-bottom: 10px !important;
  }
  #delete-confirm-modal #delete-confirm-warning > * {
    padding: 10px 12px !important;
    border-radius: 10px !important;
    font-size: 12.5px !important;
    line-height: 1.45 !important;
  }
  #delete-confirm-modal #delete-confirm-recommendation {
    margin-bottom: 10px !important;
  }
  #delete-confirm-modal #delete-confirm-recommendation > * {
    padding: 10px 12px !important;
    border-radius: 10px !important;
    font-size: 12.5px !important;
    line-height: 1.45 !important;
  }
  #delete-confirm-modal #delete-confirm-details {
    margin-bottom: 0 !important;     /* footer adds its own spacing */
    padding: 12px 14px !important;
    border-radius: 12px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }

  /* Footer — Cancel + (optional Postpone) + Delete.
     Allow them to wrap if there are 3, since 3 buttons rarely fit on a phone
     comfortably side-by-side. */
  #delete-confirm-modal .modal-content > .flex.gap-3.justify-end {
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    margin-top: 14px !important;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 5;
    flex-wrap: wrap !important;
    justify-content: stretch !important;
    gap: 8px !important;
  }
  #delete-confirm-modal .modal-content > .flex.gap-3.justify-end button {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    flex: 1 1 calc(50% - 4px) !important;
    justify-content: center;
  }
  /* If only Cancel + Delete are visible (postpone hidden via inline style),
     they each take ~50% as above. If all three are visible, postpone wraps
     to the next row by itself. */
  #delete-confirm-modal #delete-confirm-postpone-btn {
    flex: 1 1 100% !important;
    order: 3;     /* push to last in the wrap order */
  }

  body:has(#delete-confirm-modal.show) { overflow: hidden !important; }

  /* =========================================================================
     /dashboard mobile adaptation
     -------------------------------------------------------------------------
     Reuses the shared top-bar (navy, white text), hamburger drawer, and
     page-label sizing already defined above. Below: dashboard-specific
     adjustments — collapse the multi-column grids to a single column,
     tighten the side padding, and hide visual flourishes that crowd the
     phone viewport (gradient orbs).
     ========================================================================= */

  /* Decorative gradient orbs are pure visual noise on a small screen */
  body > .gradient-orb,
  .gradient-orb { display: none !important; }

  /* Top white bar — kill the desktop padding-left/right of 40 px so the
     navy bar reaches the edges (consistent with /miagenda). */
  main > div[style*="padding-left: 40px"][style*="padding-right: 40px"][style*="height: 60px"] {
    padding-left: 8px !important;
    padding-right: 10px !important;
  }

  /* ----- Main content container ------------------------------------------ */
  main #main-content-area[style] {
    padding: 14px 14px !important;
  }

  /* ----- Upgrade banner -------------------------------------------------- */
  #upgrade-banner[style] {
    margin: 12px 14px 0 !important;
    width: calc(100% - 28px) !important;
  }
  #upgrade-banner .upgrade-banner-text { font-size: 12px !important; }
  #upgrade-banner .upgrade-banner-icon i,
  #upgrade-banner .upgrade-banner-arrow i { font-size: 12px !important; }

  /* ----- Hero header (KARDIA gradient banner) ---------------------------- */
  /* Desktop has 77px vertical padding and a doctors image at right:-2rem;
     on mobile we hide the doctors image entirely, give the box a fixed taller
     height, and let the title flow as inline text across 2 reserved lines. */
  main header[style*="background"][style*="padding: 77px"] {
    padding: 22px 20px !important;
    border-radius: 18px !important;
    margin-bottom: 16px !important;
    min-height: 150px !important;
  }
  /* Override the inline `display: flex; align-items: center` on the h1 so the
     typewriter span wraps word-by-word as normal inline text (instead of the
     whole flex item dropping to a new flex line). Reserve ~2 lines of height
     so the box doesn't visibly resize as phrases get longer/shorter. */
  main header[style*="background"][style*="padding: 77px"] h1 {
    display: block !important;
    min-height: 56px !important;
    line-height: 1.2 !important;
    word-break: normal;
    overflow-wrap: break-word;
  }
  main header[style*="background"][style*="padding: 77px"] h1 > span:first-child { font-size: 1.45rem !important; }
  main header[style*="background"][style*="padding: 77px"] #typewriter-text,
  main header[style*="background"][style*="padding: 77px"] #typewriter-cursor   { font-size: 1rem !important; vertical-align: baseline; }
  main header[style*="background"][style*="padding: 77px"] p { font-size: 11px !important; line-height: 1.4 !important; }
  /* Hide the doctors/secretary image entirely on mobile per user request.
     The wrapper div uses Tailwind class `bottom-0` (not inline `bottom: 0`),
     so we match its inline `right: -2rem` instead, and also hide the <img>
     directly as a belt-and-suspenders fallback. */
  main header[style*="background"][style*="padding: 77px"] > div[style*="right: -2rem"],
  main header[style*="background"][style*="padding: 77px"] #header-role-image {
    display: none !important;
  }

  /* ----- Section headings ----------------------------------------------- */
  main section > h2.text-2xl,
  main h2.text-2xl[id="agenda-title"],
  main h2.text-2xl[id="progress-title"] {
    font-size: 1.05rem !important;
    margin-bottom: 12px !important;
  }

  /* ----- Quick tools cards (Nuevo paciente, Nueva cita, etc.) ----------- */
  /* 2-column grid on mobile (like the admin reference). Reduce min-height.
     The decorative image stays at the right edge but capped so the title
     doesn't get hidden. The subtitle <p> is hidden because the narrower
     2-col card doesn't have horizontal room for both lines + image. */
  main .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  main .tool-card {
    min-height: 110px !important;
    padding: 12px !important;
    border-radius: 14px !important;
  }
  main .tool-card h3 { font-size: 13px !important; margin-bottom: 0 !important; line-height: 1.15 !important; }
  main .tool-card p  { display: none !important; }
  main .tool-card .absolute.bottom-6.left-6 {
    bottom: 10px !important;
    left: 12px !important;
    right: 12px !important;
    max-width: none;
  }
  /* Cap the right-side decorative image — smaller on a half-width card */
  main .tool-card img {
    max-height: 64px !important;
    object-fit: contain !important;
  }
  main .tool-card .absolute.bottom-0[style*="right"] {
    height: auto !important;
    max-height: 64px !important;
    right: -4px !important;
  }

  /* ----- Main 2-column grid (left timeline / right progress + stats) --- */
  /* Each grid item needs explicit min-width:0 so its intrinsic content
     (e.g. the timeline's `min-width: max-content` hours track) does NOT
     propagate up and expand the column past the viewport. Without this,
     CSS Grid's default `min-width: auto` would make every card overflow. */
  main .grid.grid-cols-1.lg\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    min-width: 0 !important;
  }
  main .grid.grid-cols-1.lg\:grid-cols-3 > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  main .lg\:col-span-2.space-y-12,
  main .space-y-12 > * + * {
    margin-top: 14px !important;
  }

  /* Safety net: nothing inside the dashboard content area is allowed to
     push the page horizontally. Components that need horizontal scroll
     (e.g. the timeline) declare their own `overflow-x: auto` and remain
     functional inside this clip. */
  main #main-content-area {
    overflow-x: hidden;
  }

  /* ----- Inner card padding ---------------------------------------------- */
  main .bg-white.rounded-2xl.p-8,
  main .bg-white.rounded-2xl[class*="p-8"] {
    padding: 14px !important;
    border-radius: 14px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* ----- Timeline (horizontal scroll) ---------------------------------- */
  main .timeline-nav-btn {
    width: 36px !important;
    height: 36px !important;
  }
  main .timeline-nav-btn i { font-size: 12px !important; }
  /* Each hour cell — let the JS-rendered widths still apply but tighten gap.
     Also force the scroll container to obey its parent width so 24 × 80px
     of hours cells (~2200px) stay inside the card, behind the scrollbar. */
  main .timeline-hours-wrapper { gap: 0.5rem !important; }
  main .timeline-scroll-container {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100%;
  }
  main #upcoming-appointments-title { font-size: 14px !important; }
  /* Today's appointments list — the .mt-8.pt-8 separator is too tall */
  main .mt-8.pt-8.border-t { margin-top: 14px !important; padding-top: 14px !important; }
  /* Appointment rows shouldn't push the card width either */
  main #today-appointments > * {
    min-width: 0 !important;
    max-width: 100% !important;
    word-break: break-word;
  }

  /* ----- Progress ring section ------------------------------------------
     The dashboard.html SVG now declares `viewBox="0 0 128 128"`, so the
     <circle cx=64 cy=64 r=36 …> coords scale proportionally — we can
     finally shrink the outer box on phones without clipping. */
  main #progress-section .bg-white > .flex {
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
  }
  main #progress-section .bg-white > .flex > div:first-child {
    flex: 1 1 auto;
    min-width: 0 !important;
  }
  main .progress-ring {
    width: 88px !important;
    height: 88px !important;
    flex-shrink: 0;
  }
  main #progress-percentage { font-size: 1.85rem !important; margin-bottom: 4px !important; line-height: 1.1 !important; }
  main #progress-section .text-sm { font-size: 12px !important; }

  /* The progress + stats sections start with inline `opacity: 0` and fade
     in via JS once data loads. On mobile we force them visible so a slow
     fetch (or a JS hiccup) never leaves the user staring at empty space.
     The data still updates in place when it arrives. */
  main #progress-section,
  main #stats-section {
    opacity: 1 !important;
  }

  /* ----- Stats section --------------------------------------------------- */
  /* The generic `main .space-y-6 { display: none }` rule above (added for
     /miagenda pre-calendar helpers) accidentally hides the inner content of
     this dashboard card. Re-show it explicitly. */
  main #stats-section .space-y-6,
  main #progress-section .space-y-6 {
    display: block !important;
  }
  main #stats-section .space-y-6 > * + * { margin-top: 12px !important; }
  main #stats-section .text-2xl { font-size: 1.15rem !important; }
  main #stats-section .text-sm { font-size: 12px !important; }
  main #stats-section .flex.justify-between {
    gap: 8px;
    min-width: 0;
  }
  main #stats-section .flex.justify-between > span:first-child {
    min-width: 0;
    flex: 1 1 auto;
  }

  /* ----- Generic large-text clamping (catches ad-hoc usages) ----------- */
  main .text-5xl, main .text-6xl, main .text-7xl { font-size: 1.85rem !important; }
  main .text-4xl                                  { font-size: 1.55rem !important; }
  main .text-3xl                                  { font-size: 1.3rem !important; }

  /* ----- Section vertical spacing -------------------------------------- */
  main .mb-16 { margin-bottom: 18px !important; }
  main .mb-12 { margin-bottom: 16px !important; }
  main .mb-8  { margin-bottom: 12px !important; }
  main .gap-12 { gap: 16px !important; }
  main .gap-6  { gap: 12px !important; }

  /* Charts: prevent overflow on narrow viewports */
  main canvas, main svg { max-width: 100% !important; height: auto !important; }

} /* end @media (max-width: 1099px) */

/* =============================================================================
   Desktop-only: hide every mobile-only control at viewport >=768px.
   IMPORTANT: this rule MUST be scoped to desktop (min-width: 1100px) so it
   does NOT override the mobile @media above. Putting `display: none` outside
   any media query would win (same-specificity cascade) and blank the page
   on mobile.
   ========================================================================== */
@media (min-width: 1100px) {
  #mobile-hamburger,
  #mobile-fab,
  #mobile-fab-sheet,
  #mobile-right-rail,
  #mobile-overflow-btn,
  #mobile-overflow-sheet,
  #mobile-today-view,
  #mobile-drawer-close,
  #sidebar-mobile-overlay {
    display: none !important;
  }
}
