/* ════════════════════════════════════════════════════════════════════
   CloudPrescription — NUCLEAR Responsive v3
   ════════════════════════════════════════════════════════════════════
   This file forces EVERY element to stay within viewport width.
   Loaded last in every page.  Uses high-specificity selectors to
   override fixed-width / padding / gap declarations from home.css,
   app-doctor.css, app-admin.css etc.
   ════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL: nothing escapes the viewport, ever
   ═══════════════════════════════════════════════════════════════════ */
html, body {
  overflow-x: clip !important;
  max-width: 100vw !important;
  width: 100% !important;
  -webkit-text-size-adjust: 100% !important;
  margin: 0;
  padding: 0;
}

*, *::before, *::after {
  box-sizing: border-box !important;
  max-width: 100% !important;
}

img, video, svg, iframe, embed, object, canvas, picture {
  max-width: 100% !important;
  height: auto !important;
}

table {
  max-width: 100% !important;
  table-layout: auto;
  word-break: break-word;
}

/* Wrappers can't overflow */
.container, .wrap, .page, .main, section, header, footer, nav,
.section, .hero, .footer, .nav-inner, .hero-inner {
  max-width: 100% !important;
}

/* Mobile menu helper */
.cp-menu-btn {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 9999;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(10, 22, 18, .95);
  color: #f7f3ec;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  align-items: center;
  justify-content: center;
}
.cp-menu-btn:active { transform: scale(.96); }

/* ═══════════════════════════════════════════════════════════════════
   ≤ 1100 px : tablet landscape / small laptop
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  body .sidebar { width: 200px !important; }

  body .stats,
  body .stats-row,
  body .features-grid,
  body .pricing-cards { grid-template-columns: repeat(2, 1fr) !important; }

  body .content-grid,
  body .content-grid.equal,
  body .content-grid.three { grid-template-columns: 1fr !important; }

  body .hero { gap: 30px !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   ≤ 900 px : tablet portrait, large phones landscape
   Switches the entire homepage hero from 2-col to 1-col
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* HERO 2-col → 1-col */
  body .hero,
  body section.hero,
  body div.hero {
    display: block !important;
    grid-template-columns: 1fr !important;
    padding: 40px 18px 50px !important;
    text-align: center;
  }

  body .hero-content,
  body .hero-left { text-align: center; }

  body .hero-eyebrow,
  body .hero-trust { margin-left: auto; margin-right: auto; }

  body .hero h1 {
    font-size: clamp(1.6rem, 6vw, 2.4rem) !important;
    text-align: center;
  }
  body .hero p {
    margin-left: auto; margin-right: auto;
    text-align: center;
  }

  body .hero-ctas {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }

  body .hero-visual {
    margin-top: 36px;
    transform: none !important;
  }
  body .hero-visual .dash-mock,
  body .hero-visual .rx-mock {
    transform: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   ≤ 880 px : universal "mobile mode" — hamburger, sidebar slides out
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {

  /* ───── HOMEPAGE NAVIGATION ───── */
  body .nav-inner,
  body .nav > div {
    padding: 12px 14px !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
  }
  body .nav-links { display: none !important; }
  /* ═══ Polished mobile dropdown menu (fixed position = never clipped) ═══ */
  body .nav-links.show {
    display: flex !important;
    position: fixed !important;
    top: 64px !important;
    left: 12px !important;
    right: 12px !important;
    flex-direction: column !important;
    gap: 2px !important;
    background: var(--paper, #fffdf8) !important;
    border: 1px solid var(--line, #e5dccb) !important;
    border-radius: 16px !important;
    box-shadow: 0 18px 50px rgba(10,22,18,.20) !important;
    padding: 10px !important;
    z-index: 2147483600 !important;
    animation: navSlideDown .22s cubic-bezier(.4,0,.2,1) !important;
  }
  body .nav-links.show a {
    display: flex !important;
    align-items: center !important;
    gap: 13px !important;
    padding: 13px 14px !important;
    font-size: .96rem !important;
    font-weight: 600 !important;
    color: var(--ink, #0a1612) !important;
    width: 100% !important;
    border-radius: 11px !important;
    background: transparent !important;
    transition: background .14s, transform .14s !important;
  }
  body .nav-links.show a:active {
    background: var(--cream-2, #efe8db) !important;
    transform: scale(.98) !important;
  }
  body .nav-links.show a .nav-ico {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px !important;
    height: 34px !important;
    border-radius: 9px !important;
    background: var(--cream, #f7f3ec) !important;
    color: var(--emerald, #0d6b4f) !important;
    font-size: .9rem !important;
    flex-shrink: 0 !important;
  }
  body .nav-links.show a:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,.04) !important;
  }
  /* Hamburger button polish */
  body .nav-menu-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: 11px !important;
    background: var(--cream, #f7f3ec) !important;
    border: 1px solid var(--line, #e5dccb) !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .14s !important;
  }
  body .nav-menu-btn:active { background: var(--cream-2, #efe8db) !important; }
  body .nav-cta { margin-left: auto !important; gap: 6px !important; }

  /* HIDE "Start free trial" button entirely on mobile — keep only "Sign in" */
  body .nav-cta .cta-big,
  body .nav-cta a[href*="register"],
  body .nav-cta .btn-primary { display: none !important; }

  body .nav-cta > a,
  body .nav-cta > .btn-ghost,
  body .btn-ghost,
  body .nav-cta a.btn-ghost {
    padding: 8px 14px !important;
    font-size: .84rem !important;
    white-space: nowrap;
  }
  body .nav-brand { font-size: 1rem !important; }
  body .nav-brand .mark {
    width: 30px !important;
    height: 30px !important;
    font-size: .76rem !important;
  }
  body .nav-menu-btn { display: inline-flex !important; }

  /* ───── FIND-DOCTOR SEARCH BAR FIX ───── */
  body .find-doctor {
    grid-template-columns: 1fr !important;
    padding: 22px 16px !important;
    gap: 22px !important;
  }
  body .fd-search {
    flex-wrap: nowrap !important;
    width: 100% !important;
  }
  body .fd-search input {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 12px 12px !important;
    font-size: .88rem !important;
  }
  body .fd-search button {
    padding: 12px 16px !important;
    font-size: .82rem !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }
  body .fd-filters {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch;
  }
  body .fd-chip { flex-shrink: 0 !important; white-space: nowrap !important; }
  body .fd-right {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* ───── DOCTOR/ADMIN TOPBAR — HIDE search box on mobile ───── */
  body .tb-search {
    display: none !important;
  }
  body .tb-kbd { display: none !important; }

  /* ───── HERO (bigger, readable text on mobile) ───── */
  body .hero {
    padding: 36px 16px 50px !important;
    gap: 24px !important;
  }
  body .hero h1 {
    font-size: clamp(2rem, 8vw, 2.6rem) !important;
    line-height: 1.12 !important;
    margin-bottom: 18px !important;
    font-weight: 800 !important;
  }
  body .hero h1 em::after { bottom: 2px !important; height: 7px !important; }
  body .hero p {
    font-size: 1.02rem !important;
    margin-bottom: 24px !important;
    line-height: 1.55 !important;
    color: var(--mute, #6b6155) !important;
  }
  body .hero-eyebrow {
    font-size: .78rem !important;
    padding: 6px 14px 6px 8px !important;
    margin-bottom: 20px !important;
  }
  body .hero-ctas {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 10px !important;
    margin-bottom: 26px !important;
  }
  body .hero-ctas > .cta-big,
  body .hero-ctas > .cta-outline,
  body .hero-ctas > a {
    width: 100% !important;
    justify-content: center !important;
    padding: 15px 22px !important;
    font-size: 1rem !important;
    text-align: center !important;
  }
  body .hero-trust {
    flex-direction: column !important;
    gap: 10px !important;
    align-items: center !important;
    text-align: center !important;
    font-size: .82rem !important;
  }
  body .hero-visual { margin-top: 24px; }

  /* ───── SECTIONS ───── */
  body .section,
  body section {
    padding: 50px 14px !important;
  }

  /* ───── DOCTOR/ADMIN PORTAL SIDEBAR ───── */
  body .app {
    grid-template-columns: 1fr !important;
    display: block !important;
    background: var(--cream) !important;
  }

  body .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;
    width: 270px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 9998 !important;
    transition: left .25s ease !important;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  body .sidebar.show { left: 0 !important; }

  body .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9997;
    backdrop-filter: blur(2px);
  }
  body .sidebar-overlay.show { display: block; }

  body .cp-menu-btn,
  body .tb-mobile-menu {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* ───── MAIN CONTENT ───── */
  body .main {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body .topbar {
    padding: 10px 12px !important;
    gap: 10px !important;
    flex-wrap: wrap;
  }
  body .tb-title {
    font-size: .92rem !important;
    flex: 1 1 auto;
    min-width: 0;
  }
  body .tb-actions {
    gap: 5px !important;
    margin-left: auto;
  }
  body .tb-btn {
    padding: 7px 10px !important;
    font-size: .76rem !important;
    white-space: nowrap;
  }
  body .tb-btn span:not(.icon),
  body .tb-btn-text { display: none !important; }
  body .tb-btn i { margin: 0 !important; }

  body .page,
  body .page.narrow,
  body .main .page {
    padding: 14px 12px !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  body .breadcrumb {
    flex-wrap: wrap !important;
    gap: 4px !important;
    font-size: .8rem !important;
  }

  /* ───── DASHBOARD HERO (doctor/admin top of dashboard) ───── */
  body .page-hero,
  body .dash-hero {
    padding: 18px 16px !important;
    border-radius: 14px !important;
  }
  body .dash-hero h1,
  body .page-hero h1 { font-size: 1.3rem !important; line-height: 1.2 !important; }
  body .dash-hero .greeting,
  body .dash-hero p { font-size: .88rem !important; }
  body .dash-hero-actions,
  body .page-hero-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin-top: 14px !important;
  }
  body .dash-hero-actions a,
  body .dash-hero-actions button,
  body .page-hero-actions a,
  body .page-hero-actions button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* ───── FORM GRIDS ───── */
  body .form-grid,
  body .form-grid.three,
  body .form-grid.four,
  body .fg2, body .fg3, body .fg4,
  body .grid-2, body .grid-3, body .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  body input, body select, body textarea,
  body .form-control { max-width: 100% !important; }

  /* ───── CTA ROWS GENERAL ───── */
  body .hero-cta,
  body .cta-row,
  body .success-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  body .hero-cta > *,
  body .cta-row > *,
  body .success-actions > * {
    width: 100% !important;
    justify-content: center !important;
  }

  /* ───── BOOKING ───── */
  body .cal-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 6px !important; }
  body .slots-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  body .mode-row { grid-template-columns: 1fr !important; }

  /* ───── PRESCRIPTION CREATE (rx-layout / rx-history) ───── */
  body .rx-layout,
  body .rx-page {
    grid-template-columns: 1fr !important;
    display: block !important;
    gap: 14px !important;
  }
  body .rx-history,
  body .rx-left-panel {
    position: static !important;
    height: auto !important;
    max-height: 380px !important;        /* collapsible scrollable panel */
    overflow-y: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line, #e5dccb) !important;
    width: 100% !important;
    margin-bottom: 14px !important;
  }
  body .pat-vitals-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  body .cond-grid { grid-template-columns: repeat(2, 1fr) !important; }
  body .rx-search-wrap,
  body .rx-form-card { padding: 14px !important; }
  body .rx-meta-grid,
  body .rx-vitals-input-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  body .rx-med-input-row { grid-template-columns: 1fr !important; gap: 6px !important; }
  body .rx-foot-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  body .rx-foot-actions > * { width: 100% !important; justify-content: center !important; }

  /* ───── TABLES → MOBILE CARDS ───── */
  body .data-table thead { display: none !important; }
  body .data-table,
  body .data-table tbody,
  body .data-table tr,
  body .data-table td {
    display: block !important;
    width: 100% !important;
  }
  body .data-table tr {
    background: var(--paper, #fffdf8) !important;
    border: 1px solid var(--line, #e5dccb) !important;
    border-radius: 11px !important;
    margin-bottom: 10px !important;
    padding: 6px 0 !important;
  }
  body .data-table td {
    border: 0 !important;
    padding: 9px 14px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 12px !important;
    text-align: right !important;
    word-break: break-word !important;
  }
  body .data-table td::before {
    content: attr(data-label);
    font-size: .68rem !important;
    font-weight: 800 !important;
    color: var(--mute, #6b6155) !important;
    text-transform: uppercase !important;
    letter-spacing: .07em !important;
    text-align: left !important;
    flex-shrink: 0 !important;
    min-width: 90px;
    padding-top: 2px;
  }
  body .data-table td:first-child { padding-top: 12px !important; }
  body .data-table td:last-child  { padding-bottom: 12px !important; }
  body .data-table td:empty { display: none !important; }

  /* ───── STATS ───── */
  body .stats,
  body .stat-row,
  body .stats-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  body .stat-value { font-size: 1.45rem !important; }
  body .stat-card {
    padding: 14px 14px !important;
    border-radius: 12px !important;
  }
  body .stat-label { font-size: .7rem !important; }

  /* ───── MODALS ───── */
  body .modal {
    max-width: 100% !important;
    max-height: 95vh !important;
    max-height: 95dvh !important;
    border-radius: 14px 14px 0 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  body .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  /* ───── HOMEPAGE COMPARISON / FEATURES / PRICING ───── */
  body .pricing-cards,
  body .features-grid,
  body .comparison-table,
  body .comparison-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Comparison table on homepage — turn off horizontal layout */
  body .comparison-table table { display: block; }
  body .comparison-table table thead {
    display: block;
    overflow-x: auto;
  }

  /* ───── FOOTER ───── */
  body .footer-cols,
  body .footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px !important;
  }
  body .footer-cols > div:first-child,
  body .footer-grid > div:first-child {
    grid-column: 1 / -1 !important;
  }
  body .footer { padding: 40px 16px 24px !important; }

  /* ───── FILTER CHIPS ───── */
  body .filters,
  body .filter-row {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 14px !important;
    margin-bottom: 14px !important;
  }
  body .filter-chip { flex-shrink: 0 !important; white-space: nowrap !important; }

  /* ───── FLOATING WHATSAPP ───── */
  body .wa-float,
  body .whatsapp-float {
    bottom: 18px !important;
    right: 14px !important;
    width: 52px !important;
    height: 52px !important;
  }

  /* ───── DOCTOR CARDS ───── */
  body .doc-card,
  body .doctor-card { padding: 14px !important; }

  /* ───── HORIZONTAL OVERFLOW EMERGENCY KILL ───── */
  body div, body section, body article, body aside, body header, body footer, body main {
    max-width: 100vw !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   ≤ 640 px : standard phones (iPhone 12-15, Pixel)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  body .hero { padding: 32px 14px 40px !important; }
  body .hero h1 { font-size: clamp(1.35rem, 7vw, 1.8rem) !important; }
  body .hero p { font-size: .9rem !important; }

  body .stats,
  body .stat-row,
  body .stats-row { grid-template-columns: 1fr !important; }

  body .rx-toolbar {
    gap: 6px !important;
    padding: 10px 12px !important;
    flex-wrap: wrap !important;
  }
  body .tb-brand-text { display: none !important; }

  body .rx-sheet { margin: 8px 0 !important; border-radius: 0 !important; }
  body .rx-head {
    padding: 20px 16px !important;
    flex-direction: column !important;
    gap: 14px !important;
    text-align: center !important;
  }
  body .rx-chamber {
    text-align: center !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  body .rx-doc-name { font-size: 1.3rem !important; }
  body .rx-meta-bar, body .rx-patient, body .rx-cd, body .rx-vitals,
  body .rx-meds, body .rx-advice, body .rx-footer, body .rx-disclaimer {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  body .rx-patient-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  body .rx-vitals-grid  { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  body .rx-med-item {
    grid-template-columns: 28px 1fr !important;
    gap: 8px !important;
  }
  body .rx-med-dose-box {
    grid-column: 1 / -1 !important;
    text-align: left !important;
    padding-left: 36px !important;
    margin-top: 4px !important;
  }
  body .rx-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }

  body .cal-grid { grid-template-columns: repeat(3, 1fr) !important; }
  body .slots-grid { grid-template-columns: repeat(2, 1fr) !important; }
  body .summary-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  body .footer-cols,
  body .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
  body .footer-cols > div:first-child,
  body .footer-grid > div:first-child { grid-column: auto !important; }

  body .nav { padding: 10px 14px !important; }
  body .nav-inner { padding: 0 !important; }

  body .doctor-list,
  body .doctors-grid,
  body .featured-docs {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  body .btn,
  body a.btn,
  body button.btn {
    padding: 10px 18px !important;
    font-size: .9rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   ≤ 430 px : Oppo Reno 8T (412px), Pixel 7, Galaxy S22, iPhone 15 Pro Max
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 430px) {
  body .page,
  body .page.narrow { padding: 12px 10px !important; }

  body .topbar { padding: 8px 10px !important; }
  body .tb-title { font-size: .86rem !important; }

  body .hero { padding: 28px 14px 36px !important; }
  body .hero h1 { font-size: 1.85rem !important; line-height: 1.12 !important; }
  body .hero p { font-size: .96rem !important; }
  body .hero-eyebrow { font-size: .72rem !important; padding: 5px 11px 5px 6px !important; }
  body .hero-stats {
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: center !important;
  }
  body .hero-stat-num { font-size: 1.2rem !important; }
  body .hero-ctas > * {
    padding: 14px 20px !important;
    font-size: .96rem !important;
  }
  body .hero-trust { gap: 8px !important; font-size: .78rem !important; }
  body .trust-av {
    width: 26px !important;
    height: 26px !important;
    font-size: .62rem !important;
  }

  body .stat-value { font-size: 1.35rem !important; }
  body .stat-card { padding: 12px 12px !important; }
  body .stat-label { font-size: .66rem !important; }

  /* Header CTA further compressed */
  body .nav-cta > a {
    padding: 7px 12px !important;
    font-size: .8rem !important;
  }
  body .nav-brand { font-size: .92rem !important; }
  body .nav-brand .mark { width: 26px !important; height: 26px !important; font-size: .68rem !important; }

  body .sidebar {
    width: 250px !important;
    max-width: 80vw !important;
  }

  body .doctor-list,
  body .doctors-grid,
  body .featured-docs,
  body .fd-right {
    grid-template-columns: 1fr !important;
  }

  body .section,
  body section { padding: 36px 14px !important; }

  /* Compact section headlines */
  body section h2,
  body .section h2,
  body .section-title {
    font-size: 1.55rem !important;
    line-height: 1.18 !important;
  }
  body .section p,
  body .section-sub,
  body .section-subtitle { font-size: .92rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   ≤ 380 px : iPhone SE 1, old Galaxy, narrow phones
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  body .page,
  body .page.narrow { padding: 10px 8px !important; }

  body .hero { padding: 22px 12px 28px !important; }
  body .hero h1 { font-size: 1.65rem !important; }
  body .hero p { font-size: .9rem !important; }
  body .stat-value { font-size: 1.18rem !important; }
  body .btn, body .tb-btn {
    font-size: .8rem !important;
    padding: 8px 12px !important;
  }
  body .form-control {
    font-size: 16px !important;     /* prevent iOS zoom */
    padding: 9px 11px !important;
  }
  body .rx-doc-name { font-size: 1.18rem !important; }
  body .cal-num { font-size: 1rem !important; }
  body .filter-chip {
    padding: 7px 12px !important;
    font-size: .76rem !important;
  }
  body .fd-search input { padding: 10px 10px !important; font-size: .84rem !important; }
  body .fd-search button { padding: 10px 14px !important; font-size: .78rem !important; }

  body .cal-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 5px !important; }
  body .slots-grid { grid-template-columns: repeat(2, 1fr) !important; }

  body .sidebar { width: 230px !important; }

  body section h2,
  body .section h2,
  body .section-title { font-size: 1.35rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   Landscape phones (height ≤ 500px landscape)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
  body .hero {
    padding-top: 24px !important;
    padding-bottom: 24px !important;
    min-height: auto !important;
  }
  body .hero h1 { font-size: 1.4rem !important; }
  body .section { padding: 28px 14px !important; }
  body .sidebar { width: 210px !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════ */
@media print {
  body .cp-menu-btn,
  body .sidebar,
  body .sidebar-overlay,
  body .topbar,
  body .tb-mobile-menu,
  body .rx-toolbar,
  body .nav, body nav,
  body .footer, body footer,
  body .wa-float, body .whatsapp-float,
  body .breadcrumb,
  body .filters,
  body .pagination,
  body button:not(.print-keep) { display: none !important; }

  body .app, body .main { display: block !important; }
  body .page { padding: 0 !important; max-width: 100% !important; }
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
  }
  body a { color: #000 !important; text-decoration: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   TOUCH DEVICES — min tap targets, prevent iOS zoom
   ═══════════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  body .btn, body .tb-btn, body .filter-chip, body .page-btn,
  body .sb-item, body .sb-logout, body .nav-link,
  body a.btn, body button { min-height: 42px; }

  body input, body select, body textarea {
    font-size: 16px !important;     /* iOS auto-zoom prevention */
    min-height: 42px;
  }
  body textarea { min-height: 80px; }
}

/* ═══════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════ */
*:focus-visible {
  outline: 2px solid #c2792a !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════ */
.mobile-only  { display: none !important; }
.desktop-only { display: block !important; }

@media (max-width: 880px) {
  .mobile-only  { display: block !important; }
  .desktop-only { display: none !important; }
}

.filters::-webkit-scrollbar { height: 4px; }
.filters::-webkit-scrollbar-track { background: transparent; }
.filters::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

.btn, button, a.btn, .filter-chip, .tb-btn {
  -webkit-tap-highlight-color: rgba(13, 107, 79, 0.15);
}

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP: sticky sidebar with its own scroll (fix for "sidebar stuck on top")
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  body .app {
    grid-template-columns: 220px 1fr !important;
    align-items: start !important;
    min-height: 100vh;
  }
  body .sidebar {
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    align-self: start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  body .main {
    min-width: 0 !important;            /* fix flex/grid child overflow */
    overflow-x: hidden !important;
  }
}
/* ═══ Mobile nav dropdown animation (top-level so it always parses) ═══ */
@keyframes navSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══ Global mobile safety net (prevents horizontal overflow / squished media) ═══ */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  img, video, canvas, svg { max-width: 100%; height: auto; }
  .page, .main .page { padding: 16px !important; }
  /* any element accidentally wider than screen won't force sideways scroll */
  .app, .main { max-width: 100vw; }
}
