/* ==========================================================================
   THEME 3: STYLE.CSS - PRECISION PHARMA HUB (HIGH-CONTRAST UTILITY)
   ========================================================================== */

/* 1. RESET & BASE */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow: hidden;
}

h1, h2, h3, h4, .brand-title {
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
}

.num, .kpi-value, .table-cell-num {
  font-variant-numeric: tabular-nums;
}

/* 2. APP SHELL LAYOUT */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   SIDEBAR (DEEP FOREST GREEN & CRISP ACCENTS)
   ========================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  z-index: 40;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  color: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: #ffffff;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 45;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #ffffff;
}

.brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.brand-title-wrap h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
}

.brand-title-wrap span {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: block;
}

/* Role Selector */
.sidebar-role-panel {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-role-panel label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.role-select-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.15s;
}

.role-select-input:focus {
  border-color: var(--primary);
}

/* Nav Menu */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.nav-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  width: 18px;
  font-size: 0.95rem;
  text-align: center;
  color: #a7f3d0;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-link:hover .nav-icon {
  color: #ffffff;
}

.nav-item.active .nav-link {
  background: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.nav-item.active .nav-icon {
  color: #ffffff !important;
}

.nav-item.active .nav-pill {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
}

.nav-pill {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.user-name {
  font-size: 0.825rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.user-role-tag {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.app-topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 30;
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle-btn {
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-surface-alt);
  border-color: var(--primary);
  color: var(--primary);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb .divider {
  font-size: 0.7rem;
  color: var(--text-subtle);
}

.breadcrumb .active {
  font-weight: 700;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-search-btn {
  display: none;
}

.topbar-role-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.global-search-box {
  position: relative;
  width: 270px;
}

.global-search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 0.9rem;
}

.global-search-box input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.15s;
}

.global-search-box input:focus {
  background: var(--bg-surface);
  border-color: var(--primary);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--bg-surface-alt);
  border-color: var(--primary);
  color: var(--primary);
}

.icon-badge-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.ai-copilot-btn {
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.ai-copilot-btn:hover {
  background: var(--primary-hover);
}

/* Workspace Scroll Area */
.app-workspace {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Page Header & Actions */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title-box h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-title-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: inherit;
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-medium);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border-strong);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-medium);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-surface-alt);
}

/* ==========================================================================
   HIGH CONTRAST KPI CARDS
   ========================================================================== */
.kpi-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1.1;
  font-family: var(--font-heading);
}

.kpi-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.775rem;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.trend-badge.up {
  background: var(--success-bg);
  color: var(--success-text);
}

.trend-badge.down {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.kpi-subtext {
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   ANALYTICS & AI SPLIT
   ========================================================================== */
.analytics-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 1024px) {
  .analytics-split {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 18px;
}

/* Chart Bars */
.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 190px;
  padding-top: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.bars-stack {
  width: 100%;
  max-width: 40px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  height: 100%;
  justify-content: flex-start;
}

.bar-segment {
  width: 100%;
  border-radius: var(--radius-xs);
  transition: height 0.2s ease;
  position: relative;
}

.bar-segment.antibiotic { background: var(--primary); }
.bar-segment.cardio { background: var(--secondary); }
.bar-segment.vitamins { background: var(--accent); }

.chart-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  font-size: 0.775rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* AI Copilot Card */
.ai-card {
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ai-recommendation-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-item {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 12px;
  position: relative;
}

.ai-item-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ai-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.ai-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.ai-btn-sm {
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-btn-sm:hover {
  background: var(--primary-hover);
}

/* ==========================================================================
   DATA GRID (CLEAR BORDERS & ACCESSIBLE)
   ========================================================================== */
.grid-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.grid-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.grid-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-search-box {
  position: relative;
  width: 230px;
}

.grid-search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.grid-search-box input {
  width: 100%;
  padding: 6px 12px 6px 30px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.825rem;
  outline: none;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-grid th {
  background: var(--bg-surface-alt);
  padding: 12px 14px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-medium);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-grid td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  white-space: nowrap;
}

.data-grid tbody tr:hover {
  background-color: var(--bg-surface-alt);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

.grid-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.page-btn.active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

/* AI DRAWER & MODAL */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 390px;
  max-width: 90vw;
  background: var(--bg-surface);
  box-shadow: var(--shadow-drawer);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.drawer-overlay.open .ai-drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-bubble-ai {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.drawer-input-wrap {
  display: flex;
  gap: 8px;
}

.drawer-input-wrap input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  outline: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  width: 580px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  font-size: 0.85rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   MOBILE & RESPONSIVE ADAPTATIONS (PRECISION PHARMA HUB)
   ========================================================================== */

/* Tablet & Mobile: Collapsible Sidebar Drawer */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 84vw;
    transform: translateX(-100%);
    box-shadow: var(--shadow-drawer);
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .global-search-box {
    display: none;
  }
}

/* Mobile Screens: Topbar Overflow Fix, Touch Actions & Component Scaling */
@media (max-width: 768px) {
  .app-container {
    width: 100vw;
    overflow-x: hidden;
  }

  .app-main {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Fixed Header Bar - No Overflow */
  .app-topbar {
    padding: 0 10px;
    height: 54px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
    gap: 8px;
  }

  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .breadcrumb {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.8rem;
    gap: 4px;
  }

  .breadcrumb a,
  .breadcrumb .divider {
    display: none;
  }

  .breadcrumb .active {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.825rem;
    font-weight: 700;
    max-width: 140px;
    display: inline-block;
  }

  .topbar-right {
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
  }

  .mobile-search-btn {
    display: flex !important;
    width: 34px;
    height: 34px;
  }

  .topbar-role-wrap {
    display: none !important;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  /* AI Copilot Button compact icon on mobile */
  .ai-copilot-btn {
    padding: 0 !important;
    width: 34px !important;
    height: 34px !important;
    justify-content: center !important;
    border-radius: var(--radius-sm);
    position: relative;
  }

  .ai-copilot-btn .ai-btn-text,
  .ai-copilot-btn span {
    display: none !important;
  }

  .ai-copilot-btn i {
    font-size: 0.95rem;
    margin: 0;
  }

  /* Workspace Padding with Bottom Nav Compensation */
  .app-workspace {
    padding: 12px 10px 85px 10px !important;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-title-box h1 {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  .page-title-box p {
    font-size: 0.775rem;
    line-height: 1.4;
  }

  .page-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
  }

  .page-actions .btn {
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 6px 12px;
    white-space: nowrap;
  }

  /* Grid Toolbar Touch Optimization */
  .grid-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .grid-actions-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  .grid-search-box {
    width: 100% !important;
  }

  .grid-filter-pills {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  .grid-filter-pills .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-xs);
  }

  .card-header {
    padding: 12px 14px;
  }

  .card-body {
    padding: 12px 14px;
  }

  .modal-box {
    width: 95vw !important;
    max-width: 95vw !important;
    margin: 8px auto !important;
  }

  .ai-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
  }
}

/* Compact Mobile (< 540px) Phone Tweaks */
@media (max-width: 540px) {
  .kpi-container {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .kpi-card {
    padding: 10px 12px;
  }

  .kpi-label {
    font-size: 0.68rem;
  }

  .kpi-icon {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  .kpi-value {
    font-size: 1.25rem;
    margin-bottom: 3px;
  }

  .kpi-bottom {
    font-size: 0.68rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .kpi-subtext {
    display: none;
  }

  .breadcrumb .active {
    max-width: 105px;
  }
}
