/**
 * VCONSYST360 — Professional ERP Design System
 * Theme: Clean White & Cream with Emerald Accents
 * Version: 6.0.0 — Professional Redesign
 * 
 * Sections:
 *  1. Reset & Base
 *  2. Design Tokens (CSS Variables)
 *  3. Typography
 *  4. App Shell (Topbar, Sidebar, Main)
 *  5. Page Header
 *  6. Buttons
 *  7. Forms & Inputs
 *  8. Cards
 *  9. Tables
 * 10. Badges
 * 11. Alerts
 * 12. Dropdowns
 * 13. Stat Cards (KPI)
 * 14. Empty States
 * 15. Grid System
 * 16. Modal / Dialog
 * 17. Customer Debt Groups
 * 18. Payment Forms
 * 19. Scrollbar
 * 20. Animations
 * 21. Mobile Responsive
 * 22. Utility Classes
 */

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

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--bg-page);
  overflow-x: hidden;
  min-height: 100vh;
}

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

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

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

/* ============================================
   2. DESIGN TOKENS
   ============================================ */
:root {
  /* ── Emerald Green (accent — slightly more vibrant) ── */
  --primary-50: #f0fdf4;
  --primary-100: #dcfce7;
  --primary-200: #bbf7d0;
  --primary-300: #86efac;
  --primary-400: #4ade80;
  --primary-500: #22c55e;
  --primary-600: #16a34a;
  --primary-700: #15803d;
  --primary-800: #166534;
  --primary-900: #14532d;

  /* ── Neutral / Warm Gray (cream undertones) ── */
  --gray-50: #fafaf9;
  --gray-100: #f5f5f4;
  --gray-200: #e7e5e4;
  --gray-300: #d6d3d1;
  --gray-400: #a8a29e;
  --gray-500: #78716c;
  --gray-600: #57534e;
  --gray-700: #44403c;
  --gray-800: #292524;
  --gray-900: #1c1917;

  /* ── Status Colors (slightly more vivid) ── */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-text: #166534;
  --warning: #ea580c;
  --warning-bg: #fff7ed;
  --warning-text: #9a3412;
  --error: #e11d48;
  --error-bg: #fff1f2;
  --error-text: #9f1239;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --info-text: #1d4ed8;

  /* ── Semantic Aliases ── */
  --color-primary: var(--primary-600);
  --color-primary-hover: var(--primary-700);
  --color-primary-light: var(--primary-50);
  --color-primary-500: var(--primary-500);
  --color-primary-600: var(--primary-600);
  --color-success: var(--success);
  --color-warning: var(--warning);
  --color-error: var(--error);
  --color-info: var(--info);
  --color-text-primary: var(--gray-800);
  --color-text-secondary: var(--gray-500);
  --color-text-muted: var(--gray-400);
  --color-border: var(--gray-200);
  --color-bg-primary: #ffffff;
  --color-bg-secondary: var(--gray-50);

  /* ── Backgrounds (warm cream/white) ── */
  --bg-page: #fafaf8;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;

  /* ── Spacing ── */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Aliases used by templates */
  --spacing-2: var(--space-2);
  --spacing-3: var(--space-3);
  --spacing-4: var(--space-4);
  --spacing-6: var(--space-6);
  --spacing-8: var(--space-8);

  /* ── Border Radius ── */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* ── Shadows (softer, warmer) ── */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-emerald: 0 4px 14px rgba(22, 163, 74, 0.12);

  /* ── Typography Scale ── */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* ── Font Size Aliases (used by some templates) ── */
  --font-size-xs: var(--text-xs);
  --font-size-sm: var(--text-sm);
  --font-size-base: var(--text-base);
  --font-size-md: var(--text-md);
  --font-size-lg: var(--text-lg);
  --font-size-xl: var(--text-xl);
  --font-size-2xl: var(--text-2xl);

  /* ── Layout ── */
  --topbar-height: 60px;
  --sidebar-width: 250px;
  --sidebar-collapsed: 68px;

  /* ── Color aliases used by inline styles in templates ── */
  --color-neutral-200: var(--gray-200);
  --color-success-600: var(--success);
  --color-error-600: var(--error);
}

/* ============================================
   3. TYPOGRAPHY
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-weight-semibold);
  color: var(--gray-900);
  line-height: 1.3;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

h5 {
  font-size: var(--text-md);
}

h6 {
  font-size: var(--text-base);
}

.text-xs {
  font-size: var(--text-xs) !important;
}

.text-sm {
  font-size: var(--text-sm) !important;
}

.text-base {
  font-size: var(--text-base) !important;
}

.text-lg {
  font-size: var(--text-lg) !important;
}

.text-xl {
  font-size: var(--text-xl) !important;
}

.text-2xl {
  font-size: var(--text-2xl) !important;
}

.font-light {
  font-weight: var(--font-weight-light) !important;
}

.font-normal {
  font-weight: var(--font-weight-normal) !important;
}

.font-medium {
  font-weight: var(--font-weight-medium) !important;
}

.font-semibold {
  font-weight: var(--font-weight-semibold) !important;
}

.font-bold {
  font-weight: var(--font-weight-bold) !important;
}

.text-primary {
  color: var(--primary-600) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-error {
  color: var(--error) !important;
}

.text-info {
  color: var(--info) !important;
}

.text-muted {
  color: var(--gray-400) !important;
}

.text-secondary {
  color: var(--gray-500) !important;
}

/* ============================================
   4. APP SHELL
   ============================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
}

/* ── TOPBAR ── */
.app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: #ffffff;
  color: var(--gray-800);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  z-index: 100;
}

.app-topbar-menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--gray-700);
  transition: background 0.2s;
}

.app-topbar-menu-toggle:hover {
  background: var(--gray-200);
}

.app-topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none !important;
  margin-right: auto;
}

.app-topbar-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}

.app-topbar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-topbar-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--primary-700);
  letter-spacing: 0.02em;
}

.app-topbar-subtitle {
  font-size: 10px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* Search Bar */
.app-topbar-search {
  position: relative;
  width: 280px;
}

.app-topbar-search-input {
  width: 100%;
  padding: 8px 12px 8px 38px;
  font-size: 13px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  color: var(--gray-800);
  transition: all 0.2s;
}

.app-topbar-search-input::placeholder {
  color: var(--gray-400);
}

.app-topbar-search-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08);
}

.app-topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

/* Topbar Actions */
.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.2s;
  position: relative;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.erp-notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

/* User Menu */
.app-topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
}

.app-topbar-user:hover {
  background: var(--gray-100);
}

.app-topbar-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary-600);
  border-radius: var(--radius-full);
}

.app-topbar-user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.app-topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.2;
}

.app-topbar-user-role {
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.2;
}

/* ── SIDEBAR ── */
.app-sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.app-sidebar-nav {
  padding: var(--space-3) var(--space-3);
  flex: 1;
}

.app-sidebar-section {
  margin-bottom: var(--space-4);
}

.app-sidebar-section-title {
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
  font-size: 10px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 12px;
  margin-bottom: 1px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none !important;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.app-sidebar-item:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.app-sidebar-item.is-active {
  background: var(--primary-100);
  color: var(--primary-800);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary-500);
}

.app-sidebar-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-sidebar-item.is-active .app-sidebar-item-icon {
  opacity: 1;
}

.app-sidebar-item-text {
  flex: 1;
  white-space: nowrap;
}

/* ── SIDEBAR COLLAPSIBLE GROUP ── */
.app-sidebar-group {
  margin-bottom: 1px;
}

.app-sidebar-group-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.app-sidebar-chevron {
  flex-shrink: 0;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.app-sidebar-group.is-open .app-sidebar-chevron {
  transform: rotate(180deg);
}

.app-sidebar-group-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.app-sidebar-group.is-open .app-sidebar-group-menu {
  max-height: 200px;
}

.app-sidebar-subitem {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 12px 7px 40px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none !important;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.app-sidebar-subitem:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.app-sidebar-subitem.is-active {
  background: var(--primary-100);
  color: var(--primary-800);
  font-weight: 600;
}

/* ── SIDEBAR DROPDOWN (Inline collapsible) ── */
.app-sidebar-dropdown {
  margin-bottom: 1px;
}

.app-sidebar-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  user-select: none;
}

.app-sidebar-dropdown-trigger:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.app-sidebar-dropdown-icon {
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.5;
  transition: transform 0.25s ease;
}

.app-sidebar-dropdown.is-open .app-sidebar-dropdown-icon {
  transform: rotate(180deg);
}

.app-sidebar-dropdown-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin: 0 6px 0 12px;
  border-left: 2px solid var(--gray-200);
}

.app-sidebar-dropdown.is-open .app-sidebar-dropdown-menu {
  max-height: 300px;
  margin-top: 2px;
  margin-bottom: 4px;
}

.app-sidebar-dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none !important;
  transition: all 0.15s ease;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.app-sidebar-dropdown-item:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.app-sidebar-dropdown-item.is-active {
  background: var(--primary-100);
  color: var(--primary-800);
  font-weight: 600;
  border-left: none;
}

/* ── MAIN CONTENT ── */
.app-main {
  flex: 1;
  margin-top: var(--topbar-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 0.3s ease;
}

.app-content {
  padding: var(--space-6) var(--space-8);
  max-width: 100%;
  width: 100%;
}

@media (min-width: 1400px) {
  .app-content {
    max-width: 1440px;
    margin: 0 auto;
  }
}

/* ============================================
   5. PAGE HEADER
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-header-content {
  flex: 1;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
  line-height: 1.3;
}

.page-subtitle,
.page-description {
  font-size: var(--text-sm);
  color: var(--gray-500);
  line-height: 1.5;
}

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

/* ============================================
   6. BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 18px;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none !important;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--primary-600);
  color: white;
  border-color: var(--primary-600);
  box-shadow: var(--shadow-sm), 0 1px 2px rgba(5, 150, 105, 0.15);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-700);
  border-color: var(--primary-700);
  box-shadow: var(--shadow-md), 0 2px 4px rgba(5, 150, 105, 0.2);
  transform: translateY(-1px);
  color: white;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--gray-800);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
  color: white;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  color: white;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-outline {
  background: transparent;
  color: var(--primary-600);
  border-color: var(--primary-300);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-50);
  border-color: var(--primary-500);
  color: var(--primary-700);
}

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

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

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================
   7. FORMS & INPUTS
   ============================================ */
.form-group,
.input-group {
  margin-bottom: var(--space-4);
}

.label,
.input-label,
.form-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.input,
.select,
.textarea,
.form-control {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--gray-800);
  background: white;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.input:hover:not(:focus):not(:disabled),
.select:hover:not(:focus):not(:disabled),
.form-control:hover:not(:focus):not(:disabled) {
  border-color: var(--gray-400);
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.form-control:disabled {
  background: var(--gray-100);
  color: var(--gray-400);
  cursor: not-allowed;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.input-sm,
.input.input-sm {
  padding: 5px 8px;
  font-size: var(--text-xs);
}

/* ============================================
   8. CARDS
   ============================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--gray-50);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ============================================
   9. TABLES
   ============================================ */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--primary-200);
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--gray-50);
  z-index: 1;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--primary-50);
}

.table-striped tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--primary-50);
}

/* ============================================
   10. BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-primary {
  background: var(--primary-100);
  color: var(--primary-800);
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-neutral {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ============================================
   11. ALERTS
   ============================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-xs);
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
  line-height: 1.5;
}

.alert-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.5;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.alert-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success-text);
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning-text);
}

.alert-error,
.alert-danger {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error-text);
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info-text);
}

/* ============================================
   12. DROPDOWNS
   ============================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 200px;
  padding: var(--space-1);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.dropdown.is-open .dropdown-menu {
  display: block;
  animation: dropdownIn 0.15s ease-out;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--gray-700);
  text-decoration: none !important;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.dropdown-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.dropdown-divider {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--gray-100);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   13. STAT CARDS (KPI)
   ============================================ */
.card-stat {
  position: relative;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

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

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

.card-stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.card-stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

/* ============================================
   14. EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--gray-400);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.empty-state h3 {
  font-size: var(--text-lg);
  color: var(--gray-500);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--gray-400);
  max-width: 400px;
  margin: 0 auto;
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--gray-400);
  margin: 0 auto;
}

/* ── Actions ── */
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-100);
}

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

.input-error-message {
  font-size: var(--text-sm);
  color: var(--error);
  margin-top: var(--space-1);
}

/* ============================================
   15. GRID SYSTEM
   ============================================ */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}

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

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

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

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

/* Responsive grid breakpoints */
@media (min-width: 640px) {
  .grid-cols-sm-2 {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

@media (min-width: 1024px) {
  .grid-cols-lg-2 {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

/* ============================================
   16. MODAL / DIALOG
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   17. CUSTOMER DEBT GROUPS
   ============================================ */
.customer-debt-group {
  margin-bottom: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: white;
}

.customer-debt-group:last-child {
  margin-bottom: 0;
}

.customer-debt-header {
  background: linear-gradient(135deg, var(--primary-50), var(--gray-50));
  padding: var(--space-3) var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary-500);
}

.customer-debt-header h3 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-800);
}

/* ============================================
   18. PAYMENT FORMS
   ============================================ */
.payment-form {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================
   19. SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-400);
}

/* ============================================
   20. ANIMATIONS
   ============================================ */
.slide-in-down {
  animation: slideInDown 0.35s ease-out;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.page-enter {
  animation: pageEnter 0.35s ease-out;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ============================================
   21. MOBILE RESPONSIVE
   ============================================ */

/* Tablet / Small Desktop */
@media (max-width: 1024px) {
  .app-topbar-menu-toggle {
    display: flex;
  }

  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

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

  .app-topbar-search {
    width: 200px;
  }

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

/* Mobile */
@media (max-width: 768px) {
  .app-topbar {
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }

  .app-topbar-search {
    display: none;
  }

  .app-topbar-user-info {
    display: none;
  }

  .app-topbar-subtitle {
    display: none;
  }

  .app-content {
    padding: var(--space-4);
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .page-title {
    font-size: 20px;
  }

  .page-header-actions {
    width: 100%;
  }

  .table-container {
    margin: 0 calc(-1 * var(--space-4));
    padding: 0 var(--space-4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 600px;
  }

  /* Mobile input zoom prevention */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-sm-2,
  .grid-cols-sm-3,
  .grid-cols-sm-4,
  .grid-cols-lg-2,
  .grid-cols-lg-3,
  .grid-cols-lg-4 {
    grid-template-columns: 1fr;
  }

  .payment-form {
    flex-direction: column;
    align-items: stretch;
  }

  .payment-form .input,
  .payment-form .select {
    width: 100% !important;
  }

  .card-stat {
    padding: var(--space-4);
  }

  .card-stat-value {
    font-size: var(--text-xl);
  }
}

/* Very small mobile */
@media (max-width: 480px) {
  .btn {
    width: 100%;
    justify-content: center;
  }

  .btn-sm {
    width: auto;
  }

  .page-header-actions {
    flex-direction: column;
  }

  .page-header-actions .btn {
    width: 100%;
  }
}

/* ============================================
   22. UTILITY CLASSES
   ============================================ */

/* Text alignment */
.text-left {
  text-align: left !important;
}

.text-center {
  text-align: center !important;
}

.text-right {
  text-align: right !important;
}

/* Display */
.d-none {
  display: none !important;
}

.d-flex {
  display: flex !important;
}

.d-grid {
  display: grid !important;
}

.d-block {
  display: block !important;
}

.d-inline {
  display: inline !important;
}

.d-inline-flex {
  display: inline-flex !important;
}

/* Flex */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

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

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

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.flex-1 {
  flex: 1;
}

/* Gaps */
.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.gap-6 {
  gap: var(--space-6);
}

.gap-8 {
  gap: var(--space-8);
}

/* Margins */
.m-0 {
  margin: 0 !important;
}

.m-2 {
  margin: var(--space-2) !important;
}

.m-4 {
  margin: var(--space-4) !important;
}

.mt-0 {
  margin-top: 0 !important;
}

.mt-1 {
  margin-top: var(--space-1) !important;
}

.mt-2 {
  margin-top: var(--space-2) !important;
}

.mt-3 {
  margin-top: var(--space-3) !important;
}

.mt-4 {
  margin-top: var(--space-4) !important;
}

.mt-6 {
  margin-top: var(--space-6) !important;
}

.mt-8 {
  margin-top: var(--space-8) !important;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mb-1 {
  margin-bottom: var(--space-1) !important;
}

.mb-2 {
  margin-bottom: var(--space-2) !important;
}

.mb-3 {
  margin-bottom: var(--space-3) !important;
}

.mb-4 {
  margin-bottom: var(--space-4) !important;
}

.mb-6 {
  margin-bottom: var(--space-6) !important;
}

.mb-8 {
  margin-bottom: var(--space-8) !important;
}

.ml-2 {
  margin-left: var(--space-2) !important;
}

.ml-4 {
  margin-left: var(--space-4) !important;
}

.mr-2 {
  margin-right: var(--space-2) !important;
}

.mr-4 {
  margin-right: var(--space-4) !important;
}

/* Paddings */
.p-0 {
  padding: 0 !important;
}

.p-2 {
  padding: var(--space-2) !important;
}

.p-3 {
  padding: var(--space-3) !important;
}

.p-4 {
  padding: var(--space-4) !important;
}

.p-6 {
  padding: var(--space-6) !important;
}

.p-8 {
  padding: var(--space-8) !important;
}

.px-4 {
  padding-left: var(--space-4) !important;
  padding-right: var(--space-4) !important;
}

.py-2 {
  padding-top: var(--space-2) !important;
  padding-bottom: var(--space-2) !important;
}

.py-4 {
  padding-top: var(--space-4) !important;
  padding-bottom: var(--space-4) !important;
}

/* Width */
.w-full {
  width: 100% !important;
}

.w-auto {
  width: auto !important;
}

/* Borders */
.border {
  border: 1px solid var(--gray-200) !important;
}

.border-t {
  border-top: 1px solid var(--gray-200) !important;
}

.border-b {
  border-bottom: 1px solid var(--gray-200) !important;
}

.border-0 {
  border: 0 !important;
}

.rounded {
  border-radius: var(--radius-md) !important;
}

.rounded-lg {
  border-radius: var(--radius-lg) !important;
}

.rounded-xl {
  border-radius: var(--radius-xl) !important;
}

.rounded-full {
  border-radius: var(--radius-full) !important;
}

/* Shadows */
.shadow-sm {
  box-shadow: var(--shadow-sm) !important;
}

.shadow-md {
  box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

.shadow-none {
  box-shadow: none !important;
}

/* Overflow */
.overflow-hidden {
  overflow: hidden !important;
}

.overflow-auto {
  overflow: auto !important;
}

.overflow-x-auto {
  overflow-x: auto !important;
}

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

/* Opacity */
.opacity-50 {
  opacity: 0.5 !important;
}

.opacity-75 {
  opacity: 0.75 !important;
}

/* Whitespace */
.whitespace-nowrap {
  white-space: nowrap !important;
}

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

/* Visually Hidden (SR only) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── LOGIN PAGE ── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-800) 0%, var(--primary-600) 50%, var(--primary-400) 100%);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-container::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -30%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
  pointer-events: none;
}

.login-card {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05);
  width: 100%;
  max-width: 420px;
  padding: var(--space-10);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-700);
  letter-spacing: -0.02em;
}

.login-logo p {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.login-input-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.login-input-group input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
  font-family: inherit;
}

.login-input-group input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.login-btn {
  width: 100%;
  padding: 13px;
  background: var(--primary-600);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.login-btn:hover {
  background: var(--primary-700);
  box-shadow: var(--shadow-emerald);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #fecaca;
  font-size: var(--text-sm);
}

/* ── Print styles ── */
@media print {

  .app-topbar,
  .app-sidebar,
  .app-topbar-menu-toggle,
  .btn,
  .dropdown {
    display: none !important;
  }

  .app-main {
    margin: 0 !important;
  }

  .app-content {
    padding: 0 !important;
  }

  body {
    background: white !important;
  }
}