/* ============================================================
   Maslaha ERP — Design System
   Bold & Modern | Mobile-First | Modular
   ============================================================ */

/* ─── 1. DESIGN TOKENS ────────────────────────────────────── */
:root {
  /* Brand — Tenant (green) */
  --color-primary:         #16a34a;
  --color-primary-light:   #22c55e;
  --color-primary-dark:    #15803d;
  --color-primary-subtle:  #f0fdf4;
  --color-accent:          #f59e0b;
  --color-accent-subtle:   #fffbeb;

  /* Semantic */
  --color-danger:          #ef4444;
  --color-danger-subtle:   #fef2f2;
  --color-warning:         #f97316;
  --color-warning-subtle:  #fff7ed;
  --color-success:         #22c55e;
  --color-success-subtle:  #f0fdf4;
  --color-info:            #3b82f6;
  --color-info-subtle:     #eff6ff;

  /* Surfaces */
  --color-bg:              #f4f6f8;
  --color-surface:         #ffffff;
  --color-surface-alt:     #f8fafc;
  --color-border:          #e5e7eb;
  --color-border-light:    #f3f4f6;

  /* Text */
  --color-text:            #111827;
  --color-text-secondary:  #6b7280;
  --color-text-muted:      #9ca3af;

  /* Sidebar — Tenant */
  --sidebar-bg:            #111827;
  --sidebar-text:          rgba(255,255,255,.68);
  --sidebar-text-hover:    rgba(255,255,255,.90);
  --sidebar-text-active:   #ffffff;
  --sidebar-hover-bg:      rgba(255,255,255,.06);
  --sidebar-active-bg:     rgba(255,255,255,.09);
  --sidebar-active-accent: var(--color-primary);
  --sidebar-section:       rgba(255,255,255,.28);
  --sidebar-divider:       rgba(255,255,255,.07);
  --sidebar-footer:        rgba(255,255,255,.22);

  /* Typography */
  --font-family:           'Plus Jakarta Sans', 'Inter', -apple-system, 'Segoe UI', sans-serif;

  /* Font scale */
  --font-size-xs:          11px;
  --font-size-sm:          13px;
  --font-size-base:        14px;
  --font-size-md:          15px;
  --font-size-lg:          17px;
  --font-size-xl:          20px;
  --font-size-2xl:         24px;
  --font-size-3xl:         30px;

  /* Spacing */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   32px;
  --space-2xl:  48px;

  /* Layout */
  --sidebar-width:  256px;
  --topbar-height:  60px;

  /* Borders */
  --border-radius: 8px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     20px;
  --radius-full:   9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 8px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.09), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.06);

  /* Transitions */
  --transition:      150ms ease;
  --transition-slow: 250ms ease;
}

/* Super Admin theme override */
.theme-superadmin {
  --sidebar-bg:            #0f172a;
  --sidebar-active-accent: #3b82f6;
  --color-primary:         #2563eb;
  --color-primary-light:   #3b82f6;
  --color-primary-dark:    #1d4ed8;
  --color-primary-subtle:  #eff6ff;
  --color-success:         #10b981;
  --color-success-subtle:  #ecfdf5;
}


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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img, svg { display: block; }

button, input, select, textarea { font-family: inherit; }


/* ─── 3. LAYOUT SHELL ─────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.page-content {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
}


/* ─── 4. SIDEBAR ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px var(--space-lg) 18px;
  font-size: var(--font-size-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  border-bottom: 1px solid var(--sidebar-divider);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.3;
  flex-shrink: 0;
}

.sidebar-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--sidebar-active-accent);
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--sidebar-active-accent);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm) 0;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12);
  border-radius: 3px;
}

.nav-section {
  padding: 14px 16px 4px;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--sidebar-section);
  font-weight: 600;
  margin: 0 8px;
  pointer-events: none;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--sidebar-text);
  font-size: var(--font-size-sm);
  font-weight: 450;
  transition: background var(--transition), color var(--transition);
  position: relative;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  line-height: 1.4;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--sidebar-active-accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .65;
  transition: opacity var(--transition);
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-xs);
  color: var(--sidebar-footer);
  border-top: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
}


/* ─── 4b. NAV GROUPS (collapsible sections — tenant only) ─── */
.nav-group { position: relative; }

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 4px 16px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.nav-group-header:hover {
  background: rgba(255,255,255,.04);
}

.nav-section-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--sidebar-section);
  font-weight: 600;
  transition: color var(--transition);
  pointer-events: none;
}
.nav-group-header:hover .nav-section-label {
  color: rgba(255,255,255,.45);
}

.nav-chevron {
  width: 12px;
  height: 12px;
  color: rgba(255,255,255,.25);
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

/* Submenu — hidden by default */
.nav-submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--transition-slow);
}
.nav-submenu-inner { overflow: hidden; }

/* ── Desktop: hover to reveal ── */
@media (min-width: 769px) {
  .nav-group:hover > .nav-submenu,
  .nav-group.has-active > .nav-submenu {
    grid-template-rows: 1fr;
  }
  .nav-group:hover > .nav-group-header .nav-chevron,
  .nav-group.has-active > .nav-group-header .nav-chevron {
    transform: rotate(90deg);
    color: rgba(255,255,255,.55);
  }
}

/* ── Mobile: open class toggled by JS ── */
.nav-group.open > .nav-submenu { grid-template-rows: 1fr; }
.nav-group.open > .nav-group-header .nav-chevron {
  transform: rotate(90deg);
  color: rgba(255,255,255,.55);
}

/* Active section: always expanded on all viewports */
.nav-group.has-active > .nav-submenu { grid-template-rows: 1fr; }
.nav-group.has-active > .nav-group-header .nav-chevron {
  transform: rotate(90deg);
  color: rgba(255,255,255,.55);
}


/* ─── 5. TOPBAR ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.topbar-toggle:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.topbar-title {
  font-weight: 800;
  font-size: var(--font-size-lg);
  color: var(--color-text);
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

/* ─── Confirm Modal ────────────────────────────────────── */
.erp-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.erp-confirm-backdrop[hidden] { display: none !important; }
.erp-confirm-backdrop.visible { opacity: 1; }
.erp-confirm-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 420px;
  width: 100%;
  padding: var(--space-xl);
  transform: scale(.93) translateY(-10px);
  transition: transform var(--transition-slow), opacity var(--transition-slow);
  opacity: 0;
}
.erp-confirm-backdrop.visible .erp-confirm-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.erp-confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-warning-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}
.erp-confirm-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-warning);
}
.erp-confirm-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-xs);
}
.erp-confirm-msg {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--space-lg);
}
.erp-confirm-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-xs);
  flex-shrink: 0;
  border: 2px solid var(--color-primary-subtle);
  text-transform: uppercase;
}

.topbar-username {
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-sm);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 6. NOTIFICATIONS ────────────────────────────────────── */
.notification-bell { position: relative; }

.bell-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.bell-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.notification-dropdown[hidden] { display: none !important; }

.notification-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-height: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notif-header {
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.notif-header strong {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 0;
  font-family: inherit;
  transition: opacity var(--transition);
}
.btn-link:hover { opacity: .75; }

.notif-body { overflow-y: auto; flex: 1; }

.notif-item {
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface-alt); }
.notif-item.unread { background: #f0f9ff; }
.notif-item.unread:hover { background: #e0f2fe; }

.notif-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.3;
}
.notif-item.unread .notif-title { font-weight: 700; }

.notif-body-text {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.notif-time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.notif-read-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 0;
  margin-top: 4px;
  font-family: inherit;
  font-weight: 500;
}

.notif-footer {
  padding: 10px var(--space-md);
  border-top: 1px solid var(--color-border);
  text-align: center;
  flex-shrink: 0;
}
.notif-footer a {
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  font-weight: 500;
}
.notif-footer a:hover { text-decoration: underline; }

.notif-empty {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}


/* ─── 7. PAGE HEADER ──────────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-header-text { flex: 1; min-width: 0; }

.page-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--color-text);
  line-height: 1.2;
}

.page-header p {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}


/* ─── 8. CARDS ────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.card-header {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -.01em;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}


/* ─── 8b. NAV CARDS (clickable module shortcuts) ─────────── */
.nav-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.nav-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: var(--space-lg);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: border-color var(--transition-slow),
              box-shadow var(--transition-slow),
              transform var(--transition-slow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.nav-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-slow);
}

.nav-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
  color: inherit;
}

.nav-card:hover::after { transform: scaleX(1); }

.nav-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
}

.nav-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-slow), color var(--transition-slow);
}
.nav-card:hover .nav-card-icon {
  background: var(--color-primary);
  color: #fff;
}

.nav-card-arrow {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-top: 2px;
  transition: transform var(--transition), color var(--transition);
}
.nav-card:hover .nav-card-arrow {
  transform: translate(3px, -3px);
  color: var(--color-primary);
}

.nav-card-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-primary);
  margin-top: var(--space-sm);
}

.nav-card-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}


/* ─── 9. STAT CARDS ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  padding: var(--space-lg);
  transition: transform var(--transition-slow), box-shadow var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  opacity: .7;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--color-text);
  line-height: 1;
}


/* ─── 10. BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
  transition: background var(--transition), box-shadow var(--transition),
              border-color var(--transition), color var(--transition),
              transform 80ms ease;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(22,163,74,.30);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
  border-color: #d1d5db;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(239,68,68,.30);
}

.btn-warning {
  background: var(--color-warning);
  color: #fff;
  border-color: var(--color-warning);
}
.btn-warning:hover {
  background: #ea580c;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(249,115,22,.30);
}

.btn-sm {
  padding: 5px 12px;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: var(--font-size-base);
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
}
.btn-icon:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
  border-color: #d1d5db;
}


/* ─── 11. FORMS ───────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-md); }

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
.form-control::placeholder { color: var(--color-text-muted); }
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.10);
}

.form-error,
.invalid-feedback {
  color: var(--color-danger);
  font-size: var(--font-size-xs);
  margin-top: 4px;
  display: block;
}

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

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

.checkbox-group { display: flex; flex-direction: column; gap: var(--space-xs); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.checkbox-label:hover { background: var(--color-surface-alt); }
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}


/* ─── 12. TABLES ──────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  background: var(--color-surface);
}

th {
  padding: 10px 14px;
  text-align: left;
  background: var(--color-surface-alt);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: var(--color-surface-alt); }

.table-actions {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}


/* ─── 13. BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-success { background: var(--color-success-subtle); color: #15803d; }
.badge-danger  { background: var(--color-danger-subtle);  color: #dc2626; }
.badge-warning { background: var(--color-warning-subtle); color: #c2410c; }
.badge-info    { background: var(--color-info-subtle);    color: #1d4ed8; }
.badge-muted   {
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}


/* ─── 14. ALERTS ──────────────────────────────────────────── */
.alert {
  padding: 12px var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-subtle); border-color: #86efac; color: #15803d; }
.alert-danger  { background: var(--color-danger-subtle);  border-color: #fca5a5; color: #dc2626; }
.alert-warning { background: var(--color-warning-subtle); border-color: #fed7aa; color: #c2410c; }
.alert-info    { background: var(--color-info-subtle);    border-color: #bfdbfe; color: #1d4ed8; }


/* ─── 15. PAGINATION ──────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.page-link {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  text-decoration: none;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  transition: all var(--transition);
  font-weight: 500;
}
.page-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
  border-color: #d1d5db;
}
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-link.disabled { opacity: .4; pointer-events: none; }


/* ─── 16. AUTH LAYOUT ─────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(22,163,74,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(245,158,11,.08) 0%, transparent 50%),
    linear-gradient(135deg, #0f172a 0%, #1a2332 60%, #111827 100%);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.auth-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-xl);
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,.06);
  position: relative;
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}
.auth-logo h1 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -.03em;
}
.auth-logo p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 4px;
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  margin-bottom: var(--space-md);
  box-shadow: 0 8px 24px rgba(22,163,74,.35);
}

.auth-brand-mark svg { color: #fff; }

.auth-brand h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.auth-brand p {
  font-size: var(--font-size-sm);
  color: rgba(255,255,255,.5);
  margin-top: 4px;
}


/* ─── 17. UTILITIES ───────────────────────────────────────── */
.text-muted       { color: var(--color-text-muted) !important; }
.text-secondary   { color: var(--color-text-secondary) !important; }
.text-danger      { color: var(--color-danger) !important; }
.text-success     { color: var(--color-success) !important; }
.text-warning     { color: var(--color-warning) !important; }
.text-primary     { color: var(--color-primary) !important; }
.text-sm          { font-size: var(--font-size-sm) !important; }
.text-xs          { font-size: var(--font-size-xs) !important; }
.text-bold        { font-weight: 700 !important; }
.text-semibold    { font-weight: 600 !important; }
.text-right       { text-align: right !important; }
.text-center      { text-align: center !important; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.d-flex          { display: flex; }
.align-center    { align-items: center; }
.align-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }
.gap-xs  { gap: var(--space-xs); }
.gap-sm  { gap: var(--space-sm); }
.gap-md  { gap: var(--space-md); }
.gap-lg  { gap: var(--space-lg); }
.w-full  { width: 100%; }
.flex-1  { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.no-wrap { white-space: nowrap; }

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


/* ─── 18. RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { left: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  .main-area { width: 100%; }
  .topbar-toggle { display: flex; }
  .topbar-username { display: none; }

  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-sm); }
  .page-content { padding: var(--space-md); }
  .page-header { flex-direction: column; align-items: flex-start; }

  .notification-dropdown {
    width: calc(100vw - 32px);
    right: -8px;
  }

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

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card  { padding: var(--space-lg); }
  .table-actions { flex-wrap: wrap; }
  .btn-sm { padding: 5px 10px; }
}


/* ─── 19. PRINT ───────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .no-print,
  .notification-bell,
  .filter-bar { display: none !important; }

  .page-content { padding: 0; overflow: visible; }
  .main-area { width: 100%; }
  body { background: #fff; font-size: 12px; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; margin-bottom: 16px; }
  .table-wrapper { border: 1px solid #ccc; }
  a { color: #000; text-decoration: underline; }
}
