/* ============================================================
   Hotel Management SaaS — Mobile Responsive Overrides
   Targets: 320px – 767px (phones), with some fixes at 768px
   Strategy: desktop-first; all rules inside media queries
   IMPORTANT: No rules outside of @media blocks — desktop
   appearance is preserved entirely.
   ============================================================ */

/* ============================================================
   SHARED SAFE-AREA SUPPORT
   (for notched iPhones and Android devices)
   ============================================================ */
@supports (padding: env(safe-area-inset-left)) {
  @media (max-width: 767px) {
    .topbar,
    .p-topbar,
    .acc-topbar,
    .nav-wrap {
      padding-left: max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }
    .sidebar {
      padding-left: env(safe-area-inset-left);
    }
    .page-content,
    .p-content {
      padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    .mobile-nav {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
      padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    .acc-body {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
  }
}

/* ============================================================
   A. HOTEL ADMIN PANEL — app.css based
   ============================================================ */

/* ── A1. Topbar ── */
@media (max-width: 767px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .topbar-left {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }
  .topbar-search {
    display: none !important; /* replaced by separate search on page */
  }
  .menu-toggle {
    display: flex !important;
    flex-shrink: 0;
  }
  .topbar-user-name {
    display: none; /* show only avatar on tiny screens */
  }
  .topbar-right {
    gap: 4px;
  }
  /* Shrink notification dropdown to stay in viewport */
  .notification-panel {
    width: calc(100vw - 24px);
    max-width: 340px;
    right: 0;
    left: auto;
  }
  /* Dropdown menus stay inside viewport */
  .topbar-right .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 160px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 374px) {
  .topbar {
    padding: 0 10px;
  }
  .topbar-btn {
    width: 32px;
    height: 32px;
  }
}

/* ── A2. Sidebar ── */
@media (max-width: 767px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .main-content {
    margin-left: 0 !important;
  }
  /* Prevent body scroll when sidebar is open — handled by JS */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 250;
    cursor: pointer;
  }
  .sidebar-overlay.show {
    display: block;
  }
}

/* ── A3. Page content & headers ── */
@media (max-width: 767px) {
  .page-content {
    padding: 14px 12px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-title {
    font-size: 1.15rem;
  }
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  /* Buttons in page actions: allow wrapping, prevent overflow */
  .page-actions .btn {
    flex-shrink: 0;
  }
}

@media (max-width: 374px) {
  .page-content {
    padding: 10px 10px;
  }
  .page-title {
    font-size: 1.05rem;
  }
}

/* ── A4. Stat cards ── */
@media (max-width: 767px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 14px 12px;
    gap: 10px;
  }
  .stat-value {
    font-size: 1.2rem;
  }
  .stat-icon {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 374px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
}

/* ── A5. Grid layouts ── */
@media (max-width: 767px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  /* Allow 2-col layout for larger phones */
  .grid-auto {
    grid-template-columns: 1fr;
  }
}

/* ── A6. Cards ── */
@media (max-width: 767px) {
  .card {
    padding: 14px 12px;
    border-radius: 10px;
  }
  .card-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  /* Card header actions: stack below title if needed */
  .card-header > :last-child {
    margin-left: 0;
  }
}

/* ── A7. Tables ── */
@media (max-width: 767px) {
  /* Wrap tables in a horizontally scrollable container.
     The .table-wrap class already exists in markup. */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Subtle right-shadow to hint scrollability */
    background:
      linear-gradient(to right, white 30%, rgba(255,255,255,0)),
      linear-gradient(to left,  white 30%, rgba(255,255,255,0)) 100% 0,
      radial-gradient(farthest-side at 0%   50%, rgba(0,0,0,.08), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.08), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .table-card {
    border-radius: 10px;
    overflow: hidden;
  }
  .table-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .table-search {
    min-width: 0;
    flex: 1;
    width: 100%;
  }
  .table-filters {
    width: 100%;
  }
  /* Tighten cell padding on small screens */
  th {
    padding: 9px 10px;
    font-size: 0.68rem;
  }
  td {
    padding: 10px 10px;
    font-size: 0.8rem;
  }
  .table-actions {
    flex-wrap: nowrap;
    gap: 2px;
  }
  /* Prevent btn-icon from shrinking too small */
  .table-actions .btn-icon {
    padding: 6px;
  }
}

/* ── A8. Forms ── */
@media (max-width: 767px) {
  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr !important;
  }
  .form-row {
    gap: 12px;
  }
  .form-group {
    margin-bottom: 12px;
  }
  /* Input group on mobile: stack if very narrow */
  .input-group {
    flex-wrap: wrap;
  }
  .input-group .form-control {
    border-radius: var(--radius-sm);
    border-right: 1px solid var(--border);
    width: 100%;
  }
  .input-group-append .btn {
    border-radius: var(--radius-sm);
    border-left: 1px solid transparent;
    margin-top: 4px;
  }
}

/* ── A9. Modals ── */
@media (max-width: 767px) {
  .modal-overlay {
    padding: 12px 10px;
    align-items: flex-end; /* bottom-sheet style on mobile */
  }
  .modal {
    max-height: 92vh;
    border-radius: 16px 16px 0 0; /* bottom-sheet shape */
    width: 100%;
    max-width: 100% !important;
    margin: 0;
  }
  .modal-header {
    padding: 16px 16px 12px;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    min-width: 100px;
  }
}

@media (max-width: 374px) {
  .modal-footer .btn {
    width: 100%;
    flex: none;
  }
}

/* ── A10. Tabs ── */
@media (max-width: 767px) {
  .tabs {
    gap: 0;
    padding-bottom: 0;
    /* Already has overflow-x: auto — ensure it works */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    padding: 9px 14px;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* ── A11. Pagination ── */
@media (max-width: 767px) {
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
  }
  .page-btn {
    min-width: 34px;
    height: 34px;
    font-size: 0.78rem;
  }
}

/* ── A12. Toast ── */
@media (max-width: 767px) {
  .toast-container {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
  }
}

/* ── A13. Dropdown menus ── */
@media (max-width: 767px) {
  /* Ensure dropdowns never go off-screen right edge */
  .dropdown-menu {
    right: 0;
    left: auto;
    min-width: min(180px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
}

/* ── A14. Breadcrumb ── */
@media (max-width: 374px) {
  .breadcrumb {
    font-size: 0.7rem;
    flex-wrap: wrap;
    gap: 3px;
  }
}

/* ── A15. Wizard steps ── */
@media (max-width: 767px) {
  .wizard-steps {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
  }
  .wizard-step {
    flex: 0 0 auto;
    min-width: 0;
  }
  .step-label {
    font-size: 0.68rem;
    white-space: normal;
  }
  .step-line {
    display: none;
  }
}

/* ── A16. Subscription warning banner ── */
@media (max-width: 767px) {
  /* The inline banner in admin layout */
  div[style*="background:#92400e"] {
    margin: -14px -12px 12px !important;
    padding: 10px 12px !important;
    font-size: 0.78rem !important;
    flex-wrap: wrap !important;
  }
}

/* ── A17. Global search overlay (mobile) ── */
@media (max-width: 767px) {
  /* When topbar-search is hidden, show a search icon button instead */
  .menu-toggle-search {
    display: flex;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
  }
}

/* ── A18. Horizontal overflow protection ── */
@media (max-width: 767px) {
  .app-wrapper {
    overflow-x: hidden;
  }
  /* Prevent any child from causing horizontal scroll */
  .main-content {
    min-width: 0;
    overflow-x: hidden;
  }
  /* Inline flex/grid helpers shouldn't overflow */
  .d-flex {
    flex-wrap: wrap;
  }
  /* Long content truncation */
  td .truncate,
  .truncate {
    max-width: 160px;
  }
}

/* ── A19. Action button groups inside cards ── */
@media (max-width: 767px) {
  .page-actions {
    gap: 6px;
  }
  .page-actions .btn-sm {
    padding: 6px 10px;
    font-size: 0.76rem;
  }
}

/* ── A20. Profile page grid ── */
@media (max-width: 767px) {
  .grid-sidebar-form {
    grid-template-columns: 1fr !important;
  }
  .grid-sidebar-form > .card {
    position: static !important;
  }
}


/* ============================================================
   B. PLATFORM ADMIN — platform.css based
   ============================================================ */

/* ── B1. Sidebar mobile ── */
@media (max-width: 1023px) {
  .p-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 300;
    transition: transform 0.28s ease;
    box-shadow: none;
  }
  .p-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .p-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 290;
  }
  .p-overlay.show {
    display: block;
  }
  .p-menu-btn {
    display: flex !important;
  }
  .p-main {
    /* takes full width when sidebar is collapsed */
    width: 100%;
  }
}

/* ── B2. Topbar ── */
@media (max-width: 767px) {
  .p-topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .p-topbar-left {
    min-width: 0;
    flex: 1;
  }
  .p-breadcrumb-page {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .p-topbar-right {
    gap: 4px;
  }
  /* Hide "New Customer" text label, show only icon on tiny screens */
  .p-topbar-right .p-btn-primary span {
    display: none;
  }
  /* Keep messages icon, hide View Site */
  .p-view-site {
    display: none;
  }
}

@media (max-width: 374px) {
  .p-topbar {
    padding: 0 10px;
  }
  .p-breadcrumb-page {
    max-width: 80px;
  }
}

/* ── B3. Page content ── */
@media (max-width: 767px) {
  .p-content {
    padding: 12px 12px 32px;
    overflow-x: hidden;
  }
  .p-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .p-page-title {
    font-size: 1.15rem;
  }
  .p-page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ── B4. Platform stat cards ── */
@media (max-width: 767px) {
  .p-stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .p-stat-card {
    padding: 14px 12px;
    gap: 10px;
    border-radius: 10px;
  }
  .p-stat-info .val {
    font-size: 1.4rem;
  }
  .p-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }
  .p-stat-icon svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 374px) {
  .p-stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ── B5. Platform grids ── */
@media (max-width: 767px) {
  .p-grid-2,
  .p-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* ── B6. Platform cards ── */
@media (max-width: 767px) {
  .p-card {
    padding: 14px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .p-card-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
  }
}

/* ── B7. Platform tables ── */
@media (max-width: 767px) {
  .p-tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  .p-tbl {
    min-width: 480px; /* let it scroll horizontally */
  }
  .p-tbl th {
    padding: 8px 10px;
    font-size: 0.64rem;
  }
  .p-tbl td {
    padding: 10px 10px;
    font-size: 0.78rem;
  }
  /* Ensure action buttons in table don't wrap awkwardly */
  .col-shrink {
    white-space: nowrap;
  }
}

/* ── B8. Platform modals ── */
@media (max-width: 767px) {
  .p-modal-overlay {
    padding: 10px 8px;
    align-items: flex-end;
  }
  .p-modal {
    border-radius: 16px 16px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh;
    padding: 18px 16px;
    width: 100%;
  }
  .p-modal-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 14px;
  }
  .p-modal-footer .p-btn {
    flex: 1;
    justify-content: center;
    min-width: 90px;
  }
}

/* ── B9. Platform filters & search ── */
@media (max-width: 767px) {
  .p-filter-tabs {
    gap: 4px;
    flex-wrap: wrap;
  }
  .p-filter-tab {
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  .p-search-input {
    min-width: 0;
    width: 100%;
  }
  .p-search-wrap {
    width: 100%;
  }
}

/* ── B10. Platform forms ── */
@media (max-width: 767px) {
  .p-form-row,
  .p-form-row-2 {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .p-form-group {
    margin-bottom: 12px;
  }
  .p-input-group {
    flex-direction: column;
    gap: 8px;
  }
  .p-input-group .p-form-control {
    width: 100%;
  }
  .p-input-group .p-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── B11. Platform settings tabs ── */
@media (max-width: 767px) {
  .p-settings-tabs {
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }
  .p-settings-tab {
    padding: 10px 12px;
    font-size: 0.74rem;
  }
  /* Hide text, keep icon if present */
  .p-settings-tab .tab-label {
    display: none;
  }
}

/* ── B12. Platform pagination ── */
@media (max-width: 767px) {
  .p-pagination {
    justify-content: center;
    gap: 4px;
  }
  .p-page-link {
    padding: 5px 9px;
    font-size: 0.74rem;
  }
  .p-page-info {
    width: 100%;
    text-align: center;
  }
}

/* ── B13. Status chips ── */
@media (max-width: 767px) {
  .p-status-chips {
    gap: 8px;
  }
  .p-status-chip {
    padding: 10px 12px;
    min-width: 70px;
  }
  .p-status-chip-num {
    font-size: 1.2rem;
  }
  .p-status-chip-lbl {
    font-size: 0.6rem;
  }
}

/* ── B14. Metrics row ── */
@media (max-width: 767px) {
  .p-metric-item {
    padding: 9px 10px;
  }
  .p-metric-label {
    font-size: 0.78rem;
  }
  .p-metric-val {
    font-size: 0.95rem;
  }
}

/* ── B15. Entity header ── */
@media (max-width: 767px) {
  .p-entity-header {
    padding: 14px 14px 0;
    border-radius: 10px;
  }
  .p-entity-title {
    font-size: 1.1rem;
  }
  .p-entity-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .p-entity-tabs {
    gap: 0;
  }
  .p-entity-tab {
    padding: 10px 12px;
    font-size: 0.75rem;
  }
}

/* ── B16. Plan grid ── */
@media (max-width: 767px) {
  .p-plan-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ── B17. Toast ── */
@media (max-width: 767px) {
  .p-toast-container {
    bottom: 12px;
    right: 10px;
    left: 10px;
  }
  .p-toast {
    min-width: 0;
    max-width: 100%;
  }
}

/* ── B18. Detail rows ── */
@media (max-width: 480px) {
  .p-detail-row {
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
  }
  .p-detail-lbl {
    width: 100%;
    font-size: 0.7rem;
  }
  .p-detail-val {
    font-size: 0.82rem;
  }
}

/* ── B19. General overflow protection ── */
@media (max-width: 767px) {
  .p-root {
    overflow-x: hidden;
  }
  .p-main {
    overflow-x: hidden;
    min-width: 0;
  }
}


/* ============================================================
   C. PUBLIC WEBSITE — saas.css based
   ============================================================ */

/* ── C1. Navigation ── */
@media (max-width: 767px) {
  .nav-wrap {
    padding: 0 16px;
    gap: 10px;
  }
  .nav-links {
    display: none;
  }
  .nav-cta {
    display: none;
  }
  .hamburger {
    display: flex;
  }
  /* Compact logo on small screens */
  .nav-logo-sub {
    display: none;
  }
  .nav-logo-name {
    font-size: 0.88rem;
  }
  .nav-logo-icon {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 374px) {
  .nav-wrap {
    padding: 0 12px;
  }
}

/* ── C2. Mobile nav drawer ── */
@media (max-width: 767px) {
  .mobile-nav {
    padding: 16px 16px;
    gap: 2px;
  }
  .mobile-nav a {
    padding: 13px 14px;
    font-size: 0.92rem;
    border-radius: 10px;
  }
  .mobile-nav-cta {
    padding: 14px;
    font-size: 0.9rem;
    border-radius: 10px;
    text-align: center;
    display: block;
  }
}

/* ── C3. Hero section ── */
@media (max-width: 767px) {
  .hero {
    min-height: auto;
    padding: calc(var(--nav-h) + 36px) 16px 56px;
  }
  .hero-body {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero-visual {
    display: none; /* dashboard preview card — too complex for tiny screens */
  }
  .hero-h1 {
    font-size: clamp(1.8rem, 7vw, 2.4rem);
    letter-spacing: -0.025em;
  }
  .hero-lead {
    font-size: 0.95rem;
    max-width: 100%;
    margin-bottom: 24px;
  }
  .hero-btns {
    flex-direction: column;
    gap: 10px;
  }
  .hero-btns .btn {
    width: 100%;
    justify-content: center;
  }
  .hero-trust {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .hero-eyebrow {
    font-size: 0.65rem;
    padding: 5px 12px;
  }
  /* Float cards hidden on mobile */
  .hero-float {
    display: none;
  }
}

@media (max-width: 374px) {
  .hero-h1 {
    font-size: 1.65rem;
  }
  .hero-lead {
    font-size: 0.88rem;
  }
}

/* ── C4. Trust strip ── */
@media (max-width: 767px) {
  .trust-strip {
    padding: 16px;
  }
  .trust-strip .container {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .trust-logos {
    gap: 6px;
  }
  .trust-logo {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
}

/* ── C5. Section system ── */
@media (max-width: 767px) {
  .section {
    padding: 56px 16px;
  }
  .section-sm {
    padding: 36px 16px;
  }
  .section-lg {
    padding: 72px 16px;
  }
  .section-title {
    font-size: clamp(1.4rem, 5.5vw, 1.9rem);
    margin-bottom: 12px;
  }
  .section-lead {
    font-size: 0.92rem;
    margin-bottom: 24px;
    max-width: 100%;
  }
  .section-eyebrow {
    font-size: 0.65rem;
  }
}

@media (max-width: 374px) {
  .section {
    padding: 44px 12px;
  }
  .section-sm {
    padding: 28px 12px;
  }
}

/* ── C6. Features grid ── */
@media (max-width: 767px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 0;
    border-radius: 12px;
  }
  .feat-card {
    padding: 22px 18px;
  }
  .feat-title {
    font-size: 0.9rem;
  }
  .feat-desc {
    font-size: 0.8rem;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── C7. Showcase rows ── */
@media (max-width: 767px) {
  .showcase-row,
  .showcase-row.flip {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .showcase-row.flip > *:first-child,
  .showcase-row.flip > *:last-child {
    order: 0;
  }
  .showcase-img-wrap {
    border-radius: 12px;
    aspect-ratio: 16/9;
  }
  .showcase-img-badge {
    bottom: 10px;
    left: 10px;
    padding: 8px 10px;
  }
  .showcase-features {
    gap: 14px;
    margin-top: 18px;
  }
  .showcase-feat-icon {
    width: 30px;
    height: 30px;
  }
  .showcase-feat-title {
    font-size: 0.85rem;
  }
  .showcase-feat-desc {
    font-size: 0.78rem;
  }
}

/* ── C8. Metrics strip ── */
@media (max-width: 767px) {
  .metrics-strip {
    padding: 28px 16px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }
  .metric-cell {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 16px;
  }
  .metric-cell:nth-child(odd) {
    border-right: 1px solid rgba(255,255,255,0.1);
  }
  .metric-num {
    font-size: 1.7rem;
  }
  .metric-lbl {
    font-size: 0.72rem;
  }
}

@media (max-width: 374px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .metric-cell {
    border-right: none;
  }
  .metric-cell:nth-child(odd) {
    border-right: none;
  }
}

/* ── C9. Steps row ── */
@media (max-width: 767px) {
  .steps-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .steps-row::before {
    display: none;
  }
  .step {
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 16px;
  }
  .step-icon-box {
    margin: 0;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
  }
  .step-icon-box svg {
    width: 26px;
    height: 26px;
  }
  .step-num-badge {
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }
  .step-title {
    font-size: 0.88rem;
    margin-bottom: 5px;
  }
  .step-desc {
    font-size: 0.78rem;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .steps-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .step {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .step-icon-box {
    margin: 0 auto 14px;
  }
}

/* ── C10. Pricing section ── */
@media (max-width: 767px) {
  .pricing-toggle {
    margin-bottom: 32px;
    gap: 10px;
  }
  .pricing-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 420px;
    margin: 0 auto;
  }
  .pricing-card {
    padding: 22px 18px;
    border-radius: 14px;
  }
  .pricing-amount {
    font-size: 2.4rem;
  }
  .pricing-features {
    gap: 8px;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .pricing-grid {
    max-width: 100%;
  }
}

/* ── C11. Comparison table ── */
@media (max-width: 767px) {
  .comparison-table {
    font-size: 0.76rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid var(--border);
  }
  .comparison-table th,
  .comparison-table td {
    padding: 10px 12px;
    white-space: nowrap;
  }
  /* Allow first column to wrap */
  .comparison-table td:first-child,
  .comparison-table th:first-child {
    white-space: normal;
    min-width: 140px;
  }
}

/* ── C12. FAQ accordion ── */
@media (max-width: 767px) {
  .faq-question-text {
    font-size: 0.88rem;
  }
  .faq-answer-inner {
    font-size: 0.82rem;
  }
  .faq-question {
    padding: 16px 0;
  }
}

/* ── C13. CTA section ── */
@media (max-width: 767px) {
  .cta-section {
    padding: 56px 16px;
  }
  .cta-title {
    font-size: clamp(1.5rem, 5.5vw, 2.2rem);
    margin-bottom: 12px;
  }
  .cta-sub {
    font-size: 0.9rem;
    margin-bottom: 24px;
  }
  .cta-btns {
    flex-direction: column;
    align-items: center;
  }
  .cta-btns .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
  }
}

/* ── C14. Footer ── */
@media (max-width: 767px) {
  footer {
    padding: 48px 16px 0;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-bottom: 32px;
  }
  .footer-nl-row {
    flex-wrap: nowrap;
  }
  .footer-nl-inp {
    min-width: 0;
    flex: 1;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 0;
  }
  .footer-blinks {
    gap: 12px;
    flex-wrap: wrap;
  }
  .footer-socials {
    margin-bottom: 4px;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── C15. Auth pages ── */
@media (max-width: 1023px) {
  .auth-wrap {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }
  .auth-panel-left {
    display: none;
  }
  .auth-panel-right {
    padding: 40px 32px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .auth-form-wrap {
    max-width: 400px;
    width: 100%;
  }
}

@media (max-width: 767px) {
  .auth-panel-right {
    padding: 28px 20px;
    align-items: flex-start;
    padding-top: 40px;
  }
  .auth-form-title {
    font-size: 1.4rem;
  }
  .auth-form-sub {
    font-size: 0.83rem;
  }
  .auth-form-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .auth-btn-submit {
    padding: 13px;
    font-size: 0.9rem;
  }
}

@media (max-width: 374px) {
  .auth-panel-right {
    padding: 20px 14px;
  }
  .auth-form-title {
    font-size: 1.25rem;
  }
}

/* ── C16. Contact page ── */
@media (max-width: 767px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .contact-form-card {
    padding: 22px 18px;
  }
}

/* ── C17. About page ── */
@media (max-width: 767px) {
  .about-hero {
    padding: calc(var(--nav-h) + 48px) 16px 48px;
  }
  .about-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .values-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .value-card {
    padding: 20px 16px;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .values-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── C18. Pricing hero ── */
@media (max-width: 767px) {
  .pricing-hero {
    padding: calc(var(--nav-h) + 48px) 16px 64px;
  }
  .pricing-hero h1 {
    font-size: clamp(1.8rem, 6.5vw, 2.8rem);
  }
  .pricing-hero p {
    font-size: 0.92rem;
  }
}

/* ── C19. Button sizes on mobile ── */
@media (max-width: 767px) {
  .btn-xl {
    padding: 13px 28px;
    font-size: 0.95rem;
  }
  .btn-lg {
    padding: 12px 24px;
    font-size: 0.92rem;
  }
}

/* ── C20. Global overflow prevention ── */
@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }
  .container,
  .container-sm,
  .container-md {
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
  }
  /* Images inside sections should never exceed viewport */
  .section img,
  .showcase-img-wrap img {
    max-width: 100%;
    height: auto;
  }
  /* Prevent long words/URLs from overflowing */
  p, li, td, th, .footer-brand-text, .feat-desc, .step-desc, .value-desc {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
}


/* ============================================================
   D. ACCOUNT DASHBOARD — account_layout.php based
   NOTE: All layout/component responsive rules are now authoritative
   in the inline <style> block inside account_layout.php and in
   each page's own trailing <style> block. Rules here are limited
   to things that cannot easily live inline (print, edge cases).
   ============================================================ */

/* ── D1. Overflow safety — belt-and-suspenders ── */
@media (max-width: 900px) {
  /* Ensure the sidebar never forces horizontal scroll */
  .acc-sidebar { max-width: 100%; box-sizing: border-box; }
  .acc-nav-card { max-width: 100%; box-sizing: border-box; }
}

/* ── D2. Safe-area insets for notched phones ── */
@supports (padding: env(safe-area-inset-left)) {
  @media (max-width: 900px) {
    .acc-topbar {
      padding-left: max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }
    .acc-body {
      padding-left: max(10px, env(safe-area-inset-left));
      padding-right: max(10px, env(safe-area-inset-right));
      padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
  }
}

/* ── D3. Print — hide chrome ── */
@media print {
  .acc-topbar,
  .acc-sidebar { display: none !important; }
  .acc-body { display: block !important; }
  .acc-main { width: 100% !important; }
}


/* ============================================================
   E. SHARED FIXES (apply across all interfaces)
   ============================================================ */

/* ── E1. Long text overflow ── */
@media (max-width: 767px) {
  /* Email addresses, URLs, long IDs */
  .email-cell,
  .url-cell,
  td[data-label],
  .break-all {
    word-break: break-all;
  }
  /* URLs in footer */
  .footer-copy,
  .footer-blinks a {
    word-break: break-word;
  }
}

/* ── E2. Prevent fixed-width elements from causing overflow ── */
@media (max-width: 767px) {
  /* Charts wrapped in table-card or card should be scrollable */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  /* Chart containers */
  [style*="width:"] canvas,
  .chart-container canvas {
    width: 100% !important;
  }
}

/* ── E3. Images ── */
@media (max-width: 767px) {
  img {
    max-width: 100%;
    height: auto;
  }
  .img-thumb {
    width: 36px;
    height: 36px;
  }
}

/* ── E4. Alert messages ── */
@media (max-width: 767px) {
  .alert {
    padding: 10px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
  }
  .p-alert {
    padding: 10px 12px;
    font-size: 0.8rem;
  }
}

/* ── E5. Badge wrapping ── */
@media (max-width: 767px) {
  .badge {
    font-size: 0.66rem;
    padding: 2px 7px;
  }
  .p-badge {
    font-size: 0.63rem;
    padding: 2px 7px;
  }
}

/* ── E6. Focus rings (accessibility) ── */
@media (max-width: 767px) {
  :focus-visible {
    outline: 2px solid var(--primary, #0E3A5F);
    outline-offset: 2px;
  }
}

/* ── E7. Print media ── */
@media print {
  .sidebar,
  .topbar,
  .p-sidebar,
  .p-topbar,
  .acc-topbar,
  .nav,
  .mobile-nav,
  .toast-container,
  .p-toast-container,
  .sidebar-overlay,
  .p-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
  .p-main {
    width: 100% !important;
  }
}

/* ── E8. Landscape phone adjustments ── */
@media (max-width: 767px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding-top: calc(var(--nav-h) + 24px);
    padding-bottom: 40px;
  }
  .modal-overlay {
    align-items: center; /* center modals in landscape */
  }
  .modal {
    border-radius: var(--radius-lg, 14px); /* restore rounded corners in landscape */
    max-height: 88vh;
  }
  .p-modal-overlay {
    align-items: center;
  }
  .p-modal {
    border-radius: 14px !important;
  }
  .acc-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ── E9. Very small screen adjustments (320px) ── */
@media (max-width: 320px) {
  html {
    font-size: 13px;
  }
  .btn {
    padding: 7px 12px;
    font-size: 0.76rem;
    gap: 4px;
  }
  .badge {
    font-size: 0.62rem;
    padding: 1px 6px;
  }
  .page-content,
  .p-content {
    padding: 8px;
  }
  .acc-body {
    padding: 8px;
  }
}


/* ============================================================
   COMPREHENSIVE MOBILE FIXES — ALL FOUR INTERFACES
   Brand colors: Primary #0E3A5F | Accent #FF8A00 | Sky #3B82F6 | Light #F1F7FD
   Strategy: desktop-first; ALL rules inside @media blocks only.
   ============================================================ */


/* ============================================================
   F. PUBLIC WEBSITE — ADDITIONAL FIXES
   ============================================================ */

/* ── F1. Pricing hero ── */
@media (max-width: 767px) {
  .pricing-hero {
    padding: calc(var(--nav-h, 66px) + 40px) 16px 48px;
    text-align: center;
  }
  .pricing-hero h1 {
    font-size: clamp(1.7rem, 6vw, 2.4rem);
    line-height: 1.2;
  }
  .pricing-hero p {
    font-size: 0.9rem;
    max-width: 100%;
  }
  /* Trust items row */
  .pricing-hero > div[style*="display:flex"][style*="justify-content:center"] {
    gap: 14px !important;
    flex-wrap: wrap !important;
  }
}

/* ── F2. Pricing toggle + grid ── */
@media (max-width: 767px) {
  .pricing-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
  }
  .pricing-card {
    padding: 22px 18px;
    border-radius: 14px;
  }
  .pricing-card.featured::before {
    font-size: 0.6rem;
    padding: 3px 12px;
  }
  .pricing-amount {
    font-size: 2.4rem;
  }
  .pricing-features {
    gap: 8px;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .pricing-grid {
    max-width: 100%;
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── F3. Button sizes on mobile CTA actions ── */
@media (max-width: 767px) {
  .pricing-card .btn,
  .pricing-card a[class*="btn"] {
    width: 100%;
    justify-content: center;
    font-size: 0.88rem;
    padding: 12px 16px;
  }
}

/* ── F4. Auth pages — focus styles with new primary ── */
@media (max-width: 767px) {
  .auth-form-input:focus {
    box-shadow: 0 0 0 3px rgba(14, 58, 95, 0.1);
  }
  .auth-panel-right {
    padding: 28px 16px;
  }
  .auth-form-wrap {
    max-width: 100%;
  }
}

/* ── F5. Homepage hero — btn-gold uses new accent orange ── */
@media (max-width: 767px) {
  .btn-gold {
    background: var(--secondary, #FF8A00);
    color: #fff;
  }
}

/* ── F6. Pricing page filter / comparison table overflow ── */
@media (max-width: 767px) {
  .comparison-table {
    font-size: 0.74rem;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
  }
  .comparison-table table {
    min-width: 500px;
  }
}

/* ── F7. Contact & about — form cards ── */
@media (max-width: 767px) {
  .contact-form-card {
    padding: 20px 16px;
    border-radius: 14px;
  }
  .contact-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  .about-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  .values-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  /* show 2 columns on wider phones */
}
@media (min-width: 480px) and (max-width: 767px) {
  .values-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── F8. FAQ section ── */
@media (max-width: 767px) {
  .faq-question-text {
    font-size: 0.87rem;
    line-height: 1.5;
  }
  .faq-answer-inner {
    font-size: 0.82rem;
    line-height: 1.75;
  }
}

/* ── F9. Metrics strip — 2×2 on mobile ── */
@media (max-width: 767px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .metric-cell {
    border-right: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    padding: 16px !important;
  }
  .metric-cell:nth-child(odd) {
    border-right: 1px solid rgba(255,255,255,0.1) !important;
  }
  .metric-num { font-size: 1.6rem !important; }
  .metric-lbl { font-size: 0.72rem !important; }
}
@media (max-width: 374px) {
  .metrics-grid {
    grid-template-columns: 1fr !important;
  }
  .metric-cell:nth-child(odd) {
    border-right: none !important;
  }
}

/* ── F10. Register page ── */
@media (max-width: 767px) {
  /* Register multi-step form */
  .register-steps {
    gap: 8px;
    flex-wrap: wrap;
  }
  .register-step-label {
    font-size: 0.7rem;
  }
}

/* ── F11. Mobile nav drawer — new brand color fix ── */
@media (max-width: 767px) {
  .mobile-nav-cta {
    background: var(--primary, #0E3A5F) !important;
    color: #fff !important;
  }
  .mobile-nav a.active {
    color: var(--primary, #0E3A5F);
  }
}

/* ── F12. Footer ── */
@media (max-width: 767px) {
  footer {
    padding: 44px 16px 0;
  }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
    padding-bottom: 28px;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 18px 0;
  }
  .footer-blinks {
    flex-wrap: wrap;
    gap: 10px;
  }
  .footer-nl-row {
    flex-wrap: nowrap;
  }
  .footer-nl-inp {
    min-width: 0;
    flex: 1;
  }
}
@media (min-width: 480px) and (max-width: 767px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}


/* ============================================================
   G. CUSTOMER ACCOUNT DASHBOARD — ADDITIONAL FIXES
   NOTE: Per-page responsive rules now live in each page's own
   trailing <style> block using explicit BEM-style classes
   (e.g. .idx-quick-actions, .plan-cards-grid, .billing-tbl-scroll,
   .team-tbl, .settings-two-col). Rules here only cover genuine
   cross-page gaps not handled by the inline layout CSS.
   ============================================================ */

/* ── G1. Stat box overflow safety (all account pages) ── */
@media (max-width: 767px) {
  .acc-main .stat-box {
    min-width: 0;
    overflow: hidden;
  }
  .acc-main .stat-val {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── G2. Upload zone — bank transfer proof ── */
@media (max-width: 767px) {
  /* File upload drag-drop area: more thumb-friendly */
  .acc-main label[for="mp-proof-input"] {
    padding: 18px 12px !important;
  }
}

/* ── G3. Very narrow topbar controls ── */
@media (max-width: 374px) {
  .acc-topbar-link {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    padding: 0 !important;
  }
  .acc-topbar-avatar {
    width: 26px !important;
    height: 26px !important;
    font-size: 0.56rem !important;
  }
}


/* ============================================================
   H. HOTEL ADMIN PANEL — ADDITIONAL FIXES
   ============================================================ */

/* ── H1. Admin dashboard — charts grid ── */
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

@media (max-width: 767px) {
  /* Quick actions grid */
  .quick-action-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px;
  }
  .quick-action-card {
    padding: 12px 8px;
    gap: 6px;
  }
  .qa-icon {
    width: 32px;
    height: 32px;
  }
  .qa-label {
    font-size: 0.7rem;
  }
}

@media (max-width: 374px) {
  .quick-action-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── H2. Room status filter chips — horizontal scroll ── */
@media (max-width: 767px) {
  /* Filter chips row — prevent wrapping chaos */
  div[style*="display:flex"][style*="gap:8px"][style*="flex-wrap:wrap"] {
    /* Allow natural wrapping but constrain */
    max-width: 100%;
    box-sizing: border-box;
  }
  /* Room status badges used as filter links */
  a.badge[style*="padding:6px 12px"] {
    font-size: 0.72rem !important;
    padding: 5px 10px !important;
  }
}

/* ── H3. Bookings page — table horizontal scroll ── */
@media (max-width: 767px) {
  .table-card {
    border-radius: 10px;
    overflow: hidden;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Scroll shadow hint */
    background: linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
                linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) 100% 0,
                radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,0.06), transparent),
                radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.06), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: #fff;
    background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  /* Table minimum widths to prevent column cramming */
  .table-wrap table {
    min-width: 580px;
  }
  /* Table toolbar — stack filters */
  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  .table-toolbar form {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .table-search {
    min-width: 0;
    flex: 1;
    width: 100%;
    min-width: 0;
  }
  .table-toolbar > span {
    font-size: 0.74rem;
    color: var(--text-muted);
  }
  /* Tighten table cells */
  th {
    padding: 9px 10px;
    font-size: 0.68rem;
  }
  td {
    padding: 10px 10px;
    font-size: 0.8rem;
    vertical-align: middle;
  }
  /* Action buttons */
  .table-actions {
    flex-wrap: nowrap;
    gap: 3px;
  }
  .table-actions .btn-icon {
    padding: 5px !important;
    min-width: 28px;
    height: 28px;
  }
}

/* ── H4. Booking create form — date pickers / multi-col ── */
@media (max-width: 767px) {
  .form-row-2,
  .form-row-3,
  .form-row[style*="grid-template-columns:1fr 1fr"],
  .form-row[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  /* Date range picker inline layout */
  [style*="display:flex"][style*="gap:12px"] > .form-group {
    flex: 1 1 100%;
    min-width: 0;
  }
}

/* ── H5. Room grid view (room cards) ── */
@media (max-width: 767px) {
  /* Room cards grid */
  .room-grid,
  [style*="grid-template-columns: repeat(auto-fill, minmax(240px"],
  [style*="grid-template-columns:repeat(auto-fill, minmax(240px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
}
@media (max-width: 374px) {
  .room-grid,
  [style*="grid-template-columns: repeat(auto-fill, minmax(240px"],
  [style*="grid-template-columns:repeat(auto-fill, minmax(240px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── H6. Guests page ── */
@media (max-width: 767px) {
  /* Guest profile: avatar + info stacked */
  [style*="display:flex"][style*="align-items:center"][style*="gap:16px"] {
    flex-wrap: wrap;
    gap: 10px;
  }
  /* Guest table */
  .table-wrap table {
    min-width: 520px;
  }
}

/* ── H7. Modals — keep within viewport ── */
@media (max-width: 767px) {
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }
  .modal {
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100% !important;
    margin: 0;
    overflow-y: auto;
  }
  .modal-header {
    padding: 14px 16px 10px;
    position: sticky;
    top: 0;
    background: var(--surface, #fff);
    z-index: 10;
    border-bottom: 1px solid var(--border);
  }
  .modal-body {
    padding: 14px 16px;
    overflow-y: auto;
    max-height: calc(92vh - 130px);
  }
  .modal-footer {
    padding: 10px 16px;
    position: sticky;
    bottom: 0;
    background: var(--surface, #fff);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    min-width: 90px;
  }
  /* Large modals (booking create, settings) */
  .modal-lg,
  .modal-xl {
    max-width: 100% !important;
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  .modal {
    border-radius: 14px;
    max-height: 90vh;
  }
  .modal-overlay {
    align-items: center;
    padding: 12px;
  }
}

/* ── H8. Settings pages — tabs + content ── */
@media (max-width: 767px) {
  /* Settings tab bar */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 9px 14px;
  }
  /* Settings grid */
  .grid-sidebar-form {
    grid-template-columns: 1fr !important;
  }
  .grid-sidebar-form > .card {
    position: static !important;
  }
}

/* ── H9. Reports page — charts responsiveness ── */
@media (max-width: 767px) {
  /* Charts */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  /* Chart containers */
  .chart-container,
  [style*="position:relative"][style*="height:"] {
    height: 220px !important;
  }
  /* Report filter row */
  [style*="display:flex"][style*="gap:10px"][style*="flex-wrap:wrap"] {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

/* ── H10. Notification panel on mobile ── */
@media (max-width: 767px) {
  .notification-panel {
    width: calc(100vw - 20px);
    max-width: 340px;
    right: 0;
    left: auto;
    position: fixed;
    top: 64px;
  }
  .notif-list {
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── H11. Gallery page ── */
@media (max-width: 767px) {
  /* Image gallery grid */
  [style*="grid-template-columns:repeat(auto-fill, minmax(180px"],
  [style*="grid-template-columns: repeat(auto-fill, minmax(180px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
}

/* ── H12. Check-in/out page — action cards ── */
@media (max-width: 767px) {
  /* Checkin cards grid */
  .checkin-grid,
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* ── H13. Audit logs table ── */
@media (max-width: 767px) {
  .table-wrap table {
    min-width: 520px;
  }
  /* Long log messages */
  td .log-message,
  td[data-label="Message"] {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── H14. Profile page ── */
@media (max-width: 767px) {
  /* Profile header section */
  [style*="display:flex"][style*="align-items:center"][style*="gap:20px"] {
    flex-wrap: wrap;
    gap: 12px;
  }
  /* Profile avatar */
  [style*="width:80px"][style*="height:80px"],
  [style*="width: 80px"][style*="height: 80px"] {
    flex-shrink: 0;
  }
}

/* ── H15. Payment / financial pages ── */
@media (max-width: 767px) {
  /* Payment summary cards */
  [style*="grid-template-columns:repeat(auto-fill, minmax(200px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  /* Payment table */
  .table-wrap table {
    min-width: 540px;
  }
  /* Receipt page */
  .receipt-content {
    padding: 16px !important;
  }
}

/* ── H16. Room inventory / channel manager ── */
@media (max-width: 767px) {
  /* Calendar / inventory grid */
  .inventory-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .inventory-grid table {
    min-width: 600px;
  }
}

/* ── H17. Pagination — center on mobile ── */
@media (max-width: 767px) {
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 12px;
  }
  .page-btn {
    min-width: 32px;
    height: 32px;
    font-size: 0.76rem;
  }
}

/* ── H18. Page actions — wrap and full-width on small ── */
@media (max-width: 480px) {
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 120px;
  }
}

/* ── H19. Subscription warning banner in admin ── */
@media (max-width: 767px) {
  /* The subscription warning banner injected in admin.php */
  div[style*="background:#92400e"],
  div[style*="background: #92400e"] {
    margin: -14px -12px 12px -12px !important;
    padding: 10px 12px !important;
    font-size: 0.78rem !important;
    border-radius: 0 !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
}

/* ── H20. Table responsive: show data-label when stacked ── */
/* (JS adds data-label via responsive-stack class — purely presentational) */
@media (max-width: 520px) {
  table.responsive-stack {
    display: block;
    width: 100%;
  }
  table.responsive-stack thead {
    display: none;
  }
  table.responsive-stack tbody {
    display: block;
    width: 100%;
  }
  table.responsive-stack tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--surface, #fff);
  }
  table.responsive-stack td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    gap: 10px;
    flex-wrap: wrap;
  }
  table.responsive-stack td:last-child {
    border-bottom: none;
  }
  table.responsive-stack td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
    flex-shrink: 0;
    min-width: 90px;
    margin-top: 2px;
  }
}


/* ============================================================
   I. PLATFORM SUPER ADMIN — ADDITIONAL FIXES
   ============================================================ */

/* ── I1. Platform dashboard — p-stat-grid ── */
@media (max-width: 767px) {
  .p-stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .p-stat-card {
    padding: 14px 12px;
    border-radius: 10px;
  }
  .p-stat-info .val {
    font-size: 1.35rem !important;
  }
  .p-stat-info .lbl {
    font-size: 0.7rem;
  }
  .p-stat-info .sub {
    font-size: 0.68rem;
  }
  .p-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    flex-shrink: 0;
  }
  .p-stat-icon svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 374px) {
  .p-stat-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── I2. Platform page header — actions row ── */
@media (max-width: 767px) {
  .p-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .p-page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .p-page-title {
    font-size: 1.1rem;
  }
}

/* ── I3. Platform topbar — "New Customer" button label ── */
@media (max-width: 767px) {
  /* Hide "New Customer" text on small screens — show icon only */
  .p-topbar .p-btn-primary span,
  .p-topbar a.p-btn-primary > span:not(:only-child) {
    display: none;
  }
  .p-topbar .p-btn-primary {
    padding: 6px 8px;
    min-width: 34px;
    justify-content: center;
  }
}

/* ── I4. Platform tables — horizontal scroll ── */
@media (max-width: 767px) {
  .p-tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    /* Scroll shadow */
    background:
      linear-gradient(to right, var(--p-surface, #fff) 30%, rgba(255,255,255,0)),
      linear-gradient(to left, var(--p-surface, #fff) 30%, rgba(255,255,255,0)) 100% 0,
      radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,0.05), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.05), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: var(--p-surface, #fff);
    background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .p-tbl {
    min-width: 520px;
  }
  .p-tbl th {
    padding: 8px 10px;
    font-size: 0.66rem;
    white-space: nowrap;
  }
  .p-tbl td {
    padding: 10px 10px;
    font-size: 0.79rem;
    vertical-align: middle;
  }
  /* Action buttons in platform tables */
  .p-tbl .table-actions,
  .p-tbl td:last-child > div {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
  }
  .p-tbl .p-btn-sm {
    padding: 4px 8px;
    font-size: 0.72rem;
  }
  .col-shrink {
    white-space: nowrap;
  }
}

/* ── I5. Platform customers — customer table ── */
@media (max-width: 767px) {
  /* Customer/tenant name + email cell */
  .p-tbl td strong {
    display: block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Status chips in table */
  .p-badge {
    font-size: 0.62rem;
    padding: 2px 7px;
  }
}

/* ── I6. Platform search + filter row ── */
@media (max-width: 767px) {
  /* P-card toolbar that contains search + filter */
  .p-card > div[style*="display:flex"][style*="justify-content:space-between"],
  .p-card > div[style*="display:flex"][style*="flex-wrap:wrap"] {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  /* Search input — full width */
  .p-search-wrap {
    width: 100%;
  }
  .p-search-input {
    width: 100%;
    min-width: 0;
  }
  /* Filter tabs — horizontal scroll */
  .p-filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .p-filter-tabs::-webkit-scrollbar { display: none; }
  .p-filter-tab {
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 0.72rem;
  }
}

/* ── I7. Platform cards — padding on mobile ── */
@media (max-width: 767px) {
  .p-card {
    padding: 14px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .p-card-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  .p-card-header > :last-child {
    margin-left: 0;
  }
  .p-card-title {
    font-size: 0.88rem;
  }
}

/* ── I8. Platform modal — mobile bottom-sheet ── */
@media (max-width: 767px) {
  .p-modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }
  .p-modal {
    border-radius: 18px 18px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh;
    padding: 18px 16px;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .p-modal-header {
    position: sticky;
    top: 0;
    background: var(--p-surface, #fff);
    z-index: 10;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
  .p-modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--p-surface, #fff);
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
  }
  .p-modal-footer .p-btn {
    flex: 1;
    justify-content: center;
    min-width: 80px;
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  .p-modal-overlay {
    align-items: center;
    padding: 12px;
  }
  .p-modal {
    border-radius: 14px !important;
  }
}

/* ── I9. Platform settings — tabs ── */
@media (max-width: 767px) {
  /* Settings tab bar */
  .p-settings-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    gap: 0;
  }
  .p-settings-tabs::-webkit-scrollbar { display: none; }
  .p-settings-tab {
    flex-shrink: 0;
    padding: 10px 12px;
    font-size: 0.74rem;
    white-space: nowrap;
  }
}

/* ── I10. Platform forms ── */
@media (max-width: 767px) {
  .p-form-row,
  .p-form-row-2,
  .p-form-row[style*="grid-template-columns"],
  [style*="grid-template-columns:1fr 1fr"].p-form-row {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .p-form-group {
    margin-bottom: 12px;
  }
  .p-input-group {
    flex-direction: column;
    gap: 8px;
  }
  .p-input-group .p-form-control {
    width: 100%;
  }
  .p-input-group .p-btn {
    width: 100%;
    justify-content: center;
  }
  .p-form-control {
    font-size: 0.875rem;
    padding: 9px 12px;
  }
}

/* ── I11. Manual payments — slip upload + approval ── */
@media (max-width: 767px) {
  /* Slip image preview */
  [style*="max-width:320px"],
  [style*="max-width: 320px"] {
    max-width: 100% !important;
    width: 100% !important;
  }
  /* Approval action buttons */
  div[style*="display:flex"][style*="gap:10px"] > .p-btn {
    flex: 1;
    justify-content: center;
  }
}

/* ── I12. Platform subscription detail page ── */
@media (max-width: 767px) {
  .p-entity-header {
    padding: 14px;
    border-radius: 10px;
  }
  .p-entity-title {
    font-size: 1.05rem;
  }
  .p-entity-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .p-entity-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .p-entity-tabs::-webkit-scrollbar { display: none; }
  .p-entity-tab {
    flex-shrink: 0;
    padding: 10px 12px;
    font-size: 0.74rem;
    white-space: nowrap;
  }
}

/* ── I13. Platform plan cards ── */
@media (max-width: 767px) {
  .p-plan-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}
@media (min-width: 480px) and (max-width: 767px) {
  .p-plan-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── I14. Backups page ── */
@media (max-width: 767px) {
  /* Backup list items */
  .p-card div[style*="display:flex"][style*="justify-content:space-between"] {
    flex-wrap: wrap;
    gap: 8px;
  }
  .p-card div[style*="display:flex"][style*="justify-content:space-between"] > div:last-child {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }
}

/* ── I15. Audit logs ── */
@media (max-width: 767px) {
  /* Log entry rows */
  .p-tbl td {
    word-break: break-word;
    overflow-wrap: break-word;
  }
  /* Long IP / user-agent truncation */
  .p-tbl td:nth-child(4),
  .p-tbl td:nth-child(5) {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── I16. Refunds page ── */
@media (max-width: 767px) {
  .p-tbl table,
  .p-tbl-wrap table {
    min-width: 480px;
  }
}

/* ── I17. Platform pagination ── */
@media (max-width: 767px) {
  .p-pagination {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 14px;
  }
  .p-page-link {
    padding: 5px 9px;
    font-size: 0.74rem;
  }
  .p-page-info {
    width: 100%;
    text-align: center;
    font-size: 0.74rem;
  }
}

/* ── I18. Status chips panel (platform dashboard) ── */
@media (max-width: 767px) {
  .p-status-chips {
    gap: 6px;
    flex-wrap: wrap;
  }
  .p-status-chip {
    padding: 10px 12px;
    min-width: 0;
    flex: 1;
    min-width: 70px;
  }
  .p-status-chip-num {
    font-size: 1.15rem;
  }
  .p-status-chip-lbl {
    font-size: 0.6rem;
  }
}

/* ── I19. Overflow protection — p-root and p-content ── */
@media (max-width: 767px) {
  .p-root {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }
  .p-main {
    min-width: 0;
    overflow-x: hidden;
    width: 100%;
  }
  .p-content {
    padding: 12px 12px 32px;
    overflow-x: hidden;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* ── I20. Inline grids in platform pages (using style= attribute) ── */
@media (max-width: 767px) {
  /* 2-column stats or cards in inline styles */
  .p-content [style*="grid-template-columns:1fr 1fr"],
  .p-content [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* 3-column => 1-column */
  .p-content [style*="grid-template-columns:1fr 1fr 1fr"],
  .p-content [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* Auto-fill grids */
  .p-content [style*="grid-template-columns:repeat(auto-fill"],
  .p-content [style*="grid-template-columns: repeat(auto-fill"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
}


/* ============================================================
   J. GLOBAL OVERFLOW & SAFETY NET
   ============================================================ */

/* ── J1. Global no-horizontal-scroll for all wrappers ── */
@media (max-width: 767px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  /* Shared wrappers */
  .app-wrapper,
  .p-root,
  .p-main,
  .main-content,
  .acc-body,
  .page-content,
  .p-content {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  /* Any inline flexbox that might cause overflow */
  .d-flex {
    flex-wrap: wrap;
    max-width: 100%;
  }
  /* Min-width zero for flex children */
  .main-content > *,
  .p-main > *,
  .acc-main > * {
    min-width: 0;
  }
}

/* ── J2. Images ── */
@media (max-width: 767px) {
  img {
    max-width: 100%;
    height: auto;
  }
  /* Hero images */
  .hero-visual img,
  .showcase-img-wrap img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }
}

/* ── J3. Long text overflow ── */
@media (max-width: 767px) {
  p, li, td, th, span, div.alert, .badge, .p-badge {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  /* Email addresses and URLs */
  a[href^="mailto:"],
  a[href^="http"] {
    word-break: break-all;
  }
}

/* ── J4. Dropdowns — keep within viewport ── */
@media (max-width: 767px) {
  .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    min-width: min(180px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    position: fixed !important;
    top: auto !important;
    z-index: 900;
  }
}

/* ── J5. Focus rings — new brand color ── */
:focus-visible {
  outline: 2px solid var(--primary, #0E3A5F);
  outline-offset: 2px;
}

/* ── J6. 320px — extra-small phone ── */
@media (max-width: 320px) {
  html {
    font-size: 13px;
  }
  .btn {
    padding: 7px 10px;
    font-size: 0.76rem;
    gap: 4px;
  }
  .badge, .p-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
  }
  .page-content, .p-content {
    padding: 8px;
  }
  .acc-body {
    padding: 6px !important;
  }
  /* Stat values — prevent overflow at 320px */
  .stat-value, .stat-val, .p-stat-info .val {
    font-size: 1.1rem !important;
  }
}

/* ── J7. Safe-area insets (notched phones) ── */
@supports (padding: env(safe-area-inset-left)) {
  @media (max-width: 767px) {
    .topbar,
    .p-topbar,
    .acc-topbar,
    .nav-wrap {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    .sidebar {
      padding-left: env(safe-area-inset-left);
    }
    .mobile-nav {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
      padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    .page-content,
    .p-content {
      padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    /* Bottom-sheet modals */
    .modal.open,
    .p-modal {
      padding-bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
    }
  }
}

/* ============================================================
   BRANDING — Logo image mobile responsive rules
   Added by: Branding Settings feature
============================================================ */

/* Account layout: logo image switches to mobile dimensions */
@media (max-width: 767px) {
  .acc-brand img[style*="width:var(--logo-w-desk"],
  .acc-brand img.branding-logo {
    width: var(--logo-w-mob, 130px) !important;
    max-height: var(--logo-h-mob, 44px) !important;
  }
  /* Prevent logo from causing topbar overflow */
  .acc-brand {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }
  .acc-brand img {
    flex-shrink: 1;
    min-width: 40px;
  }
}

/* Public nav: logo image switches to mobile dimensions */
@media (max-width: 767px) {
  .nav-logo-image {
    width: var(--logo-w-mob, 130px) !important;
    max-height: var(--logo-h-mob, 44px) !important;
  }
  /* Prevent overflow on narrow screens */
  .nav-logo {
    overflow: hidden;
    max-width: calc(100vw - 160px);
  }
}

/* Platform admin sidebar: logo image on mobile */
@media (max-width: 1023px) {
  .p-brand-logo {
    width: var(--logo-w-mob, 130px) !important;
    max-height: var(--logo-h-mob, 44px) !important;
  }
}
