/* ============================================================
   MALABAR INVENTORY MANAGEMENT SYSTEM — Design System
   Premium Dark Theme with Glassmorphism & Vibrant Accents
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('../fonts/fonts.css');

/* ==========================================================
   1. CSS CUSTOM PROPERTIES
   ========================================================== */
:root {
  /* ---- Backgrounds ---- */
  --bg-main: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252830;
  --bg-hover: #2a2d38;
  --bg-sidebar: rgba(22, 25, 35, 0.82);
  --bg-topbar: rgba(15, 17, 23, 0.85);
  --bg-modal-backdrop: rgba(0, 0, 0, 0.6);

  /* ---- Accent / Brand ---- */
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-end: #8b5cf6;
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-hover: linear-gradient(135deg, #818cf8, #a78bfa);
  --gradient-subtle: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.12));

  /* ---- Semantic Colours ---- */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);

  /* ---- Text ---- */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f1117;

  /* ---- Borders ---- */
  --border: #2d3140;
  --border-light: #363a48;
  --border-focus: rgba(99, 102, 241, 0.5);

  /* ---- Shadows / Glows ---- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 0 20px rgba(99, 102, 241, 0.25);
  --glow-accent-strong: 0 0 30px rgba(99, 102, 241, 0.4);
  --glow-success: 0 0 20px rgba(16, 185, 129, 0.25);
  --glow-danger: 0 0 20px rgba(239, 68, 68, 0.25);

  /* ---- Radius ---- */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-card: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* ---- Sizing ---- */
  --sidebar-width: 260px;
  --topbar-height: 64px;

  /* ---- Transition ---- */
  --speed: 0.2s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Font ---- */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================
   2. RESET & BASE
   ========================================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--speed) var(--ease);
}
a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

::selection {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================
   3. KEYFRAME ANIMATIONS
   ========================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================
   4. APP LAYOUT — Sidebar + Main
   ========================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-right: 1px solid var(--border);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, transparent 40%);
  pointer-events: none;
}

.sidebar-header {
  padding: 24px 22px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.logo span {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Sidebar Navigation ---------- */
.sidebar-nav {
  padding: 12px 10px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  transition: all var(--speed) var(--ease);
  border-left: 3px solid transparent;
}

.nav-item i,
.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-left-color: var(--border-light);
}

.nav-item.active {
  background: var(--gradient-subtle);
  color: #fff;
  border-left-color: transparent;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--gradient);
}
.nav-item.active i,
.nav-item.active svg {
  color: var(--accent-light);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 14px 6px;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  flex: 1;
}
.topbar-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-display {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--speed) var(--ease);
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}
.sidebar-toggle i,
.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

/* ---------- Content Area ---------- */
.content-area {
  padding: 28px;
  flex: 1;
}

/* ==========================================================
   5. CARDS
   ========================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: all 0.25s var(--ease);
  position: relative;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.04), rgba(139, 92, 246, 0.04));
  pointer-events: none;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--glow-accent);
  transform: translateY(-2px);
}
.card:hover::after {
  opacity: 1;
}

/* Stack form cards sequentially to ensure search dropdowns overlay correctly */
form .card {
  position: relative;
}
form .card:nth-of-type(1) {
  z-index: 10;
}
form .card:nth-of-type(2) {
  z-index: 9;
}
form .card:nth-of-type(3) {
  z-index: 8;
}
form .card:nth-of-type(4) {
  z-index: 7;
}
form .card:nth-of-type(5) {
  z-index: 6;
}

/* Cards containing search dropdowns — need overflow visible on desktop */
.card-has-dropdown {
  overflow: visible;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.card-body {
  position: relative;
}

.card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Card that should not lift on hover */
.card-static {
  composes: card;
}
.card-static:hover {
  transform: none;
  box-shadow: none;
}

/* ==========================================================
   6. STATS / KPI CARDS
   ========================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.25s var(--ease);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.stat-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--glow-accent);
  transform: translateY(-2px);
}
.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--gradient-subtle);
}
.stat-icon i,
.stat-icon svg {
  width: 22px;
  height: 22px;
  color: var(--accent-light);
}
.stat-icon.success {
  background: var(--success-bg);
}
.stat-icon.success i,
.stat-icon.success svg {
  color: var(--success);
}
.stat-icon.warning {
  background: var(--warning-bg);
}
.stat-icon.warning i,
.stat-icon.warning svg {
  color: var(--warning);
}
.stat-icon.danger {
  background: var(--danger-bg);
}
.stat-icon.danger i,
.stat-icon.danger svg {
  color: var(--danger);
}
.stat-icon.info {
  background: var(--info-bg);
}
.stat-icon.info i,
.stat-icon.info svg {
  color: var(--info);
}

.stat-details {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.stat-change.up {
  color: var(--success);
  background: var(--success-bg);
}
.stat-change.down {
  color: var(--danger);
  background: var(--danger-bg);
}
.stat-change i,
.stat-change svg {
  width: 14px;
  height: 14px;
}

.stat-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  display: block;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

/* ==========================================================
   7. TABLES
   ========================================================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: rgba(99, 102, 241, 0.06);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: inherit;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: all var(--speed) var(--ease);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
  transform: translateX(2px);
  border-left: 3px solid var(--accent);
}

tbody td,
tfoot td {
  padding: 13px 18px;
  color: var(--text-primary);
  white-space: nowrap;
}

tfoot tr {
  border-top: 2px solid var(--border);
  background: rgba(99, 102, 241, 0.03);
}

.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.table-empty i,
.table-empty svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* Right-align numeric columns */
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}

/* ==========================================================
   8. FORMS
   ========================================================== */
.form-group {
  margin-bottom: 18px;
}

.form-group label,
label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="search"],
input[type="password"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: all var(--speed) var(--ease);
  outline: none;
}

.form-control:hover,
input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-light);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
  background: var(--bg-main);
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

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

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
}

.invalid-feedback {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
}

.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ==========================================================
   9. BUTTONS
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  outline: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn i,
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.96);
}

/* Primary */
.btn-primary {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  background: var(--gradient-hover);
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
  color: #fff;
}
.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
  color: var(--text-primary);
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: #0fd192;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
  color: #fff;
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: #f85e5e;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
  color: #fff;
}

/* Warning */
.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
  background: #fbbf24;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.45);
  transform: translateY(-1px);
  color: var(--text-inverse);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--accent-light);
  border-color: var(--accent);
}
.btn-outline:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-light);
  transform: translateY(-1px);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
  transform: translateY(-1px);
}

/* Sizes */
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-sm i,
.btn-sm svg {
  width: 15px;
  height: 15px;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius);
}
.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

/* Button Group */
.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================
   10. BADGES / PILLS
   ========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
}
.badge-success {
  background: var(--success-bg);
  color: var(--success);
}
.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge-info {
  background: var(--info-bg);
  color: var(--info);
}
.badge-secondary {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
}

/* Dot before badge text */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ==========================================================
   11. ALERTS
   ========================================================== */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-card);
  margin: 0 28px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: fadeIn 0.3s var(--ease);
  border: 1px solid transparent;
}

.alert i,
.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--speed) var(--ease);
  padding: 4px;
  display: flex;
}
.alert-close:hover {
  opacity: 1;
}
.alert-close i,
.alert-close svg {
  width: 16px;
  height: 16px;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}
.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}
.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.2);
}
.alert-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.2);
}

/* ==========================================================
   12. MODALS
   ========================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-modal-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s var(--ease);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.25s var(--ease);
}

.modal-lg {
  max-width: 720px;
}
.modal-xl {
  max-width: 960px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--speed) var(--ease);
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.modal-close i,
.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ==========================================================
   13. SEARCH DROPDOWN
   ========================================================== */
.search-wrapper {
  position: relative;
}

.search-input {
  padding-left: 40px !important;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-icon i,
.search-icon svg {
  width: 17px;
  height: 17px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  animation: fadeIn 0.2s var(--ease);
}

.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent !important;
}
.search-dropdown-item:last-child {
  border-bottom: none;
}
.search-dropdown-item:hover,
.search-dropdown-item.active {
  background: rgba(99, 102, 241, 0.15) !important;
  border-left-color: var(--accent) !important;
}

.search-dropdown-item .item-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.search-dropdown-item .item-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.search-dropdown-item .item-price {
  margin-left: auto;
  font-weight: 700;
  color: var(--accent-light);
  font-size: 0.9rem;
}

.search-dropdown-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================================
   14. PAGINATION
   ========================================================== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.pagination li {
  list-style: none;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: all var(--speed) var(--ease);
  cursor: pointer;
  text-decoration: none;
}

.pagination a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.pagination .active span,
.pagination .active a {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.pagination .disabled span,
.pagination .disabled a {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================
   15. PAGE HEADER (title + action buttons row)
   ========================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 1.35rem;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* ==========================================================
   16. FILTER BAR
   ========================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-control,
.filter-bar select,
.filter-bar input {
  width: auto;
  min-width: 180px;
}

/* ==========================================================
   17. ACTION ICONS (Edit / Delete in tables)
   ========================================================== */
.action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}
.action-btn i,
.action-btn svg {
  width: 15px;
  height: 15px;
}
.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.action-btn.edit:hover {
  color: var(--accent-light);
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}
.action-btn.delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}
.action-btn.view:hover {
  color: var(--info);
  border-color: var(--info);
  background: var(--info-bg);
}

/* ==========================================================
   18. DETAIL / SHOW PAGES
   ========================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.detail-item {
  padding: 12px 0;
}
.detail-item .detail-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.detail-item .detail-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================
   19. SUMMARY / TOTALS PANEL (invoice-like)
   ========================================================== */
.summary-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  min-width: 280px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.9rem;
}
.summary-row:not(:last-child) {
  border-bottom: 1px solid rgba(45, 49, 64, 0.5);
}
.summary-row .label {
  color: var(--text-secondary);
}
.summary-row .value {
  font-weight: 600;
  color: var(--text-primary);
}
.summary-row.total {
  padding-top: 12px;
  margin-top: 4px;
  border-top: 2px solid var(--border);
}
.summary-row.total .label,
.summary-row.total .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================
   20. LOADING / SKELETON
   ========================================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px;
}

/* ==========================================================
   21. TABS
   ========================================================== */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--speed) var(--ease);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}
.tab:hover {
  color: var(--text-primary);
}
.tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ==========================================================
   22. TOOLTIP
   ========================================================== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s var(--ease);
  z-index: 300;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================
   23. UTILITY CLASSES
   ========================================================== */

/* ---- Text Colours ---- */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary-color { color: var(--accent-light) !important; }
.text-secondary-color { color: var(--text-secondary) !important; }
.text-white   { color: #fff !important; }

/* ---- Font Weight ---- */
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* ---- Font Size ---- */
.fs-sm  { font-size: 0.8rem; }
.fs-md  { font-size: 0.9rem; }
.fs-lg  { font-size: 1.1rem; }
.fs-xl  { font-size: 1.3rem; }
.fs-2xl { font-size: 1.6rem; }

/* ---- Display / Flex ---- */
.d-none          { display: none; }
.d-block         { display: block; }
.d-inline        { display: inline; }
.d-inline-block  { display: inline-block; }
.d-flex          { display: flex; }
.d-inline-flex   { display: inline-flex; }
.d-grid          { display: grid; }

.flex-column     { flex-direction: column; }
.flex-wrap       { flex-wrap: wrap; }
.flex-1          { flex: 1; }
.flex-shrink-0   { flex-shrink: 0; }

.align-items-center   { align-items: center; }
.align-items-start    { align-items: flex-start; }
.align-items-end      { align-items: flex-end; }

.justify-center       { justify-content: center; }
.justify-between      { justify-content: space-between; }
.justify-end          { justify-content: flex-end; }
.justify-start        { justify-content: flex-start; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }

/* ---- Spacing: Margin ---- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 32px; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: 6px; }
.ml-2 { margin-left: 12px; }
.ml-auto { margin-left: auto; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: 6px; }
.mr-2 { margin-right: 12px; }
.mr-auto { margin-right: auto; }

/* ---- Spacing: Padding ---- */
.p-0 { padding: 0; }
.p-1 { padding: 6px; }
.p-2 { padding: 12px; }
.p-3 { padding: 20px; }
.p-4 { padding: 32px; }

.px-1 { padding-left: 6px; padding-right: 6px; }
.px-2 { padding-left: 12px; padding-right: 12px; }
.px-3 { padding-left: 20px; padding-right: 20px; }
.px-4 { padding-left: 32px; padding-right: 32px; }

.py-1 { padding-top: 6px; padding-bottom: 6px; }
.py-2 { padding-top: 12px; padding-bottom: 12px; }
.py-3 { padding-top: 20px; padding-bottom: 20px; }
.py-4 { padding-top: 32px; padding-bottom: 32px; }

/* ---- Width ---- */
.w-100 { width: 100%; }
.w-auto { width: auto; }

/* ---- Grid Columns ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ---- Visibility ---- */
.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* ---- Overflow ---- */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }

/* ---- Border ---- */
.border      { border: 1px solid var(--border); }
.border-top  { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }
.rounded     { border-radius: var(--radius); }
.rounded-lg  { border-radius: var(--radius-card); }

/* ---- Text Alignment ---- */
.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ---- Truncate ---- */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Cursor ---- */
.cursor-pointer { cursor: pointer; }

/* ---- Animations ---- */
.animate-fadeIn    { animation: fadeIn 0.35s var(--ease); }
.animate-slideIn   { animation: slideIn 0.3s var(--ease); }
.animate-pulse     { animation: pulse 2s infinite; }

/* ==========================================================
   24. CHART CONTAINER
   ========================================================== */
.chart-container {
  position: relative;
  width: 100%;
  padding: 12px 0;
}
.chart-container canvas {
  max-height: 340px;
}

/* ==========================================================
   25. SCROLLABLE TABLE FRAME
   Fills the remaining viewport height, with sticky thead
   ========================================================== */

/* Full-page scrollable table layout — fills remaining viewport */
.page-table-frame {
  display: flex;
  flex-direction: column;
  /* topbar (64px) + content padding (28px top + 28px bottom) + page header (~48px) + search bar (~82px) + gaps (~40px) */
  height: calc(100vh - var(--topbar-height) - 56px);
  min-height: 300px;
}

/* Compact variant — reduced height for pages that have stat cards or extra content above */
.page-table-frame.compact {
  height: calc(100vh - var(--topbar-height) - 160px);
  min-height: 250px;
}

/* Extra compact variant — for pages with titles + stat cards + search card above */
.page-table-frame.extra-compact {
  height: calc(100vh - var(--topbar-height) - 340px);
  min-height: 200px;
}

/* When there's no search bar, adjust */
.page-table-frame.no-search {
  height: calc(100vh - var(--topbar-height) - 56px);
}

/* The sticky search/filter bar at the top */
.sticky-search-card {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

/* The scrollable table card that fills remaining space */
.scrollable-table-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* When no search card above, keep rounded corners */
.scrollable-table-card.standalone {
  border-radius: var(--radius-card);
}

.scrollable-table-card .card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

/* Sticky table header inside scrollable container */
.scrollable-table-card .card-body thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
}

.scrollable-table-card .card-body thead th {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

/* Sticky table footer inside scrollable container */
.scrollable-table-card .card-body tfoot {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--bg-card);
}

.scrollable-table-card .card-body tfoot td {
  background: var(--bg-card);
  border-top: 2px solid var(--border);
  box-shadow: 0 -1px 0 var(--border);
}

/* Disable hover-lift on scrollable table cards to prevent layout shift */
.scrollable-table-card:hover {
  transform: none;
  box-shadow: none;
}

.sticky-search-card:hover {
  transform: none;
  box-shadow: none;
}

/* --- Dashboard Fixed-Height Widgets --- */
.dashboard-widget-card {
  display: flex;
  flex-direction: column;
  height: 280px;
  overflow: hidden;
}

.dashboard-widget-card:hover {
  transform: none;
}

.dashboard-widget-card .card-header {
  flex-shrink: 0;
}

.dashboard-widget-card .card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

/* Sticky header inside dashboard widget tables */
.dashboard-widget-card .card-body thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-card);
}

.dashboard-widget-card .card-body thead th {
  background: var(--bg-card);
  box-shadow: 0 1px 0 var(--border);
}

/* Dashboard chart card — fixed height, no scroll */
.dashboard-chart-card {
  display: flex;
  flex-direction: column;
  height: 280px;
  overflow: hidden;
}

.dashboard-chart-card:hover {
  transform: none;
}

.dashboard-chart-card .card-header {
  flex-shrink: 0;
}

.dashboard-chart-card .card-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.dashboard-chart-card .card-body canvas {
  max-height: 100% !important;
}

/* Record count badge at bottom of scrollable tables */
.table-record-count {
  flex-shrink: 0;
  padding: 8px 18px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-record-count strong {
  color: var(--accent-light);
}

/* ==========================================================
   26. PRINT STYLES
   ========================================================== */
@media print {
  .sidebar,
  .topbar,
  .sidebar-toggle,
  .btn,
  .action-btns,
  .alert,
  .filter-bar {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
  .content-area {
    padding: 0 !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
  table {
    font-size: 12px;
  }
  thead th {
    background: #f0f0f0;
    color: #333;
  }
  tbody tr:hover {
    transform: none;
    border-left: none;
  }
}

/* ==========================================================
   27. RESPONSIVE — Tablet (≤ 768px)
   ========================================================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  /* Overlay when sidebar is open */
  .sidebar.open ~ .main-content::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .content-area {
    padding: 20px 16px;
  }

  .topbar {
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .form-control,
  .filter-bar select,
  .filter-bar input {
    width: 100%;
    min-width: 0;
  }

  .modal {
    margin: 12px;
    max-height: 90vh;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .alert {
    margin: 0 16px 12px;
  }
}

/* ==========================================================
   28. RESPONSIVE — Mobile (≤ 480px)
   ========================================================== */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  .btn-group .btn {
    width: 100%;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .content-area {
    padding: 16px 12px;
  }

  .topbar {
    padding: 0 12px;
  }

  .pagination-wrapper {
    flex-direction: column;
    align-items: center;
  }

  .pagination a,
  .pagination span {
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .date-display {
    display: none;
  }

  .summary-panel {
    padding: 16px;
  }

  .table-container {
    border-radius: var(--radius);
  }

  thead th {
    padding: 10px 12px;
  }
  tbody td {
    padding: 10px 12px;
  }
}

/* ==========================================================
   29. MISCELLANEOUS / EXTRAS
   ========================================================== */

/* Rupee display helper */
.rupee::before {
  content: '₹';
  margin-right: 2px;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i,
.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 0.88rem;
  max-width: 360px;
  margin: 0 auto;
}

/* Price / Currency formatting */
.price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.price-positive { color: var(--success); }
.price-negative { color: var(--danger); }

/* Row item product helper (for search dropdowns / order line items) */
.product-info {
  display: flex;
  flex-direction: column;
}
.product-name {
  font-weight: 600;
  color: var(--text-primary);
}
.product-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Item count badge for tables */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--gradient-subtle);
  color: var(--accent-light);
}

/* Avatar placeholder */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gradient-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-light);
  flex-shrink: 0;
}
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.72rem;
}
.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
}

/* IST Clock Widget */
.ist-clock-widget {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  background: rgba(26, 29, 39, 0.6);
  backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.ist-time-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.ist-time-group i,
.ist-time-group svg {
  width: 14px;
  height: 14px;
  color: var(--accent-light);
  margin-top: -1px;
}

.ist-time {
  letter-spacing: 0.02em;
}

.ist-ampm {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-left: 2px;
}

.ist-date {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

@media (max-width: 576px) {
  .ist-clock-widget {
    padding: 4px 8px;
  }
  .ist-date {
    display: none;
  }
}

/* Discount Percentage Badge */
.discount-pct-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
  background: var(--success-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================
   CUSTOM CONTEXT MENU & TEXT SELECTION CONTROLS
   ========================================================== */

/* Disable default text selection on everything except inputs/textareas */
*, *::before, *::after {
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, [contenteditable="true"], input *, textarea * {
  user-select: text !important;
  -webkit-user-select: text !important;
}

/* Custom Context Menu */
.custom-context-menu {
  background: rgba(9, 13, 22, 0.85); /* Premium glassmorphism */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 12px);
  width: 220px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 6px;
  animation: contextMenuFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes contextMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-secondary, #94a3b8);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm, 8px);
  transition: all 0.2s ease;
}

.context-menu-item:hover {
  background: rgba(99, 102, 241, 0.15); /* Accent tint */
  color: var(--text-primary, #ffffff);
}

.context-menu-item .context-icon {
  width: 16px;
  height: 16px;
  color: inherit;
}

.context-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

/* ==========================================================
   28. MOBILE BOTTOM NAVIGATION & CARD LIST CONVERSIONS
   ========================================================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  /* Dynamic layout adjustments for mobile */
  .content-area {
    padding: calc(var(--topbar-height) + 16px) 8px 84px 8px !important; /* Avoid bottom nav clipping and topbar overlay */
    overflow-x: hidden !important;
  }

  /* Tighter card padding on mobile to reclaim horizontal space */
  .card {
    padding: 12px 10px !important;
  }

  .card-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  /* Prevent page from expanding horizontally on item add */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* On mobile, prevent dropdown cards from overflowing horizontally, but keep dropdown content visible */
  .card-has-dropdown {
    overflow: visible !important;
  }

  .card-has-dropdown .card-body {
    overflow: visible !important;
  }

  .card-body {
    overflow: hidden;
    max-width: 100%;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(15, 17, 23, 0.88);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 600;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    padding-top: 6px;
  }

  .mobile-nav-item i,
  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease, color 0.2s ease;
    color: inherit;
  }

  .mobile-nav-item:hover,
  .mobile-nav-item:focus {
    color: var(--text-primary);
    outline: none;
  }

  .mobile-nav-item.active {
    color: var(--accent-light);
  }

  .mobile-nav-item.active i,
  .mobile-nav-item.active svg {
    transform: translateY(-2px);
    color: var(--accent-light);
    filter: drop-shadow(0 0 4px rgba(129, 140, 248, 0.4));
  }

  .mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 22px;
    height: 3px;
    background: var(--gradient);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 0 8px var(--accent-light);
  }

  /* Table Card View Conversion for Mobile Screens */
  .table, 
  .table thead, 
  .table tbody, 
  .table th, 
  .table td, 
  .table tr {
    display: block !important;
    width: 100% !important;
  }

  .table thead {
    display: none !important;
  }

  .table tr {
    background: rgba(26, 29, 39, 0.48) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    padding: 12px 14px !important;
    margin-bottom: 16px !important;
    box-shadow: var(--shadow-md) !important;
    transition: border-color var(--speed) var(--ease) !important;
  }

  .table tr:hover {
    border-color: var(--border-light) !important;
  }

  .table td {
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 6px !important;
    text-align: right !important;
    font-size: 0.88rem !important;
  }

  .table td:last-child {
    border-bottom: none !important;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-align: left;
    margin-right: 16px;
    flex-shrink: 0;
  }

  .table td.table-empty-cell {
    display: block !important;
    text-align: center !important;
    justify-content: center !important;
    border: none !important;
    padding: 24px !important;
  }

  .table td.table-empty-cell::before {
    display: none !important;
  }

  /* Strip card decoration wrapping tables to avoid double box visual nesting */
  .scrollable-table-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .scrollable-table-card > .card-body {
    padding: 0 !important;
  }

  .page-table-frame {
    height: auto !important; /* Let body auto-scroll on mobile */
    min-height: 0 !important;
  }
}

/* ==========================================================
   29. RESPONSIVE HELPERS & GRID LAYOUTS
   ========================================================== */

/* Responsive Display Helpers */
.mobile-only {
  display: none !important;
}
.desktop-only {
  display: block;
}
table.desktop-only {
  display: table;
}
div.desktop-only {
  display: block;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: block !important;
  }
  
  /* Collapsible Filters on Mobile */
  .mobile-hide-filters {
    display: none !important;
  }
  
  /* Mobile Sales Card Layout */
  .sales-cards-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
  }

  .sales-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
  }

  .sales-mobile-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--glow-accent);
  }

  .sales-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
  }

  .invoice-badge {
    background: var(--gradient-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-weight: 700;
    font-size: 0.85rem;
  }

  .sales-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
  }

  .sales-card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
  }

  .customer-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  .customer-info .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
  }
  
  .customer-info .card-icon i,
  .customer-info .card-icon svg {
    width: 18px;
    height: 18px;
  }

  .customer-label,
  .amount-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
  }

  .customer-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .amount-info {
    text-align: right;
  }

  .amount-value {
    font-weight: 800;
    color: var(--success);
    font-size: 1.15rem;
  }

  .sales-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 10px;
    margin-top: 4px;
  }

  .card-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    text-decoration: none;
  }

  .card-action-btn i,
  .card-action-btn svg {
    width: 14px;
    height: 14px;
  }

  .card-action-btn.view {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
    color: var(--text-primary);
  }
  .card-action-btn.view:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
  }

  .card-action-btn.edit {
    background: var(--warning-bg);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--warning);
  }
  .card-action-btn.edit:hover {
    background: rgba(245, 158, 11, 0.2);
  }

  .card-action-btn.delete {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
  }
  .card-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
  }

  /* ── Compact Mobile Product Item Cards ── */
  .m-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    min-width: 0;
    max-width: 100%;
  }

  .m-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    border-left: 3px solid var(--accent);
    transition: border-color 0.2s ease;
    overflow: hidden;
    max-width: 100%;
    min-width: 0; /* Enable flex-shrink correctly */
  }

  .m-item--err {
    border-left-color: var(--danger);
  }

  /* Row 1 — header */
  .m-item__head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
  }

  .m-item__idx {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.12);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
  }

  .m-item__name {
    flex: 1;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .m-item__stock {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .m-item__stock.ok {
    background: var(--success-bg);
    color: var(--success);
  }
  .m-item__stock.warn {
    background: var(--warning-bg);
    color: var(--warning);
  }
  .m-item__stock.danger {
    background: var(--danger-bg);
    color: var(--danger);
  }

  .m-item__del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease;
  }
  .m-item__del:hover {
    color: var(--danger);
    background: var(--danger-bg);
  }
  .m-item__del i,
  .m-item__del svg {
    width: 14px;
    height: 14px;
  }

  /* Row 2 — prices inline */
  .m-item__prices {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-wrap: wrap;
  }
  .m-item__prices b {
    color: var(--text-secondary);
    font-weight: 700;
  }
  .m-sep {
    color: var(--border-light);
    font-weight: 400;
  }

  /* Row 3 — controls (qty + disc + total) */
  .m-item__controls {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 100%;
    overflow: hidden;
  }

  .m-input-grp {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    position: relative;
  }

  .m-input-grp label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0;
  }

  .m-inp {
    width: 100%;
    min-width: 0; /* Prevent default browser input min-width from breaking borders */
    height: 32px;
    padding: 4px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s ease;
  }

  .m-inp:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
  }

  .m-inp.inp-err {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
  }

  .m-inp-unit {
    position: absolute;
    right: 6px;
    bottom: 9px;
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    pointer-events: none;
  }

  .m-inp-hint {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--success);
    margin-top: 1px;
  }
  .m-inp-hint.muted {
    color: var(--text-muted);
    font-weight: 600;
  }

  .m-item__total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    flex-shrink: 0;
    min-width: 58px;
    gap: 1px;
    padding-bottom: 2px;
  }

  .m-total-lbl {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .m-item__total b {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--success);
    white-space: nowrap;
  }

  /* Error row */
  .m-item__errs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding-top: 2px;
  }
  .m-item__errs span {
    font-size: 0.62rem;
    color: var(--danger);
    font-weight: 600;
    line-height: 1.2;
  }

  /* Grand total bar */
  .m-grand-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
    margin-top: 4px;
  }
  .m-grand-total span {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
  }
  .m-grand-total b {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--success);
  }
}

/* Sales Filter Form Grid Layout */
.sales-filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: flex-end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.filter-btn, .filter-btn-clear {
  flex: 1;
  justify-content: center;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 992px) {
  .sales-filter-form {
    grid-template-columns: repeat(2, 1fr);
  }
  .filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 576px) {
  .sales-filter-form {
    grid-template-columns: 1fr;
  }
  .filter-actions {
    grid-column: span 1;
  }
}

@media (max-width: 576px) {
  /* Stack headers and forms on extra small mobile devices */
  .d-flex.justify-between.align-items-center {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .d-flex.justify-between.align-items-center .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  form.d-flex, .form-container .d-flex {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  form.d-flex input, 
  form.d-flex select, 
  form.d-flex button {
    width: 100% !important;
    max-width: none !important;
  }
}
