/* =============================================
   TilesERP — Google Material Palette
   ============================================= */
:root {
  --g-blue:   #4285F4;
  --g-red:    #EA4335;
  --g-yellow: #FBBC05;
  --g-green:  #34A853;

  --g-blue-dark:   #1a56d6;
  --g-red-dark:    #c5221f;
  --g-yellow-dark: #e37400;
  --g-green-dark:  #137333;

  --g-blue-light:   #8ab4f8;
  --g-green-light:  #81c995;
  --g-yellow-light: #fdd663;
  --g-red-light:    #f28b82;

  /* Dark Theme */
  --bg-primary:   #0a0e1a;
  --bg-secondary: #111827;
  --bg-card:      #1a2035;
  --bg-card-2:    #1e2a45;
  --bg-hover:     #253354;
  --bg-input:     #1e2842;
  --border:       #2a3a5c;
  --border-light: #374868;

  /* Text */
  --text-primary:   #e8eaf6;
  --text-secondary: #8892b0;
  --text-muted:     #546e8a;
  --text-white:     #ffffff;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --glow-blue:   0 0 20px rgba(66,133,244,0.3);
  --glow-green:  0 0 20px rgba(52,168,83,0.3);
  --glow-red:    0 0 20px rgba(234,67,53,0.3);
  --glow-yellow: 0 0 20px rgba(251,188,5,0.3);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Sidebar */
  --sidebar-w: 260px;
  --sidebar-collapsed: 68px;
  --header-h: 64px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 14px; }

body {
  font-family: 'Google Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--g-blue); }

/* ── Selection ── */
::selection { background: rgba(66,133,244,0.3); color: var(--text-white); }

/* =============================================
   LAYOUT
   ============================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
  flex-shrink: 0;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--g-blue) 0%, var(--g-green) 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: var(--glow-blue);
}

.logo-text { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; }
.logo-text strong { font-size: 15px; font-weight: 700; color: var(--text-white); letter-spacing: 0.3px; }
.logo-text span { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }

.sidebar.collapsed .logo-text { display: none; }

/* ── Nav ── */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { margin: 4px 0; }
.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-muted); padding: 12px 20px 4px;
  text-transform: uppercase; white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  color: var(--text-secondary); text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(66,133,244,0.15); color: var(--g-blue); }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--g-blue); border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { font-size: 13px; font-weight: 500; }
.sidebar.collapsed .nav-label { display: none; }

.nav-badge {
  margin-left: auto; background: var(--g-red);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}
.sidebar.collapsed .nav-badge { display: none; }

/* ── Main ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
  min-width: 0;
}
.main-content.collapsed { margin-left: var(--sidebar-collapsed); }

/* ── Header ── */
.top-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  gap: 16px;
}

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

.toggle-sidebar {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all var(--transition);
}
.toggle-sidebar:hover { background: var(--bg-hover); color: var(--text-primary); }

.page-title { font-size: 16px; font-weight: 600; color: var(--text-white); }

.header-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 16px;
  flex: 1; max-width: 360px;
}
.header-search input {
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; flex: 1;
  min-width: 0;
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search .search-icon { color: var(--text-muted); font-size: 16px; }

.header-right { display: flex; align-items: center; gap: 8px; }

.header-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all var(--transition);
  position: relative;
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-btn .badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--g-red); color: #fff; font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--g-blue), var(--g-green));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; cursor: pointer;
  flex-shrink: 0;
}

/* ── Page Content ── */
.page-content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* =============================================
   CARDS & GRID
   ============================================= */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
}
.card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-action {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px; border-radius: 4px;
  transition: color var(--transition);
}
.card-action:hover { color: var(--g-blue); }

/* ── Stat Cards ── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative; overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before   { background: var(--g-blue); box-shadow: var(--glow-blue); }
.stat-card.green::before  { background: var(--g-green); box-shadow: var(--glow-green); }
.stat-card.red::before    { background: var(--g-red); box-shadow: var(--glow-red); }
.stat-card.yellow::before { background: var(--g-yellow); box-shadow: var(--glow-yellow); }

.stat-card-inner { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-white); margin: 6px 0; line-height: 1; }
.stat-change { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.stat-change.up   { color: var(--g-green); }
.stat-change.down { color: var(--g-red); }

.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(66,133,244,0.15); color: var(--g-blue); }
.stat-icon.green  { background: rgba(52,168,83,0.15);  color: var(--g-green); }
.stat-icon.red    { background: rgba(234,67,53,0.15);  color: var(--g-red); }
.stat-icon.yellow { background: rgba(251,188,5,0.15);  color: var(--g-yellow); }

/* ── Mini Sparkline ── */
.sparkline { height: 40px; margin-top: 12px; }

/* =============================================
   TABLES
   ============================================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px; font-size: 13px; color: var(--text-primary);
  border-bottom: 1px solid rgba(42,58,92,0.5);
}
tr:hover td { background: rgba(255,255,255,0.02); }
tr:last-child td { border-bottom: none; }

/* =============================================
   BADGES & TAGS
   ============================================= */
.badge, .tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px;
}
.badge-blue   { background: rgba(66,133,244,0.15);  color: var(--g-blue-light); }
.badge-green  { background: rgba(52,168,83,0.15);   color: var(--g-green-light); }
.badge-red    { background: rgba(234,67,53,0.15);   color: var(--g-red-light); }
.badge-yellow { background: rgba(251,188,5,0.15);   color: var(--g-yellow-light); }
.badge-gray   { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; padding: 8px 18px;
  border-radius: var(--radius-sm); cursor: pointer;
  border: none; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  letter-spacing: 0.2px;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--g-blue); color: #fff; }
.btn-primary:hover { background: var(--g-blue-dark); box-shadow: var(--glow-blue); }

.btn-success { background: var(--g-green); color: #fff; }
.btn-success:hover { background: var(--g-green-dark); box-shadow: var(--glow-green); }

.btn-danger { background: var(--g-red); color: #fff; }
.btn-danger:hover { background: var(--g-red-dark); box-shadow: var(--glow-red); }

.btn-warning { background: var(--g-yellow); color: #111; }
.btn-warning:hover { background: var(--g-yellow-dark); box-shadow: var(--glow-yellow); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--g-blue); color: var(--g-blue); background: rgba(66,133,244,0.08); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

/* =============================================
   FORMS
   ============================================= */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; text-transform: uppercase; letter-spacing: 0.4px; }
.form-control {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px;
  padding: 9px 14px; transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--g-blue); box-shadow: 0 0 0 3px rgba(66,133,244,0.1); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* =============================================
   MODULE PAGES
   ============================================= */
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text-white); }
.page-header .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 16px; }
.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-muted); }

/* =============================================
   PROGRESS
   ============================================= */
.progress-bar {
  height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.8s ease;
}
.progress-fill.blue   { background: var(--g-blue); }
.progress-fill.green  { background: var(--g-green); }
.progress-fill.red    { background: var(--g-red); }
.progress-fill.yellow { background: var(--g-yellow); }

/* =============================================
   DONUT / CHART PLACEHOLDERS
   ============================================= */
.chart-container { width: 100%; position: relative; }
canvas { max-width: 100%; }

/* =============================================
   AI PANEL
   ============================================= */
.ai-panel {
  background: linear-gradient(135deg, rgba(66,133,244,0.08) 0%, rgba(52,168,83,0.08) 100%);
  border: 1px solid rgba(66,133,244,0.2);
  border-radius: var(--radius-lg); padding: 20px;
}
.ai-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.ai-badge {
  background: linear-gradient(135deg, var(--g-blue), var(--g-green));
  color: #fff; font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; letter-spacing: 0.5px;
}
.ai-insight {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.ai-insight:last-child { margin-bottom: 0; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.ai-dot.blue   { background: var(--g-blue); box-shadow: var(--glow-blue); }
.ai-dot.green  { background: var(--g-green); box-shadow: var(--glow-green); }
.ai-dot.yellow { background: var(--g-yellow); box-shadow: var(--glow-yellow); }
.ai-dot.red    { background: var(--g-red); box-shadow: var(--glow-red); }
.ai-insight-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }

/* =============================================
   INVENTORY TILES
   ============================================= */
.tile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; transition: all var(--transition);
  cursor: pointer;
}
.tile-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--g-blue); }
.tile-preview {
  height: 100px; position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
}
.tile-card-body { padding: 14px; }
.tile-name { font-size: 13px; font-weight: 600; color: var(--text-white); margin-bottom: 4px; }
.tile-code { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; font-family: monospace; }
.tile-meta { display: flex; gap: 8px; flex-wrap: wrap; }

/* =============================================
   KPI ROW
   ============================================= */
.kpi-row { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.kpi-item { display: flex; align-items: center; gap: 8px; }
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kpi-label { font-size: 12px; color: var(--text-muted); }
.kpi-val { font-size: 13px; font-weight: 700; color: var(--text-white); margin-left: 4px; }

/* =============================================
   NOTIFICATIONS / ALERTS
   ============================================= */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 8px; border-left: 3px solid;
}
.alert-blue   { background: rgba(66,133,244,0.08);  border-color: var(--g-blue); }
.alert-green  { background: rgba(52,168,83,0.08);   border-color: var(--g-green); }
.alert-red    { background: rgba(234,67,53,0.08);   border-color: var(--g-red); }
.alert-yellow { background: rgba(251,188,5,0.08);   border-color: var(--g-yellow); }
.alert-icon { font-size: 18px; flex-shrink: 0; }
.alert-text { font-size: 13px; color: var(--text-primary); }
.alert-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* =============================================
   TABS
   ============================================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--g-blue); border-bottom-color: var(--g-blue); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px;
  width: 90%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-white); }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-hover); border: none; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all var(--transition);
}
.modal-close:hover { background: var(--g-red); color: #fff; }

/* =============================================
   WHATSAPP PANEL
   ============================================= */
.wa-btn {
  background: #25D366; color: #fff;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; padding: 8px 18px;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  transition: all var(--transition);
}
.wa-btn:hover { background: #128C7E; box-shadow: 0 0 20px rgba(37,211,102,0.3); }

/* =============================================
   LOADING / SKELETON
   ============================================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================
   LIVE INDICATOR
   ============================================= */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--g-green);
  box-shadow: 0 0 0 0 rgba(52,168,83,0.4);
  animation: pulse-live 1.5s infinite;
  display: inline-block;
}
@keyframes pulse-live {
  0%   { box-shadow: 0 0 0 0 rgba(52,168,83,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(52,168,83,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,168,83,0); }
}

/* =============================================
   MOBILE OVERLAY
   ============================================= */
.mobile-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 199;
  -webkit-tap-highlight-color: transparent;
}
.mobile-overlay.show { display: block; }

/* =============================================
   MOBILE BOTTOM NAV — hidden by default (shown via JS)
   ============================================= */
.mobile-nav-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 150;
  height: 58px;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; padding: 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 10px; font-weight: 500;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none;
  min-width: 0;
}
.mobile-nav-item .mn-icon { font-size: 22px; line-height: 1; }
.mobile-nav-item.active  { color: var(--g-blue); }
.mobile-nav-item:active  { background: var(--bg-hover); border-radius: var(--radius-sm); }

/* =============================================
   SCROLLABLE TABLES — all screens
   ============================================= */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
.table-wrap table { min-width: 600px; }

/* Mobile-card table: transform table rows into cards on narrow screens */
@media (max-width: 600px) {
  .table-card thead { display: none; }
  .table-card, .table-card tbody, .table-card tr, .table-card td {
    display: block; width: 100%;
  }
  .table-card tr {
    background: var(--bg-card-2); border: 1px solid var(--border);
    border-radius: var(--radius-md); margin-bottom: 10px; padding: 12px;
  }
  .table-card td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; font-size: 12px; border-bottom: 1px solid rgba(42,58,92,0.4);
  }
  .table-card td:last-child { border-bottom: none; padding-bottom: 0; }
  .table-card td::before {
    content: attr(data-label);
    color: var(--text-muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.4px; flex-shrink: 0; margin-right: 8px;
  }
}

/* =============================================
   BREAKPOINTS
   ============================================= */
@media (max-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Tablet (769px – 900px) ── */
@media (max-width: 900px) {
  .page-content { padding: 16px; }
  .chart-container canvas { max-height: 260px; }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {

  /* ── Sidebar ── */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(0,0,0,0.7);
  }
  .sidebar.mobile-open .logo-text,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-section-title { display: block !important; opacity: 1 !important; }
  .sidebar.mobile-open .nav-badge         { display: inline-flex !important; }

  /* ── Main layout ── */
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 12px 10px 74px; } /* bottom pad clears bottom nav */

  /* ── Top header ── */
  .top-header { padding: 0 10px; gap: 8px; height: 54px; }
  .page-title  { font-size: 14px; }
  .header-search { display: none; } /* show in a search modal instead */
  .header-btn-hide { display: none; } /* hide non-essential header buttons */

  /* ── Grids → responsive ── */
  .grid-2 { grid-template-columns: repeat(2, 1fr); } /* keep 2-col for stat pairs */
  .grid-3,
  .grid-4,
  .grid-5,
  .grid-6 { grid-template-columns: repeat(2, 1fr); }

  /* ── Page header ── */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  .page-header h1 { font-size: 18px; }
  .page-header .ph-actions { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
  .page-header .ph-actions .btn { flex: 1; min-width: 120px; justify-content: center; }
  .page-header .ph-actions select { flex: 1; min-width: 120px; }

  /* ── Cards ── */
  .card { padding: 14px 12px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header .btn, .card-header select { font-size: 11px; padding: 5px 10px; }

  /* ── Stat cards ── */
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 20px !important; }
  .stat-label { font-size: 11px; }
  .stat-icon  { width: 38px; height: 38px; font-size: 18px; }
  .stat-change { font-size: 11px; }

  /* ── Charts ── */
  .chart-container { height: 200px !important; }
  canvas { max-height: 200px; }

  /* ── Tabs ── */
  .tabs {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; gap: 0;
    scrollbar-width: none; /* Firefox */
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 10px 14px; white-space: nowrap; font-size: 12px; flex-shrink: 0; }

  /* ── Modals → full-screen ── */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 20px 16px;
    animation: modalSlideUp .25s ease;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* ── Forms ── */
  .form-row { grid-template-columns: 1fr; gap: 0; }

  /* ── AI panel ── */
  .ai-panel { padding: 14px 12px; }

  /* ── Buttons ── */
  .btn { min-height: 40px; }

  /* ── Tile cards grid ── */
  .tile-card .tile-preview { height: 70px; }

  /* ── Table: hide lower-priority cols on mobile via class ── */
  .mobile-hide { display: none !important; }

  /* ── Bottom nav bar ── */
  .mobile-nav-bar { display: flex; }

  /* ── Install banner ── */
  .install-banner { bottom: 70px; left: 8px; right: 8px; }
}

/* ── Small phones (≤420px) ── */
@media (max-width: 420px) {
  .page-content { padding: 8px 8px 74px; }
  .grid-2 { grid-template-columns: 1fr; }          /* single col on very small */
  .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
  .stat-value { font-size: 18px !important; }
  .top-header { padding: 0 8px; }
  .modal { padding: 16px 12px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .badge, .tag { font-size: 10px; padding: 2px 7px; }
  .wa-btn { font-size: 12px; padding: 6px 12px; }
}

/* ── Touch targets ── */
@media (hover: none) and (pointer: coarse) {
  .nav-item     { min-height: 44px; }
  .btn          { min-height: 44px; }
  .tab          { min-height: 42px; }
  .form-control { min-height: 44px; font-size: 16px; } /* prevents iOS zoom */
  select.form-control { font-size: 16px; }
}

/* =============================================
   PRINT
   ============================================= */
@media print {
  .sidebar, .top-header { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { border: 1px solid #ccc !important; }
}

/* =============================================
   MISC
   ============================================= */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-blue   { color: var(--g-blue); }
.text-green  { color: var(--g-green); }
.text-red    { color: var(--g-red); }
.text-yellow { color: var(--g-yellow); }
.fw-bold { font-weight: 700; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none; }
.rounded { border-radius: var(--radius-sm); }
.overflow-hidden { overflow: hidden; }
.cursor-pointer { cursor: pointer; }

/* Install Banner */
.install-banner {
  display: none;
  position: fixed;
  bottom: 80px; /* above mobile bottom bar */
  left: 12px; right: 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--g-blue);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 9998;
  gap: 12px;
  align-items: center;
  animation: slideUpBanner .35s ease;
}
.install-banner.show { display: flex; }
@keyframes slideUpBanner {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (min-width: 500px) {
  .install-banner { left: auto; right: 20px; max-width: 340px; bottom: 24px; }
}
