/* =============================================================
   LAMBAKLAD — Mobile app shell (smartphones, max-width: 768px)
   Loaded after style.css / internal-system.css / auth.css.
   Desktop + tablet (>= 769px) are untouched by this file.

   Contents
   01. Base
   02. Public top bar + drawer + bottom nav
   03. Internal top bar (60px) + search sheet
   04. Internal sidebar drawer
   05. Bottom navigation (shared)
   06. Content, grids, cards
   07. Forms, buttons, tables
   08. Overlays: auth bottom-sheet, modals
   09. Floating widgets (AI assistant)
   10. Small phones
   ============================================================= */

/* The legacy mobile backdrop is only needed for the off-canvas drawer on
   phones. Above 768px it used to blur the whole page on laptops/tablets,
   so hide it there. */
@media (min-width: 769px) {
  .mobile-sidebar-backdrop { display: none !important; }
}

/* Above 768px, hide all mobile-only chrome so it can't push the
   desktop layout down or leak into the viewport. */
@media (min-width: 769px) {
  .lk-nav-burger,
  .lk-drawer,
  .lk-backdrop,
  .lk-bottomnav { display: none !important; }
}

/* ---------------- 01. Base ---------------- */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  html, body {
    max-width: 100%;
    overflow-x: hidden !important;
  }
  /* Neutralise legacy `zoom` hacks in auth.css — they scale the whole page,
     which caused the header mis-position and off-screen widths. */
  html, body { zoom: 1 !important; }
  .weather-page { zoom: 1 !important; }

  body {
    font-size: 15.5px !important;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-x: none;
  }
  * { -webkit-tap-highlight-color: transparent; }

  /* Font Awesome family/weight safety (solid glyphs like fa-peso-sign) */
  .fa, .fas, .far, .fab, .fad, .fal, .fat,
  .fa-solid, .fa-regular, .fa-brands {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 6 Brands" !important;
  }
  .fa-solid, .fas { font-weight: 900 !important; }
  .fa-regular, .far { font-weight: 400 !important; }
  .fa-brands, .fab { font-weight: 400 !important; }
  .fa-peso-sign { font-size: 1em !important; vertical-align: baseline; line-height: 1; }

  /* Images never blow out the viewport */
  img, svg, canvas, video { max-width: 100%; }
  canvas { height: auto !important; }

  /* Page content clears the fixed bottom bar */
  body.internal-system,
  body.has-lc-nav {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------------- 02. Public top bar + drawer ---------------- */
@media (max-width: 768px) {
  .lc-nav,
  .lc-nav.scrolled {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    min-height: 60px !important;
    padding: 0 14px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    border-radius: 0 !important;
    z-index: 1000 !important;
  }
  .lc-nav-brand { gap: 9px !important; min-width: 0 !important; flex: 1 1 auto; }
  .lc-nav-brand img { width: 36px !important; height: 36px !important; }
  .lc-nav-brand-text { min-width: 0; }
  .lc-nav-brand-name {
    font-size: 1.02rem !important;
    letter-spacing: 0.04em !important;
    line-height: 1.1 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lc-nav-brand-sub { display: none !important; }
  .lc-nav-tabs, .lc-nav-cta { display: none !important; }

  .lk-nav-burger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1.5px solid rgba(58, 143, 184, 0.28);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: #2E7A9C;
    font-size: 1.05rem;
    cursor: pointer;
  }
  .lc-nav.scrolled .lk-nav-burger {
    background: rgba(58, 143, 184, 0.10);
    border-color: rgba(58, 143, 184, 0.26);
  }
  .lk-nav-burger:active { transform: scale(0.96); }

  /* Public drawer */
  .lk-drawer {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 330px);
    background: #F7F4ED;
    box-shadow: -12px 0 40px rgba(10, 40, 60, 0.28);
    transform: translateX(103%);
    transition: transform 0.15s cubic-bezier(0.33, 1, 0.68, 1);
    z-index: 10100;
    display: flex;
    flex-direction: column;
    padding: 14px 14px calc(20px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  body.lk-drawer-open .lk-drawer { transform: translateX(0); }

  .lk-drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 14px;
    border-bottom: 1px solid rgba(58, 143, 184, 0.18);
    margin-bottom: 10px;
  }
  .lk-drawer-head img { width: 34px; height: 34px; object-fit: contain; }
  .lk-drawer-head span {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: #1A3A52;
    flex: 1;
  }
  .lk-drawer-close {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 11px;
    background: rgba(58, 143, 184, 0.10);
    color: #2E7A9C; font-size: 1rem; cursor: pointer;
  }
  .lk-drawer-links { display: flex; flex-direction: column; gap: 4px; }
  .lk-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 12px;
    border-radius: 12px;
    color: #1A3A52;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    font-family: 'Poppins', sans-serif;
  }
  .lk-drawer-link i { width: 22px; text-align: center; color: #3A8FB8; font-size: 1rem; }
  .lk-drawer-link:active { background: rgba(58, 143, 184, 0.12); transform: scale(0.99); }
  .lk-drawer-link.is-active {
    background: linear-gradient(135deg, #3A8FB8, #25A2E0);
    color: #fff;
  }
  .lk-drawer-link.is-active i { color: #fff; }

  .lk-drawer-cta {
    margin-top: 14px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #3A8FB8, #25A2E0);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    cursor: pointer;
  }
  .lk-drawer-cta:active { transform: scale(0.98); }

  /* Shared backdrop for both drawers */
  .lk-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 24, 36, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    z-index: 10090;
  }
  body.lk-drawer-open .lk-backdrop,
  body.lk-nav-open .lk-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hero / landing spacing (public pages) */
  .lc-hero-content {
    grid-template-columns: 1fr !important;
    gap: 22px !important;
    padding: 76px 16px 26px !important;
  }
  .lc-hero-right { order: 0 !important; }
  .lc-hero-left { gap: 18px !important; }
  .lc-hero-title { font-size: 1.75rem !important; line-height: 1.2 !important; }
  .lc-hero-subtitle { font-size: 0.95rem !important; line-height: 1.5 !important; }
  .lc-hero-cards { grid-template-columns: 1fr !important; gap: 12px !important; }
  .lc-about-card { padding: 1rem !important; border-radius: 12px !important; }
  .lc-hero-netoff { top: 66px !important; }

  .lc-section,
  .lc-section[style] { padding: 40px 16px !important; }
  body.has-lc-nav > .lc-section,
  body.has-lc-nav > .lc-section[style] { padding-top: 76px !important; }
  .lc-section-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .lc-section-header h2 { font-size: 1.35rem !important; }
  .lc-glass { border-radius: 14px !important; }

  .lc-footer {
    flex-direction: column !important;
    gap: 10px !important;
    text-align: center !important;
    padding: 18px 16px calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ---------------- 03. Internal top bar (60px) + search sheet ---------------- */
@media (max-width: 768px) {
  .internal-system .top-bar,
  .top-bar {
    height: 60px !important;
    min-height: 60px !important;
    padding: 0 10px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    border-radius: 0 !important;
  }
  .top-bar > .d-flex.align-items-center {
    flex: 1 1 auto;
    min-width: 0;
    align-items: center !important;
    gap: 2px;
  }
  .top-bar > .d-flex.align-items-center > div {
    min-width: 0 !important;
    overflow: hidden;
  }
  .top-bar h3 {
    font-size: 1rem !important;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .top-bar h3 i { display: none !important; }
  .top-bar .breadcrumb { display: none !important; }

  .toggle-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    margin: 0 2px 0 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.1rem !important;
    border-radius: 11px !important;
  }
  .toggle-btn:active { background: rgba(58, 143, 184, 0.14); }

  /* Compact icon-only search, expands to a sheet */
  .internal-system .top-bar .tbs-search,
  .top-bar .tbs-search {
    position: static !important;
    order: 0 !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    max-width: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .tbs-input-row {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    border-radius: 11px !important;
    overflow: hidden;
  }
  .tbs-input-icon { font-size: 0.98rem !important; }
  .tbs-input { width: 0 !important; opacity: 0; pointer-events: none; }
  .tbs-hotkey { display: none !important; }
  .tbs-panel-close { display: none !important; }

  body.lk-search-open .internal-system .top-bar .tbs-search,
  body.internal-system.lk-search-open .top-bar .tbs-search,
  body.lk-search-open .top-bar .tbs-search {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    max-width: none !important;
    flex: none !important;
    height: 64px !important;
    padding: 10px 12px !important;
    background: rgba(248, 246, 240, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 24px rgba(10, 40, 60, 0.16);
    z-index: 10080 !important;
    display: flex !important;
    align-items: center !important;
  }
  body.lk-search-open .tbs-input-row {
    width: 100% !important;
    height: 44px !important;
    padding: 8px 12px !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    border-radius: 12px !important;
  }
  body.lk-search-open .tbs-input {
    width: auto !important;
    flex: 1 1 auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    font-size: 16px !important; /* prevents iOS zoom on focus */
  }
  body.lk-search-open .tbs-panel-close { display: inline-flex !important; }
  body.lk-search-open .tbs-panel {
    top: calc(100% + 4px) !important;
    left: 12px !important;
    right: 12px !important;
    min-width: 0 !important;
    max-height: 62vh;
  }
  body.lk-search-open .tbs-body { max-height: 54vh; }

  .top-bar-user { gap: 4px !important; flex: 0 0 auto !important; }
}

/* ---------------- 04. Internal sidebar drawer ---------------- */
@media (max-width: 768px) {
  #sidebar,
  .internal-system #sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(84vw, 320px) !important;
    max-width: 320px !important;
    height: 100dvh !important;
    transform: translateX(-103%) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    border-radius: 0 20px 20px 0 !important;
    border-right: none !important;
    box-shadow: 12px 0 44px rgba(6, 28, 44, 0.30) !important;
    z-index: 10100 !important;
    animation: none !important;
    transition: transform 0.15s cubic-bezier(0.33, 1, 0.68, 1) !important;
    padding-top: env(safe-area-inset-top, 0px);
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #sidebar.collapsed,
  #sidebar.visible,
  #sidebar.mobile-open,
  .internal-system #sidebar.collapsed {
    width: min(84vw, 320px) !important;
  }
  body.lk-nav-open #sidebar,
  body.lk-nav-open .internal-system #sidebar {
    transform: translateX(0) !important;
  }

  #sidebar .sidebar-brand { padding: 14px 14px 10px !important; }
  #sidebar .brand-title { font-size: 0.95rem !important; }
  #sidebar .brand-subtitle {
    font-size: 0.64rem !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  #sidebar .brand-text {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    overflow: hidden;
  }
  #sidebar .nav-menu { align-items: stretch !important; }
  #sidebar .nav-section { width: 100% !important; }

  /* The sidebar keeps its desktop `collapsed` class on phones (the legacy
     toggle never runs), so un-hide the labels it was hiding. */
  #sidebar .brand-text,
  #sidebar .nav-text,
  #sidebar .nav-arrow,
  #sidebar .nav-section-label,
  .internal-system #sidebar.collapsed .brand-text,
  .internal-system #sidebar.collapsed .nav-text,
  .internal-system #sidebar.collapsed .nav-arrow,
  .internal-system #sidebar.collapsed .nav-section-label,
  .internal-system #sidebar.collapsed .dropdown-item span {
    display: revert !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
    transition: none !important;
    padding-top: revert !important;
    padding-bottom: revert !important;
    margin-bottom: revert !important;
  }
  #sidebar .brand-text { display: flex !important; }
  #sidebar .nav-section-label { display: block !important; }
  .internal-system #sidebar.collapsed .brand-logo,
  #sidebar .brand-logo { justify-content: flex-start !important; gap: 10px !important; }
  .internal-system #sidebar.collapsed .nav-item,
  #sidebar .nav-item { justify-content: flex-start !important; gap: 12px !important; margin: 0 !important; }
  #sidebar { background: #F7F4ED !important; }
  body.dark-theme #sidebar,
  html.theme-dark #sidebar,
  [data-theme="dark"] #sidebar { background: #0E1E2A !important; }
  #sidebar .nav-menu { padding: 4px 10px 12px !important; }
  #sidebar .nav-item {
    min-height: 48px !important;
    padding: 10px 12px !important;
    border-radius: 12px !important;
    font-size: 0.92rem !important;
  }
  #sidebar .nav-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.95rem !important;
  }
  #sidebar .nav-item.active {
    background: linear-gradient(135deg, #3A8FB8, #25A2E0) !important;
    color: #fff !important;
  }
  #sidebar .nav-item.active .nav-icon,
  #sidebar .nav-item.active .nav-text { color: #fff !important; }
  #sidebar .sidebar-footer { padding: 10px !important; }
  #sidebar .logout-btn {
    min-height: 48px !important;
    border-radius: 12px !important;
    justify-content: center;
  }
  .mobile-sidebar-backdrop { display: none !important; }

  /* Main content clears the drawer + bottom bar */
  .main-content,
  .main-content.expanded,
  .internal-system .main-content,
  body.sidebar-hidden .main-content,
  body.sidebar-visible .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    transform: none !important;
  }
  .main-content {
    padding: 0 12px calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .internal-system .container,
  .dash-container.container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }
}

/* ---------------- 05. Bottom navigation (shared) ---------------- */
.lk-bottomnav { display: none; }

@media (max-width: 768px) {
  .lk-bottomnav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10060;
    display: flex !important;
    align-items: stretch;
    gap: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: rgba(250, 248, 243, 0.97);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 1px solid rgba(58, 143, 184, 0.16);
    box-shadow: 0 -6px 24px rgba(10, 40, 60, 0.10);
  }
  .lk-bn-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    padding: 6px 2px 4px;
    color: #66808F;
    font-family: 'Poppins', sans-serif;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
  }
  .lk-bn-item i {
    font-size: 1.12rem;
    line-height: 1;
    width: 34px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  }
  .lk-bn-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .lk-bn-item:active { transform: scale(0.96); }
  .lk-bn-item.is-active { color: #2E7A9C; }
  .lk-bn-item.is-active i {
    background: rgba(58, 143, 184, 0.14);
    color: #2E7A9C;
  }
  body.dark-theme .lk-bottomnav,
  [data-theme="dark"] .lk-bottomnav {
    background: rgba(12, 26, 38, 0.97);
    border-top-color: rgba(90, 150, 180, 0.22);
  }
  body.dark-theme .lk-bn-item,
  [data-theme="dark"] .lk-bn-item { color: #7E99AA; }
  body.dark-theme .lk-bn-item.is-active,
  [data-theme="dark"] .lk-bn-item.is-active { color: #6ee7f5; }
  body.dark-theme .lk-bn-item.is-active i,
  [data-theme="dark"] .lk-bn-item.is-active i {
    background: rgba(58, 143, 184, 0.22);
    color: #6ee7f5;
  }
}

/* ---------------- 06. Content, grids, cards ---------------- */
@media (max-width: 768px) {
  /* Bootstrap gutters: tighter, no negative horizontal overflow */
  .row { --bs-gutter-x: 12px; margin-left: 0 !important; margin-right: 0 !important; }
  .row > * { padding-left: 6px !important; padding-right: 6px !important; }

  /* Public 4-stat grid -> 2 x 2 */
  .lc-stats { padding: 0 16px !important; }
  .lc-stats-card {
    grid-template-columns: 1fr 1fr !important;
    padding: 6px !important;
    gap: 4px !important;
    border-radius: 14px !important;
  }
  .lc-stat-item {
    padding: 12px 10px !important;
    border: none !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.45);
  }
  .lc-stat-value { font-size: 1.15rem !important; }
  .lc-stat-label { font-size: 0.68rem !important; }

  .lc-news-layout,
  .lc-feedback-layout,
  .lc-features-grid,
  .features-grid,
  .feedback-grid {
    grid-template-columns: 1fr !important;
  }
  .lc-prices-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .lc-prices-toolbar { flex-wrap: wrap; gap: 8px; }
  .lc-price-val { font-size: 1rem !important; }

  /* Cards */
  .glass-card,
  .stat-card,
  .chart-card,
  .about-card {
    border-radius: 14px !important;
    padding: 14px !important;
    margin-bottom: 12px !important;
  }
  .dash-container { padding-top: 12px !important; }
  .dash-welcome { padding: 14px !important; gap: 8px !important; }
  .dash-welcome h2 { font-size: 1.1rem !important; }
  .dash-welcome p { font-size: 0.8rem !important; }
  .dash-welcome-clock { font-size: 0.78rem !important; }

  /* Dashboard KPI: 2 x 2 compact */
  .dash-kpi { min-height: 0 !important; border-radius: 13px !important; }
  .dash-kpi-body { padding: 10px 11px 11px !important; }
  .dash-kpi-label { font-size: 0.66rem !important; line-height: 1.25 !important; }
  .dash-kpi-value { font-size: 1.12rem !important; line-height: 1.2 !important; }
  .dash-kpi-value .fa-peso-sign { font-size: 0.8em !important; }
  .dash-kpi-trend { font-size: 0.66rem !important; }
  .dash-kpi-icon { width: 30px !important; height: 30px !important; font-size: 0.82rem !important; }
  .dash-kpi-sparkline { width: 54px !important; height: 26px !important; }
  .dash-kpi-sparkline canvas { width: 54px !important; height: 26px !important; }

  /* Filter toolbar: chips wrap, date range gets its own row */
  .dash-toolbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px !important;
    overflow: visible !important;
  }
  .dash-toolbar-left {
    flex: 1 1 auto !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    row-gap: 6px !important;
    column-gap: 6px !important;
  }
  .dash-toolbar-form {
    flex: 1 1 100% !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .dash-toolbar-form .lamb-daterangepicker {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  .period-btn { flex: 0 0 auto !important; padding: 7px 11px !important; font-size: 0.78rem !important; }

  .chart-card h5, .glass-card h5 { font-size: 0.92rem !important; }
  .chart-container { height: 260px !important; }

  /* PAGASA marine panel: compact horizontal card */
  .marine-advisory { padding: 14px !important; border-radius: 16px !important; }
  .marine-head {
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding-bottom: 10px !important;
  }
  .marine-brand { gap: 8px !important; }
  .marine-brand-logo { width: 38px !important; height: 38px !important; flex: 0 0 38px !important; }
  .marine-brand-name { font-size: 0.86rem !important; }
  .marine-brand-sub { display: none !important; }
  .marine-issued { align-items: flex-end !important; text-align: right !important; }
  .marine-issued-label { font-size: 0.54rem !important; }
  .marine-issued-value { font-size: 0.68rem !important; line-height: 1.3 !important; }
  .marine-issued-alt { font-size: 0.58rem !important; }
  .marine-body { padding: 10px 0 2px !important; }
  .marine-status { flex-direction: row !important; align-items: flex-start !important; gap: 10px !important; }
  .marine-status-icon { width: 38px !important; height: 38px !important; font-size: 0.95rem !important; flex: 0 0 38px !important; border-radius: 12px !important; }
  .marine-status-eyebrow { font-size: 0.58rem !important; }
  .marine-status-title { font-size: 1.15rem !important; line-height: 1.25 !important; }
  .marine-status-msg { font-size: 0.78rem !important; }
  .marine-status-action { font-size: 0.72rem !important; }
  .marine-kpis {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin-top: 10px !important;
  }
  .marine-kpi { padding: 9px !important; border-radius: 11px !important; }
  .marine-kpi:nth-child(3) { grid-column: 1 / -1 !important; }
  .marine-kpi-value { font-size: 0.95rem !important; }
  .marine-kpi-label { font-size: 0.6rem !important; }
  .marine-kpi-note { font-size: 0.62rem !important; }
  .marine-strip { font-size: 0.74rem !important; padding: 9px 10px !important; }
  .marine-source { gap: 8px !important; }
  .marine-source-links { width: 100% !important; gap: 8px !important; }
  .marine-source-links a { font-size: 0.64rem !important; }

  /* Weather page */
  .weather-page .glass-card { padding: 12px !important; }
  .weather-page .forecast-grid { flex-wrap: nowrap !important; overflow-x: auto; gap: 8px; }
  .weather-page .forecast-card { flex: 0 0 45% !important; min-width: 45% !important; }
  .weather-page .weather-metrics { grid-template-columns: 1fr 1fr !important; }
  .weather-page .marine-status-title { font-size: 1.3rem !important; }
  .weather-page .marine-kpi-value { font-size: 1.25rem !important; }
  .weather-page .forecast-temp { font-size: 1.35rem !important; }
  .weather-page .metric-info span { font-size: 1.15rem !important; }
  .weather-page .tide-time { font-size: 1.1rem !important; }
}

/* ---------------- 07. Forms, buttons, tables ---------------- */
@media (max-width: 768px) {
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important; /* stops iOS auto-zoom */
    min-height: 46px;
    border-radius: 11px !important;
  }
  .form-label, label { font-size: 0.85rem; }

  .btn, .filter-btn, .filter-btn-primary, .filter-btn-secondary {
    min-height: 46px;
    font-size: 0.9rem !important;
    border-radius: 12px !important;
  }
  .filter-row, .filter-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  td.text-primary.fw-bold,
  td.cell-total {
    white-space: nowrap !important;
    font-size: 1rem !important;
  }
  td.text-primary.fw-bold .fa-peso-sign,
  td.cell-total .fa-peso-sign { font-size: 1em !important; margin-right: 1px; }

  .table-responsive,
  .data-table-wrapper,
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    background:
      linear-gradient(to right, rgba(255,255,255,0) 85%, rgba(46,122,156,0.10)) right / 22px 100% no-repeat;
  }
  .table-responsive table,
  .data-table,
  .data-table th,
  .data-table td,
  .table-responsive th,
  .table-responsive td { white-space: nowrap; }
  table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 9px 10px !important; }

  /* Touch feedback */
  .btn:active,
  a.lc-btn-outline:active,
  .lc-nav-tab:active,
  .period-btn:active { transform: scale(0.98); }
}

/* ---------------- 08. Overlays: auth bottom-sheet, modals ---------------- */
@media (max-width: 768px) {
  /* Auth / login overlay -> bottom sheet */
  .auth-overlay {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }
  .auth-overlay .auth-modal {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: 92svh;
    margin: 0 !important;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 22px 22px 0 0 !important;
    transform: translateY(100%) scale(1) !important;
    transition: transform 0.15s cubic-bezier(0.33, 1, 0.68, 1) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .auth-overlay.show .auth-modal { transform: translateY(0) scale(1) !important; }
  .auth-overlay .auth-modal::after {
    content: '';
    position: sticky;
    top: -10px;
    display: block;
    width: 44px;
    height: 5px;
    margin: -8px auto 10px;
    border-radius: 999px;
    background: rgba(26, 58, 82, 0.22);
  }
  .auth-modal .btn-auth,
  .auth-modal input:not([type="checkbox"]):not([type="radio"]),
  .auth-modal .auth-guest-btn { min-height: 48px !important; }
  .auth-modal input { font-size: 16px !important; }
  .auth-logo-badge, .auth-logo-ring { width: 66px !important; height: 66px !important; }
  .auth-modal-wave { display: none !important; }
  .auth-step-item { min-width: 46px !important; }
  .auth-otp-box { width: 38px !important; height: 46px !important; }

  /* Bootstrap modals -> bottom sheets */
  .modal { overflow-y: hidden; }
  .modal-dialog {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
  }
  .modal.show .modal-dialog { transform: none !important; }
  .modal .modal-content {
    border: none !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90svh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-header { padding: 14px 16px !important; }
  .modal-body { padding: 14px 16px !important; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Custom overlays using .modal-overlay + .glass-card / .modal-card */
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal-overlay > .glass-card,
  .modal-overlay > .modal-card,
  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90svh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------------- 09. Floating widgets ---------------- */
@media (max-width: 768px) {
  #ai-assistant-wrapper {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    z-index: 10070 !important;
  }
  #ai-toggle {
    width: 54px !important;
    height: 54px !important;
    font-size: 1.25rem !important;
    animation: none !important;
  }
  #ai-chat-window {
    width: calc(100vw - 24px) !important;
    max-width: 420px !important;
    height: min(68vh, 520px) !important;
    right: 0 !important;
    bottom: 64px !important;
    border-radius: 18px !important;
  }
  #ai-messages { font-size: 0.86rem !important; }
  #ai-user-input { font-size: 16px !important; }

  .lc-theme-toggle {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
  }
}

/* ---------------- 10. Small phones (<= 480px) ---------------- */
@media (max-width: 480px) {
  body { font-size: 15px !important; zoom: 1 !important; }
  .weather-page { zoom: 1 !important; }
  .lc-hero-title { font-size: 1.6rem !important; }
  .lc-section { padding: 34px 14px !important; }
  body.has-lc-nav > .lc-section,
  body.has-lc-nav > .lc-section[style] { padding-top: 72px !important; }
  .lc-hero-content { padding: 72px 14px 22px !important; }
  .top-bar h3 { font-size: 0.94rem !important; }
  .glass-card, .stat-card, .chart-card, .about-card { padding: 12px !important; }
  .dash-kpi-value { font-size: 1.04rem !important; }
  .lk-bn-item { font-size: 0.58rem; }
  .lk-bn-item i { font-size: 1.05rem; }
  .modal .modal-content, .auth-overlay .auth-modal { border-radius: 18px 18px 0 0 !important; }
}

/* ---------------- 11. Legacy page safety net ----------------
   Some internal pages still ship older responsive rules which shrink the
   entire document with `zoom`.  A zoomed document has an incorrect viewport
   width, making controls and the fixed navigation feel inconsistent on a
   phone.  Keep the viewport at its real size and let the component rules
   above reflow the content instead. */
@media (max-width: 768px) {
  body.internal-system {
    zoom: 1 !important;
  }

  /* Covers older page-specific flex rows that do not expose a shared class. */
  .internal-system [style*="display:flex"] {
    max-width: 100%;
  }

  /* Prevent long form controls and popup panels from pushing the page wider
     than the device. Wide data tables keep their intentional horizontal
     scroll inside their wrapper. */
  .internal-system input,
  .internal-system select,
  .internal-system textarea,
  .internal-system .dropdown-menu,
  .internal-system .tb-dropdown,
  .internal-system .notif-panel {
    max-width: 100%;
  }

  .internal-system .table-responsive,
  .internal-system .data-table-wrapper,
  .internal-system .table-wrap {
    max-width: 100%;
  }
}

/* ---------------- 12. Phone UX and performance ----------------
   Navigation has one clear home on a phone: the menu button in the top bar.
   The sidebar opens as that menu, so a second fixed navigation bar is neither
   needed nor allowed to consume screen space. */
@media (max-width: 768px) {
  .lk-bottomnav { display: none !important; }

  body.internal-system,
  body.has-lc-nav { padding-bottom: env(safe-area-inset-bottom, 0px) !important; }

  .main-content { padding-bottom: 24px !important; }
  .lc-footer { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Keep the assistant clear of the screen edge now that the bottom bar is gone. */
  #ai-assistant-wrapper,
  .lc-theme-toggle { bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Open the navigation immediately. On lower-powered phones even a
     transform transition can hitch when a long dashboard is being painted. */
  #sidebar,
  .internal-system #sidebar,
  .lk-drawer {
    will-change: auto;
    transition: none !important;
  }
  .lk-backdrop {
    will-change: auto;
    transition: none !important;
  }

  /* Stop decorative work while a user scrolls. Page-specific rules include
     several blurred panels, looping effects, and `transition: all`; those are
     particularly expensive on lower-powered phones. */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  #sidebar,
  .internal-system #sidebar,
  .lk-drawer,
  .lk-backdrop { transition: none !important; }

  .lc-hero-slide { transition: none !important; }
  .lc-hero-slide:not(.active) { display: none; }

  /* Isolate the scrolling surface from the drawer compositor layer. */
  body { overscroll-behavior-x: none; }
  .main-content,
  .lc-section { transform: translateZ(0); }
}

/* ---------------- 13. Data-first phone layouts ----------------
   These are purpose-built compact patterns for the system screens. They keep
   the information hierarchy of a dashboard without squeezing desktop-sized
   panels into a narrow viewport. */
@media (max-width: 768px) {
  :root {
    --lk-phone-gap: 12px;
    --lk-phone-radius: 16px;
  }

  .internal-system .main-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* KPI and summary cards: a deliberate two-column mobile grid. */
  .dash-container .row > .col-6,
  .stat-grid > .stat-card,
  .inv-stat-grid > .inv-stat-card {
    min-width: 0;
  }
  .dash-container .row > .col-6 { flex: 0 0 50% !important; max-width: 50% !important; }
  .stat-grid,
  .inv-stat-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: var(--lk-phone-gap) !important;
  }
  .inv-stat-grid > .inv-stat-card:last-child { grid-column: 1 / -1; }
  .stat-card,
  .inv-stat-card,
  .dash-kpi {
    min-height: 112px !important;
    border-radius: var(--lk-phone-radius) !important;
    box-shadow: 0 3px 12px rgba(20, 56, 78, 0.08) !important;
  }
  .dash-kpi { min-height: 126px !important; }
  .dash-kpi-body { padding: 13px 12px 12px !important; gap: 5px !important; }
  .dash-kpi-icon { width: 32px !important; height: 32px !important; border-radius: 10px !important; }
  .dash-kpi-sparkline { display: none !important; }
  .dash-kpi-label,
  .inv-stat-label,
  .stat-info > span { font-size: 0.64rem !important; line-height: 1.2 !important; }
  .dash-kpi-value,
  .inv-stat-value,
  .stat-info h4 { font-size: clamp(1.05rem, 5vw, 1.35rem) !important; line-height: 1.1 !important; }
  .dash-kpi-trend { font-size: 0.62rem !important; line-height: 1.25 !important; }
  .dash-help { min-width: 32px; min-height: 32px; }

  /* Charts become clear, touch-sized visual panels rather than short desktop
     fragments. Each chart gets its own row and a fixed usable plotting area. */
  .dash-container .chart-card,
  .chart-card {
    padding: 14px !important;
    border-radius: var(--lk-phone-radius) !important;
    margin-bottom: 2px !important;
  }
  .dash-container .chart-card .d-flex.justify-content-between,
  .chart-card .d-flex.justify-content-between {
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .chart-card h5 { font-size: 0.84rem !important; line-height: 1.35 !important; }
  .chart-canvas-wrap,
  .chart-container { height: 232px !important; min-height: 232px !important; }
  .chart-canvas-wrap canvas,
  .chart-container canvas { width: 100% !important; height: 100% !important; }
  .chart-type-toggle { flex: 0 0 auto; }
  .chart-type-toggle button { min-height: 34px !important; padding: 6px 8px !important; font-size: 0.68rem !important; }

  /* Toolbars follow a scan -> control -> action flow on a phone. */
  .report-card-head,
  .report-toolbar,
  .inv-table-header,
  .species-table-header,
  .filter-card .filter-toolbar {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .report-card-head > h5,
  .inv-table-header > h6 { width: 100%; }
  .report-toolbar .lmb-search,
  .inv-table-header .lmb-search { flex: 1 1 100% !important; width: 100% !important; }
  .report-toolbar > button,
  .report-toolbar > a { flex: 1 1 calc(50% - 5px); }
  .catch-form-row { flex-direction: column !important; gap: 14px !important; }
  .catch-form-row > div { width: 100% !important; flex: 1 1 auto !important; }

  /* Tables remain tables, but become a horizontally swipable data sheet:
     first field stays visible as the user compares columns. */
  .table-responsive,
  .data-table-wrapper,
  .table-wrap,
  .inv-table-wrap > div[style*="overflow-x"] {
    position: relative;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    border: 1px solid rgba(58, 143, 184, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
  }
  .data-table,
  .species-table,
  .inv-table,
  .audit-table { min-width: 620px !important; margin-bottom: 0 !important; }
  .data-table th,
  .data-table td,
  .species-table th,
  .species-table td,
  .inv-table th,
  .inv-table td,
  .audit-table th,
  .audit-table td { padding: 12px 13px !important; font-size: 0.78rem !important; }
  .data-table thead th,
  .species-table thead th,
  .inv-table thead th,
  .audit-table thead th { font-size: 0.64rem !important; letter-spacing: 0.05em; }
  .data-table th:first-child,
  .data-table td:first-child,
  .species-table th:first-child,
  .species-table td:first-child,
  .inv-table th:first-child,
  .inv-table td:first-child,
  .audit-table th:first-child,
  .audit-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 8px 0 12px -12px rgba(22, 48, 74, 0.45);
  }
  .data-table thead th:first-child,
  .species-table thead th:first-child,
  .inv-table thead th:first-child,
  .audit-table thead th:first-child { z-index: 3; }
  [data-theme="dark"] .data-table td:first-child,
  [data-theme="dark"] .species-table td:first-child,
  [data-theme="dark"] .inv-table td:first-child,
  [data-theme="dark"] .audit-table td:first-child { background: #102635; }

  /* A real empty/summary card should use the same compact visual language. */
  .glass-card,
  .about-card { border-radius: var(--lk-phone-radius) !important; }
  .scope-bar,
  .selection-bar { border-radius: 14px !important; padding: 10px 12px !important; }
}

@media (max-width: 380px) {
  .dash-container .row > .col-6 { flex-basis: 100% !important; max-width: 100% !important; }
  .stat-grid,
  .inv-stat-grid { grid-template-columns: 1fr !important; }
  .inv-stat-grid > .inv-stat-card:last-child { grid-column: auto; }
}

/* Responsive performance baseline (all viewports) */
html { scroll-behavior: auto !important; }
*, *::before, *::after {
  animation: none !important;
  transition: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body { overscroll-behavior-x: none; }


/* Smooth, lightweight sidebar drawer (all viewports) */
@media (max-width: 768px) {
  #sidebar,
  .internal-system #sidebar {
    transition: transform 0.18s cubic-bezier(0.33, 1, 0.68, 1) !important;
  }
  .mobile-sidebar-backdrop {
    transition: opacity 0.18s ease !important;
  }
}

