/* ============================================================
   Sarkar Hardware — Global Stylesheet
   Font: Google Outfit | Accent: #4361ee
   Responsive: Mobile → Tablet → Desktop
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  --accent:       #4361ee;
  --accent-dark:  #3451d1;
  --accent-light: #eef0fd;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --secondary:    #64748b;

  --sidebar-bg:   #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #2563eb;
  --sidebar-active-text: #fff;
  --sidebar-width: 260px;
  --topbar-h:     64px;

  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06);
  --transition:   .2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden; /* prevent horizontal scroll everywhere */
}
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden; /* belt-and-suspenders for mobile */
  max-width: 100vw;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; }
ul { list-style: none; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 900;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo .brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: block;
  line-height: 1.2;
}
.sidebar-logo .brand-sub {
  font-size: .72rem;
  color: var(--sidebar-text);
  margin-top: 3px;
}

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
}
.user-info .user-name  { font-size: .85rem; font-weight: 600; color: #e2e8f0; }
.user-info .user-role  { font-size: .72rem; color: var(--sidebar-text); }

.nav-section {
  padding: 16px 0 8px;
}
.nav-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 0 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
  border-left: 4px solid #93c5fd;
  padding-left: 16px;
  box-shadow: inset 0 0 20px rgba(0,0,0,.15);
}
.nav-item .nav-icon {
  width: 20px; height: 20px;
  opacity: .65;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:hover .nav-icon  { opacity: .9; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  width: calc(100vw - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
  overflow-x: hidden;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 800;
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  width: 36px; height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); }
.sidebar-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-clock {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}
.topbar-user:hover { background: var(--accent-light); }
.topbar-user .avatar-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Page Content ---- */
.page-content {
  padding: 24px;
  flex: 1;
}
.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.page-header .breadcrumb {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-header .breadcrumb a { color: var(--accent); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
/* Stat cards never go below 3 per row until very narrow */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }
.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.stat-info .stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-info .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin: 3px 0;
}
.stat-info .stat-sub {
  font-size: .78rem;
  color: var(--text-muted);
}
.stat-change {
  font-size: .78rem;
  font-weight: 600;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { background: #f8fafc; }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.table-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
label .req { color: var(--danger); margin-left: 3px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}
input:disabled, select:disabled, textarea:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
  color: var(--text-muted);
}
textarea { resize: vertical; min-height: 90px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }
.form-hint { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .76rem; color: var(--danger); margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: 'Outfit', sans-serif;
  font-size: .875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm        { padding: 7px 14px; font-size: .8rem; }
.btn-icon      { padding: 8px; border-radius: var(--radius-sm); }
.btn-icon svg  { width: 18px; height: 18px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: .73rem;
  font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary   { background: var(--accent-light); color: var(--accent); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-danger  { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }
.alert-dismissible .alert-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  opacity: .6;
}
.alert-dismissible .alert-close:hover { opacity: 1; }

/* ============================================================
   ACTIVITY FEED
   ============================================================ */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
}
.activity-dot.sale    { background: var(--success); }
.activity-dot.service { background: var(--warning); }
.activity-dot.stock   { background: var(--info); }
.activity-dot.auth    { background: var(--secondary); }
.activity-dot.danger  { background: var(--danger); }
.activity-text { font-size: .83rem; color: var(--text); line-height: 1.5; }
.activity-time { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 20px;
  justify-content: center;
}
.page-btn {
  width: 36px; height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover, .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 340px;
}
.search-bar input {
  padding-left: 38px;
}
.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px; height: 16px;
  pointer-events: none;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(20px);
  transition: transform .2s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning{ color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm  { font-size: .83rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.ms-auto { margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Responsive layout grids (used by module pages) */
.stat-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-grid-5 .stat-card { flex-direction: column; gap: 8px; }
.resp-grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.resp-grid-chart {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
.invoice-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Loading spinner */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(67,97,238,.15) 0%, transparent 70%);
  top: -100px; right: -100px;
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .brand { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.login-logo .tagline { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--accent);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.login-logo .logo-icon svg { width: 34px; height: 34px; color: #fff; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  /* Stat grid stays 3 cols on tablet — true 3×2 */
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .stat-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .resp-grid-sidebar { grid-template-columns: 1fr; }
  .resp-grid-sidebar > div:last-child .card { position: static !important; }
  .resp-grid-chart { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   Mobile phones are 360–430px wide — 3 cols WILL overflow!
   Switch to 2 columns here so all content fits the viewport.
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  /* --- Sidebar off-canvas --- */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 30px rgba(0,0,0,.4);
  }
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
  }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 899;
  }
  .sidebar-overlay.show { display: block; }

  /* --- Page layout --- */
  .page-content {
    padding: 12px;
    width: 100%;
    overflow-x: hidden;
  }

  /* --- Stat grid: 2 cols × 3 rows — fits any phone --- */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .stat-card {
    padding: 14px;
    gap: 12px;
    align-items: center;
  }
  .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .stat-icon i { font-size: 1.15rem !important; }
  .stat-info .stat-label { font-size: .72rem; }
  .stat-info .stat-value { font-size: 1.2rem; margin: 2px 0; }
  .stat-info .stat-sub   { font-size: .7rem; }

  /* --- Tables: scroll within card, not the whole page --- */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  table { font-size: .8rem; min-width: 480px; }
  th, td { padding: 9px 10px; }

  /* --- Other layout fixes --- */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .resp-grid-sidebar { grid-template-columns: 1fr; }
  .resp-grid-sidebar > div:last-child .card { position: static !important; }
  .resp-grid-chart { grid-template-columns: 1fr; }
  .invoice-header { grid-template-columns: 1fr; gap: 16px; }
  .invoice-header > div:last-child { text-align: left !important; }
  .form-row { grid-template-columns: 1fr; }
  .form-row > * { grid-column: auto !important; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar-clock { display: none; }
  .topbar { padding: 0 14px; }
  .card-body { padding: 14px; }
  .card-header { padding: 14px 16px; flex-wrap: wrap; }
  .login-card { padding: 28px 20px; }

  /* --- Sidebar toggle: larger touch target --- */
  .sidebar-toggle {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  /* --- Filter forms inside card-headers --- */
  .search-bar { max-width: 100% !important; width: 100%; }
  .card-header form.d-flex {
    gap: 10px;
  }
  .card-header form input[type="date"],
  .card-header form select {
    width: 100%;
  }

  /* --- Bill type toggle wraps on mobile --- */
  .bill-type-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .bill-type-bar label {
    font-size: .8rem !important;
    padding: 5px 12px !important;
  }

  /* --- Quick action buttons — 2-col grid --- */
  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* --- Modal responsive --- */
  .modal { max-width: 100%; margin: 10px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }

  /* --- Payment status bar on invoice view --- */
  .invoice-footer-bar { flex-direction: column; gap: 12px; align-items: flex-start !important; }

  /* --- Topbar user: hide name on mobile, keep avatar --- */
  .topbar-user > span { display: none; }
}

/* ============================================================
   RESPONSIVE — SMALL PHONES (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  /* Stat cards: single column on phones */
  .stat-grid { grid-template-columns: 1fr; gap: 8px; }
  .stat-grid-5 { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-info .stat-value { font-size: 1.1rem; }
  .btn { padding: 9px 14px; font-size: .82rem; }
  .topbar { padding: 0 12px; }
  .page-header h1 { font-size: 1.15rem; }
  .topbar-title { font-size: .9rem; }
  /* Quick actions: single column on small phones */
  .quick-actions-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   RESPONSIVE — VERY SMALL (≤ 360px)
   ============================================================ */
@media (max-width: 360px) {
  .page-content { padding: 10px; }
  .stat-grid { grid-template-columns: 1fr; gap: 7px; }
  .stat-card { padding: 10px 8px; gap: 8px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-info .stat-label { font-size: .65rem; }
  .stat-info .stat-value { font-size: 1rem; }
  .stat-info .stat-sub { font-size: .63rem; }
  .btn { padding: 8px 10px; font-size: .78rem; }
  .btn-sm { padding: 6px 10px; font-size: .75rem; }
  .badge { font-size: .68rem; padding: 2px 8px; }
}

/* ============================================================
   DASHBOARD — CONTENT + SIDEBAR GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* On smaller desktops / tablets — single column */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  /* Unstick the activity card on single-column layout */
  .dashboard-grid > div:last-child .card {
    position: static !important;
  }
}

/* On mobile — tighten the gap */
@media (max-width: 768px) {
  .dashboard-grid {
    gap: 14px;
  }
}

/* ============================================================
   MOBILE-FIRST ENHANCEMENTS
   Optimised for department heads & employees on phones
   ============================================================ */

/* ── Larger touch targets on mobile ── */
@media (max-width: 768px) {
  /* Inputs & selects — bigger tap area */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 1rem !important;
    padding: 12px 14px !important;
    min-height: 48px;
  }

  /* Buttons — minimum 44px touch target */
  .btn {
    min-height: 44px;
    padding: 11px 18px;
    font-size: .9rem;
  }
  .btn-sm {
    min-height: 38px;
    padding: 8px 14px;
    font-size: .82rem;
  }
  .btn-icon {
    min-width: 40px;
    min-height: 40px;
  }

  /* Page content padding */
  .page-content {
    padding: 14px 12px !important;
  }

  /* Cards */
  .card { border-radius: 10px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 14px !important; }

  /* Stat grid — 2 columns on phone */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 1.2rem !important; }
  .stat-icon { width: 38px !important; height: 38px !important; font-size: 1rem; }

  /* Tables — horizontal scroll with sticky first column */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table { min-width: 600px; }
  .table-wrap th, .table-wrap td {
    padding: 10px 12px;
    font-size: .82rem;
    white-space: nowrap;
  }

  /* Form rows — stack on mobile */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0;
  }

  /* Nav items — bigger */
  .nav-item {
    padding: 13px 16px !important;
    font-size: .92rem;
    min-height: 48px;
  }
  .nav-icon { font-size: 1rem !important; }
  .nav-badge { font-size: .65rem !important; }

  /* Topbar */
  .topbar { padding: 10px 14px !important; }
  .topbar-title { font-size: .95rem !important; }

  /* Modal overlays */
  .modal-overlay .modal {
    margin: 12px;
    max-width: calc(100vw - 24px);
    border-radius: 12px;
  }

  /* Breadcrumb — hide on very small */
  .breadcrumb { font-size: .78rem; }

  /* Table actions — stack vertically */
  .table-actions { flex-direction: column; gap: 4px; align-items: flex-start; }

  /* Sidebar — full-width overlay on mobile */
  .sidebar { width: 82vw !important; max-width: 300px; }

  /* Responsive sidebar grid (inventory locations etc.) */
  .resp-grid-sidebar {
    grid-template-columns: 1fr !important;
  }
}

/* ── Extra small phones (≤ 400px) ── */
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  .stat-value { font-size: 1.05rem !important; }
  .page-content { padding: 10px 8px !important; }
}

/* ── New Sale page — mobile optimised ── */
@media (max-width: 768px) {
  #itemsTable { min-width: 540px; font-size: .8rem; }
  #itemsTable input[type="number"] {
    width: 60px !important;
    padding: 6px 8px !important;
    min-height: unset;
  }
  .bill-type-bar { flex-wrap: wrap; }

  /* Float "New Sale" button for quick access */
  .fab-new-sale {
    display: flex !important;
    position: fixed;
    bottom: 20px;
    right: 16px;
    z-index: 800;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(67,97,238,.5);
    text-decoration: none;
  }
}
@media (min-width: 769px) {
  .fab-new-sale { display: none !important; }
}

/* ── Daily report — mobile ── */
@media (max-width: 768px) {
  .daily-method-grid { flex-direction: column !important; }
}
