/* ============================================================
   ERP Pro — Professional Stylesheet v3
   Fixed: Fonts embedded, RTL complete, DreamHost compatible
   Supports: LTR (English) + RTL (Arabic)
   ============================================================ */

/* Arabic font from jsDelivr CDN (works on DreamHost, no Google Fonts block) */
@import url('https://cdn.jsdelivr.net/npm/@fontsource/ibm-plex-sans-arabic@5/400.css');
@import url('https://cdn.jsdelivr.net/npm/@fontsource/ibm-plex-sans-arabic@5/500.css');
@import url('https://cdn.jsdelivr.net/npm/@fontsource/ibm-plex-sans-arabic@5/600.css');
@import url('https://cdn.jsdelivr.net/npm/@fontsource/ibm-plex-sans-arabic@5/700.css');

/* ---------- CSS Variables ---------- */
:root {
  --brand:          #4f46e5;
  --accent:         #06b6d4;
  --brand-dark:     #4338ca;
  --brand-light:    rgba(79,70,229,.08);
  --sidebar-w:      260px;
  --sidebar-bg:     #0c0f1d;
  --sidebar-text:   #8b92a9;
  --sidebar-active: #fff;
  --topbar-h:       64px;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 3px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:      0 12px 40px rgba(0,0,0,.12);
  --bg-page:        #f4f6fb;
  --bg-card:        #ffffff;
  --border:         #e8ecf3;
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --transition:     all .2s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[lang="ar"], [dir="rtl"] {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  flex-shrink: 0; position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  z-index: 200;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.04);
}
/* RTL sidebar */
[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid rgba(255,255,255,.04);
}
[dir="rtl"] .main {
  margin-left: 0 !important;
  margin-right: var(--sidebar-w) !important;
}

.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 200px;
  background: radial-gradient(ellipse at 50% 0%, rgba(79,70,229,.25) 0%, transparent 70%);
  pointer-events: none;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0; position: relative; z-index: 1;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.15rem; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,.4);
}
.brand-img { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; }
.brand-name {
  color: #fff; font-weight: 700; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em;
}
.brand-version { font-size: .6rem; color: rgba(255,255,255,.3); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; margin-top: 1px; }

nav { flex: 1; padding: 10px 0; }
.nav-group {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.2); padding: 16px 22px 6px; font-weight: 700;
}
nav .nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 14px; margin: 2px 10px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: .845rem; font-weight: 500; border-radius: var(--radius-sm);
  transition: var(--transition); position: relative;
}
nav .nav-link i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
nav .nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(79,70,229,.3), rgba(79,70,229,.1));
}
nav .nav-link.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}
[dir="rtl"] nav .nav-link { flex-direction: row; }
[dir="rtl"] nav .nav-link.active::before {
  left: auto; right: 0;
  border-radius: 3px 0 0 3px;
}

.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px; border-top: 1px solid rgba(255,255,255,.05); flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .85rem; font-weight: 700; flex-shrink: 0;
}
.user-name { color: #e2e8f0; font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .68rem; color: #4f6282; margin-top: 1px; }
.logout-btn {
  color: #4f6282; text-decoration: none; padding: 7px 8px;
  border-radius: var(--radius-sm); transition: var(--transition); font-size: 1.05rem;
}
.logout-btn:hover { color: #ef4444; background: rgba(239,68,68,.1); }

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

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 0 var(--border);
}
/* backdrop-filter fallback for DreamHost/older Safari */
@supports (backdrop-filter: blur(12px)) {
  .topbar {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}
.page-title { font-weight: 700; font-size: 1rem; color: var(--text-primary); letter-spacing: -.01em; }
.btn-icon {
  width: 36px; height: 36px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary);
  font-size: 1.1rem; transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-page); color: var(--text-primary); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-page); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px 5px 6px;
  font-size: .78rem; font-weight: 600; color: var(--text-secondary);
}
.user-chip .mini-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .7rem; font-weight: 700;
}
.role-badge {
  background: var(--brand-light); color: var(--brand);
  border-radius: 20px; padding: 2px 8px; font-size: .65rem; font-weight: 700;
}

/* ---------- Content ---------- */
.content { padding: 24px; flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header {
  padding: 15px 20px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: .875rem; color: var(--text-primary);
}
.card-body { padding: 20px; }

/* ---------- Stat Cards ---------- */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0; width: 90px; height: 90px;
  background: radial-gradient(ellipse at 100% 0%, var(--brand-light) 0%, transparent 70%);
}
[dir="rtl"] .stat-card::after { right: auto; left: 0; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem; margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.stat-label { font-size: .75rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); letter-spacing: -.03em; line-height: 1; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; font-size: .875rem; }
.table thead th {
  background: #f8fafc; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-secondary); font-weight: 700;
  border-bottom: 1px solid var(--border); padding: 11px 16px; white-space: nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: #f1f5f9; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f8fafc; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-color: var(--border); border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--text-primary);
  background: var(--bg-card); transition: var(--transition); padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.1); background: #fff;
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-weight: 600; font-size: .8rem; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.input-group-text { background: #f8fafc; border-color: var(--border); color: var(--text-secondary); font-size: .85rem; }

/* RTL form alignment */
[dir="rtl"] .form-control,
[dir="rtl"] .form-select,
[dir="rtl"] .form-label,
[dir="rtl"] .input-group-text { text-align: right; }
[dir="rtl"] .input-group > .form-control:not(:last-child) {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .input-group > .input-group-text:last-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .845rem; transition: var(--transition); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #6366f1);
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.28);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(79,70,229,.4); transform: translateY(-1px);
}
.btn-primary:active { transform: none; }
.btn-primary:disabled { opacity: .55; transform: none; box-shadow: none; }
.btn-light { background: var(--bg-page); border-color: var(--border); color: var(--text-secondary); }
.btn-light:hover { background: #e8ecf3; border-color: #d1d9e8; color: var(--text-primary); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: .72rem; padding: .35em .65em; border-radius: 6px; }
.badge-soft { background: var(--brand-light); color: var(--brand); font-size: .78rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.badge-soft-success { background: rgba(16,185,129,.1); color: #059669; }
.badge-soft-danger  { background: rgba(239,68,68,.1);  color: #dc2626; }
.badge-soft-warning { background: rgba(245,158,11,.1); color: #d97706; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); border: none; font-size: .875rem; }
.alert-success { background: rgba(16,185,129,.08); color: #065f46; }
.alert-danger   { background: rgba(239,68,68,.08);  color: #991b1b; }
.alert-warning  { background: rgba(245,158,11,.08); color: #92400e; }

/* ---------- Invoice Print ---------- */
.invoice { background: #fff; padding: 36px; border-radius: var(--radius); border: 1px solid var(--border); }
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; padding-bottom: 24px; border-bottom: 2px solid var(--border); }
@media print {
  .no-print { display: none !important; }
  .sidebar, .topbar { display: none !important; }
  .main { margin-left: 0 !important; margin-right: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; }
  .invoice { border: none !important; padding: 0 !important; }
}

/* ---------- Login Page ---------- */
.login-page {
  background: var(--sidebar-bg); min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(79,70,229,.18) 0%, transparent 70%);
  top: -200px; left: -200px;
}
.login-page::after {
  content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(6,182,212,.12) 0%, transparent 70%);
  bottom: -100px; right: -100px;
}
.login-card {
  background: rgba(255,255,255,.97); border-radius: 20px; padding: 48px 44px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
}
.login-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2.1rem; margin: 0 auto 28px;
  box-shadow: 0 8px 28px rgba(79,70,229,.35);
}
.login-title { font-size: 1.5rem; font-weight: 800; text-align: center; color: var(--text-primary); margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: .875rem; margin-bottom: 28px; }
[dir="rtl"] .login-card { direction: rtl; text-align: right; }
[dir="rtl"] .login-title, [dir="rtl"] .login-sub { text-align: center; }

/* ---------- Settings ---------- */
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-tab {
  cursor: pointer; padding: 10px 14px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .845rem; color: var(--text-secondary);
  transition: var(--transition); border: none; background: none;
  text-align: start; width: 100%; display: flex; align-items: center; gap: 9px;
}
.settings-tab:hover { background: var(--bg-page); color: var(--text-primary); }
.settings-tab.active { background: var(--brand-light); color: var(--brand); }
.settings-tab i { font-size: .95rem; }
[dir="rtl"] .settings-tab { text-align: right; }

.lang-switch { display: flex; background: var(--bg-page); border-radius: var(--radius-sm); padding: 3px; gap: 2px; border: 1px solid var(--border); }
.lang-option {
  flex: 1; padding: 9px 14px; border-radius: 6px; border: none;
  background: transparent; cursor: pointer; font-size: .845rem; font-weight: 600;
  color: var(--text-secondary); transition: var(--transition);
  display: flex; align-items: center; gap: 7px; justify-content: center;
}
.lang-option.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow); }

.currency-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.currency-btn {
  padding: 12px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); cursor: pointer; text-align: center;
  font-size: .78rem; font-weight: 600; color: var(--text-secondary); transition: var(--transition);
}
.currency-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.currency-btn.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.currency-symbol { font-size: 1.2rem; font-weight: 800; display: block; margin-bottom: 3px; }

/* ---------- Color Picker ---------- */
.color-option {
  display: inline-block; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer;
  border: 3px solid transparent;
  transition: var(--transition); box-shadow: var(--shadow);
}
.color-option.selected,
.color-option:hover { border-color: #fff; box-shadow: 0 0 0 3px rgba(0,0,0,.2); transform: scale(1.1); }

/* ---------- Mobile Sidebar ---------- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; }
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .main { margin-left: 0 !important; margin-right: 0 !important; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-overlay { display: block; }
  .content { padding: 16px; }
  .currency-grid { grid-template-columns: repeat(3, 1fr); }
  .login-card { padding: 32px 24px; margin: 16px; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------- Utility ---------- */
.text-brand { color: var(--brand); }
.bg-brand { background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: .4; }

/* ---------- RTL Bootstrap overrides ---------- */
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .me-1  { margin-left: .25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2  { margin-left: .5rem !important;  margin-right: 0 !important; }
[dir="rtl"] .ms-1  { margin-right: .25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2  { margin-right: .5rem !important;  margin-left: 0 !important; }
[dir="rtl"] .text-end { text-align: left !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .float-end { float: left !important; }
[dir="rtl"] .float-start { float: right !important; }
[dir="rtl"] .alert-dismissible .btn-close { left: 0; right: auto; }
[dir="rtl"] .d-flex { direction: rtl; }
[dir="rtl"] .table { direction: rtl; }
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .input-group { flex-direction: row-reverse; }

/* ============================================================
   ERP Pro — Responsive + New Settings Variables (v5.1)
   ============================================================ */

/* ---------- New CSS Variables for nav-group & logo size ---------- */
:root {
  --nav-group-size:  .62rem;
  --nav-group-color: rgba(255,255,255,.2);
  --logo-size:       38px;
}

/* Apply nav-group variables */
.nav-group {
  font-size: var(--nav-group-size) !important;
  color: var(--nav-group-color) !important;
}

/* Apply logo size variable */
.brand-logo,
.brand-img {
  width: var(--logo-size) !important;
  height: var(--logo-size) !important;
}

/* ============================================================
   RESPONSIVE — Mobile First Full Overhaul
   ============================================================ */

/* ---------- Responsive Tables ---------- */
.table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
/* Wrap all card-contained tables */
.card .table-responsive { border-radius: 0; }

/* ---------- Topbar mobile ---------- */
@media (max-width: 991px) {
  .topbar { padding: 0 16px; gap: 8px; }
  .page-title { font-size: .9rem; }
}

/* ---------- Mobile (< 768px) ---------- */
@media (max-width: 767px) {

  /* Sidebar slide-in */
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    width: 270px;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); left: auto; right: 0; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-overlay { display: block; }
  .sidebar-overlay { z-index: 299; }

  /* Main takes full width */
  .main { margin-left: 0 !important; margin-right: 0 !important; }

  /* Content padding */
  .content { padding: 12px; }

  /* Topbar */
  .topbar { padding: 0 12px; }
  .user-chip { display: none !important; }

  /* Cards */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; font-size: .82rem; }

  /* Tables — horizontal scroll with sticky first column */
  .card .table-responsive,
  .table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .table { min-width: 600px; }
  .table thead th { font-size: .68rem; padding: 9px 12px; }
  .table tbody td { padding: 10px 12px; font-size: .82rem; }

  /* Stat cards grid: 2 per row */
  .row.g-4 > [class*="col-"] { margin-bottom: 8px; }

  /* Buttons */
  .btn { font-size: .8rem; padding: .4rem .75rem; }
  .btn-sm { font-size: .75rem; padding: .3rem .6rem; }

  /* Form layouts: stack all to full width on mobile */
  .col-md-6, .col-md-4, .col-md-3, .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-9 {
    /* let Bootstrap grid handle it, but force stacking for form rows */
  }

  /* Settings tabs: horizontal scroll on mobile */
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }
  .settings-tab {
    white-space: nowrap;
    font-size: .78rem;
    padding: 8px 12px;
    flex-shrink: 0;
  }

  /* Currency grid: 3 → 2 */
  .currency-grid { grid-template-columns: repeat(2, 1fr); }

  /* Login card */
  .login-card { padding: 28px 18px; margin: 12px; }

  /* Invoice: stack header */
  .invoice-head { flex-direction: column; gap: 16px; }

  /* Hide non-critical table columns using data-hide-mobile */
  th[data-hide-mobile], td[data-hide-mobile] { display: none; }

  /* Stat value font size */
  .stat-value { font-size: 1.4rem; }
  .stat-card { padding: 16px; }

  /* Font size preview & controls */
  .font-size-btn { font-size: .75rem; padding: 4px 10px; }
}

/* ---------- Small mobile (< 480px) ---------- */
@media (max-width: 479px) {
  .content { padding: 10px 8px; }
  .card-body { padding: 12px 10px; }
  .stat-value { font-size: 1.25rem; }
  .table { min-width: 500px; }
  .currency-grid { grid-template-columns: repeat(2, 1fr); }

  /* Action buttons in table: icon only */
  .btn-action-label { display: none; }
}

/* ---------- Tablet (768–991px) ---------- */
@media (min-width: 768px) and (max-width: 991px) {
  .sidebar { width: 220px; }
  :root { --sidebar-w: 220px; }
  .main { margin-left: 220px; }
  [dir="rtl"] .main { margin-left: 0 !important; margin-right: 220px !important; }
  .content { padding: 18px; }
  .nav-link .nav-label { font-size: .8rem; }
}

/* ---------- Large tablet / small desktop (992–1199px) ---------- */
@media (min-width: 992px) and (max-width: 1199px) {
  .content { padding: 20px; }
}

/* ============================================================
   Sidebar Toggle button — always visible on mobile
   ============================================================ */
#sidebarToggle { display: flex !important; }
@media (min-width: 768px) {
  #sidebarToggle { display: none !important; }
}

/* ============================================================
   Table scroll helper class — add to card-body wrapping a table
   ============================================================ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .table { min-width: 580px; }


/* ============================================================
   v6 — Modern Mobile-First Overhaul (May 2026)
   Full-width mobile layout, slide sidebar < 992px,
   gracefully-wrapping card headers, sticky CTAs, smooth scroll.
   ============================================================ */

/* Make hamburger visible up to lg (sidebar slides in below 992px) */
@media (max-width: 991.98px) {
  #sidebarToggle { display: inline-flex !important; }
  .sidebar { transform: translateX(-100%); width: 280px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
  [dir="rtl"] .sidebar { transform: translateX(100%); left: auto; right: 0; }
  .sidebar-open .sidebar { transform: translateX(0) !important; }
  .sidebar-open .sidebar-overlay { display: block !important; }
  .main, [dir="rtl"] .main { margin-left: 0 !important; margin-right: 0 !important; }
}
@media (min-width: 992px) {
  #sidebarToggle { display: none !important; }
}

/* Topbar — wrap gracefully + thumb-friendly */
.topbar {
  min-height: var(--topbar-h);
  height: auto;
  flex-wrap: wrap;
  padding: 10px 16px;
  gap: 10px;
}
.topbar .topbar-right { gap: 6px; flex-wrap: wrap; }
.page-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card header — wrap on small screens, never overflow */
.card-header {
  flex-wrap: wrap;
  gap: 10px;
  row-gap: 10px;
}
.card-header > * { min-width: 0; }
.card-header .d-flex { flex-wrap: wrap; }

/* Buttons inside card-header become full-width pills on phones */
@media (max-width: 575.98px) {
  .card-header { padding: 12px 14px; }
  .card-header .btn { font-size: .78rem; padding: .42rem .7rem; }
  .card-header .d-flex.gap-2 { width: 100%; }
  .card-header .d-flex.gap-2 .btn { flex: 1 1 auto; justify-content: center; }
}

/* Tables — auto horizontal scroll, sticky-feeling rows */
.table-responsive, .table-scroll, .table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-responsive::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { height: 6px; }
@media (max-width: 767.98px) {
  .table { min-width: 560px; }
  .table thead th { font-size: .68rem; padding: 10px 12px; }
  .table tbody td { padding: 11px 12px; font-size: .82rem; }
  /* Action cells stay tight */
  .table .btn-sm { padding: .28rem .45rem; }
  .table form.d-inline { display: inline-block; }
}

/* Stat cards — better mobile rhythm */
@media (max-width: 575.98px) {
  .stat-card { padding: 14px 14px 16px; border-radius: 14px; }
  .stat-icon { width: 38px; height: 38px; font-size: 1rem; margin-bottom: 10px; border-radius: 10px; }
  .stat-label { font-size: .65rem; }
  .stat-value { font-size: 1.15rem; }
}

/* Forms — comfortable touch targets */
@media (max-width: 767.98px) {
  .form-control, .form-select {
    font-size: 16px !important;  /* prevent iOS zoom */
    padding: .6rem .75rem;
    min-height: 44px;
  }
  .input-group .btn { min-height: 44px; }
  label, .form-label { font-size: .82rem; }
  .row.g-3 > [class*="col-"] { margin-bottom: .25rem; }
}

/* Content padding on small screens */
@media (max-width: 575.98px) {
  .content { padding: 12px 10px 28px; }
  .card { border-radius: 14px; }
}

/* Sidebar polish on mobile */
@media (max-width: 991.98px) {
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
  .brand { padding: 18px 16px; }
  .nav-link { padding: 11px 14px !important; font-size: .9rem !important; }
  .nav-group { padding: 14px 18px 6px !important; }
}

/* Hamburger styling — modern circle */
#sidebarToggle {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--brand);
}
#sidebarToggle:hover { background: var(--brand); color: #fff; }

/* Search input full width on tablet */
@media (max-width: 991.98px) {
  .topbar form { flex: 1 1 100%; order: 5; }
  .topbar form .form-control { width: 100% !important; }
}

/* Login page — stay readable on tiny phones */
@media (max-width: 420px) {
  .login-card { padding: 28px 20px; border-radius: 16px; }
  .login-logo { width: 60px; height: 60px; font-size: 1.7rem; }
  .login-title { font-size: 1.25rem; }
}

/* Smooth body scroll lock when sidebar open */
body.sidebar-open { overflow: hidden; }

/* Bigger tap targets for icon buttons */
@media (max-width: 767.98px) {
  .btn-icon { width: 40px; height: 40px; }
}

/* Modern user-chip hides label on small */
@media (max-width: 575.98px) {
  .user-chip { display: none !important; }
}

/* Settings tabs scroll snap */
@media (max-width: 991.98px) {
  .settings-nav { -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
  .settings-tab { scroll-snap-align: start; }
}

/* Page wrapper to prevent horizontal page-scroll on mobile */
html, body { max-width: 100%; overflow-x: hidden; }
.main { overflow-x: hidden; }

/* Modern subtle gradient page background */
body { background: linear-gradient(180deg, var(--bg-page) 0%, #eef2f9 100%); }

/* Make alerts dismiss button reachable on mobile */
.alert-dismissible { padding-inline-end: 3rem; }

/* ============================================================
   v6.1 — Sidebar toggle bulletproof fix
   ============================================================ */
.sidebar-toggle-btn {
  display: none;
  position: relative;
  z-index: 110;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover,
.sidebar-toggle-btn:focus { background: var(--brand); color: #fff; outline: none; }
.sidebar-toggle-btn i { line-height: 1; }

@media (max-width: 991.98px) {
  .sidebar-toggle-btn { display: inline-flex !important; }
}
@media (min-width: 992px) {
  .sidebar-toggle-btn { display: none !important; }
}

/* Topbar must allow the button to be visible & clickable */
.topbar { position: sticky; z-index: 120; }

/* Sidebar overlay above content but below sidebar */
.sidebar-overlay { z-index: 1040; cursor: pointer; }
.sidebar { z-index: 1050 !important; }
body.sidebar-open .sidebar-overlay { display: block !important; }
body.sidebar-open { overflow: hidden; }

/* Slide animation (always present so it works on first toggle) */
.sidebar { transition: transform .28s cubic-bezier(.4,0,.2,1); }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.sidebar-open .sidebar { transform: translateX(0) !important; }
}
