/**
 * EduOxy — cross-device responsive layer (phones, tablets, desktops).
 * Loaded last so it can tame Porto/Bootstrap fixed widths without rewriting pages.
 */

/* ── Base: no accidental horizontal page scroll ── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* Safe areas — header only here; content-body handled in breakpoints */
@supports (padding: max(0px, env(safe-area-inset-left))) {
  html.epx-app .header,
  html.glass-theme .header {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/*
 * ═══════════════════════════════════════════════════════════
 * Fixed topbar — all devices (phone / tablet / desktop)
 * Porto used static/2-row mobile + fixed desktop; unify to one
 * fixed bar and offset the shell with --epx-topbar-h.
 * ═══════════════════════════════════════════════════════════
 */
:root {
  --epx-topbar-h: 64px;
}

html.epx-app .header,
html.glass-theme.epx-app .header,
html.fixed.epx-app .header,
html.epx-app .header.header-nav-menu {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1030 !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between;
  gap: 8px 12px;
  width: 100% !important;
  height: var(--epx-topbar-h) !important;
  min-height: var(--epx-topbar-h) !important;
  max-height: var(--epx-topbar-h) !important;
  margin: 0 !important;
  padding: 0 14px !important;
  padding-left: max(14px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(14px, env(safe-area-inset-right, 0px)) !important;
  padding-top: env(safe-area-inset-top, 0px) !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  background: rgba(255, 255, 255, 0.86) !important;
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  border: 0 !important;
  border-bottom: 1px solid rgba(15, 55, 75, 0.1) !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07) !important;
}

/* Offset page content under fixed topbar */
html.epx-app .inner-wrapper,
html.fixed.epx-app .inner-wrapper,
html.glass-theme.epx-app .inner-wrapper,
html.epx-app .body > .inner-wrapper {
  padding-top: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
  margin-top: 0 !important;
}

html.epx-app .header .logo-env,
html.glass-theme.epx-app .header .logo-env {
  position: static !important;
  float: none !important;
  display: flex !important;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  z-index: auto !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
}

html.epx-app .header .logo-env .logo {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

html.epx-app .header .logo-env .logo img {
  display: block;
  height: 36px !important;
  width: auto !important;
  max-width: 140px;
  object-fit: contain;
}

html.epx-app .header .header-left {
  float: none !important;
  display: flex !important;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

html.epx-app .header .header-left .header-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

html.epx-app .header .header-left .search.nav-form,
html.epx-app .header .header-left .input-search {
  max-width: min(280px, 32vw);
  margin-left: 8px;
}

html.epx-app .header .header-right {
  float: none !important;
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  min-width: 0;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

html.epx-app .header .header-right .header-menu {
  display: flex !important;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}

html.epx-app .header .header-right .header-menu > li {
  float: none !important;
  margin: 0 !important;
}

html.epx-app .header .separator {
  align-self: center;
  width: 1px;
  height: 22px;
  margin: 0 6px !important;
  background: rgba(15, 55, 75, 0.12) !important;
}

html.epx-app .header .header-menu-icon,
html.epx-app .header .toggle-sidebar-left,
html.epx-app .header .header-right > li > a.header-menu-icon,
html.epx-app .header .header-right > li > .header-menu-icon {
  width: 40px !important;
  height: 40px !important;
  flex: 0 0 40px;
}

html.epx-app .header .userbox {
  margin: 0 0 0 4px !important;
}

html.epx-app .header .userbox .profile-picture img {
  width: 34px !important;
  height: 34px !important;
}

/* Dropdowns above content while topbar is fixed */
html.epx-app .header .dropdown-menu,
html.epx-app .header-right .dropdown-menu {
  z-index: 1040 !important;
  max-height: min(70vh, 420px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Desktop/tablet: sidebar sits under fixed topbar */
@media (min-width: 768px) {
  html.fixed.epx-app .sidebar-left,
  html.epx-app.fixed .sidebar-left {
    top: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
  }
}

@media (max-width: 1024px) {
  :root {
    --epx-topbar-h: 60px;
  }

  html.epx-app .header .header-left .search.nav-form,
  html.epx-app .header .header-left .input-search {
    max-width: min(200px, 28vw);
  }

  html.epx-app .header .logo-env .logo img {
    height: 32px !important;
    max-width: 120px;
  }
}

/* Tables: scroll instead of blowing out layout */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-body > .table,
.panel-body > form > .table,
.tab-pane > .table,
.tab-content > .table,
.dataTables_wrapper {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ══════════════════ Tablet (≤1024) ══════════════════ */
@media (max-width: 1024px) {
  html.epx-app .content-body,
  html.glass-theme .content-body {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  html.epx-app .panel-body,
  html.glass-theme .panel-body {
    padding: 16px !important;
  }

  /* Filter / action toolbars */
  .page-header .pull-right,
  .page-header > .btn-group,
  .panel-heading .pull-right,
  .panel-heading .panel-actions {
    float: none !important;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    position: static !important;
  }

  .tabs-custom > .nav-tabs,
  .nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .tabs-custom > .nav-tabs > li,
  .nav-tabs > li {
    flex: 0 0 auto;
    float: none;
  }
}

/* ══════════════════ Phone + small tablet (≤767) ══════════════════ */
@media (max-width: 767px) {
  :root {
    --epx-topbar-h: 56px;
  }

  /*
   * Fixed single-row topbar (overrides Porto 2-row mobile header).
   * Content offset comes from --epx-topbar-h on .inner-wrapper.
   */
  html.epx-app .header,
  html.glass-theme.epx-app .header,
  html.fixed.epx-app .header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030 !important;
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100% !important;
    height: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
    min-height: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
    max-height: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
    margin: 0 !important;
    padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right, 0px)) 0
      max(10px, env(safe-area-inset-left, 0px)) !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border-bottom: 1px solid rgba(15, 55, 75, 0.08) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
    overflow: visible !important;
  }

  html.epx-app .header .header-left.hidden-xs,
  html.epx-app .header .header-left {
    display: none !important;
  }

  html.epx-app .header .logo-env,
  html.glass-theme.epx-app .header .logo-env,
  html.epx-app .header.epx-topbar .logo-env {
    position: static !important;
    float: none !important;
    display: flex !important;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 38% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    z-index: auto !important;
  }

  html.epx-app .header .logo-env .logo img {
    height: 26px !important;
    width: auto !important;
    max-width: 88px !important;
  }

  html.epx-app .header .toggle-sidebar-left,
  html.epx-app .header .logo-env .toggle-sidebar-left,
  html.epx-app .visible-xs.toggle-sidebar-left,
  html.epx-app .header.epx-topbar .toggle-sidebar-left {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    flex: 0 0 36px !important;
    margin: 0 !important;
    float: none !important;
    line-height: 1 !important;
  }

  /* Icon cluster — kill Porto float + 17px gaps that break mobile */
  html.epx-app .header .header-right,
  html.glass-theme.epx-app .header .header-right {
    float: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 1 1 auto !important;
    gap: 4px !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  html.epx-app .header .header-right .header-menu {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 1 1 auto !important;
    gap: 4px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    /* Must stay visible — overflow-y:hidden clipped session/lang/msg dropdowns */
    overflow: visible !important;
  }

  html.epx-app .header .header-right .header-menu::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  html.epx-app .header .header-menu > li,
  html.epx-app .header .header-right .header-menu > li {
    float: none !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html.epx-app .header .header-menu .header-menu-icon:before,
  html.epx-app .header .header-menu-icon:before {
    display: none !important;
    content: none !important;
    box-shadow: none !important;
  }

  html.epx-app .header .header-menu-icon,
  html.epx-app .header .header-right > li > a.header-menu-icon,
  html.epx-app .header .header-right > li > .header-menu-icon,
  html.epx-app .header .header-right .header-menu > li > a.header-menu-icon,
  html.epx-app .header .header-right .header-menu > li > .header-menu-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    flex: 0 0 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 10px !important;
    line-height: 1 !important;
  }

  html.epx-app .header .header-menu-icon i,
  html.epx-app .header .header-right .header-menu-icon i,
  html.epx-app .header .toggle-sidebar-left i {
    font-size: 0.9rem !important;
    line-height: 1 !important;
    width: auto !important;
    height: auto !important;
  }

  html.epx-app .header .header-menu-icon .badge,
  html.epx-app .header .header-right .badge {
    top: -2px !important;
    right: -2px !important;
    min-width: 16px !important;
    height: 16px !important;
    padding: 0 4px !important;
    font-size: 0.58rem !important;
    line-height: 16px !important;
  }

  html.epx-app .header .separator {
    display: none !important;
  }

  html.epx-app .header .userbox,
  html.epx-app .header #userbox {
    float: none !important;
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
  }

  html.epx-app .header .userbox > a {
    display: inline-flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  html.epx-app .header .userbox .profile-info,
  html.epx-app .header .userbox .name,
  html.epx-app .header .userbox .role {
    display: none !important;
  }

  html.epx-app .header .userbox .profile-picture {
    margin: 0 !important;
    width: 30px !important;
    height: 30px !important;
  }

  html.epx-app .header .userbox .profile-picture img {
    width: 30px !important;
    height: 30px !important;
    max-width: 30px !important;
    border-radius: 50% !important;
    object-fit: cover;
  }

  /* Keep dropdown panels on-screen and above page content */
  html.epx-app .header .header-right,
  html.epx-app .header .userbox,
  html.epx-app .header #userbox {
    overflow: visible !important;
  }

  html.epx-app .header .header-menu > li.open,
  html.epx-app .header .header-right .dropdown.open,
  html.epx-app .header .userbox.open {
    z-index: 1060 !important;
  }

  html.epx-app .header .dropdown-menu,
  html.epx-app .header-right .dropdown-menu,
  html.epx-app .header .header-menubox {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: calc(100% + 8px) !important;
    min-width: min(280px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 16px) !important;
    z-index: 1060 !important;
  }

  html.epx-app .header .dropdown.open > .dropdown-menu,
  html.epx-app .header .header-menu > li.open > .dropdown-menu,
  html.epx-app .header .userbox.open > .dropdown-menu {
    display: block !important;
  }

  /* Keep content clear of fixed topbar */
  html.epx-app .inner-wrapper,
  html.fixed.epx-app .inner-wrapper,
  html.glass-theme .inner-wrapper,
  html.glass-theme.epx-app .inner-wrapper {
    padding-top: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
    margin-top: 0 !important;
  }

  html.epx-app .sidebar-left,
  html.fixed.epx-app .sidebar-left {
    top: calc(var(--epx-topbar-h) + env(safe-area-inset-top, 0px)) !important;
    padding-top: 0 !important;
  }

  /* Tight, even content gutters — no leftover Porto top pad */
  html.epx-app .content-body,
  html.glass-theme .content-body,
  html.glass-theme.epx-app .content-body {
    margin-left: 0 !important;
    padding: 8px 12px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html.fixed .content-body {
    margin-left: 0 !important;
  }

  /* Page title — compact, single row when possible */
  .page-header,
  html.epx-app .page-header,
  html.fixed.epx-app .page-header,
  html.glass-theme .page-header {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center !important;
    gap: 8px 10px !important;
    height: auto !important;
    margin: 0 0 10px !important;
    padding: 0 !important;
  }

  .page-header h2,
  html.epx-app .page-header h2,
  html.glass-theme .page-header h2 {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.2rem !important;
    line-height: 1.25 !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .page-header .page-title-icon {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
  }

  .page-header .pull-right {
    width: auto;
    margin: 0 !important;
  }

  .page-header .pull-right .btn,
  .page-header .btn {
    margin: 0 !important;
  }

  /* Panels */
  html.epx-app .panel,
  html.epx-app section.panel,
  html.glass-theme .panel {
    border-radius: 14px !important;
  }

  /* Don't force margin on dashboard panels (they use flex gap) */
  html.epx-app .panel,
  html.epx-app section.panel,
  html.glass-theme .panel {
    margin-bottom: 14px !important;
  }

  html.epx-app .dash-premium .panel,
  html.epx-app .dash-premium section.panel,
  html.glass-theme .dash-premium .panel,
  html.glass-theme .dash-premium .dash-panel {
    margin-bottom: 0 !important;
  }

  html.epx-app .panel-heading,
  html.epx-app .panel > .panel-heading {
    padding: 12px 14px !important;
  }

  html.epx-app .panel-body,
  html.glass-theme .panel-body {
    padding: 12px !important;
  }

  html.epx-app .panel-title {
    font-size: 0.95rem !important;
    flex-wrap: wrap;
  }

  /* Keep Bootstrap gutters; do NOT bleed rows past content padding */
  .content-body > .row,
  .dash-premium .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .content-body > .row > [class*="col-"],
  .dash-premium .row > [class*="col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
  }

  /* ── Dashboard: equal widths + denser grids ── */
  html.glass-theme .dash-premium,
  .dashboard-page.dash-premium {
    gap: 14px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  html.glass-theme .dash-welcome,
  html.glass-theme .dash-section,
  html.glass-theme .dash-stat-grid,
  html.glass-theme .dash-charts-row,
  html.glass-theme .dash-bottom-row,
  html.glass-theme .dash-stack,
  html.glass-theme .dash-side-stack {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  html.glass-theme .dash-charts-row,
  html.glass-theme .dash-bottom-row,
  html.glass-theme .dash-premium > .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    row-gap: 12px !important;
  }

  html.glass-theme .dash-charts-row > [class*="col-"],
  html.glass-theme .dash-bottom-row > [class*="col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }

  html.glass-theme .dash-welcome {
    padding: 14px !important;
    gap: 12px !important;
  }

  html.glass-theme .dash-welcome__title {
    font-size: 1.25rem !important;
  }

  html.glass-theme .dash-welcome__metrics {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    justify-content: stretch !important;
  }

  html.glass-theme .dash-mini-metric {
    flex: none !important;
    min-width: 0 !important;
    width: 100%;
    padding: 10px 8px !important;
  }

  html.glass-theme .dash-mini-metric strong {
    font-size: 0.95rem !important;
  }

  html.glass-theme .dash-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  html.glass-theme .dash-stat {
    padding: 12px 10px !important;
    gap: 10px !important;
    border-radius: 14px !important;
  }

  html.glass-theme .dash-stat__icon {
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
  }

  html.glass-theme .dash-stat__value {
    font-size: 1.05rem !important;
  }

  html.glass-theme .dash-stat__arrow {
    display: none !important;
  }

  html.glass-theme .dash-cal-grid {
    min-width: 0 !important;
  }

  html.glass-theme .dash-premium .panel,
  html.glass-theme .dash-premium .dash-panel {
    margin: 0 !important;
    width: 100%;
  }

  /* Common filter bars: full-width controls */
  .form-group {
    margin-bottom: 12px;
  }

  .form-control,
  select.form-control,
  textarea.form-control,
  .select2-container {
    max-width: 100% !important;
    width: 100% !important;
  }

  .input-group {
    width: 100%;
  }

  label.control-label {
    display: block;
    margin-bottom: 4px;
  }

  /* Buttons: wrap & touch-friendly */
  .btn {
    max-width: 100%;
  }

  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .btn-group > .btn {
    float: none;
    margin: 0 !important;
  }

  .mb-sm,
  .mb-md {
    margin-bottom: 10px !important;
  }

  /* DataTables chrome */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
    width: 100% !important;
    margin-bottom: 8px;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    display: block;
    margin-top: 6px;
  }

  .dataTables_wrapper .dataTables_paginate .pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Tables denser */
  .table > thead > tr > th,
  .table > tbody > tr > td,
  .table > tfoot > tr > td {
    white-space: nowrap;
    padding: 8px 10px !important;
    font-size: 0.84rem;
  }

  .table td.wrap,
  .table th.wrap {
    white-space: normal;
    min-width: 120px;
  }

  /* Modals nearly full-bleed */
  .modal-dialog,
  .bootbox .modal-dialog,
  .FormModal .modal-dialog,
  .form-modal-dialog {
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    margin: 10px auto !important;
  }

  .modal-body {
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Checkbox / radio rows */
  .checkbox-inline,
  .radio-inline {
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
    margin-bottom: 6px;
    white-space: normal;
  }

  .tab-content {
    padding-top: 10px;
  }

  .min-w-md,
  .mw-md {
    min-width: 0 !important;
  }

  .invoice-matrix,
  .fee-matrix,
  .attendance-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* ══════════════════ Narrow phones (≤480) ══════════════════ */
@media (max-width: 480px) {
  html.epx-app .content-body,
  html.glass-theme .content-body {
    padding: 6px 10px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .page-header h2,
  html.epx-app .page-header h2 {
    font-size: 1.1rem !important;
  }

  html.glass-theme .dash-welcome__metrics {
    grid-template-columns: 1fr !important;
  }

  html.glass-theme .dash-mini-metric {
    display: flex;
  }

  html.glass-theme .dash-stat-grid {
    gap: 8px !important;
  }

  html.glass-theme .dash-stat__meta {
    font-size: 0.7rem;
  }

  .btn-lg {
    padding: 8px 12px;
    font-size: 0.95rem;
  }

  .pull-right .btn + .btn {
    margin-left: 0 !important;
  }

  .well {
    padding: 12px !important;
  }

  html.epx-app .header .logo-env .logo img {
    max-width: 72px !important;
  }

  html.epx-app .header .header-menu-icon,
  html.epx-app .header .header-right .header-menu-icon,
  html.epx-app .header .toggle-sidebar-left {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-basis: 32px !important;
  }
}

/* ══════════════════ Landscape phones ══════════════════ */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  html.epx-app .content-body,
  html.glass-theme .content-body {
    padding-top: 8px !important;
    padding-bottom: 16px !important;
  }

  .page-header {
    margin-bottom: 8px !important;
  }

  .modal-body {
    max-height: calc(100dvh - 100px);
  }
}

/* ══════════════════ Print: hide chrome ══════════════════ */
@media print {
  .header,
  .sidebar-left,
  .toggle-sidebar-left,
  .er-dock {
    display: none !important;
  }

  .content-body {
    margin: 0 !important;
    padding: 0 !important;
  }
}

/*
 * Final mobile topbar pass — beat Porto min-width:200px / absolute hamburger
 * so dashboard icons stay evenly aligned on phones.
 */
@media (max-width: 767px) {
  html.epx-app header.header.epx-topbar {
    --epx-tb-icon: 34px;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    overflow: visible !important;
  }

  html.epx-app header.header.epx-topbar .logo-env {
    min-width: 0 !important;
    width: auto !important;
    max-width: 36vw !important;
    height: var(--epx-tb-icon) !important;
    background: none !important;
  }

  html.epx-app header.header.epx-topbar .logo-env .logo {
    display: inline-flex !important;
    align-items: center !important;
    max-width: calc(36vw - 44px);
    overflow: hidden;
  }

  html.epx-app header.header.epx-topbar .logo-env .logo img {
    height: 24px !important;
    max-width: 100% !important;
    width: auto !important;
  }

  html.epx-app header.header.epx-topbar .toggle-sidebar-left {
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: var(--epx-tb-icon) !important;
    height: var(--epx-tb-icon) !important;
    min-width: var(--epx-tb-icon) !important;
    border-radius: 10px !important;
  }

  html.epx-app header.header.epx-topbar .header-right {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: var(--epx-tb-icon) !important;
    gap: 3px !important;
    overflow: visible !important;
  }

  html.epx-app header.header.epx-topbar .header-right .header-menu {
    flex: 0 1 auto !important;
    justify-content: flex-end !important;
    gap: 3px !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: var(--epx-tb-icon) !important;
    overflow: visible !important;
  }

  html.epx-app header.header.epx-topbar .header-menu > li {
    float: none !important;
    margin: 0 !important;
    height: auto !important;
    min-height: var(--epx-tb-icon) !important;
    overflow: visible !important;
  }

  html.epx-app header.header.epx-topbar .header-menu-icon,
  html.epx-app header.header.epx-topbar .header-menu > li > a.header-menu-icon,
  html.epx-app header.header.epx-topbar .header-menu > li > .header-menu-icon {
    width: var(--epx-tb-icon) !important;
    height: var(--epx-tb-icon) !important;
    min-width: var(--epx-tb-icon) !important;
    border-radius: 10px !important;
  }

  html.epx-app header.header.epx-topbar .header-menu-icon:before {
    display: none !important;
    content: none !important;
  }

  html.epx-app header.header.epx-topbar .header-menu-icon i {
    font-size: 0.88rem !important;
  }

  html.epx-app header.header.epx-topbar .userbox,
  html.epx-app header.header.epx-topbar #userbox {
    height: var(--epx-tb-icon) !important;
    margin: 0 0 0 2px !important;
  }

  html.epx-app header.header.epx-topbar .userbox .profile-picture,
  html.epx-app header.header.epx-topbar .userbox .profile-picture img {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
  }

  /* Very small phones: hide branch + language to keep icons perfect */
  @media (max-width: 400px) {
    html.epx-app header.header.epx-topbar .epx-tb-branch {
      display: none !important;
    }

    html.epx-app header.header.epx-topbar {
      --epx-tb-icon: 32px;
    }
  }
}
