/* =============================================================================
   LareesApp ERP — Main RTL CSS Theme
   Design: Enterprise Light (Default) · Golden Potato Accent · Cairo Font
   Direction: RTL (Arabic-first)
   ============================================================================= */

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

/* ── CSS Variables (Default: Enterprise Light Theme) ───────────────────────── */
:root {
  --primary:        #B8860B; /* Dark Goldenrod / Potato Amber */
  --primary-light:  #D4A017;
  --primary-dark:   #8C6308;
  --secondary:      #F1F5F9; /* Light slate for subtle elements */
  --surface:        #F8FAFC; /* Clean off-white page background */
  --card:           #FFFFFF; /* Pure white cards */
  --card-hover:     #F8FAFC;
  --border:         #E2E8F0; /* Slate 200 border */
  --border-light:   #CBD5E1; /* Slate 300 border */
  --text:           #0F172A; /* Slate 900 primary text */
  --text-muted:     #64748B; /* Slate 500 secondary text */
  --text-light:     #334155; /* Slate 700 medium text */
  --success:        #059669; /* Emerald 600 */
  --success-bg:     rgba(5, 150, 105, 0.1);
  --danger:         #DC2626; /* Red 600 */
  --danger-bg:      rgba(220, 38, 38, 0.1);
  --warning:        #D97706; /* Amber 600 */
  --warning-bg:     rgba(217, 119, 6, 0.1);
  --info:           #0284C7; /* Sky 600 */
  --info-bg:        rgba(2, 132, 199, 0.1);
  --sidebar-w:      240px;
  --sidebar-mini-w: 68px;
  --topbar-h:       50px;
  --radius:         8px;
  --radius-sm:      5px;
  --radius-lg:      10px;
  --shadow:         0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-lg:      0 8px 24px -4px rgba(15, 23, 42, 0.07);
  --trans:          all .15s ease;
}

/* Optional Dark Theme (active only when data-theme="dark") */
[data-theme="dark"] {
  --primary:        #C8973A;
  --primary-light:  #E5B860;
  --primary-dark:   #A07828;
  --secondary:      #1A2535;
  --surface:        #0F1923;
  --card:           #162033;
  --card-hover:     #1C2940;
  --border:         #2A3A52;
  --border-light:   #3A4F6A;
  --text:           #E8EDF5;
  --text-muted:     #7A8BA0;
  --text-light:     #A8B8CC;
  --success:        #2DD4A4;
  --success-bg:     rgba(45, 212, 164, .12);
  --danger:         #F05252;
  --danger-bg:      rgba(240, 82, 82, .12);
  --warning:        #F5A623;
  --warning-bg:     rgba(245, 166, 35, .12);
  --info:           #38BDF8;
  --info-bg:        rgba(56, 189, 248, .12);
  --shadow:         0 4px 20px rgba(0, 0, 0, .35);
  --shadow-sm:      0 2px 8px rgba(0, 0, 0, .25);
  --shadow-lg:      0 8px 40px rgba(0, 0, 0, .5);
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cairo', 'Tajawal', 'Almarai', 'Segoe UI Arabic', 'Segoe UI', Tahoma, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea, optgroup {
  font-family: 'Cairo', 'Tajawal', 'Almarai', 'Segoe UI Arabic', 'Segoe UI', Tahoma, sans-serif;
}

/* ── Code & Numeric Typography: Strictly enforce project standard Cairo & Tajawal ── */
code, kbd, samp, pre, .font-mono, .font-monospace, .font-tabular, [style*="monospace"] {
  font-family: 'Cairo', 'Tajawal', sans-serif !important;
  font-variant-numeric: tabular-nums;
}

.table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

a { color: var(--primary); text-decoration: none; transition: var(--trans); }
a:hover { color: var(--primary-light); }

img { max-width: 100%; height: auto; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Selection ─────────────────────────────────────────────────────────────── */
::selection { background: var(--primary); color: #fff; }

/* ─────────────────────────────────────────────────────────────────────────────
   LAYOUT: Sidebar + Topbar + Main
   ───────────────────────────────────────────────────────────────────────── */

.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (Dark Executive Luxury ERP) ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w, 245px);
  background: #0b1329;
  border-left: 1px solid #1e293b;
  color: #cbd5e1;
  box-shadow: -2px 0 16px rgba(0, 0, 0, 0.25);
  font-family: 'Tajawal', 'Almarai', 'Cairo', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 100;
  transition: width .22s cubic-bezier(0.4, 0, 0.2, 1), transform .28s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background-color: #334155;
  border-radius: 4px;
}

.sidebar-brand {
  padding: 16px 14px 14px;
  min-height: 72px;
  height: auto;
  border-bottom: 1px solid #1e293b;
  background: #070c1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}

.sidebar-brand-logo {
  width: 48px;
  height: 48px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid #f59e0b;
  padding: 2px;
  margin: 0 auto;
}

.sidebar-brand-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.sidebar-brand-text {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.sidebar-brand-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  text-align: center;
  overflow: visible;
}

.sidebar-brand-tagline {
  font-size: 0.7rem;
  font-weight: 700;
  color: #f59e0b;
  display: inline-block;
  align-self: center;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 2px 9px;
  border-radius: 12px;
  margin-top: 5px;
  line-height: 1.3;
  text-align: center;
}

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

/* Standalone Item (Dashboard) */
.nav-item.single-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.18s ease;
  margin-bottom: 2px;
}

.nav-item.single-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.single-item.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.25) 0%, rgba(245, 158, 11, 0.06) 100%);
  color: #fbbf24;
  font-weight: 700;
  border-right: 3px solid #f59e0b;
}

/* Accordion Nav Groups */
.nav-group {
  margin: 1px 0;
  border-radius: 8px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  outline: none;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  box-sizing: border-box;
}

.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-group.is-active > .nav-group-header {
  color: #fbbf24;
}

.nav-group.open > .nav-group-header {
  background: rgba(255, 255, 255, 0.04);
}

.nav-header-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav-group-header .nav-icon,
.nav-item.single-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  flex-shrink: 0;
  transition: color 0.18s ease;
}

.nav-group-header:hover .nav-icon,
.nav-item.single-item:hover .nav-icon,
.nav-group.is-active > .nav-group-header .nav-icon,
.nav-item.single-item.active .nav-icon {
  color: #f59e0b;
}

.nav-chevron {
  color: #64748b;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-group.open > .nav-group-header .nav-chevron {
  transform: rotate(180deg);
  color: #f59e0b;
}

/* Accordion Body & Sub-items */
.nav-group-body {
  display: none;
}

.nav-group.open > .nav-group-body {
  display: block;
}

.nav-group-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 6px 0;
  margin-right: 22px;
  border-right: 2px solid #1e293b;
  padding-right: 8px;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-sub-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  transform: translateX(-3px);
}

.nav-sub-item.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.25) 0%, rgba(245, 158, 11, 0.06) 100%);
  color: #fbbf24;
  font-weight: 700;
  border-right: 3px solid #f59e0b;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid #1e293b;
  background: #070c1a;
  margin-top: auto;
  flex-shrink: 0;
}

.sidebar-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #1e293b;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.sidebar-collapse-btn:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* ── Desktop Mini Sidebar (body.sidebar-mini) ────────────────────────────── */
@media (min-width: 1025px) {
  body.sidebar-mini {
    --sidebar-w: var(--sidebar-mini-w);
  }

  body.sidebar-mini .sidebar {
    width: var(--sidebar-mini-w) !important;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  body.sidebar-mini .sidebar-nav {
    overflow: visible !important;
  }

  body.sidebar-mini .sidebar-brand {
    justify-content: center;
    padding: 0;
  }

  body.sidebar-mini .sidebar-brand-text,
  body.sidebar-mini .nav-label,
  body.sidebar-mini .nav-chevron,
  body.sidebar-mini .collapse-text {
    display: none;
  }

  body.sidebar-mini .nav-item,
  body.sidebar-mini .nav-group-header {
    justify-content: center;
    padding: 10px 0;
    margin: 2px 4px;
  }

  body.sidebar-mini .sidebar-footer {
    padding: 10px 6px;
  }

  body.sidebar-mini .sidebar-collapse-btn {
    justify-content: center;
    padding: 7px 0;
  }

  body.sidebar-mini .sidebar-collapse-btn svg {
    transform: rotate(180deg);
  }

  /* In mini mode: unconditionally hide all sub-items when not hovered */
  body.sidebar-mini .sidebar .nav-group-body,
  body.sidebar-mini .sidebar .nav-group.open > .nav-group-body,
  body.sidebar-mini .sidebar .nav-group.is-active > .nav-group-body {
    display: none !important;
    position: static !important;
  }

  body.sidebar-mini .sidebar .nav-group {
    position: relative !important;
  }

  body.sidebar-mini .sidebar .nav-group:hover > .nav-group-body,
  body.sidebar-mini .sidebar .nav-group.flyout-active > .nav-group-body {
    display: block !important;
    position: absolute !important;
    right: calc(100% + 6px) !important;
    top: 0 !important;
    min-width: 215px !important;
    max-width: 270px !important;
    background: #0b1329 !important;
    border: 1px solid #1e293b !important;
    border-radius: 10px !important;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.8), 0 4px 14px rgba(0, 0, 0, 0.45) !important;
    z-index: 99999 !important;
    padding: 6px 8px !important;
  }
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

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

.topbar-title { font-size: 1rem; font-weight: 600; }

.topbar-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: var(--trans);
  font-family: inherit;
  background: var(--card);
  color: var(--text-muted);
}
.topbar-action:hover { background: var(--secondary); color: var(--text); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--trans);
}
.user-menu:hover { background: var(--secondary); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info { text-align: right; }
.user-name  { font-size: .82rem; font-weight: 600; line-height: 1.2; }
.user-role  { font-size: .7rem; color: var(--text-muted); }

/* ── Main Content Area ─────────────────────────────────────────────────────── */
.main-content {
  margin-right: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  max-width: calc(100% - var(--sidebar-w));
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex: 1;
  box-sizing: border-box;
  overflow-x: hidden;
  transition: margin-right .22s cubic-bezier(0.4, 0, 0.2, 1), width .22s cubic-bezier(0.4, 0, 0.2, 1), max-width .22s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-body { 
  padding: 14px 18px; 
  flex: 1; 
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-title   { font-size: 1.2rem; font-weight: 800; }
.page-subtitle{ font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep::before { content: '‹'; margin: 0 2px; }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Cards
   ───────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  transition: var(--trans);
}
.card:hover { border-color: var(--border-light); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .96rem; font-weight: 800; }
.card-body { }
.card-footer { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }

/* KPI / Stat Cards — Standard Executive Design (Unified Top Border, No Side Lines) */
.stat-card,
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border) !important;
  border-top: 3.5px solid var(--primary) !important;
  border-right: 1px solid var(--border) !important;
  border-left: 1px solid var(--border) !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: var(--radius-md, 10px) !important;
  padding: 14px 18px !important;
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  box-shadow: var(--shadow-sm) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
  position: relative !important;
  overflow: hidden !important;
}

.stat-card::before,
.kpi-card::before {
  display: none !important;
  content: none !important;
}

.stat-card:hover,
.kpi-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08)) !important;
}

/* Color Themes (Top Border Accents — Clean, No Side Bars) */
.stat-card.primary,
.kpi-card.primary {
  border-top: 3.5px solid #2563eb !important;
  border-right: 1px solid var(--border) !important;
}
.stat-card.primary .stat-value,
.kpi-card.primary .stat-value {
  color: #1e40af;
}

.stat-card.success,
.kpi-card.success {
  border-top: 3.5px solid #059669 !important;
  border-right: 1px solid var(--border) !important;
}
.stat-card.success .stat-value,
.kpi-card.success .stat-value {
  color: #047857;
}

.stat-card.warning,
.kpi-card.warning {
  border-top: 3.5px solid #d97706 !important;
  border-right: 1px solid var(--border) !important;
}
.stat-card.warning .stat-value,
.kpi-card.warning .stat-value {
  color: #b45309;
}

.stat-card.danger,
.kpi-card.danger {
  border-top: 3.5px solid #dc2626 !important;
  border-right: 1px solid var(--border) !important;
}
.stat-card.danger .stat-value,
.kpi-card.danger .stat-value {
  color: #b91c1c;
}

.stat-card.info,
.kpi-card.info {
  border-top: 3.5px solid #7c3aed !important;
  border-right: 1px solid var(--border) !important;
}
.stat-card.info .stat-value,
.kpi-card.info .stat-value {
  color: #5b21b6;
}

.stat-card.neutral,
.stat-card.no-color,
.kpi-card.neutral,
.kpi-card.no-color {
  border-top: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm, 10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon.primary  { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.stat-icon.success  { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.stat-icon.warning  { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.stat-icon.danger   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.stat-icon.info     { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }

.stat-info,
.stat-content { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  font-family: 'Cairo', 'Tajawal', 'Almarai', system-ui, -apple-system, sans-serif !important;
  font-variant-numeric: tabular-nums;
  color: var(--text, #0f172a);
}
.stat-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  margin-top: 2px;
}
.stat-trend { font-size: .75rem; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Tables
   ───────────────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-container { overflow-x: auto; }

table.data-table,
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  border: 1px solid var(--border-light);
}

table.data-table thead tr,
table.table thead tr {
  background: var(--secondary);
}

table.data-table th,
table.table th {
  padding: 8px 10px;
  text-align: right;
  font-weight: 800;
  font-size: .8rem;
  color: var(--text);
  letter-spacing: .2px;
  border: 1px solid var(--border-light);
  border-bottom: 2px solid var(--border-light);
  white-space: nowrap;
}

/* Universal Table Sorting Header Styles */
th.sortable-th {
  cursor: pointer !important;
  user-select: none !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
  position: relative;
}

th.sortable-th[class*="col-sticky"],
th.sortable-th.col-sticky-emp,
th.sortable-th.col-sticky-job,
th.sortable-th.col-sticky-type,
th.sortable-th.col-sticky-summary {
  position: sticky !important;
}

th.sortable-th:hover {
  background-color: rgba(37, 99, 235, 0.08) !important;
  color: var(--primary, #2563eb) !important;
}

th.sortable-th .sort-icon {
  display: inline-flex;
  align-items: center;
  margin: 0 4px;
  font-size: 0.72rem;
  opacity: 0.35;
  transition: opacity 0.15s ease, transform 0.15s ease;
  vertical-align: middle;
}

th.sortable-th:hover .sort-icon {
  opacity: 0.8;
  color: var(--primary, #2563eb);
}

th.sortable-th.sort-asc,
th.sortable-th.sort-desc {
  background-color: rgba(37, 99, 235, 0.1) !important;
  color: var(--primary, #2563eb) !important;
  border-bottom: 2px solid var(--primary, #2563eb) !important;
}

th.sortable-th.sort-asc .sort-icon,
th.sortable-th.sort-desc .sort-icon {
  opacity: 1 !important;
  color: var(--primary, #2563eb) !important;
  font-weight: 900;
}

table.data-table td,
table.table td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  vertical-align: middle;
  font-size: .84rem;
}

table.data-table tbody tr:hover,
table.table tbody tr:hover { background: var(--card-hover); }

/* Audit icon per row */
.btn-history {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .72rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans);
  font-weight: 800;
}
.btn-history:hover { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Buttons
   ───────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--trans);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: rgba(184,134,11,.08); color: var(--primary-dark); }

.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--secondary); border-color: var(--border); color: var(--text); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: .9; color: #fff; }

.btn-ghost     { background: transparent; color: var(--text-light); border-color: transparent; }
.btn-ghost:hover { background: var(--secondary); color: var(--text); }

.btn-sm { padding: 4px 9px; font-size: .76rem; }
.btn-lg { padding: 9px 20px; font-size: .9rem; }
.btn-icon { padding: 6px; aspect-ratio: 1; justify-content: center; }
.btn-icon.btn-sm { padding: 4px; }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Forms
   ───────────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 11px; }

.form-label {
  display: block;
  font-size: .84rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 6px 10px;
  background: var(--card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .84rem;
  transition: var(--trans);
  outline: none;
  direction: rtl;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2.5px rgba(184,134,11,.15);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: .6; cursor: not-allowed; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 70px; }

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

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

/* ── Input Group ──────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control { border-radius: 0; flex: 1; }
.input-group .form-control:first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .form-control:last-child  { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-text {
  padding: 9px 12px;
  background: var(--secondary);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: .875rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.input-group-text:first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.input-group-text:last-child  { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Badges & Status
   ───────────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
}
.badge-primary { background: rgba(184,134,11,.12); color: var(--primary-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: var(--secondary);  color: var(--text-muted); }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Modal (Clean Light Design)
   ───────────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: all !important;
}

/* Salesmen & Horizontal KPI Grid on Desktop */
.salesmen-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1200px) {
  .salesmen-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
@media (max-width: 640px) {
  .salesmen-kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(10px);
  transition: transform .25s ease;
}
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }

.modal-box.modal-sm { max-width: 420px; }
.modal-box.modal-lg { max-width: 860px; }
.modal-box.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--trans);
  font-size: 1rem;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.modal-footer { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }

/* ── History / Audit Modal ─────────────────────────────────────────────────── */
.history-timeline { list-style: none; padding: 0; }
.history-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.history-dot.create { background: var(--success); }
.history-dot.update { background: var(--warning); }
.history-dot.delete { background: var(--danger); }
.history-dot.login  { background: var(--info); }

.history-meta { font-size: .78rem; color: var(--text-muted); }
.history-action { font-size: .8rem; font-weight: 600; }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Attachments
   ───────────────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--trans);
  background: var(--secondary);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(184, 134, 11, .05);
}
.dropzone-icon { font-size: 2rem; margin-bottom: 8px; color: var(--text-muted); }
.dropzone-text { font-size: .85rem; color: var(--text-muted); }
.dropzone input[type="file"] { display: none; }

.attachment-list { list-style: none; padding: 0; margin-top: 14px; }
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: var(--trans);
}
.attachment-item:hover { border-color: var(--border-light); }
.attachment-icon { font-size: 1.4rem; flex-shrink: 0; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-meta { font-size: .72rem; color: var(--text-muted); }

.icon-pdf   { color: #F05252; }
.icon-excel { color: #2DD4A4; }
.icon-word  { color: #38BDF8; }
.icon-image { color: var(--primary); }
.icon-file  { color: var(--text-muted); }

/* ── Attachment count badge on rows ─────────────────────────────────────────── */
.attach-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--trans);
}
.attach-count:hover { color: var(--primary); }

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Flash / Toast Notifications
   ───────────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: auto;
  top: auto;
  z-index: 999999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  font-size: .85rem;
  font-weight: 600;
  min-width: 280px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-in .3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all .3s ease;
}
.toast.success { border-right: 4px solid var(--success); }
.toast.error   { border-right: 4px solid var(--danger); }
.toast.warning { border-right: 4px solid var(--warning); }
.toast.info    { border-right: 4px solid var(--info); }

@keyframes toast-in {
  from { transform: translateX(-30px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* Inline In-Page Alert Banners */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 16px;
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.alert-banner.danger, .alert-banner.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
  border-right: 4px solid #ef4444;
}
.alert-banner.success {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
  border-right: 4px solid #22c55e;
}
.alert-banner.warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
  border-right: 4px solid #f59e0b;
}
.alert-banner.info {
  background: #f0f9ff;
  color: #075985;
  border-color: #bae6fd;
  border-right: 4px solid #0ea5e9;
}

@media (max-width: 576px) {
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Invoice Draft Watermark
   ───────────────────────────────────────────────────────────────────────── */
.draft-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 8rem;
  font-weight: 900;
  color: rgba(240,82,82,.12);
  pointer-events: none;
  z-index: 1;
  white-space: nowrap;
  letter-spacing: 6px;
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
/* ─────────────────────────────────────────────────────────────────────────────
   AUTH PAGE LAYOUT — Modern Larees Branded Glass & Blurred Backdrop
   ───────────────────────────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  width: 100%;
  background: radial-gradient(circle at 50% 15%, #0e1c2e 0%, #091320 50%, #050a12 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 30px 16px;
  font-family: 'Tajawal', 'Almarai', 'Cairo', sans-serif;
}

/* Ambient Blurred & Enlarged Logo Backdrop */
.auth-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

/* Ambient Color Lighting Aura */
.auth-backdrop-aura {
  position: absolute;
  width: 900px;
  height: 900px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.18) 0%, rgba(11, 37, 69, 0.45) 45%, transparent 72%);
  filter: blur(60px);
  animation: authAuraPulse 12s ease-in-out infinite alternate;
}

/* Heavily blurred enlarged brand logo with radial mask to feather edges completely */
.auth-backdrop-blur-deep {
  position: absolute;
  width: min(850px, 90vw);
  max-width: 900px;
  height: auto;
  object-fit: contain;
  border-radius: 50%;
  filter: blur(48px) saturate(1.4) brightness(0.95);
  opacity: 0.28;
  transform: scale(1.22);
  mask-image: radial-gradient(ellipse at center, black 40%, rgba(0,0,0,0.6) 60%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, rgba(0,0,0,0.6) 60%, transparent 72%);
  animation: authLogoFloat 18s ease-in-out infinite alternate;
}

/* Faded and softly blurred watermark logo for distinct brand contours without square edges */
.auth-backdrop-watermark {
  position: absolute;
  width: min(720px, 80vw);
  max-width: 760px;
  height: auto;
  object-fit: contain;
  border-radius: 50%;
  filter: blur(14px) brightness(0.9);
  opacity: 0.10;
  transform: scale(1.05);
  mask-image: radial-gradient(ellipse at center, black 42%, rgba(0,0,0,0.5) 60%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 42%, rgba(0,0,0,0.5) 60%, transparent 72%);
}

/* Soft dark vignette to ensure perfect card contrast */
.auth-backdrop-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(5, 10, 18, 0.65) 75%, rgba(5, 10, 18, 0.95) 100%);
}

@keyframes authLogoFloat {
  0%   { transform: scale(1.18) translate(0, 0) rotate(0deg); }
  50%  { transform: scale(1.25) translate(18px, -12px) rotate(1.2deg); }
  100% { transform: scale(1.20) translate(-14px, 14px) rotate(-1deg); }
}

@keyframes authAuraPulse {
  0%   { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(1.22); opacity: 1; }
}

/* Modern Auth Card */
.auth-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 24px;
  padding: 38px 34px 30px;
  box-shadow: 
    0 25px 60px -15px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.15),
    0 0 50px rgba(184, 134, 11, 0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: authCardFadeUp 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFadeUp {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo {
  text-align: center;
  margin-bottom: 22px;
}

.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: #ffffff;
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: 
    0 10px 28px -4px rgba(11, 37, 69, 0.18),
    0 0 0 3px rgba(184, 134, 11, 0.38),
    0 0 24px rgba(184, 134, 11, 0.15);
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.auth-logo-badge:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 
    0 14px 34px -4px rgba(184, 134, 11, 0.35),
    0 0 0 3.5px rgba(184, 134, 11, 0.65);
}

.auth-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(11, 37, 69, 0.12));
}

.auth-app-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
  font-family: 'Tajawal', 'Almarai', sans-serif;
}

.auth-tagline-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.auth-badge-erp {
  background: rgba(184, 134, 11, 0.12);
  color: #946705;
  padding: 2px 9px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.76rem;
  border: 1px solid rgba(184, 134, 11, 0.25);
}

.auth-tagline {
  color: #64748b;
  font-weight: 500;
}

/* Alert Error Toast */
.auth-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-right: 4px solid #dc2626;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
  color: #991b1b;
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: authShake 0.4s ease;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Form Groups & Inputs */
.auth-form-group {
  margin-bottom: 18px;
}

.auth-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 7px;
}

.auth-label.required::after {
  content: " *";
  color: #dc2626;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.2s ease;
  overflow: hidden;
}

.auth-input-wrapper:focus-within {
  border-color: #B8860B;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.15);
}

.auth-field-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 46px;
  color: #94a3b8;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: color 0.2s ease;
  user-select: none;
}

.auth-input-wrapper:focus-within .auth-field-icon {
  color: #B8860B;
}

.auth-input-field {
  flex: 1;
  height: 46px;
  border: none;
  background: transparent;
  padding: 0 12px 0 6px;
  font-size: 0.95rem;
  color: #0f172a;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  width: 100%;
}

.auth-input-field::placeholder {
  color: #94a3b8;
  font-size: 0.88rem;
}

/* Overwrite Chrome pale blue/yellow autofill */
.auth-input-field:-webkit-autofill,
.auth-input-field:-webkit-autofill:hover, 
.auth-input-field:-webkit-autofill:focus,
.auth-input-field:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 50px #ffffff inset !important;
  -webkit-text-fill-color: #0f172a !important;
  transition: background-color 5000s ease-in-out 0s;
}

.auth-toggle-pwd-btn {
  background: transparent;
  border: none;
  width: 42px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  color: #64748b;
  transition: all 0.15s ease;
  border-radius: 8px;
  margin-left: 4px;
}

.auth-toggle-pwd-btn:hover {
  color: #B8860B;
  background: rgba(184, 134, 11, 0.08);
}

/* Remember me & Security hint */
.auth-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 24px;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.86rem;
  color: #475569;
  font-weight: 500;
  user-select: none;
  margin: 0;
}

.auth-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid #cbd5e1;
  accent-color: #B8860B;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-security-hint {
  font-size: 0.78rem;
  color: #059669;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Submit Button */
.auth-submit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: linear-gradient(135deg, #D4A017 0%, #B8860B 50%, #8C6308 100%);
  color: #ffffff;
  font-size: 1.02rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 20px -3px rgba(184, 134, 11, 0.42), 0 3px 6px rgba(0,0,0,0.06);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.auth-submit-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-25deg);
  transition: left 0.75s ease;
}

.auth-submit-btn:hover::before {
  left: 140%;
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(184, 134, 11, 0.55), 0 4px 10px rgba(0,0,0,0.1);
  background: linear-gradient(135deg, #E5B860 0%, #C8973A 50%, #966C07 100%);
}

.auth-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.35);
}

.auth-submit-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
}

/* Footer info */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.6;
}

.auth-footer-version {
  font-weight: 700;
  color: #334155;
}

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Pagination
   ───────────────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  flex-wrap: wrap;
  gap: 10px;
}
.pagination-info { color: var(--text-muted); }
.pagination-pages { display: flex; gap: 4px; }
.pg-btn {
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  transition: var(--trans);
  font-family: inherit;
}
.pg-btn:hover  { border-color: var(--primary); color: var(--primary-dark); }
.pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ─────────────────────────────────────────────────────────────────────────────
   UTILITIES
   ───────────────────────────────────────────────────────────────────────── */
.text-primary { color: var(--primary)  !important; }
.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-center  { text-align: center !important; }
.text-left    { text-align: left !important; }   /* For LTR exceptions */
.text-right   { text-align: right !important; }
.text-bold    { font-weight: 700 !important; }

.d-flex       { display: flex !important; }
.d-none       { display: none !important; }
.d-block      { display: block !important; }
.align-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-1 { gap: 6px !important; }
.gap-2 { gap: 12px !important; }
.gap-3 { gap: 18px !important; }

.mt-1 { margin-top: 6px !important; }
.mt-2 { margin-top: 12px !important; }
.mt-3 { margin-top: 18px !important; }
.mb-1 { margin-bottom: 6px !important; }
.mb-2 { margin-bottom: 12px !important; }
.mb-3 { margin-bottom: 18px !important; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 14px; opacity: .4; }
.empty-state-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-light); }
.empty-state-text  { font-size: .85rem; }

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.separator-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .78rem;
  margin: 16px 0;
}
.separator-or::before, .separator-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT STYLES (COMPACT & CONCISE)
   ───────────────────────────────────────────────────────────────────────── */
.print-only { display: none !important; }

@media print {
  @page {
    margin: 8mm 10mm;
  }
  *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
  }
  * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }
  .sidebar, 
  #sidebar,
  aside.sidebar,
  body.sidebar-mini .sidebar,
  body.sidebar-open .sidebar,
  .sidebar-backdrop,
  #sidebarBackdrop,
  .topbar, 
  header.topbar,
  .sidebar-brand,
  .sidebar-nav,
  .sidebar-footer,
  .sidebar-collapse-btn,
  .sidebar-user-card,
  .page-actions, 
  .no-print, 
  .btn, 
  .breadcrumb, 
  nav,
  .toast-container,
  .modal-overlay,
  .user-guide,
  .guide-box,
  [data-guide],
  form.filter-form,
  form.search-form,
  form.no-print,
  .card-filter,
  .search-bar,
  .filter-box,
  .filter-bar,
  .col-actions,
  .col-attachments,
  .col-history,
  .btn-history,
  th.no-print,
  td.no-print,
  th.col-actions,
  td.col-actions,
  th.col-attachments,
  td.col-attachments,
  th.col-history,
  td.col-history,
  .print-hidden-col {
    display: none !important;
    visibility: hidden !important;
    position: static !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
  .print-only {
    display: block !important;
  }
  table.print-only {
    display: table !important;
  }
  .print-only-flex {
    display: flex !important;
  }
  html {
    font-size: 9.5px !important;
  }
  body, html, body.sidebar-mini, body.sidebar-open {
    background: #ffffff !important;
    color: #0f172a !important;
    font-family: 'Tajawal', 'Almarai', 'Cairo', system-ui, -apple-system, sans-serif !important;
    font-size: 7.5pt !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .layout-wrapper, 
  .main-content, 
  body.sidebar-mini .main-content, 
  body.sidebar-open .main-content,
  .page-body {
    margin: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    box-shadow: none !important;
    border: none !important;
  }
  .page-header {
    margin: 0 0 4px 0 !important;
    padding: 0 0 3px 0 !important;
    border-bottom: 1.5px solid #0f172a !important;
  }
  .page-title {
    font-size: 9.5pt !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    margin: 0 !important;
    line-height: 1.2 !important;
  }
  .page-subtitle {
    font-size: 6.8pt !important;
    color: #475569 !important;
    margin: 0 !important;
    line-height: 1.2 !important;
  }
  .card {
    border: none !important;
    padding: 0 !important;
    margin: 0 0 4px 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .card-body {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  .card-header {
    display: none !important;
  }
  .table-responsive {
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  table.data-table,
  table.table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 7pt !important;
    margin-top: 2px !important;
    margin-bottom: 4px !important;
    table-layout: auto !important;
    border: 1.5px solid #0f172a !important;
  }
  table.data-table th,
  table.data-table td,
  table.table th,
  table.table td {
    padding: 2.5px 4px !important;
    border: 0.75pt solid #64748b !important;
    color: #0f172a !important;
    line-height: 1.15 !important;
    font-size: 7pt !important;
    vertical-align: middle !important;
  }
  table.data-table th,
  table.table th {
    background-color: #f1f5f9 !important;
    font-weight: 800 !important;
    text-align: center !important;
    border-bottom: 1.5px solid #0f172a !important;
    font-size: 7.2pt !important;
    color: #0f172a !important;
  }
  table.data-table tbody tr:nth-child(even),
  table.table tbody tr:nth-child(even) {
    background-color: #f8fafc !important;
  }
  table.data-table tfoot tr td,
  table.table tfoot tr td {
    background-color: #e2e8f0 !important;
    font-weight: 800 !important;
    border-top: 1.5px solid #0f172a !important;
    font-size: 7.2pt !important;
  }

  /* Compact all elements inside table cells */
  table.data-table th *,
  table.data-table td *,
  table.table th *,
  table.table td * {
    font-size: 7pt !important;
    line-height: 1.15 !important;
  }
  table.data-table td strong,
  table.table td strong {
    font-size: 7pt !important;
    font-weight: 800 !important;
    color: #0f172a !important;
  }
  table.data-table td div,
  table.table td div,
  table.data-table td span,
  table.table td span {
    font-size: 6.8pt !important;
    line-height: 1.15 !important;
  }

  .grid-4, .grid-3, .grid-2 {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    margin-bottom: 5px !important;
  }
  .stat-card {
    border: 1px solid #cbd5e1 !important;
    padding: 3px 6px !important;
    margin: 0 !important;
    flex: 1 !important;
    border-radius: 4px !important;
    background: #f8fafc !important;
  }
  .stat-icon {
    display: none !important;
  }
  .stat-value,
  .stat-card .stat-value {
    font-size: 8.5pt !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    margin: 0 !important;
    color: #0f172a !important;
  }
  .stat-label,
  .stat-card .stat-label {
    font-size: 6.5pt !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    margin: 0 !important;
    color: #475569 !important;
  }
  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  thead {
    display: table-header-group !important;
  }
  tfoot {
    display: table-footer-group !important;
  }
  .badge {
    border: none !important;
    background: transparent !important;
    color: #0f172a !important;
    padding: 0 !important;
    font-size: 6.8pt !important;
    font-weight: 700 !important;
  }
  /* Concise Statement Print Layout (Borderless Headers) */
  .statement-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border: none !important;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }
  .print-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 8.5pt;
    border: none !important;
  }
  .print-info-table td {
    border: none !important;
    padding: 2px 6px;
  }
  .print-info-table td.label-cell {
    background: transparent !important;
    font-weight: 800;
    width: 14%;
    border: none !important;
    color: #333;
  }
  .print-summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 8.5pt;
    border: none !important;
  }
  .print-summary-table th, .print-summary-table td {
    border: none !important;
    padding: 4px 6px;
    text-align: center;
  }
  .print-summary-table th {
    background: #f1f5f9;
    font-weight: 800;
    border: none !important;
  }
  .print-summary-table td {
    border: none !important;
  }
  .print-signatures {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    padding-top: 6px;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .print-signature-box {
    width: 30%;
    text-align: center;
    font-size: 8.5pt;
  }
  .print-signature-line {
    margin-top: 36px;
    border-top: 1px dashed #555;
    height: 1px;
  }
}

/* ── Statement Compact UI (Zero Wasted Space) ────────────────────────────── */
.statement-compact-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 6px;
}
.statement-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 5px;
  margin-top: 5px;
  border-top: 1px solid var(--border-light);
}
.statement-meta-strip strong {
  color: var(--text);
  font-weight: 700;
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.stat-strip-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat-strip-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}
.stat-strip-val {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
}
.stat-strip-item.highlight {
  background: rgba(184, 134, 11, 0.08);
  border-color: var(--primary);
}
.stat-strip-item.highlight .stat-strip-val {
  color: var(--primary-dark);
}
@media (max-width: 900px) {
  .stat-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}
.stat-strip-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 640px) {
  .stat-strip-3 {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   COMPACT SYSTEM & ENHANCED READABILITY
   ───────────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

label, .form-label {
  font-weight: 800 !important;
  color: #0f172a !important;
  font-size: 0.83rem !important;
  letter-spacing: 0.1px;
}
[data-theme="dark"] label, [data-theme="dark"] .form-label {
  color: #f1f5f9 !important;
}


/* ── Sidebar Backdrop & Close Button (Mobile & Tablet) ─────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1040;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: var(--trans);
  margin-right: auto;
}

.sidebar-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--danger);
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE: Tablet View (max-width: 1024px)
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Sidebar Drawer on Tablet */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    width: 270px;
    max-width: 85vw;
    z-index: 1050;
    transform: translateX(100%);
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.18);
    transition: transform .28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  /* Main content expands to full width */
  .main-content,
  body.sidebar-mini .main-content,
  body.sidebar-open .main-content {
    margin-right: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
  }

  .topbar-right {
    gap: 10px;
  }

  .topbar-action#sidebarToggle {
    display: inline-flex;
    padding: 8px 12px;
    font-size: 1.1rem;
    line-height: 1;
  }

  /* Grids on Tablet */
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

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

  .stat-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-strip-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE: Mobile View (max-width: 768px)
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html {
    font-size: 14.5px;
  }

  .page-body {
    padding: 10px 12px;
  }

  /* Topbar Mobile */
  .topbar {
    height: 52px;
    padding: 0 12px;
  }

  .topbar-title {
    font-size: 0.92rem;
    font-weight: 700;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-role {
    display: none;
  }

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

  .user-name {
    font-size: 0.78rem;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  /* Page Header Mobile */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .page-subtitle {
    font-size: 0.75rem;
  }

  .page-actions,
  .page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .page-header > div:last-child .btn,
  .page-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  /* Grids & Cards on Mobile */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .stat-strip,
  .stat-strip-3 {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 1.25rem !important;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  /* Forms on Mobile */
  .form-col-2,
  .form-col-3,
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-control,
  select.form-control,
  .btn {
    min-height: 40px;
    font-size: 0.88rem;
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
    max-height: 90vh !important;
    border-radius: 12px 12px 0 0;
  }

  .modal-header {
    padding: 10px 14px;
  }

  .modal-body {
    padding: 12px 14px;
    max-height: calc(90vh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 100px;
    justify-content: center;
  }

  /* Data Tables Mobile */
  .table-responsive {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 0;
    box-shadow: inset -5px 0 8px -4px rgba(0, 0, 0, 0.06);
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    padding-right: 12px;
  }

  .data-table th:last-child,
  .data-table td:last-child {
    padding-left: 12px;
  }

  .btn-sm,
  .btn-history {
    min-width: 30px;
    min-height: 30px;
  }

  /* Toasts on Mobile */
  .toast-container {
    right: 10px !important;
    left: 10px !important;
    bottom: 10px !important;
    max-width: none !important;
    width: auto !important;
  }

  .toast {
    width: 100%;
    font-size: 0.82rem;
    padding: 9px 12px;
  }

  /* Filter Bars on Mobile */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filter-bar .form-control,
  .filter-bar .btn {
    width: 100%;
  }

  /* Statement Compact Layout on Mobile */
  .statement-compact-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    height: auto !important;
    padding: 10px 12px;
  }

  .statement-meta-strip {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.74rem;
  }

  .auth-card {
    padding: 24px 18px;
  }

  /* Mobile Viewport Constraints & Zero Overflow */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .layout-wrapper, .main-content {
    width: 100% !important;
    max-width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    overflow-x: hidden !important;
    min-width: 0 !important;
  }

  /* Mobile Action Bars and Form Submit Footers */
  .form-actions,
  .form-actions-bar,
  .invoice-actions-bar,
  .page-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .form-actions .btn,
  .form-actions-bar .btn,
  .invoice-actions-bar .btn,
  .page-actions .btn {
    width: 100% !important;
    min-width: 0 !important;
    justify-content: center !important;
    min-height: 42px !important;
    font-size: 0.88rem !important;
  }

  /* Invoice & Purchase Calculation Summary Bar */
  .invoice-summary-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px 14px !important;
  }

  .invoice-summary-bar > div {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 6px;
  }

  .invoice-summary-bar > div:last-child {
    border-bottom: none !important;
    padding-bottom: 0;
  }

  /* Flexible Filter Forms & Search Bars on Mobile */
  form[method="GET"][style*="display: flex"],
  .filter-form,
  .card-body > form[style*="display: flex"] {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  form[method="GET"][style*="display: flex"] > div,
  .filter-form > div,
  .card-body > form[style*="display: flex"] > div {
    width: 100% !important;
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }
  form[method="GET"][style*="display: flex"] .btn,
  .filter-form .btn,
  .card-body > form[style*="display: flex"] .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Mobile Tabs Navigation with Momentum Scroll */
  .nav-tabs,
  .leaves-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 6px !important;
    border-bottom: 2px solid var(--border) !important;
    margin-bottom: 14px !important;
    scrollbar-width: thin !important;
    padding-bottom: 2px !important;
  }

  .nav-tabs .nav-link,
  .leaves-tabs .tab-link {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
    font-size: 0.82rem !important;
  }

  /* Settings Grid Single Column on Mobile */
  .settings-grid,
  div[style*="repeat(auto-fill, minmax(260px, 1fr))"],
  div[style*="repeat(auto-fit, minmax(220px, 1fr))"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Quick Actions Container on Mobile */
  #primaryQuickActionsContainer .quick-action-btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    text-align: center;
    min-height: 38px;
  }

  /* Form entries in invoice and production */
  .item-entry-bar,
  .item-add-container {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .item-entry-bar > div,
  .item-add-container > div {
    width: 100% !important;
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  /* Searchable Combobox on Mobile */
  .searchable-combobox {
    position: relative;
    width: 100%;
  }

  .combobox-dropdown {
    max-width: 100% !important;
    min-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 280px !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE: Extra Small Mobile Screens (max-width: 480px)
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .page-body {
    padding: 8px 10px;
  }

  .topbar {
    height: 48px;
    padding: 0 8px;
  }

  .topbar-title {
    font-size: 0.86rem;
    max-width: 130px;
  }

  .topbar-action#sidebarToggle {
    padding: 6px 10px;
    font-size: 1rem;
  }

  .user-name {
    display: none;
  }

  .user-menu {
    padding: 4px;
  }

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

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

  .page-title {
    font-size: 1.05rem;
  }

  .form-actions {
    flex-direction: column;
    gap: 8px;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  #primaryQuickActionsContainer .quick-action-btn {
    flex: 1 1 100% !important;
  }

  .btn {
    font-size: 0.84rem !important;
  }

  .data-table th,
  .data-table td {
    padding: 6px 8px !important;
    font-size: 0.78rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   COMPONENTS: Audit & History Modal (!)
   ───────────────────────────────────────────────────────────────────────── */
.btn-history {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-history:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  transform: translateY(-1px) scale(1.06);
  box-shadow: 0 3px 6px -1px rgba(2, 132, 199, 0.3);
}

.btn-history:active {
  transform: translateY(0) scale(0.96);
}

.audit-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.audit-meta-card {
  border-radius: 8px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid;
}

.audit-meta-card.created {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.audit-meta-card.updated {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.audit-meta-card.deleted {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.audit-meta-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.audit-meta-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.audit-meta-label {
  font-size: 0.73rem;
  font-weight: 700;
  opacity: 0.85;
  text-transform: uppercase;
}

.audit-meta-user {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-meta-time {
  font-size: 0.74rem;
  opacity: 0.8;
}

.audit-timeline {
  position: relative;
  padding-right: 22px;
  border-right: 2px solid #e2e8f0;
  margin-right: 12px;
  margin-top: 10px;
}

.audit-timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.audit-timeline-item:last-child {
  margin-bottom: 4px;
}

.audit-timeline-dot {
  position: absolute;
  right: -28px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px #cbd5e1;
}

.audit-timeline-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.audit-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.audit-timeline-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.audit-timeline-date {
  font-size: 0.73rem;
  color: #64748b;
}

.audit-timeline-actor {
  font-size: 0.82rem;
  color: #1e293b;
  font-weight: 600;
  margin-bottom: 4px;
}

.audit-timeline-diffs {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.8rem;
  color: #334155;
}

.audit-diff-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HR & PAYROLL MODULE DESIGN SYSTEM (Consolidated Component Architecture)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Universal Module Header & Layout ── */
.adv-container, .leaves-container {
  width: 100%;
}

.adv-page-header, .leaves-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.adv-title-group h1, .leaves-title-area h1 {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.adv-title-group .adv-subtitle, .leaves-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.adv-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── HR Executive KPI Cards & Grid ── */
.adv-kpi-grid, .leaves-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.adv-kpi-card, .leaves-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3.5px solid var(--primary) !important;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
  overflow: hidden;
}

.adv-kpi-card:hover, .leaves-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.adv-kpi-icon-box, .kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.adv-kpi-info, .kpi-data {
  flex: 1;
}

.adv-kpi-lbl, .kpi-data-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.adv-kpi-val, .kpi-data-val {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.adv-kpi-sub {
  font-size: 0.72rem;
  margin-top: 3px;
  color: #64748b;
}

/* KPI Status Color Accents */
.kpi-disbursed, .leaves-kpi-card.kpi-blue { border-top-color: #2563eb !important; }
.kpi-disbursed .adv-kpi-val { color: #1e40af; }
.kpi-disbursed .adv-kpi-icon-box { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.kpi-active { border-top-color: #dc2626 !important; }
.kpi-active .adv-kpi-val { color: #b91c1c; }
.kpi-active .adv-kpi-icon-box { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.kpi-repaid, .leaves-kpi-card.kpi-green { border-top-color: #059669 !important; }
.kpi-repaid .adv-kpi-val { color: #047857; }
.kpi-repaid .adv-kpi-icon-box { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.kpi-pending, .leaves-kpi-card.kpi-amber { border-top-color: #d97706 !important; }
.kpi-pending .adv-kpi-val { color: #b45309; }
.kpi-pending .adv-kpi-icon-box { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.leaves-kpi-card.kpi-pink { border-top-color: #db2777 !important; }
.leaves-kpi-card.kpi-slate { border-top-color: #64748b !important; }

/* ── Main Data Card & Filter Bar ── */
.adv-main-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  overflow: hidden;
}

.adv-filter-bar, .leaves-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg, #ffffff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.adv-filter-form, .filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.adv-input-sm, .filter-form select, .filter-form input {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.adv-input-sm:focus, .filter-form select:focus, .filter-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

.adv-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Tabs Navigation ── */
.leaves-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

.tab-link:hover {
  color: var(--primary);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--text);
  font-weight: 800;
}

.tab-link.active .tab-badge {
  background: var(--primary);
  color: #fff;
}

/* ── Interactive Tables ── */
.adv-table-container {
  overflow-x: auto;
  min-height: 250px;
}

table.adv-table, table.leaves-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.84rem;
}

table.adv-table thead th, table.leaves-table thead th {
  background: var(--secondary, #f8fafc);
  color: var(--text-light, #475569);
  padding: 10px 14px;
  font-weight: 800;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

table.adv-table tbody td, table.leaves-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light, #f1f5f9);
  color: var(--text);
  vertical-align: middle;
}

table.adv-table tbody tr:hover, table.leaves-table tbody tr:hover {
  background: rgba(0,0,0,0.015);
}

/* ── Employee Pills & Badges ── */
.adv-emp-pill {
  display: flex;
  flex-direction: column;
}

.adv-emp-name {
  font-weight: 800;
  color: var(--text);
}

.adv-emp-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.badge-adv, .badge-leave-type, .badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-adv-approved, .status-approved { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-adv-deducted { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-adv-pending, .status-pending { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-adv-rejected, .status-rejected { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.voucher-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.75rem;
  text-decoration: none;
  font-family: system-ui, sans-serif !important;
  transition: all .15s ease;
}

.voucher-link-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ── Action Buttons ── */
.btn-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}

.btn-action-icon:hover {
  background: var(--secondary);
  transform: scale(1.05);
}

.btn-act-print { color: #2563eb; border-color: #bfdbfe; }
.btn-act-print:hover { background: #eff6ff; }
.btn-act-approve { color: #059669; border-color: #a7f3d0; }
.btn-act-approve:hover { background: #ecfdf5; }
.btn-act-repay { color: #b45309; border-color: #fde68a; }
.btn-act-repay:hover { background: #fffbeb; }
.btn-act-delete { color: #dc2626; border-color: #fecaca; }
.btn-act-delete:hover { background: #fef2f2; }

/* ── Modal Overlay & Box ── */
.adv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.adv-modal-overlay.is-active,
.adv-modal-overlay.open {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.adv-modal-box {
  background: var(--card, #ffffff);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform .2s ease;
}

.adv-modal-overlay.is-active .adv-modal-box,
.adv-modal-overlay.open .adv-modal-box {
  transform: translateY(0) scale(1) !important;
}

.adv-modal-header {
  padding: 16px 20px;
  background: var(--secondary, #f8fafc);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.adv-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.adv-modal-close {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.adv-modal-close:hover { color: var(--text); }

.adv-modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 75vh;
}

.adv-modal-footer {
  padding: 14px 20px;
  background: var(--secondary, #f8fafc);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Form Groups ── */
.adv-form-group {
  margin-bottom: 16px;
}

.adv-form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.adv-form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

.adv-form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

.emp-balance-hint {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 5px;
}
.has-active-adv { color: #dc2626; }
.no-active-adv { color: #059669; }

/* ── Responsive Rules ── */
@media (max-width: 768px) {
  .adv-kpi-grid, .leaves-kpi-grid { grid-template-columns: 1fr 1fr; }
  .adv-filter-bar, .leaves-toolbar { flex-direction: column; align-items: stretch; }
  .adv-filter-form, .filter-form { flex-direction: column; align-items: stretch; }
  .adv-input-sm, .filter-form select, .filter-form input { width: 100%; }
}

/* ── Payroll Preparation & Daily Wages Module Components ── */
.prepare-filter-bar, .daily-date-bar {
  background: var(--card, #ffffff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.kpi-grid-5 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.payroll-input {
  text-align: center;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: var(--card, #ffffff);
  width: 100%;
  box-sizing: border-box;
}

.payroll-input:focus {
  border-color: #2563eb;
  background: #eff6ff;
  outline: none;
}

.emp-row.is-excluded {
  opacity: 0.45;
  background: #fafafa !important;
}

@media (max-width: 768px) {
  .prepare-filter-bar, .daily-date-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .prepare-filter-bar form, .daily-date-bar form {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .daily-date-bar input[type="date"] {
    width: 100% !important;
  }
  .prepare-actions-bar, .form-actions-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .prepare-actions-bar .btn,
  .prepare-actions-bar > div:last-child,
  .form-actions-bar .btn,
  .form-actions-bar > div:last-child {
    width: 100% !important;
    flex-direction: column !important;
  }
}

/* =============================================================================
   SECTION: UNIFIED FULL-WIDTH & RESPONSIVE SPLIT-FORM ARCHITECTURE
   Enterprise 100% Width Forms, Sticky Actions Panel, & Mobile Ergonomics
   ============================================================================= */

/* Universal Full Width Card & Container */
.card-full {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Master-Detail 2-Column Split Form Layout (75% / 25%) */
.form-layout-split,
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
}

.form-main-pane,
.layout-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.form-sticky-panel,
.layout-sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}

.form-action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-context-card {
  background: rgba(2, 132, 199, 0.04);
  border: 1px solid rgba(2, 132, 199, 0.18);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.82rem;
  color: #0369a1;
  line-height: 1.5;
}

/* Responsive Grid Form Helpers */
.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 1024px) {
  .form-layout-split,
  .layout-split {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .form-sticky-panel,
  .layout-sidebar {
    position: static;
  }
  .form-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .form-grid-4,
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Mobile Touch Targets & Font Zoom Protection */
  .form-control, 
  select.form-control, 
  textarea.form-control {
    min-height: 48px !important;
    font-size: 16px !important; /* Prevents auto-zoom on iOS */
    padding: 10px 14px !important;
  }
  
  .btn {
    min-height: 46px;
    font-size: 0.95rem;
  }

  /* Floating Bottom Action Bar on Mobile */
  .mobile-sticky-actions,
  .mobile-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1.5px solid var(--border);
    padding: 10px 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: flex;
    gap: 10px;
    align-items: center;
  }
  .mobile-sticky-actions .btn,
  .mobile-action-bar .btn {
    flex: 1;
    min-height: 48px;
    font-weight: 800;
    justify-content: center;
  }

  body.has-mobile-bottom-bar,
  body:has(.mobile-sticky-actions),
  body:has(.mobile-action-bar) {
    padding-bottom: 76px !important;
  }

  /* Modals as Mobile Bottom Sheets */
  .modal-overlay,
  .modal-backdrop,
  .adv-modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal-box,
  .adv-modal-box,
  .modal-bottom-sheet,
  .modal-backdrop > .card,
  .modal-backdrop > .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    animation: modalSheetUp 0.24s cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative;
  }
  .modal-box::before,
  .adv-modal-box::before,
  .modal-bottom-sheet::before {
    content: '';
    display: block;
    width: 44px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 3px;
    margin: 8px auto 4px auto;
  }
  @keyframes modalSheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

/* ══ Warehouse Category Multi-select Filter ══ */
.wh-filter-bar {
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.wh-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 8px;
  border: 1.5px solid var(--border, #cbd5e1);
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}
.wh-filter-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
.wh-filter-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
.wh-filter-btn.active[data-filter-type="cold_store"] {
  background: #0284c7;
  border-color: #0369a1;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.2);
}
.wh-filter-btn.active[data-filter-type="general"] {
  background: #475569;
  border-color: #334155;
  box-shadow: 0 2px 6px rgba(71, 85, 105, 0.2);
}
.wh-filter-btn.active[data-filter-type="storage"] {
  background: #b8860b;
  border-color: #92400e;
  box-shadow: 0 2px 6px rgba(184, 134, 11, 0.2);
}
.wh-filter-btn.active[data-filter-type="van"] {
  background: #4f46e5;
  border-color: #4338ca;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
}
.wh-filter-count {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  font-weight: 800;
}
.wh-filter-btn.active .wh-filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ══════════════════════════════════════════════════════════════════════════
   FLATPICKR MODERN ENTERPRISE THEME — Crisp Outline, Deep Shadow & Contrast
   ══════════════════════════════════════════════════════════════════════════ */
.flatpickr-calendar {
  background: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 14px !important;
  box-shadow: 0 20px 40px -4px rgba(15, 23, 42, 0.24), 0 8px 20px -4px rgba(15, 23, 42, 0.12) !important;
  font-family: 'Tajawal', 'Almarai', system-ui, sans-serif !important;
  direction: rtl !important;
  padding: 8px !important;
  width: 315px !important;
  z-index: 99999 !important;
  overflow: hidden !important;
}

.flatpickr-calendar::before,
.flatpickr-calendar::after {
  border-bottom-color: #cbd5e1 !important;
}

.flatpickr-months {
  display: flex !important;
  align-items: center !important;
  background: #f8fafc !important;
  border-radius: 10px !important;
  padding: 6px 6px !important;
  margin-bottom: 8px !important;
  border: 1px solid #e2e8f0 !important;
  position: relative !important;
}

.flatpickr-months .flatpickr-month {
  color: #0f172a !important;
  font-weight: 800 !important;
  height: 34px !important;
  line-height: 34px !important;
}

.flatpickr-current-month {
  font-size: 0.95rem !important;
  font-weight: 800 !important;
  padding: 0 !important;
  color: #0f172a !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
}

.flatpickr-current-month .cur-month {
  font-weight: 800 !important;
  color: #0f172a !important;
}

.flatpickr-current-month input.cur-year {
  font-weight: 800 !important;
  color: #2563eb !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  padding: 6px !important;
  border-radius: 8px !important;
  color: #475569 !important;
  transition: all 0.15s ease !important;
  top: 6px !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

.flatpickr-weekdays {
  margin-bottom: 6px !important;
}

span.flatpickr-weekday {
  color: #64748b !important;
  font-weight: 800 !important;
  font-size: 0.8rem !important;
}

.flatpickr-days {
  width: 100% !important;
}

.dayContainer {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  justify-content: space-around !important;
}

.flatpickr-day {
  border-radius: 8px !important;
  font-weight: 700 !important;
  font-size: 0.88rem !important;
  color: #1e293b !important;
  height: 36px !important;
  line-height: 36px !important;
  margin: 1px !important;
  transition: all 0.15s ease !important;
  border: 1px solid transparent !important;
}

.flatpickr-day:hover {
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  color: #1d4ed8 !important;
}

.flatpickr-day.today {
  border: 1.5px solid #2563eb !important;
  background: #f0fdf4 !important;
  color: #166534 !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35) !important;
  font-weight: 900 !important;
}

.flatpickr-day.inRange {
  background: #dbeafe !important;
  border-color: #bfdbfe !important;
  color: #1e40af !important;
  box-shadow: -5px 0 0 #dbeafe, 5px 0 0 #dbeafe !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: #94a3b8 !important;
  opacity: 0.45 !important;
}

/* Datepicker Form Input Controls */
input.flatpickr-input,
.date-picker-control {
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  transition: all 0.2s ease !important;
  padding: 6px 10px !important;
  cursor: pointer !important;
}

input.flatpickr-input:hover,
.date-picker-control:hover {
  border-color: #94a3b8 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12) !important;
}

input.flatpickr-input:focus,
input.flatpickr-input.active,
.date-picker-control:focus,
.date-picker-control.active {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18), 0 1px 3px rgba(15, 23, 42, 0.08) !important;
  outline: none !important;
}

/* ==============================================================================
   GENERAL ARCHIVING SUBSYSTEM (الأرشيف العام والمستندات)
   ============================================================================== */
.archive-module-container {
  width: 100%;
}

/* Year Tabs */
.archive-year-tabs-container {
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.archive-year-tabs {
  display: inline-flex;
  gap: 8px;
  background: var(--surface);
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.archive-year-tab {
  padding: 6px 16px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.archive-year-tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
.archive-year-tab.active {
  background: #2563eb;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

/* Main Split Layout */
.archive-main-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 991px) {
  .archive-main-layout {
    grid-template-columns: 1fr;
  }
}

/* Sidebar Folder Tree */
.archive-sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.archive-sidebar-header {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.archive-sidebar-body {
  padding: 8px;
  max-height: 720px;
  overflow-y: auto;
}
.archive-tree-container {
  font-size: 0.88rem;
}
.archive-tree-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tree-sublist {
  padding-right: 18px;
  border-right: 1.5px dashed var(--border);
  margin-top: 2px;
  margin-bottom: 4px;
}
.archive-tree-item {
  margin: 2px 0;
}
.archive-node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.archive-node-row:hover {
  background: rgba(37, 99, 235, 0.06);
}
.archive-node-row.active {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}
.archive-node-row.active .node-title {
  color: #1d4ed8;
  font-weight: 800;
}
.tree-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.archive-tree-item.is-open > .archive-node-row .tree-toggle-btn {
  transform: rotate(90deg);
}
.tree-spacer {
  width: 14px;
  display: inline-block;
}
.archive-node-link {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}
.node-folder-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}
.node-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.node-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  border-radius: 10px;
  flex-shrink: 0;
}
.archive-node-row.active .node-badge {
  background: #dbeafe;
  color: #1e40af;
}

/* Subfolders Grid */
.archive-subfolders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.subfolder-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.subfolder-card:hover {
  transform: translateY(-2px);
  border-color: #3b82f6;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
}
.subfolder-icon {
  font-size: 1.5rem;
}
.subfolder-title {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subfolder-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Breadcrumbs & Header Card */
.archive-breadcrumb-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.archive-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  flex-wrap: wrap;
}
.crumb-link {
  color: #2563eb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crumb-link:hover {
  text-decoration: underline;
}
.crumb-separator {
  color: var(--text-muted);
  opacity: 0.6;
}
.crumb-current {
  color: var(--text);
}
.archive-folder-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

/* View Mode Toggles */
.archive-view-toggles {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.view-toggle-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.view-toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
}

/* Files Grid View */
.archive-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.archive-file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.archive-file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}
.file-card-preview {
  height: 130px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.file-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}
.archive-file-card:hover .file-thumb-img {
  transform: scale(1.04);
}
.file-type-icon-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.file-ext-pill {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.file-card-info {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.file-card-title {
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.file-card-folder {
  margin-top: auto;
  font-size: 0.75rem;
  margin-bottom: 4px;
}
.file-card-folder a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.file-card-folder a:hover {
  text-decoration: underline;
}
.file-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #94a3b8;
  padding-top: 4px;
  border-top: 1px dashed #e2e8f0;
}
.file-card-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--border);
}
.file-card-actions .btn {
  padding: 4px 6px;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.file-card-actions form {
  display: inline-flex;
  margin: 0;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}
.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}
.dropzone-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.dropzone-browse {
  color: #2563eb;
  text-decoration: underline;
}
.dropzone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.upload-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}
.upload-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.upload-queue-item .queue-name {
  flex: 1;
}

/* Lightbox Modal */
.archive-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.archive-lightbox-overlay.active {
  display: flex;
  opacity: 1;
}
.archive-lightbox-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox-close-btn {
  position: absolute;
  top: -40px;
  left: 0;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.6);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}
.lightbox-nav-btn:hover {
  background: rgba(37, 99, 235, 0.8);
  border-color: #60a5fa;
}
.lightbox-nav-btn.prev {
  right: -60px;
}
.lightbox-nav-btn.next {
  left: -60px;
}
@media (max-width: 768px) {
  .lightbox-nav-btn.prev { right: 8px; }
  .lightbox-nav-btn.next { left: 8px; }
}
.lightbox-content {
  max-width: 85vw;
  max-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
.lightbox-caption {
  width: 100%;
  margin-top: 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 10px 16px;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.lightbox-title {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.lightbox-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
}
.lightbox-meta {
  font-size: 0.74rem;
  color: #94a3b8;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ARCHIVES: Unified Quick Live Search (Search-as-you-type 3+ chars)
   ───────────────────────────────────────────────────────────────────────── */
.archive-live-search-container {
  position: relative;
  width: 320px;
  max-width: 100%;
}
.archive-live-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card, #ffffff);
  border: 1.5px solid var(--border, #cbd5e1);
  border-radius: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.archive-live-search-box:focus-within {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.archive-search-icon {
  position: absolute;
  right: 12px;
  font-size: 0.95rem;
  color: var(--text-muted, #94a3b8);
  pointer-events: none;
  line-height: 1;
}
.archive-live-search-input {
  width: 100%;
  height: 38px;
  padding: 6px 36px 6px 34px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text-main, #1e293b);
  outline: none;
}
.archive-live-search-input::placeholder {
  color: #94a3b8;
  font-size: 0.82rem;
}
.archive-search-clear {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.archive-search-clear:hover {
  color: #ef4444;
}
.archive-search-spinner {
  position: absolute;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.archive-search-spinner .spinner-dot {
  width: 14px;
  height: 14px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary, #2563eb);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Dropdown Results Window */
.archive-live-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 480px;
  max-width: 92vw;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12), 0 5px 10px rgba(0, 0, 0, 0.06);
  z-index: 1060;
  overflow: hidden;
  animation: dropdownFadeIn 0.18s ease-out;
}
@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.archive-live-search-header {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
}
.archive-live-search-hint {
  font-size: 0.72rem;
  font-weight: normal;
  color: #94a3b8;
}
.archive-live-search-body {
  max-height: 420px;
  overflow-y: auto;
  padding: 6px 0;
}
.archive-live-section-title {
  padding: 8px 14px 4px 14px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.archive-live-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.archive-live-item:last-child {
  border-bottom: none;
}
.archive-live-item:hover {
  background: #f8fafc;
}
.archive-live-item .item-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.archive-live-item .item-icon {
  font-size: 1.25rem;
  line-height: 1;
}
.archive-live-item .item-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.archive-live-item .item-details {
  flex: 1;
  min-width: 0;
}
.archive-live-item .item-title {
  display: block;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-main, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.archive-live-item .item-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.archive-live-item .item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.archive-live-item .item-size {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
}
.archive-live-item .item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.archive-live-item .btn-icon {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border, #e2e8f0);
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.archive-live-item .btn-icon:hover {
  background: var(--primary, #2563eb);
  color: #ffffff;
  border-color: var(--primary, #2563eb);
}
.archive-live-item mark {
  background: #fef08a;
  color: #713f12;
  border-radius: 2px;
  padding: 0 2px;
}
.archive-live-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted, #64748b);
}
.archive-live-empty span {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}
.archive-live-empty p {
  margin: 0;
  font-size: 0.85rem;
}
.archive-live-search-footer {
  padding: 8px 14px;
  background: #f8fafc;
  border-top: 1px solid var(--border, #e2e8f0);
  text-align: center;
}
.archive-live-full-search-link {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary, #2563eb);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.archive-live-full-search-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .archive-live-search-container {
    width: 100%;
    order: -1;
    margin-bottom: 6px;
  }
  .archive-live-search-dropdown {
    width: 100%;
    right: 0;
    left: 0;
  }
}





