:root {
  /* --- Sci-Fi Light Palette --- */
  --bg-app: #f1f5f9;           /* Ice White/Grey */
  --bg-surface: #ffffff;       /* Pure White */
  --bg-sidebar: #ffffff;
  
  --color-primary: #2563eb;    /* Electric Blue */
  --color-primary-hover: #1d4ed8;
  --color-secondary: #64748b;  /* Slate Grey */
  
  /* --- Text Colors --- */
  --text-main: #0f172a;        /* Deep Navy/Black for max readability */
  --text-muted: #64748b;
  
  /* --- Status Colors (Vivid & Clear) --- */
  --status-paid-bg: #dcfce7;
  --status-paid-text: #15803d;  /* Deep Green */
  --status-late-bg: #fee2e2;
  --status-late-text: #b91c1c;  /* Deep Red */
  --status-due-bg: #fef9c3;
  --status-due-text: #a16207;   /* Deep Yellow */
  
  /* --- Specific Highlights --- */
  --tx-ref-color: #dc2626;     /* Vivid Red for Transactions */
  
  /* --- Dimensions --- */
  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --border-light: 1px solid #e2e8f0;
}

/* --- Base --- */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 13px;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* --- Sidebar (Clean White & Tech) --- */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: var(--border-light);
  box-shadow: 2px 0 15px rgba(0,0,0,0.03);
  z-index: 100;
}

.sidebar-header h4 {
  color: var(--color-primary) !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 900;
}

.sidebar-header .text-muted {
  color: var(--text-muted) !important;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 15px;
  margin: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-link:hover {
  background-color: #f8fafc;
  color: var(--color-primary);
  transform: translateX(3px);
}

.nav-link.active {
  background-color: #eff6ff; /* Light Blue tint */
  color: var(--color-primary);
  border: 1px solid #bfdbfe;
}

.nav-link i { width: 24px; text-align: center; }

/* --- Cards (Floating White Slabs) --- */
.card {
  background: var(--bg-surface);
  border: var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.card__header {
  background: #fff;
  border-bottom: var(--border-light);
  padding: 15px 20px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card__body { padding: 20px; }

/* --- Inputs (Crisp & Clean) --- */
.form-control, .form-select, .client-search {
  background-color: #fff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
}

.form-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
}

/* --- Tables (High Definition) --- */
.table-responsive {
  border-radius: var(--radius-sm);
  border: var(--border-light);
  overflow: hidden;
}

.table {
  margin-bottom: 0;
  border-collapse: collapse;
}

.table thead th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}

/* Row Hover */
.table-hover tbody tr:hover td {
  background-color: #f8fafc;
  cursor: pointer;
}

/* Selected Row (Active Context) */
tr.selected-invoice-row td {
  background-color: #eff6ff !important; /* Light blue highlight */
  border-top: 1px solid #bfdbfe;
  border-bottom: 1px solid #bfdbfe;
}
tr.selected-invoice-row td:first-child {
  border-left: 4px solid var(--color-primary);
}

/* --- Transaction Reference (Vivid Red Request) --- */
.tx-ref-highlight {
  color: var(--tx-ref-color) !important;
  font-weight: 800 !important;
  background-color: #fef2f2;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #fecaca;
  display: inline-block;
  margin-top: 4px;
  font-family: 'Monaco', 'Consolas', monospace; /* Tech font */
}

/* --- Status Badges (Clear & Bright) --- */
.badge {
  font-weight: 700;
  text-transform: uppercase;
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.bg-success { background-color: var(--status-paid-bg) !important; color: var(--status-paid-text) !important; }
.bg-danger   { background-color: var(--status-late-bg) !important; color: var(--status-late-text) !important; }
.bg-warning  { background-color: var(--status-due-bg) !important; color: var(--status-due-text) !important; }
.bg-info     { background-color: #e0f2fe !important; color: #0369a1 !important; }

/* --- Buttons (Tech) --- */
.btn {
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: all 0.2s;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.btn--primary {
  background-color: var(--color-primary);
  color: white;
  border: none;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}
.btn--primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.btn--outline {
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  background: #fff;
}
.btn--outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: #f8fafc;
}

/* --- KPI Cards --- */
.status-item-pro {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left-width: 4px !important; /* Keep the colored stripe */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.status-item-pro h3 { font-size: 1.8rem; letter-spacing: -1px; }

/* --- Modals (Clean) --- */
.modal-content {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0,0,0,0.1);
}
.modal-header { border-bottom: 1px solid #f1f5f9; background: #fff; padding: 20px; }
.modal-footer { border-top: 1px solid #f1f5f9; background: #f8fafc; padding: 20px; }

/* --- Full Screen Invoice Preview (Paper feel) --- */
.invoice-container-modal {
  background: white;
  width: 210mm;
  min-height: 297mm;
  margin: 30px auto;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1); /* Floating paper effect */
  border: 1px solid #e2e8f0;
}

.modal-fullscreen .modal-body {
  background-color: #e2e8f0; /* Darker backdrop for contrast with paper */
}

/* --- FIXES FOR MODAL & PREVIEW --- */

/* 1. Force Modal Title to be White (overriding the global H5 dark color) */
/* --- FIX 4: Correct Modal Title Colors --- */
/* Default modal title: Dark text */
.modal-header .modal-title {
    color: var(--text-main); 
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Exception: Preview Modal with dark header gets white text */
.modal-header.bg-dark .modal-title {
    color: #ffffff !important;
}

/* 2. Custom RED Close Button for Previews */
.btn-close-red {
    background-color: #ff0000 !important; /* Vivid Red */
    opacity: 1;
    /* White X icon */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") !important;
    border-radius: 50%;
    padding: 0.8rem; /* Bigger hit area */
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6); /* Red Glow */
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.btn-close-red:hover {
    background-color: #cc0000 !important;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
}

/* 3. Fix for the "Empty Bar" (Month Input) to look purposeful */
input[type="month"] {
    position: relative;
    color: var(--text-main);
}
/* Show a placeholder-like label when empty */
input[type="month"]:invalid::-webkit-datetime-edit {
    color: #999;
}
input[type="month"]::before {
    content: '📅 Filtrer par Mois'; /* Label for the empty bar */
    color: #999;
    position: absolute;
    left: 10px;
    pointer-events: none;
    display: block; /* Default display */
}
input[type="month"]:focus::before,
input[type="month"]:valid::before {
    display: none; /* Hide when clicked or has value */
}

/* --- FIX 2: Gentle Vertical Lines for Invoice Table --- */
.table-vertical-lines thead th {
    border-right: 1px solid #e2e8f0; /* Gentle line for headers */
    text-align: center !important;   /* Force Center */
    vertical-align: middle;
}

.table-vertical-lines tbody td {
    border-right: 1px solid #f1f5f9; /* Very gentle line for rows */
    text-align: center !important;   /* Force Center */
    vertical-align: middle;
}

/* Exception: Align the Client Name to the left because names look bad centered */
.table-vertical-lines tbody td:nth-child(4) { 
    text-align: left !important; 
    padding-left: 15px;
}
.table-vertical-lines tbody td:last-child {
    border-right: none; /* No line on the last column */
}

/* --- FIX 3: Beautify Report Totals (The Footer) --- */
.report-footer-row td {
    background-color: #2c3e50 !important; /* Dark Elegant Blue */
    color: #ffffff !important;           /* White Text */
    font-size: 0.95rem;
    padding: 15px 10px !important;
    border: 1px solid #34495e !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-footer-label {
    text-align: right !important;
    font-weight: 800;
    font-style: italic;
    padding-right: 20px !important;
}

/* Updated Footer Money Style - Forces Single Line */
.report-footer-money {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: bold;
    font-size: 1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    
    /* These 3 lines force the number to stay on one line */
    white-space: nowrap !important; 
    overflow: hidden;
    min-width: 120px; /* Ensures the cell is wide enough */
}
/* --- FIX: FROZEN HEADER & FIRST COLUMN --- */

/* 1. Header Row Freezing */
#tableReport thead th {
    position: sticky;
    top: 0;
    z-index: 10; /* Must be high */
    background-color: #f8f9fa; /* Must be opaque */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 2. First Column Header (Corner) */
#tableReport thead th:first-child {
    left: 0;
    z-index: 20; /* Highest priority (corner) */
    border-right: 2px solid #dee2e6;
}

/* 3. First Column Body (Rows) */
#tableReport tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background-color: #ffffff;
    border-right: 2px solid #dee2e6;
}

.badge-clickable {
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.badge-clickable:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

/* --- License Card Style --- */
.license-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); /* Light Green Gradient */
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.license-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.1);
}

/* Decorative circle in the corner */
.license-card::after {
    content: '';
    position: absolute;
    top: -15px;
    right: -15px;
    width: 50px;
    height: 50px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 50%;
    z-index: 0;
}

.license-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #15803d; /* Dark Green */
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.license-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: #1e293b; /* Dark Blue/Grey */
    position: relative;
    z-index: 1;
}

.license-role {
    font-size: 0.7rem;
    color: #64748b; /* Muted Grey */
    font-weight: 500;
    line-height: 1.2;
    margin-top: 2px;
    position: relative;
    z-index: 1;
}