/* ============================================================
   Bitnova ERP – v1.3 UI
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bn-blue:        #1E90FF;
  --bn-blue-dark:   #0070e0;
  --bn-blue-light:  #e8f4ff;
  --bn-blue-mid:    #c2e0ff;
  --bn-green:       #858381;
  --bn-green-light: #f0fdf4;
  --bn-sidebar-w:   220px;
  --bn-topbar-h:    58px;
  --bn-radius:      12px;
  --bn-radius-sm:   8px;
  --bn-shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --bn-shadow-md:   0 4px 16px rgba(0,0,0,.08);
  --bn-border:      #e5e7eb;
  --bn-text:        #111827;
  --bn-text-2:      #374151;
  --bn-muted:       #6b7280;
  --bn-bg:          #f3f4f6;
  --bn-white:       #ffffff;
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bn-bg);
  color: var(--bn-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.bn-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1050;
  height: var(--bn-topbar-h);
  background: var(--bn-white);
  border-bottom: 1px solid var(--bn-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 0 0;
  box-shadow: var(--bn-shadow);
}
.bn-topbar-left { display: flex; align-items: center; }
.bn-topbar-right { display: flex; align-items: center; gap: 8px; }

.bn-brand-area {
  width: var(--bn-sidebar-w);
  height: var(--bn-topbar-h);
  display: flex; align-items: center; padding: 0 20px;
  border-right: 1px solid var(--bn-border);
  flex-shrink: 0;
}
.bn-brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--bn-blue); text-decoration: none;
  font-weight: 800; font-size: 18px; letter-spacing: -.4px;
}
.bn-brand:hover { color: var(--bn-blue-dark); text-decoration: none; }

.bn-sidebar-toggle {
  background: none; border: none; border-radius: var(--bn-radius-sm);
  width: 40px; height: 40px; margin-left: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--bn-muted); cursor: pointer; font-size: 20px;
  flex-shrink: 0;
}
.bn-sidebar-toggle:hover { background: var(--bn-bg); color: var(--bn-text); }

.bn-topbar-link {
  color: var(--bn-text-2); font-size: 13.5px; font-weight: 600;
  text-decoration: none; padding: 6px 12px; border-radius: var(--bn-radius-sm);
}
.bn-topbar-link:hover { background: var(--bn-bg); color: var(--bn-text); text-decoration: none; }
.bn-topbar-date { color: var(--bn-muted); font-size: 12.5px; padding: 0 4px; }

.bn-notif-btn {
  position: relative; background: none; border: 1px solid var(--bn-border);
  border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--bn-text-2); cursor: pointer; font-size: 18px;
}
.bn-notif-btn:hover { background: var(--bn-bg); }
.bn-notif-badge {
  position: absolute; top: -3px; right: -3px;
  background: #ef4444; color: white; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid white; pointer-events: none;
}
.bn-notif-dropdown { width: 340px !important; }
.bn-notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; text-decoration: none;
  color: var(--bn-text); border-bottom: 1px solid var(--bn-border);
}
.bn-notif-item:last-child { border-bottom: none; }
.bn-notif-item:hover { background: var(--bn-bg); color: var(--bn-text); text-decoration: none; }
.bn-notif-item.unread { background: var(--bn-blue-light); }
.bn-notif-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.bn-notif-icon.blue,.bn-notif-icon.info    { background: var(--bn-blue-mid); color: var(--bn-blue); }
.bn-notif-icon.green,.bn-notif-icon.success{ background: #dcfce7; color: #166534; }
.bn-notif-icon.amber,.bn-notif-icon.warning{ background: #fef3c7; color: #92400e; }
.bn-notif-icon.danger,.bn-notif-icon.red   { background: #fee2e2; color: #991b1b; }
.bn-notif-icon.teal   { background: #ccfbf1; color: #0f766e; }
.bn-notif-icon.purple { background: #ede9fe; color: #6d28d9; }
.bn-notif-icon.muted  { background: #f3f4f6; color: #6b7280; }
.bn-notif-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.bn-notif-msg   { font-size: 12px; color: var(--bn-muted); margin-top: 2px; }
.bn-notif-time  { font-size: 11px; color: #9ca3af; margin-top: 3px; }

.bn-topbar-user {
  background: none; border: 1px solid var(--bn-border);
  border-radius: 40px; padding: 4px 10px 4px 4px;
  color: var(--bn-text); display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.bn-topbar-user:hover { background: var(--bn-bg); }
.bn-topbar-user-info { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.bn-topbar-user-role { font-size: 11px; color: var(--bn-muted); font-weight: 400; }
.bn-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bn-blue); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  color: white; flex-shrink: 0;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.bn-sidebar {
  position: fixed;
  top: var(--bn-topbar-h);
  left: 0;
  bottom: 0;
  width: var(--bn-sidebar-w);
  background: var(--bn-white);
  border-right: 1px solid var(--bn-border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease, width .25s ease;
  /* Default: visible on desktop, hidden on mobile */
  transform: translateX(0);
}

/* ── MAIN ────────────────────────────────────────────────── */
.bn-main {
  margin-left: var(--bn-sidebar-w);
  margin-top: var(--bn-topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--bn-topbar-h));
  transition: margin-left .25s ease;
  /* Prevent content from overflowing horizontally */
  overflow-x: hidden;
}

/* ── OVERLAY ─────────────────────────────────────────────── */
.bn-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1030;
}

/* ── SIDEBAR CREATE BUTTON ───────────────────────────────── */
.bn-create-btn {
  margin: 14px 16px 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bn-green); color: white; border: none;
  border-radius: var(--bn-radius-sm); padding: 9px 16px;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  width: calc(100% - 32px); flex-shrink: 0;
}
.bn-create-btn:hover { background: #15803d; color: white; text-decoration: none; }
.bn-create-btn i { font-size: 16px; }

/* ── NAV ─────────────────────────────────────────────────── */
.bn-nav { padding: 4px 0 16px; flex: 1; }

.bn-nav-section,
.bn-nav-divider {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--bn-blue);
  padding: 14px 16px 5px;
}

.bn-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; color: var(--bn-text-2);
  text-decoration: none; font-size: 13px; font-weight: 500;
  white-space: nowrap;
  /* NO position: relative here — avoids pseudo-element click interference */
  transition: background .12s, color .12s;
}
.bn-nav-item i { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; color: var(--bn-muted); }
.bn-nav-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.bn-nav-item:hover { background: var(--bn-bg); color: var(--bn-text); text-decoration: none; }
.bn-nav-item:hover i { color: var(--bn-text-2); }
.bn-nav-item.active {
  background: var(--bn-blue-light); color: var(--bn-blue); font-weight: 600;
  border-left: 3px solid var(--bn-blue);
  padding-left: 13px; /* compensate for border */
}
.bn-nav-item.active i { color: var(--bn-blue); }

.bn-sidebar-footer { border-top: 1px solid var(--bn-border); padding: 6px 0; flex-shrink: 0; }

/* ── DESKTOP COLLAPSED SIDEBAR ───────────────────────────── */
.bn-sidebar.collapsed {
  width: 60px;
}
.bn-sidebar.collapsed .bn-create-btn {
  width: 36px; height: 36px; padding: 0; margin: 14px auto 8px;
  justify-content: center; border-radius: 50%;
}
.bn-sidebar.collapsed .bn-create-btn span,
.bn-sidebar.collapsed .bn-nav-section,
.bn-sidebar.collapsed .bn-nav-divider,
.bn-sidebar.collapsed .bn-nav-item span {
  display: none;
}
.bn-sidebar.collapsed .bn-nav-item {
  justify-content: center;
  padding: 10px 0;
  border-left: none;
  /* Use title attribute for native tooltip instead of CSS pseudo-elements */
}
.bn-sidebar.collapsed .bn-nav-item.active {
  border-left: 3px solid var(--bn-blue);
  padding-left: 0;
}
.bn-sidebar.collapsed .bn-nav-item i { width: auto; margin: 0; }
.bn-main.sidebar-collapsed { margin-left: 60px; }

/* ── MOBILE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bn-sidebar {
    transform: translateX(-100%);
    width: var(--bn-sidebar-w) !important; /* always full width on mobile */
  }
  .bn-sidebar.mobile-open {
    transform: translateX(0);
  }
  .bn-overlay.active { display: block; }
  .bn-main {
    margin-left: 0 !important;
    padding: 16px;
  }
  .bn-brand-area { display: none; }
  .bn-topbar { padding: 0 12px; }
  .bn-topbar-date { display: none !important; }
  .bn-topbar-user-info { display: none !important; }
}

/* ── PERIOD BAR ──────────────────────────────────────────── */
.bn-period-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.bn-period-label { font-size: 14px; font-weight: 600; color: var(--bn-text); }
.bn-period-select {
  display: inline-flex; align-items: center; gap: 6px;
  background: white; border: 1px solid var(--bn-border);
  border-radius: var(--bn-radius-sm); padding: 7px 12px;
  font-size: 13px; font-weight: 500; color: var(--bn-text);
  cursor: pointer; box-shadow: var(--bn-shadow);
}

/* ── STAT CARDS ──────────────────────────────────────────── */
.bn-stat-card {
  background: white; border-radius: var(--bn-radius);
  border: 1px solid var(--bn-border); box-shadow: var(--bn-shadow);
  padding: 20px 22px; display: flex; align-items: flex-start;
  gap: 16px; height: 100%;
}
.bn-stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.bn-stat-icon.blue,.bn-stat-icon.info     { background: var(--bn-blue-mid); color: var(--bn-blue); }
.bn-stat-icon.green,.bn-stat-icon.success { background: #dcfce7; color: #16a34a; }
.bn-stat-icon.amber,.bn-stat-icon.warning { background: #fef3c7; color: #d97706; }
.bn-stat-icon.red,.bn-stat-icon.danger    { background: #fee2e2; color: #dc2626; }
.bn-stat-icon.teal    { background: #ccfbf1; color: #0d9488; }
.bn-stat-icon.purple  { background: #ede9fe; color: #7c3aed; }
.bn-stat-icon.coral   { background: #ffedd5; color: #ea580c; }
.bn-stat-icon.muted   { background: #f3f4f6; color: #6b7280; }
.bn-stat-icon.pink    { background: #fce7f3; color: #db2777; }
.bn-stat-body { flex: 1; min-width: 0; }
.bn-stat-label { font-size: 12.5px; color: var(--bn-muted); font-weight: 500; display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.bn-stat-num { font-size: 22px; font-weight: 800; color: var(--bn-text); line-height: 1; margin-bottom: 6px; letter-spacing: -.5px; word-break: break-word; }
.bn-stat-num.sm { font-size: 17px; }
.bn-stat-trend { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.bn-stat-trend.up   { color: #16a34a; }
.bn-stat-trend.down { color: #dc2626; }
.bn-stat-sub { font-size: 11.5px; color: var(--bn-muted); margin-top: 3px; }

/* ── QUICK ACTION CARDS ──────────────────────────────────── */
.bn-quick-card {
  background: white; border: 1px solid var(--bn-border);
  border-radius: var(--bn-radius); box-shadow: var(--bn-shadow);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--bn-text);
  transition: box-shadow .18s, border-color .18s, transform .18s;
  height: 100%;
}
.bn-quick-card:hover {
  box-shadow: var(--bn-shadow-md); transform: translateY(-1px);
  text-decoration: none; color: var(--bn-text); border-color: var(--bn-blue-mid);
}
.bn-quick-card-label { font-size: 13px; font-weight: 600; flex: 1; }
.bn-quick-card-arrow { color: var(--bn-muted); font-size: 16px; flex-shrink: 0; transition: transform .15s; }
.bn-quick-card:hover .bn-quick-card-arrow { transform: translateX(3px); color: var(--bn-blue); }

/* ── PROMO BANNER ────────────────────────────────────────── */
.bn-promo-banner {
  background: white; border: 1px solid var(--bn-border);
  border-radius: var(--bn-radius); box-shadow: var(--bn-shadow);
  padding: 18px 22px; display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.bn-promo-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: #dcfce7; color: #16a34a;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.bn-promo-title { font-size: 15px; font-weight: 700; color: var(--bn-text); }
.bn-promo-desc  { font-size: 12.5px; color: var(--bn-muted); margin-top: 2px; }
.bn-badge-new {
  background: var(--bn-blue); color: white; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; margin-left: 6px;
}
.bn-promo-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bn-promo-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: white; border: 1px solid var(--bn-border);
  border-radius: var(--bn-radius-sm); padding: 7px 14px;
  font-size: 12.5px; font-weight: 600; color: var(--bn-text);
  cursor: pointer; text-decoration: none;
}
.bn-promo-btn:hover { background: var(--bn-bg); color: var(--bn-text); text-decoration: none; }
.bn-promo-btn i { font-size: 14px; color: var(--bn-muted); }

/* ── CHART CONTAINERS — fixed height prevents infinite expand ── */
.bn-chart-wrap {
  position: relative;
  width: 100%;
  height: 260px; /* fixed pixel height — Chart.js reads this */
}
.bn-chart-wrap.donut {
  height: 220px;
}

/* ── CHART TABS ──────────────────────────────────────────── */
.bn-chart-tabs {
  display: flex; gap: 2px;
  background: var(--bn-bg); border-radius: var(--bn-radius-sm); padding: 3px;
}
.bn-chart-tab {
  padding: 5px 14px; border-radius: 6px; font-size: 12.5px;
  font-weight: 600; color: var(--bn-muted); cursor: pointer;
  border: none; background: none;
}
.bn-chart-tab.active { background: var(--bn-blue); color: white; }
.bn-chart-title { font-size: 14px; font-weight: 700; color: var(--bn-blue); margin-bottom: 14px; }

/* ── CARDS ───────────────────────────────────────────────── */
.bn-card {
  background: white; border-radius: var(--bn-radius);
  border: 1px solid var(--bn-border); box-shadow: var(--bn-shadow);
  margin-bottom: 20px; overflow: hidden;
}
.bn-card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--bn-border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.bn-card-title {
  font-weight: 700; font-size: 14.5px; margin: 0;
  display: flex; align-items: center; color: var(--bn-text);
}
.bn-card-title i { font-size: 17px; color: var(--bn-blue); margin-right: 7px; }
.bn-card-body { padding: 20px; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.bn-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 10px;
}
.bn-page-title { font-size: 19px; font-weight: 700; margin: 0; color: var(--bn-text); }
.bn-btn-home {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bn-blue-light); color: var(--bn-blue);
  border: 1px solid var(--bn-blue-mid); border-radius: var(--bn-radius-sm);
  padding: 7px 16px; font-size: 13px; font-weight: 500; text-decoration: none;
}
.bn-btn-home:hover { background: var(--bn-blue); color: white; text-decoration: none; }

/* ── MODULE CARDS ────────────────────────────────────────── */
.bn-module-card {
  background: white; border-radius: var(--bn-radius);
  border: 1px solid var(--bn-border); padding: 22px 18px 18px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; text-decoration: none; color: var(--bn-text);
  transition: border-color .2s, box-shadow .2s, transform .2s;
  box-shadow: var(--bn-shadow); height: 100%;
}
.bn-module-card:hover {
  border-color: var(--bn-blue); transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(30,144,255,.12);
  color: var(--bn-text); text-decoration: none;
}
.bn-mod-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--bn-blue-light); color: var(--bn-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 12px;
}
.bn-mod-icon--blue   { background: var(--bn-blue-mid);  color: var(--bn-blue); }
.bn-mod-icon--teal   { background: #ccfbf1; color: #0d9488; }
.bn-mod-icon--amber  { background: #fef3c7; color: #d97706; }
.bn-mod-icon--coral  { background: #ffedd5; color: #ea580c; }
.bn-mod-icon--green  { background: #dcfce7; color: #16a34a; }
.bn-mod-icon--purple { background: #ede9fe; color: #7c3aed; }
.bn-mod-icon--pink   { background: #fce7f3; color: #db2777; }
.bn-mod-icon--red    { background: #fee2e2; color: #dc2626; }
.bn-mod-icon--muted  { background: #f3f4f6; color: #6b7280; }
.bn-mod-name { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.bn-mod-desc { font-size: 11.5px; color: var(--bn-muted); line-height: 1.5; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.bn-btn-primary {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bn-blue); color: white; border: none;
  border-radius: var(--bn-radius-sm); padding: 8px 18px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.bn-btn-primary:hover { background: var(--bn-blue-dark); color: white; text-decoration: none; }

/* ── BADGES ──────────────────────────────────────────────── */
.bn-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bn-badge.success,.bn-badge.green  { background: #dcfce7; color: #166534; }
.bn-badge.warning,.bn-badge.amber  { background: #fef3c7; color: #92400e; }
.bn-badge.danger,.bn-badge.red     { background: #fee2e2; color: #991b1b; }
.bn-badge.info,.bn-badge.blue      { background: var(--bn-blue-mid); color: #0058b0; }
.bn-badge.muted   { background: #f3f4f6; color: #6b7280; }
.bn-badge.purple  { background: #ede9fe; color: #6d28d9; }
.bn-badge.teal    { background: #ccfbf1; color: #0f766e; }
.bn-badge.coral   { background: #ffedd5; color: #c2410c; }
.bn-badge.pink    { background: #fce7f3; color: #be185d; }

/* ── TABLE ───────────────────────────────────────────────── */
.bn-table { width: 100%; border-collapse: collapse; }
.bn-table th {
  background: var(--bn-bg); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--bn-muted); padding: 10px 16px;
  border-bottom: 1px solid var(--bn-border); white-space: nowrap;
}
.bn-table td { padding: 12px 16px; border-bottom: 1px solid var(--bn-border); vertical-align: middle; font-size: 13.5px; }
.bn-table tr:last-child td { border-bottom: none; }
.bn-table tbody tr:hover td { background: var(--bn-blue-light); }

/* ── FORMS ───────────────────────────────────────────────── */
.bn-form-label { font-size: 13px; font-weight: 600; margin-bottom: 5px; display: block; color: var(--bn-text); }

/* ── LOGIN ───────────────────────────────────────────────── */
.bn-login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1E90FF 0%, #0070e0 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.bn-login-card {
  background: white; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.bn-login-logo { text-align: center; margin-bottom: 28px; }
.bn-login-logo .brand-icon {
  width: 58px; height: 58px; background: var(--bn-blue);
  border-radius: 14px; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 10px; font-size: 28px; color: white;
}

/* ============================================================
   MOBILE RESPONSIVE — v2.0
   Covers all breakpoints for every ERP module
   ============================================================ */

/* ── GLOBAL RESETS FOR MOBILE ────────────────────────────── */
img { max-width: 100%; height: auto; }
* { -webkit-tap-highlight-color: rgba(0,0,0,0); }

/* Make ALL tables scroll horizontally on small screens */
.bn-table, table.table {
  min-width: 0;
}
.bn-card-body:has(> .bn-table),
.card-body:has(> table),
.card:has(> table),
.bn-card:has(> .bn-card-body > .bn-table) {
  overflow-x: auto;
}
/* Universal table-responsive via wrapper — applied to every table in bn-card-body */
.bn-card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* But don't scroll the whole card body for forms etc — only when table present */
.bn-card-body:not(:has(table)) { overflow-x: visible; }

/* ── RESPONSIVE TABLE WRAPPER ────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

/* ── BREAKPOINT: Tablet (≤ 992px) ───────────────────────── */
@media (max-width: 992px) {
  :root { --bn-sidebar-w: 240px; }
  .bn-main { padding: 20px; }

  /* Stat cards: 2 per row on tablet */
  .bn-stat-num { font-size: 19px; }

  /* Page header wraps on tablet */
  .bn-page-header { gap: 8px; }
  .bn-page-header .d-flex.gap-2 { flex-wrap: wrap; }

  /* Hide less-important topbar items */
  .bn-topbar-link { display: none; }
  .bn-topbar-date { display: none !important; }
}

/* ── BREAKPOINT: Mobile (≤ 768px) ───────────────────────── */
@media (max-width: 768px) {
  :root {
    --bn-topbar-h: 52px;
  }

  /* ── Topbar ── */
  .bn-topbar { padding: 0 10px; gap: 6px; }
  .bn-brand-area { display: none; }
  .bn-topbar-right { gap: 4px; }
  .bn-topbar-user-info,
  .bn-topbar-user > .ti-chevron-down { display: none !important; }
  .bn-topbar-user { padding: 4px; border-radius: 50%; border: 1px solid var(--bn-border); }
  .bn-notif-dropdown { width: 300px !important; min-width: unset !important; right: -60px !important; }

  /* ── Main content ── */
  .bn-main { padding: 12px; margin-left: 0 !important; }

  /* ── Page header: stack on mobile ── */
  .bn-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .bn-page-header > div,
  .bn-page-header > .d-flex { width: 100%; }
  .bn-page-header .btn,
  .bn-page-header .bn-btn-primary { width: 100%; justify-content: center; }

  /* ── Period bar ── */
  .bn-period-bar { flex-wrap: wrap; gap: 8px; }
  .bn-period-bar .btn, .bn-period-bar select { font-size: 12px; padding: 5px 10px; }

  /* ── Stat cards: full width stack ── */
  .bn-stat-card { padding: 14px 16px; }
  .bn-stat-num { font-size: 18px; }
  .bn-stat-icon { width: 38px; height: 38px; font-size: 18px; }

  /* ── Quick action cards ── */
  .bn-quick-card { padding: 12px 14px; }

  /* ── Tables: force horizontal scroll ── */
  .bn-table { font-size: 12.5px; }
  .bn-table th, .bn-table td { padding: 8px 10px; white-space: nowrap; }
  .bn-card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* ── Cards ── */
  .bn-card-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .bn-card-header > .d-flex,
  .bn-card-header > .ms-auto { width: 100%; }
  .bn-card-body { padding: 12px; }

  /* ── Promo banner: stack ── */
  .bn-promo-banner { padding: 14px; gap: 12px; }
  .bn-promo-actions { margin-left: 0; width: 100%; }
  .bn-promo-actions .bn-promo-btn { width: 100%; justify-content: center; }

  /* ── Modals ── */
  .modal-dialog { margin: 8px; max-width: calc(100vw - 16px); }
  .modal-content { border-radius: 12px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 12px 16px; }
  .modal-footer { padding: 10px 16px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1; min-width: 0; }

  /* ── Bootstrap grid: force single col on xs ── */
  .col-md-6, .col-md-4, .col-md-3, .col-md-8, .col-md-9,
  .col-lg-4, .col-lg-3, .col-lg-6, .col-lg-8, .col-lg-9 {
    /* Bootstrap handles these, but reinforce */
  }

  /* ── Form rows: stack labels and inputs ── */
  .row.g-2 > [class*="col-"], .row.g-3 > [class*="col-"] {
    /* Bootstrap responsive handles this already */
  }

  /* ── Button groups: wrap ── */
  .btn-group { flex-wrap: wrap; }
  .btn-group > .btn { flex: 1 0 auto; font-size: 12px; }

  /* ── Badges: smaller on mobile ── */
  .bn-badge { font-size: 10.5px; padding: 2px 7px; }

  /* ── Chart wraps ── */
  .bn-chart-wrap { height: 200px; }
  .bn-chart-wrap.donut { height: 180px; }

  /* ── Home page module grid ── */
  .bn-module-card { padding: 16px 12px 14px; }
  .bn-mod-icon { width: 44px; height: 44px; font-size: 20px; margin-bottom: 10px; }
  .bn-mod-name { font-size: 13px; }
}

/* ── BREAKPOINT: Small Mobile (≤ 480px) ─────────────────── */
@media (max-width: 480px) {
  .bn-main { padding: 10px; }

  /* Tables: even more compact */
  .bn-table th, .bn-table td { padding: 6px 8px; font-size: 12px; }

  /* Stat cards: tighter */
  .bn-stat-card { gap: 10px; padding: 12px; }
  .bn-stat-num { font-size: 16px; }
  .bn-stat-icon { display: none; } /* hide on very small screens */

  /* Filter bars: scroll horizontally */
  .d-flex.gap-2.flex-wrap { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }

  /* Input groups: full width */
  .input-group { flex-wrap: nowrap; }
  .input-group .form-control { min-width: 0; }
}

/* ── POS SPECIFIC ─────────────────────────────────────────── */
@media (max-width: 992px) {
  /* POS: products grid → 3 cols on tablet */
  #posProductGrid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 768px) {
  /* POS: stack cart below products */
  .pos-layout,
  div[style*="display:grid"][style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
  }

  /* POS products: 2 cols on mobile */
  #posProductGrid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* POS cart panel: full width */
  .pos-cart-panel,
  #cartPanel {
    width: 100% !important;
    max-width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--bn-border);
  }

  /* POS product cards: more compact */
  .pos-product-card { padding: 10px !important; }
  .pos-product-card img,
  .pos-product-img { height: 80px !important; }

  /* POS numpad: larger touch targets */
  .pos-numpad-btn { height: 52px !important; font-size: 18px !important; }

  /* POS header bar */
  .pos-header { flex-wrap: wrap; gap: 8px; }
  .pos-header > * { flex: 1 0 auto; }
}

/* ── INVOICE / RECEIPT (PDF view) ────────────────────────── */
@media (max-width: 768px) {
  .invoice-box, .receipt-box {
    padding: 16px !important;
    font-size: 12px;
  }
  .invoice-box table, .receipt-box table { font-size: 11px; }
  .invoice-header { flex-direction: column; gap: 12px; }
}

/* ── WEBSITE BUILDER ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Preview / storefront editor sidebar */
  .wb-editor-layout { flex-direction: column !important; }
  .wb-sidebar { width: 100% !important; max-width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--bn-border); max-height: 40vh; overflow-y: auto; }
  .wb-preview { height: auto !important; }
}

/* ── FORMS: full-width inputs on mobile ──────────────────── */
@media (max-width: 768px) {
  .form-control, .form-select, .input-group {
    font-size: 16px !important; /* prevent iOS zoom on focus */
  }
  /* But keep small variant visually small */
  .form-control-sm, .form-select-sm { font-size: 14px !important; }
}

/* ── LOGIN / AUTH PAGES ──────────────────────────────────── */
@media (max-width: 480px) {
  .bn-login-card { padding: 28px 20px; border-radius: 12px; }
}

/* ── NOTIFICATIONS PAGE ──────────────────────────────────── */
@media (max-width: 768px) {
  .bn-notif-item { padding: 10px 12px; }
  .bn-notif-icon { width: 30px; height: 30px; font-size: 14px; }
}

/* ── CARD HEADER ACTION BUTTONS ──────────────────────────── */
@media (max-width: 600px) {
  .bn-card-header .d-flex.gap-2 { gap: 4px !important; }
  .bn-card-header .btn { font-size: 12px; padding: 5px 10px; }
  .bn-card-header .btn span { display: none; } /* icon only on very small */
}

/* ── DROPDOWN MENUS ──────────────────────────────────────── */
@media (max-width: 768px) {
  .dropdown-menu { font-size: 13.5px; }
  .dropdown-menu.dropdown-menu-end { right: 0 !important; left: auto !important; }
}

/* ── SCROLLBAR STYLING ───────────────────────────────────── */
.bn-card-body::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar { height: 4px; }
.bn-card-body::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.bn-card-body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb { background: var(--bn-border); border-radius: 2px; }

/* ── TOUCH-FRIENDLY TARGETS ──────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .bn-nav-item { padding: 11px 16px; }
  .btn { min-height: 40px; }
  .dropdown-item { padding: 10px 16px; }
  .form-check-input { width: 1.1em; height: 1.1em; }
}

/* ── SAFE AREA (iPhone notch/home bar) ───────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bn-sidebar { padding-bottom: env(safe-area-inset-bottom); }
  body > .bn-topbar { padding-top: env(safe-area-inset-top); }
}

/* ── POS TERMINAL LAYOUT ─────────────────────────────────── */
.pos-terminal-layout {
  min-height: calc(100vh - 140px);
}
@media (min-width: 769px) {
  .pos-terminal-layout > .col-md-7,
  .pos-terminal-layout > .col-md-5 {
    height: calc(100vh - 140px);
    overflow-y: auto;
  }
}
@media (max-width: 768px) {
  .pos-terminal-layout {
    min-height: unset;
    height: auto;
  }
  /* Products panel on top, cart below */
  .pos-terminal-layout > [class*="col-md-7"] {
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .pos-terminal-layout > [class*="col-md-5"] {
    max-height: unset;
  }
  /* Cart action buttons: full width stack */
  .pos-terminal-layout .d-flex.gap-2:has(.bn-btn-primary) {
    flex-direction: column;
  }
  .pos-terminal-layout .d-flex.gap-2:has(.bn-btn-primary) > * {
    width: 100%;
  }
  /* Payment method options: wrap */
  .pos-terminal-layout .gw-opt { padding: 8px 10px; }
}
