/* ============================================================
   IMS Pro — Main Stylesheet
   Design: Clean Industrial ERP — Dark Sidebar, Crisp Cards
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;

  /* Colors */
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e2e6ea;
  --border-light: #f0f2f5;

  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1e293b;
  --sidebar-hover-bg: #1e293b;
  --brand-accent: #3b82f6;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --success: #22c55e;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #06b6d4;
  --info-light: #ecfeff;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);

  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --transition: 0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 200;
  overflow-y: hidden;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
  transition: transform .22s ease, box-shadow .22s ease;
}

.sidebar-desktop-hide-btn {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 27px; height: 44px; border: 1px solid rgba(148,163,184,.18); border-radius: 9px;
  background: rgba(30,41,59,.94); color: #94a3b8; cursor: pointer; z-index: 3;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.sidebar-desktop-hide-btn:hover { color: white; background: #334155; border-color: rgba(148,163,184,.35); }
.sidebar-pull-tab {
  display: none; position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  width: 34px; height: 64px; border: 0; border-radius: 0 12px 12px 0;
  background: var(--primary); color: white; cursor: pointer; z-index: 210;
  box-shadow: 4px 0 16px rgba(15,23,42,.22); align-items: center; justify-content: center;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; flex-shrink: 0;
}
.brand-name { font-size: 16px; font-weight: 700; color: white; letter-spacing: -.3px; }
.brand-sub { font-size: 10px; color: #475569; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-nav { flex: 1; min-height: 0; padding: 12px 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.sidebar-module-search {
  position: relative; display: flex; align-items: center;
  margin: 10px 12px 2px; flex-shrink: 0;
}
.sidebar-module-search > i {
  position: absolute; left: 11px; z-index: 1; color: #64748b; font-size: 12px; pointer-events: none;
}
.sidebar-module-search input {
  width: 100%; height: 36px; padding: 7px 34px 7px 32px;
  border: 1px solid rgba(148,163,184,.2); border-radius: 9px;
  background: rgba(15,23,42,.75); color: #e2e8f0; outline: none;
  font-size: 12px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.sidebar-module-search input::placeholder { color: #64748b; }
.sidebar-module-search input:focus {
  border-color: #3b82f6; background: #0f172a; box-shadow: 0 0 0 3px rgba(59,130,246,.14);
}
.sidebar-module-search button {
  position: absolute; right: 5px; width: 27px; height: 27px;
  display: none; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent; color: #64748b; cursor: pointer;
}
.sidebar-module-search button:hover { background: rgba(255,255,255,.08); color: #e2e8f0; }
.sidebar-module-search.has-value button { display: flex; }
.module-search-hidden { display: none !important; }
.module-search-empty {
  display: none; padding: 28px 14px; color: #64748b; text-align: center; font-size: 12px;
  flex-direction: column; align-items: center; gap: 8px;
}
.module-search-empty i { font-size: 20px; color: #475569; }
.module-search-empty.visible { display: flex; }
.sidebar-nav.module-searching .nav-group-body {
  max-height: none !important; opacity: 1 !important; padding-bottom: 6px !important;
}
.sidebar-nav.module-searching .nav-group-chevron { transform: none !important; }
.nav-section { margin-bottom: 4px; }
.nav-label {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: #475569;
  padding: 10px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: white; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand-accent);
  border-radius: 0 2px 2px 0;
}
.nav-item i { width: 18px; text-align: center; font-size: 13px; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: #64748b; text-transform: capitalize; }
.logout-btn {
  color: #475569; font-size: 14px;
  text-decoration: none; padding: 6px;
  border-radius: 6px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--danger); }

/* ── Main Layout ───────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
  transition: margin-left .22s ease, width .22s ease;
}

@media (min-width: 901px) {
  body.sidebar-desktop-hidden .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-desktop-hidden .main-wrapper { margin-left: 0; width: 100%; }
  body.sidebar-desktop-hidden .sidebar-pull-tab { display: flex; }
}

.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  box-shadow: var(--shadow);
  width: 100%;
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 18px; padding: 4px 8px;
  border-radius: 6px; display: none;
  align-items: center; justify-content: center;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 4px; }

/* Topbar icon buttons */
.topbar-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 16px;
  text-decoration: none; transition: all .14s;
  position: relative; font-family: var(--font);
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--primary); }
.topbar-badge {
  position: absolute; top: 1px; right: 1px;
  background: #ef4444; color: white; border-radius: 50%;
  width: 14px; height: 14px; font-size: 8px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--surface);
}
.company-badge {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.alert-bell {
  position: relative; color: var(--text-secondary);
  font-size: 16px; text-decoration: none;
  padding: 6px;
}
.alert-bell .badge {
  position: absolute; top: 0; right: 0;
  background: var(--danger); color: white;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

.content { padding: 24px; flex: 1; min-width: 0; overflow-x: hidden; width: 100%; }

/* ── Flash Messages ────────────────────────────────────── */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  font-size: 13px; font-weight: 500;
  position: relative;
}
.flash-success { background: var(--success-light); color: #15803d; border-bottom: 2px solid var(--success); }
.flash-error   { background: var(--danger-light);  color: #dc2626; border-bottom: 2px solid var(--danger); }
.flash-warning { background: var(--warning-light); color: #d97706; border-bottom: 2px solid var(--warning); }
.flash-info    { background: var(--info-light);    color: #0891b2; border-bottom: 2px solid var(--info); }
.flash-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 18px; opacity: .6; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 20px; }

/* ── Stats Grid ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.purple { background: var(--purple-light);  color: var(--purple); }
.stat-icon.teal   { background: var(--info-light);    color: var(--info); }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.9); }
.btn-danger  { background: var(--danger);  color: white; }
.btn-danger:hover  { filter: brightness(0.9); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { filter: brightness(0.9); }
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-secondary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px 10px; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge, .status {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: capitalize;
}
.badge-blue   , .status-draft       { background: var(--primary-light); color: var(--primary); }
.badge-green  , .status-received, .status-delivered, .status-completed, .status-approved, .status-paid { background: var(--success-light); color: #15803d; }
.badge-orange , .status-partial, .status-in_transit, .status-pending_approval { background: var(--warning-light); color: #92400e; }
.badge-red    , .status-cancelled, .status-rejected { background: var(--danger-light); color: var(--danger); }
.badge-purple , .status-sent, .status-confirmed, .status-shipped { background: var(--purple-light); color: var(--purple); }
.badge-teal   , .status-picking { background: var(--info-light); color: var(--info); }
.badge-gray   , .status-unpaid { background: #f1f5f9; color: #64748b; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  display: block; width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px; color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header-left h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-header-left p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-bar .form-control { max-width: 200px; }
.filter-bar input[type=text], .filter-bar input[type=search] { max-width: 260px; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input input { padding-left: 32px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-decoration: none; background: var(--surface);
  transition: all var(--transition);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  z-index: 500; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Items Table (PO/SO) ─────────────────────────────────── */
.items-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.items-table th { background: #f1f5f9; }
.items-table td input, .items-table td select { border: none; outline: none; background: transparent; width: 100%; font-family: var(--font); font-size: 13px; }
.items-table td input:focus { background: var(--primary-light); border-radius: 4px; padding: 2px 4px; }
.remove-row { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 4px 8px; }
.remove-row:hover { color: var(--danger); }

/* ── Form polish for card-based modules ───────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}
.form-group label,
.card-body label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .45px;
}
.card-body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.card-body select,
.card-body textarea,
.card-header input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.card-header select,
.page-header input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.page-header select,
td input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
td select {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.25;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.card-body textarea {
  min-height: 86px;
  resize: vertical;
}
.card-body input:focus,
.card-body select:focus,
.card-body textarea:focus,
.card-header input:focus,
.card-header select:focus,
.page-header input:focus,
.page-header select:focus,
td input:focus,
td select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.card-body select,
.card-header select,
.page-header select,
td select {
  cursor: pointer;
}

/* ── Operations modules: Manufacturing, POS, Restaurant POS ── */
.ops-page {
  --ops-soft: #f8fafc;
  --ops-border: #dbe3ee;
}
.ops-page .page-header {
  align-items: flex-start;
}
.ops-page .page-header-left h1 {
  font-size: 24px;
  letter-spacing: 0;
}
.ops-page .stats-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}
.ops-page .card {
  border-color: var(--ops-border);
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}
.ops-page .card + .card,
.ops-page .mb-16 {
  margin-bottom: 18px;
}
.ops-page .card-header {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}
.ops-page .card-title,
.ops-page .card-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}
.ops-page .card-body {
  padding: 18px 20px 20px;
}
.ops-page form.card-body {
  display: block;
}
.ops-page .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important;
}
.ops-page .table-wrap,
.ops-page .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.ops-page table {
  min-width: 760px;
}
.ops-page th {
  background: var(--ops-soft);
  color: #52637a;
  font-size: 10px;
  letter-spacing: .75px;
}
.ops-page td {
  background: #fff;
}
.ops-page tr:nth-child(even) td {
  background: #fbfcfe;
}
.ops-page tr:hover td {
  background: #f6f9ff;
}
.ops-page .card-body > div[style*="font-weight:900"],
.ops-page .card-body > div[style*="font-weight: 900"] {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px !important;
  color: var(--text-primary);
  font-size: 13px;
  letter-spacing: .2px;
}
.ops-page .card-body > div[style*="font-weight:900"]::before,
.ops-page .card-body > div[style*="font-weight: 900"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}
.ops-page .card-body .table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}
.ops-page .card-body .table-wrap table {
  min-width: 720px;
}
.ops-page .card-body .table-wrap th:first-child,
.ops-page .card-body .table-wrap td:first-child {
  padding-left: 16px;
}
.ops-page .card-body .table-wrap th:last-child,
.ops-page .card-body .table-wrap td:last-child {
  padding-right: 16px;
}
.ops-page .card-body .table-wrap td input,
.ops-page .card-body .table-wrap td select {
  min-height: 34px;
}
.ops-page .card-body > div[style*="display:grid"][style*="repeat(5"],
.ops-page .card-body > div[style*="display:grid"][style*="repeat(4"] {
  gap: 12px !important;
}
.ops-page .card-body > div[style*="display:grid"][style*="repeat(5"] > div,
.ops-page .card-body > div[style*="display:grid"][style*="repeat(4"] > div {
  border-color: var(--ops-border) !important;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.ops-page td form {
  vertical-align: middle;
}
.ops-page td form[style*="inline-flex"] {
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap;
}
.ops-page td form input,
.ops-page td form select {
  width: auto;
  min-width: 116px;
  max-width: 190px;
}
.ops-page td form input[name*="reason"] {
  min-width: 130px;
}
.ops-page .workflow-steps {
  display: grid;
  gap: 10px;
}
.ops-page .workflow-step {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
}
.ops-page .step-number {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex: 0 0 auto;
}
.ops-page .workflow-step p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}
.ops-page .quick-list {
  display: grid;
  gap: 10px;
}
.ops-page .quick-list > div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  font-size: 13px;
}

/* ── Touch POS consoles ─────────────────────────────────── */
.pos-console {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  margin-bottom: 18px;
  align-items: stretch;
}
.pos-ticket,
.pos-menu-board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15,23,42,.08);
  overflow: hidden;
}
.pos-ticket {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}
.pos-ticket-head,
.pos-board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}
.pos-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pos-ticket h3,
.pos-board-top h3 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.15;
}
.pos-order-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px 16px;
  background: #fbfdff;
  border-bottom: 1px solid var(--border-light);
}
.pos-order-meta input,
.pos-order-meta select,
.pos-board-top input {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}
.restaurant-table-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 14px;
  background: #fbfdff;
  border-bottom: 1px solid var(--border-light);
}
.restaurant-table-strip button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}
.restaurant-table-strip button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}
.pos-board-top input {
  min-width: 260px;
  background: #fff;
}
.pos-cart-lines {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  min-height: 220px;
}
.pos-empty-cart,
.pos-empty-menu {
  padding: 28px 16px;
  color: var(--text-muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fbfdff;
}
.pos-cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
}
.pos-cart-row strong {
  display: block;
  font-size: 13px;
}
.pos-cart-row span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}
.pos-qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pos-qty button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 900;
  cursor: pointer;
}
.pos-ticket-total {
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  background: #fbfdff;
}
.pos-ticket-total > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.pos-ticket-total span {
  color: var(--text-muted);
  font-weight: 700;
}
.pos-ticket-total input {
  width: 130px;
  min-height: 36px;
  text-align: right;
}
.pos-ticket-total .grand {
  margin: 10px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pos-ticket-total .grand strong {
  font-size: 24px;
}
.pos-pay-btn {
  margin: 0 16px 16px;
  min-height: 52px;
  justify-content: center;
  font-size: 15px;
}
.pos-pay-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}
.pos-menu-board {
  min-height: 560px;
}
.pos-category-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
.pos-category-strip button {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text-primary);
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.pos-category-strip button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pos-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 16px;
}
.pos-product-tile {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.pos-product-tile:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 10px 22px rgba(37,99,235,.12);
}
.pos-product-tile strong {
  font-size: 14px;
  line-height: 1.25;
}
.pos-product-tile span:last-child {
  font-weight: 900;
  color: var(--primary);
}
.tile-category {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Summary Box ─────────────────────────────────────────── */
.summary-box {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 20px;
}
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; font-size: 15px; font-weight: 700; }
.summary-row span:last-child { font-family: var(--mono); }

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .no-print { display: none !important; }
  .main-wrapper { margin: 0; }
  .content { padding: 0; }
  body { background: white; }
}

/* ── Utilities ───────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-mono { font-family: var(--mono); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.fw-700 { font-weight: 700; }
.small { font-size: 11px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: .3; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  /* ── Sidebar: slide off-screen, overlay when open ── */
  .sidebar {
    transform: translateX(-100%);
    z-index: 400;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  /* Overlay behind open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 399;
  }
  .sidebar-overlay.show,
.sidebar-overlay.visible { display: block; }

  /* ── Main wrapper: full width ── */
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .sidebar-toggle { display: flex; }
  .sidebar-desktop-hide-btn, .sidebar-pull-tab { display: none !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* ── Topbar: compact ── */
  .topbar { padding: 0 12px; }

  /* ── Tables: horizontal scroll ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* ── Cards ── */
  .card { border-radius: 10px; }

  /* ── Page header ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header > div:last-child { width: 100%; }
  .page-header > div:last-child .btn { flex: 1; justify-content: center; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { padding-bottom: 8px; }

  /* ── Filter bar: wrap ── */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .search-input,
  .filter-bar .form-control,
  .filter-bar .btn { width: 100%; }

  /* ── Modals: full width ── */
  .modal { margin: 8px; max-width: calc(100vw - 16px) !important; }

  /* ── Topbar icons: hide labels ── */
  .topbar-label { display: none; }

  /* ── Stat cards: compact ── */
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 10px; }

  /* ── Buttons: full width in page header ── */
  .page-header .btn-sm { font-size: 11px; padding: 5px 10px; }

  /* ── Form controls ── */
  .form-control { font-size: 14px; }

  /* ── Tab bars ── */
  .tab-bar { overflow-x: auto; white-space: nowrap; }
}

/* ── Dashboard Chart Area ─────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }

/* ── Low Stock Highlight ─────────────────────────────────── */
.low-stock-row td { background: #fff7ed !important; }
.out-stock-row td { background: #fef2f2 !important; }

/* ── Company Logo in Sidebar ─────────────────────────────── */
.brand-logo-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 4px;
}
.brand-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Logo on Print / Reports ─────────────────────────────── */
.print-header {
  display: none;
}
@media print {
  .print-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 0 16px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #1e293b;
  }
  .print-logo {
    max-height: 60px;
    max-width: 180px;
    object-fit: contain;
  }
  .print-company-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
  }
  .print-company-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
  }
}

/* ── Home Button in Topbar ───────────────────────────────────── */
.topbar-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1.5px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
}
.topbar-home-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59,130,246,.15);
}
.topbar-home-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.topbar-home-btn i {
  font-size: 12px;
}

/* ── Sidebar Brand as Link ───────────────────────────────────── */
a.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition);
}
a.sidebar-brand:hover {
  background: rgba(255,255,255,.05);
}
a.sidebar-brand:hover .brand-sub {
  color: #93c5fd;
}
a.sidebar-brand .brand-sub {
  transition: color var(--transition);
}

/* ── Responsive: hide Home text on small screens ─────────────── */
@media (max-width: 600px) {
  .topbar-home-btn span { display: none; }
  .topbar-home-btn { padding: 6px 10px; }
}

/* ── Collapsible Nav Sections ────────────────────────────────── */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 10px 20px 4px;
  transition: color var(--transition);
}
.collapsible-header:hover { color: #7dd3fc; }
.collapse-icon {
  font-size: 9px;
  transition: transform 0.25s ease;
  color: #475569;
}
.nav-section-body {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}
.nav-section-body.collapsed {
  max-height: 0;
  opacity: 0;
}
.collapse-icon.rotated { transform: rotate(-90deg); }

/* DB Optimize button */
.btn-optimize {
  background: linear-gradient(135deg,#7c3aed,#4f46e5);
  color: white;
}
.btn-optimize:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ═══════════════════════════════════════════════════════════════
   GROUPED COLLAPSIBLE NAV — Module Groups
   ═══════════════════════════════════════════════════════════════ */

/* Standalone items (Dashboard, Messages) */
.nav-group-standalone {
  padding: 6px 8px 2px;
}
.nav-group-standalone .nav-item {
  border-radius: 8px;
  margin-bottom: 2px;
}

/* Module Group Container */
.nav-group {
  margin: 4px 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
  transition: all .2s ease;
}
.nav-group:hover { border-color: rgba(255,255,255,.10); }

/* Group Header — the top-level module button */
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
  border-radius: 10px;
}
.nav-group-header:hover { background: rgba(255,255,255,.06); }
.nav-group-header.active, .nav-group-header:active { background: none !important; border: none !important; }

.nav-group-icon-wrap {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  border-radius: 8px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: white !important;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.nav-group-label {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: .1px;
}

.nav-group-chevron {
  font-size: 9px;
  color: #64748b;
  transition: transform .25s ease;
  flex-shrink: 0;
}
.nav-group-chevron.rotated { transform: rotate(-90deg); }

/* Group Body */
.nav-group-body {
  overflow: hidden;
  max-height: 1000px;
  transition: max-height .3s ease, opacity .25s ease;
  opacity: 1;
  padding: 0 0 6px;
}
.nav-group-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

/* Sub-group (section inside a group) */
.nav-subgroup {
  margin: 0 4px 2px;
}

.nav-sublabel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-radius: 7px;
  transition: background .15s, color .15s;
}
.nav-sublabel:hover { background: rgba(255,255,255,.05); color: #cbd5e1; }
.nav-sublabel .collapse-icon {
  margin-left: auto;
  font-size: 8px;
}
.nav-sublabel span { flex: 1; }

/* Sub-nav items inside groups */
.nav-item.sub {
  padding-left: 32px;
  font-size: 12px;
  border-radius: 7px;
  margin: 1px 4px;
}
.nav-item.sub:hover { background: rgba(255,255,255,.07); }
.nav-item.sub.active {
  background: rgba(59,130,246,.2);
  color: #60a5fa;
  font-weight: 600;
}
.nav-item.sub.active i { color: #60a5fa; }

/* Unread badge in nav */
.nav-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
}

/* Remove old section styles that conflict */
.nav-section { display: none; }
.nav-section.collapsible { display: block; }

/* ── Default: hide mobile-only elements ──────────────────────── */
.mobile-bottom-nav  { display: none !important; }
.sidebar-overlay    { display: none; }

/* Only mobile theme shows these (overridden in theme-mobile.css) */
.theme-mobile .mobile-bottom-nav { display: flex !important; }
.theme-mobile .sidebar-overlay   { display: block; }

/* ── Utility ─────────────────────────────────────────────────── */
/* .hidden removed — use inline style display:none instead */

/* ── Sidebar toggle: hidden by default, shown on mobile theme ── */
.sidebar-toggle        { display: none; }
.theme-mobile .sidebar-toggle { display: flex; }

/* ── Mobile bottom nav hidden by default ── */
#mobileBottomNav { display: none; }

/* ════════════════════════════════════════════════════════════════
   TOP NAVIGATION LAYOUT — Elegant Icon Design
   ════════════════════════════════════════════════════════════════ */



/* ── Top Bar ─────────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-bottom: 1px solid rgba(255,255,255,.07);
  z-index: 900;
  box-shadow: 0 4px 24px rgba(0,0,0,.35);
}
.topnav-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  gap: 6px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Brand ───────────────────────────────────────────────────── */
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding-right: 16px;
  border-right: 1px solid rgba(255,255,255,.08);
  margin-right: 6px;
  flex-shrink: 0;
}
.topnav-logo-img   { max-height: 34px; max-width: 110px; object-fit: contain; }
.topnav-logo-icon  {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #6d28d9);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 17px; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(59,130,246,.4);
}
.topnav-brand-name { font-size: 14px; font-weight: 800; color: white; line-height: 1.1; white-space: nowrap; }
.topnav-brand-sub  { font-size: 9px; color: rgba(255,255,255,.38); text-transform: uppercase; letter-spacing: .9px; }

/* ── Nav Menu ────────────────────────────────────────────────── */
.topnav-menu {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

/* ── Nav Group Item ──────────────────────────────────────────── */
.nav-group-item { position: relative; flex-shrink: 0; }

/* The pill button for each module group */
.nav-group-btn {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: all .18s ease;
  outline: none;
  flex-direction: column;
  width: 64px;
  height: 44px;
  justify-content: center;
  color: rgba(255,255,255,.55);
}
.nav-group-btn:hover {
  background: rgba(255,255,255,.07);
  color: white;
}
.nav-group-item.active > .nav-group-btn {
  color: white;
}

/* Icon circle inside the button */
.ngb-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all .18s ease;
  background: rgba(255,255,255,.07);
  margin-bottom: 3px;
  position: relative;
}
.nav-group-btn:hover  .ngb-icon { transform: translateY(-1px); }
.nav-group-item.active > .nav-group-btn .ngb-icon { transform: translateY(-1px); }

/* Per-group icon colors */
.ngb-home     { background: linear-gradient(135deg,#3b82f6,#6366f1); color: white; box-shadow: 0 3px 10px rgba(59,130,246,.45); }
.ngb-inventory{ background: linear-gradient(135deg,#0ea5e9,#0369a1); color: white; box-shadow: 0 3px 10px rgba(14,165,233,.4); }
.ngb-fleet    { background: linear-gradient(135deg,#f59e0b,#d97706); color: white; box-shadow: 0 3px 10px rgba(245,158,11,.4); }
.ngb-reports  { background: linear-gradient(135deg,#22c55e,#15803d); color: white; box-shadow: 0 3px 10px rgba(34,197,94,.4); }
.ngb-support  { background: linear-gradient(135deg,#a855f7,#7c3aed); color: white; box-shadow: 0 3px 10px rgba(168,85,247,.4); }
.ngb-admin    { background: linear-gradient(135deg,#ef4444,#b91c1c); color: white; box-shadow: 0 3px 10px rgba(239,68,68,.4); }

.nav-group-btn:hover .ngb-home      { box-shadow: 0 5px 16px rgba(59,130,246,.6); }
.nav-group-btn:hover .ngb-inventory { box-shadow: 0 5px 16px rgba(14,165,233,.55); }
.nav-group-btn:hover .ngb-fleet     { box-shadow: 0 5px 16px rgba(245,158,11,.55); }
.nav-group-btn:hover .ngb-reports   { box-shadow: 0 5px 16px rgba(34,197,94,.55); }
.nav-group-btn:hover .ngb-support   { box-shadow: 0 5px 16px rgba(168,85,247,.55); }
.nav-group-btn:hover .ngb-admin     { box-shadow: 0 5px 16px rgba(239,68,68,.55); }

/* Label below icon */
.ngb-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  line-height: 1;
}

/* Active state — label color matches group */
.nav-group-item.active .ngb-label { color: white; }
.ngb-active-bar {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 3px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity .18s;
}
.nav-group-item.active .ngb-active-bar { opacity: 1; }
.ngb-home-bar      { background: #60a5fa; }
.ngb-inventory-bar { background: #38bdf8; }
.ngb-fleet-bar     { background: #fbbf24; }
.ngb-reports-bar   { background: #4ade80; }
.ngb-support-bar   { background: #c084fc; }
.ngb-admin-bar     { background: #f87171; }

/* Badge on icon */
.ngb-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: #ef4444;
  color: white;
  font-size: 8px;
  font-weight: 800;
  min-width: 15px; height: 15px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #0f172a;
  padding: 0 3px;
  line-height: 1;
}

/* ── Mega Menu ───────────────────────────────────────────────── */
.nav-mega-menu {
  display: none;
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
  z-index: 901;
  min-width: 580px;
  max-width: 95vw;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  animation: megaFadeIn .18s cubic-bezier(.4,0,.2,1);
}
.nav-mega-menu.open { display: block; }

@keyframes megaFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.98); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Decorative top accent bar */
.nav-mega-menu::before {
  content: '';
  display: block;
  height: 3px;
  border-radius: 18px 18px 0 0;
}
.mega-inv::before  { background: linear-gradient(90deg,#0ea5e9,#0369a1); }
.mega-fleet::before{ background: linear-gradient(90deg,#f59e0b,#d97706); }
.mega-rep::before  { background: linear-gradient(90deg,#22c55e,#0ea5e9); }
.mega-sup::before  { background: linear-gradient(90deg,#a855f7,#7c3aed); }
.mega-adm::before  { background: linear-gradient(90deg,#ef4444,#a855f7); }

.mega-inner {
  display: flex;
  padding: 16px;
  gap: 0;
}

.mega-col {
  min-width: 190px;
  flex: 1;
  padding: 0 12px;
  border-right: 1px solid var(--border-light, #f1f5f9);
}
.mega-col:first-child { padding-left: 4px; }
.mega-col:last-child  { border-right: none; padding-right: 4px; }

.mega-col-title {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted, #94a3b8);
  margin: 4px 0 10px 6px;
}

/* ── Mega Menu Item — card style ─────────────────────────────── */
.mega-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary, #1e293b);
  transition: all .14s ease;
  margin-bottom: 2px;
}
.mega-item:hover {
  background: var(--primary-light, rgba(59,130,246,.07));
  transform: translateX(3px);
}
.mega-item.active {
  background: var(--primary-light, rgba(59,130,246,.1));
}

/* Elegant icon bubble */
.mega-item-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
  transition: transform .14s ease;
}
.mega-item:hover .mega-item-icon { transform: scale(1.08) rotate(-3deg); }

.mega-item-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  line-height: 1.2;
}
.mega-item.active .mega-item-label { color: var(--primary, #3b82f6); }
.mega-item-sub {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
  line-height: 1.2;
}

/* ── Right side ──────────────────────────────────────────────── */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.topnav-icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  color: rgba(255,255,255,.6);
  font-size: 15px;
  text-decoration: none;
  transition: all .15s;
  position: relative;
}
.topnav-icon-btn:hover {
  background: rgba(255,255,255,.12);
  color: white;
  border-color: rgba(255,255,255,.15);
}

.topnav-notif-dot {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 16px; height: 16px;
  background: #ef4444;
  border-radius: 8px;
  font-size: 8px; font-weight: 800;
  color: white;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #0f172a;
  padding: 0 3px;
}

/* ── Profile chip ────────────────────────────────────────────── */
.topnav-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 28px;
  text-decoration: none;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  transition: all .15s;
  margin-left: 4px;
}
.topnav-profile:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
}
.topnav-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  flex-shrink: 0;
}
.topnav-profile-name {
  font-size: 12px; font-weight: 700;
  color: white; white-space: nowrap;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis;
}
.topnav-profile-role {
  font-size: 9px; color: rgba(255,255,255,.45);
  text-transform: uppercase; letter-spacing: .5px;
}

/* ── Hamburger ───────────────────────────────────────────────── */
.topnav-hamburger {
  display: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: white; font-size: 16px;
  cursor: pointer;
  align-items: center; justify-content: center;
}

/* ── Main content ────────────────────────────────────────────── */
.topnav-content {
  margin-top: 60px;
  padding: 20px 24px;
  min-height: calc(100vh - 60px);
  background: var(--bg, #f8fafc);
  box-sizing: border-box;
}

/* ── Tablet ──────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .topnav-brand-text   { display: none; }
  .topnav-profile-info { display: none; }
  .ngb-label           { display: none; }
  .nav-group-btn       { width: 48px; height: 44px; }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topnav-hamburger { display: flex !important; }
  .topnav-menu {
    display: none;
    position: fixed;
    top: 60px; left: 0; right: 0; bottom: 0;
    background: #0f172a;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 4px;
    overflow-y: auto;
    z-index: 950;
  }
  .topnav-menu.mobile-open { display: flex; }
  .nav-group-item   { position: static; }
  .nav-group-btn {
    width: 100%; height: auto;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 14px;
    gap: 12px;
    border-radius: 12px;
  }
  .ngb-icon  { width: 38px; height: 38px; border-radius: 11px; margin-bottom: 0; flex-shrink: 0; }
  .ngb-label { display: block; font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 700; }
  .ngb-active-bar { display: none; }
  .nav-mega-menu {
    position: static; transform: none;
    width: 100%; min-width: unset;
    border: none; border-radius: 12px;
    box-shadow: none;
    background: rgba(255,255,255,.05);
    margin: 4px 0;
  }
  .mega-inner  { flex-direction: column; padding: 8px; }
  .mega-col    { border-right: none; padding: 8px 0; min-width: unset; }
  .mega-col:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,.05); }
  .mega-item   { color: rgba(255,255,255,.85); }
  .mega-item:hover  { background: rgba(255,255,255,.08); }
  .mega-item-label  { color: rgba(255,255,255,.9); }
  .mega-item-sub    { color: rgba(255,255,255,.4); }
  .mega-col-title   { color: rgba(255,255,255,.35); }
  #navBackdrop      { display: none !important; }
  .topnav-content   { padding: 14px; }
  .nav-mega-menu::before { border-radius: 12px 12px 0 0; }
}
@media (max-width: 480px) {
  .topnav-inner { padding: 0 10px; gap: 2px; }
  .topnav-icon-btn { width: 32px; height: 32px; }
}


/* ════════════════════════════════════════════════════════════════
   SUBBAR — Fixed quick-action bar below topnav
   ════════════════════════════════════════════════════════════════ */

.subbar {
  position: fixed;
  top: 60px;
  left: 60px;           /* after icon rail */
  right: 0;
  height: 38px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255,255,255,.07);
  z-index: 890;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.subbar::-webkit-scrollbar { display: none; }

.subbar-inner {
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 0;
  min-width: max-content;
  width: 100%;
}

.subbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
}

.subbar-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(255,255,255,.3);
  padding: 0 8px;
  white-space: nowrap;
}

.subbar-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 28px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  transition: all .14s;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
}
.subbar-item i { font-size: 11px; }
.subbar-item:hover { background: rgba(255,255,255,.1); color: white; }
.subbar-item.active { background: rgba(255,255,255,.1); color: white; }

/* "New" action items get a teal tint */
.subbar-item.subbar-new {
  color: #34d399;
  background: rgba(52,211,153,.1);
  border: 1px solid rgba(52,211,153,.2);
  margin-left: 2px;
}
.subbar-item.subbar-new:hover { background: rgba(52,211,153,.2); color: #6ee7b7; }

.subbar-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.1);
  margin: 0 6px;
  flex-shrink: 0;
}

.subbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}

/* Rail + subbar margins handled in .topnav-content base rule */



@media (max-width: 768px) {
  .subbar       { left: 0; top: 60px; }
  .icon-rail    { display: none; }
  .quick-dock   { display: none; }
  .topnav-content { padding: 14px; margin-top: 60px; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS IMPROVEMENTS
   Applies to all themes (classic, elegant) on small screens
   ═══════════════════════════════════════════════════════════ */

/* ── Touch-friendly inputs: prevent iOS zoom (requires 16px) */
@media (max-width: 768px) {
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], input[type="date"], input[type="datetime-local"],
  input[type="search"], input[type="tel"], input[type="url"],
  select, textarea, .form-control {
    font-size: 16px !important;
  }

  /* ── Touch targets: min 44px height ── */
  .btn, .nav-item, .page-link { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* ── Topbar: handle overflow on small screens ── */
  .topbar-right { gap: 2px !important; }
  .topbar-title { font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .company-badge { display: none; } /* hide company badge on mobile */

  /* ── Cards: remove side margins ── */
  .card { margin-left: 0; margin-right: 0; }

  /* ── Grid layouts: force single column ── */
  .form-row { grid-template-columns: 1fr !important; }
  .form-grid { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Items table (PO/SO): horizontal scroll ── */
  .items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
  .items-table { min-width: 600px; }

  /* ── Page header: stack actions ── */
  .page-header { flex-direction: column; gap: 10px; align-items: stretch !important; }
  .page-header .btn { width: 100%; justify-content: center; }
  .page-header > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; }

  /* ── Breadcrumb: compact ── */
  .breadcrumb { font-size: 11px; }

  /* ── Filter bar improvements ── */
  .filter-bar { flex-wrap: wrap !important; gap: 8px !important; }
  .filter-bar > * { min-width: calc(50% - 4px); }
  .filter-bar .btn { min-width: auto; flex: 0 0 auto; }

  /* ── Modals: slide-up from bottom on mobile ── */
  .modal {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-overlay { align-items: flex-end !important; }

  /* ── Sales/PO view: info grid ── */
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ── Inline item rows: stack action buttons ── */
  .btn-group { flex-wrap: wrap; gap: 4px; }

  /* ── Table action cells ── */
  table td:last-child { white-space: nowrap; }

  /* ── Topbar icons: show fewer on very small screens ── */
  .topbar-icon-btn { width: 34px !important; height: 34px !important; font-size: 14px !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .content { padding: 10px 10px 80px !important; }

  /* ── SO/PO view header grid: single column on tiny screens ── */
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Large numbers: shrink ── */
  .stat-value { font-size: 20px !important; }
  .stat-label { font-size: 10px !important; }

  /* ── Action buttons on tables: wrap ── */
  .table-actions { flex-wrap: wrap; gap: 4px; }
  .table-actions .btn { flex: 1; min-width: 80px; font-size: 11px; }

  .ops-page .page-header-left h1 { font-size: 20px !important; }
  .ops-page .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .ops-page .form-grid,
  .ops-page [style*="grid-template-columns:repeat(4"],
  .ops-page [style*="grid-template-columns:repeat(5"],
  .ops-page [style*="grid-template-columns:2fr"] {
    grid-template-columns: 1fr !important;
  }
  .ops-page .form-group[style*="grid-column"] {
    grid-column: auto !important;
  }
  .ops-page .card-header {
    align-items: flex-start !important;
    flex-direction: column !important;
  }
  .ops-page .card-header form {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .ops-page .card-header form .btn,
  .ops-page .card-header form input,
  .ops-page .card-header form select,
  .ops-page .card-header form a {
    width: 100% !important;
    justify-content: center !important;
  }
  .ops-page td form[style*="inline-flex"],
  .ops-page td form[style*="display:flex"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    margin-top: 6px !important;
  }
  .ops-page td form input,
  .ops-page td form select,
  .ops-page td form button {
    width: 100% !important;
    max-width: none !important;
  }
  .ops-page .content-grid.two-col {
    grid-template-columns: 1fr !important;
  }
  .pos-console {
    grid-template-columns: 1fr !important;
  }
  .pos-ticket,
  .pos-menu-board {
    min-height: auto;
  }
  .pos-board-top {
    align-items: stretch !important;
    flex-direction: column !important;
  }
  .pos-board-top input {
    min-width: 0;
    width: 100%;
  }
  .pos-tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px;
  }
  .pos-product-tile {
    min-height: 104px;
  }
  .restaurant-table-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* ── Card padding: tighter on tiny screens ── */
  .card-body { padding: 12px !important; }
  .card-header { padding: 10px 12px !important; }

  .ops-page .stats-grid { grid-template-columns: 1fr !important; }
  .ops-page .card-body .table-wrap {
    margin-left: -4px;
    margin-right: -4px;
  }
  .ops-page .card-header form {
    grid-template-columns: 1fr !important;
  }
  .pos-tile-grid {
    grid-template-columns: 1fr;
  }
  .pos-ticket-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .pos-ticket-total .grand strong {
    font-size: 21px;
  }

  /* ── Page title: smaller ── */
  .page-header h1 { font-size: 17px !important; }
}

/* ── Prevent horizontal overflow on ALL themes ── */
@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .main-wrapper { overflow-x: hidden; }

  /* ── Sidebar toggle: always visible on mobile ── */
  .sidebar-toggle { display: flex !important; }

  /* ── Hide topbar home button (sidebar takes over) ── */
  @media (max-width: 600px) {
    .topbar-home-btn { display: none !important; }
  }
}

/* ── Profile page: mobile fit ── */
@media (max-width: 900px) {
  .profile-page-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .profile-side-col,
  .profile-main-col,
  .profile-page-grid .card {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .profile-main-col .form-row,
  .self-service-grid,
  .employee-summary-grid {
    grid-template-columns: 1fr !important;
  }

  .self-service-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .self-service-tabs .btn {
    width: 100% !important;
    min-width: 0 !important;
    justify-content: center !important;
    white-space: normal !important;
    text-align: center !important;
    line-height: 1.2 !important;
  }

  .ss-filter-form {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
    width: 100% !important;
  }

  .ss-filter-form .form-control {
    width: 100% !important;
    min-width: 0 !important;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .profile-page-grid {
    gap: 10px !important;
  }

  .profile-page-grid .card-body {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .profile-side-col .card-body {
    padding: 18px 12px !important;
  }

  .profile-side-col [style*="font-size:20px"] {
    font-size: 18px !important;
    word-break: break-word !important;
  }

  .profile-side-col [style*="margin-top:16px"][style*="display:flex"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .profile-side-col [style*="margin-top:16px"][style*="display:flex"] .btn,
  .profile-side-col [style*="margin-top:16px"][style*="display:flex"] form {
    width: 100% !important;
  }

  .profile-side-col [style*="margin-top:16px"][style*="display:flex"] .btn {
    justify-content: center !important;
  }

  .self-service-tabs,
  .ss-filter-form,
  .profile-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .ss-filter-form .btn,
  .profile-main-col [style*="display:flex"][style*="gap:10px"] .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}
