/* ============================================
   COMERCIALE — Premium Design System
   ============================================ */

/* ── Google Fonts ────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ───────────────────────────── */
:root {
    /* Primary palette */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    /* Accent */
    --accent-400: #34d399;
    --accent-500: #10b981;
    --accent-600: #059669;

    /* Danger */
    --danger-400: #f87171;
    --danger-500: #ef4444;
    --danger-600: #dc2626;

    /* Warning */
    --warning-400: #fbbf24;
    --warning-500: #f59e0b;

    /* Neutrals — Light mode */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #030712;

    /* Light-mode surfaces */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --border: #eef2f6;
    --text: #1e293b;
    --text-muted: #64748b;

    /* Glass (light flavour) */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.text-muted {
    color: var(--gray-400);
}

.data-table td small {
    display: inline-block;
    color: var(--gray-400);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

/* ── Reset ─────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-500);
}

/* ── AUTH PAGES (Login / Register) ───────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--gray-950);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 3rem;
    box-shadow: var(--glass-shadow);
    animation: slideUp 0.5s ease-out;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fdaa00, #e7cd14);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.auth-card .logo p {
    color: var(--gray-400);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.auth-card .subtitle {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

/* ── Form Elements ───────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.925rem;
    font-family: inherit;
    color: var(--gray-900);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-base);
}

.form-control:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #ffffff;
}

.form-control::placeholder {
    color: var(--gray-500);
}

select.form-control {
    cursor: pointer;
    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 1rem center;
    padding-right: 2.5rem;
}

select.form-control option {
    background: #ffffff;
    color: #111827;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.925rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--accent-500), var(--accent-400));
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
    transform: translateY(-1px);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-600), var(--danger-500));
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, var(--danger-500), var(--danger-400));
    color: white;
}

.btn-ghost {
    background: whitesmoke;
    color: var(--primary-600);
    border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
    background: rgba(66, 66, 66, 0.554);
    color: var(--primary-600);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* ── Dashboard Layout ────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
    transform: translateX(0);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.06);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* Overlay when sidebar open on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fdaa00, #e7cd14);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand span {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.75rem 0.75rem 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sidebar-nav .nav-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.sidebar-nav .nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.05));
    color: var(--primary-600);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.sidebar-nav .nav-item .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-info .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-info .role-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-top: 0.15rem;
}

.role-badge.write {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-400);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.role-badge.read {
    background: rgba(251, 191, 36, 0.12);
    color: var(--warning-400);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.role-badge.coordinator {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    padding-top: 3.5rem;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.sidebar.collapsed~.main-content {
    margin-left: 0;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.main-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}

.main-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ── Cards ───────────────────────────────────── */
.card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: -16px 20px 14px 7px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: -9px -8px 11px 5px rgba(0, 0, 0, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.card-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* ── Stats Grid ──────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    /* Modified box-shadow */
    transition: all var(--transition-base);
    margin-bottom: 2rem;
    /* Added margin-bottom */
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.blue::before {
    background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
}

.stat-card.green::before {
    background: linear-gradient(90deg, var(--accent-500), var(--accent-400));
}

.stat-card.purple::before {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.stat-card.orange::before {
    background: linear-gradient(90deg, #f97316, #fb923c);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ── Data Table ──────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.data-table thead th {
    background: transparent;
    color: var(--gray-500);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 1.25rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    background: transparent;
    transition: all var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgb(73 52 52 / 21%);
}

.data-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--gray-700);
    vertical-align: middle;
    white-space: nowrap;
}

/* Observation / long-text column — wraps text vertically via inner div */
.data-table td.col-observation {
    white-space: normal;
    padding: 0.75rem 1rem;
}

.data-table td.col-observation .obs-text {
    display: block;
    width: 220px;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 0.8rem;
    line-height: 1.5;
}

.data-table tbody td:first-child {
    color: var(--gray-900);
    font-weight: 600;
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
    justify-content: flex-end;
}

/* Ensure Actions column is always aligned correctly */
.data-table th:last-child,
.data-table td:last-child {
    text-align: right;
    min-width: 120px;
}

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-badge.banque {
    background: rgb(7 12 241 / 44%);
    color: #f7f8fb;
    border: 1px solid rgb(11 16 239 / 66%);
}

.type-badge.compagnie {
    background: rgb(7 223 152 / 15%);
    color: #076945;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.type-badge.industriel {
    background: rgb(247 197 2 / 66%);
    color: #4000ff;
    border: 1px solid rgb(79 2 253 / 30%);
}

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-100);
    border: 1px solid var(--border);
    color: var(--gray-500);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── Pagination ──────────────────────────────── */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1.5rem 1rem 0.5rem;
    border-top: 1px solid var(--border);
    width: 100%;
}

.pg-dots {
    color: var(--gray-400);
    padding: 0 0.5rem;
    font-weight: 700;
}

.pg-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pg-btn:hover:not(:disabled) {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: var(--primary-50);
}

.pg-btn.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.pg-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--gray-50);
}

.pg-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-left: auto;
    padding-right: 0.5rem;
}

/* ── Notifications / Toast ───────────────────── */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    min-width: 280px;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
}

.toast.error {
    background: linear-gradient(135deg, var(--danger-600), var(--danger-500));
}

.toast.info {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
}

/* ── Empty State ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ── Auth Link ───────────────────────────────── */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.auth-footer a {
    font-weight: 600;
}

/* ── Sidebar Toggle Button ───────────────────── */
.hamburger {
    display: flex;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.65rem;
    color: var(--gray-300);
    cursor: pointer;
    font-size: 1.15rem;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-slow);
    backdrop-filter: blur(10px);
}

.hamburger:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-400);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Move toggle button based on sidebar state */
.sidebar:not(.collapsed)~.main-content .hamburger,
.sidebar:not(.collapsed)~* .hamburger {
    left: calc(var(--sidebar-width) + 0.75rem);
}

.sidebar.collapsed~.main-content .hamburger,
.sidebar.collapsed~* .hamburger {
    left: 1rem;
}

/* Also adjust main-content margin based on sidebar state */
.sidebar.collapsed~.main-content {
    margin-left: 0;
}

/* ── Animations ──────────────────────────────── */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem;
        padding-top: 4rem;
    }

    .sidebar.collapsed~.main-content {
        margin-left: 0;
    }

    .hamburger {
        left: 1rem !important;
    }

    .auth-card {
        padding: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding-left: 3rem;
    }

    .modal {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ── Utilities ───────────────────────────────── */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Filter Bar ──────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
}

.search-input {
    flex: 1;
    position: relative;
    max-width: 350px;
    min-width: 200px;
}

.search-input .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    pointer-events: none;
    font-size: 0.9rem;
}

.search-input input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--gray-800);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition-base);
}

.search-input input:focus {
    border-color: var(--primary-500);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.filter-controls select,
.filter-controls input[type="date"] {
    padding: 0.45rem 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--gray-800);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    min-width: 140px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

/* Dropdown options always display with black text on light bg */
.filter-controls select option {
    background: #ffffff;
    color: #111827;
}

/* Date input — make it feel like a real clickable button */
.filter-controls input[type="date"] {
    min-width: 0;
    cursor: pointer;
    color-scheme: light;
}

.filter-controls select:hover,
.filter-controls input[type="date"]:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.filter-controls select:focus,
.filter-controls input[type="date"]:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: #ffffff;
}

/* Date range label wrapper */
.filter-controls .date-range-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.3rem 0.6rem;
    transition: border-color var(--transition-fast);
    cursor: pointer;
}

.filter-controls .date-range-label:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: #ffffff;
}

.filter-controls .date-range-label input[type="date"] {
    border: none;
    background: transparent;
    padding: 0;
    min-width: 130px;
    box-shadow: none;
    color: var(--gray-800);
}

@media (max-width: 1024px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        max-width: 100%;
    }
}

/* ── Rapport Page ────────────────────────────── */
.rapport-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.rapport-card {
    padding: 2rem;
}

.rapport-card-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
}

.rapport-card-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.rapport-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-400));
    color: white;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.rapport-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    padding-left: 0.25rem;
}

.rapport-textarea {
    min-height: 200px;
    resize: vertical;
    font-size: 0.95rem;
    line-height: 1.75;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    color: var(--gray-800);
    transition: all var(--transition-base);
}

.rapport-textarea:focus {
    background: #ffffff;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.rapport-textarea::placeholder {
    color: var(--gray-400);
    font-style: italic;
}

/* ── Rapport History List ────────────────────── */
.rapport-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem;
}

.rapport-item-card {
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rapport-item-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-400);
    box-shadow: var(--shadow-lg);
}

.rapport-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 600;
}

.rapport-item-date {
    background: var(--gray-100);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
}

.rapport-item-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.5;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}

.rapport-item-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rapport-item-footer .icon {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.rapport-item-card:hover .icon {
    transform: translateX(4px);
}

/* ── Rapport A4 Preview Overlay ──────────────── */
.rapport-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: none;
    flex-direction: column;
}

.rapport-preview-overlay.show {
    display: flex;
}

.rapport-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rapport-preview-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
}

.rapport-a4 {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
    padding: 25mm 20mm;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #1a1a1a;
    line-height: 1.8;
    font-size: 12pt;
}

.rapport-a4-header {
    text-align: center;
    margin-bottom: 2rem;
}

.rapport-a4-header h1 {
    font-size: 22pt;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.rapport-a4-meta {
    font-size: 10pt;
    color: #666;
    margin-bottom: 1.5rem;
}

.rapport-a4-divider {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-600), var(--primary-400));
    margin: 0 auto;
    border-radius: 2px;
}

.rapport-a4-section {
    margin-bottom: 2rem;
    page-break-inside: avoid;
}

.rapport-a4-section h2 {
    font-size: 14pt;
    font-weight: 700;
    color: #2d2d2d;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.rapport-a4-content {
    font-size: 11pt;
    line-height: 1.9;
    color: #333;
    text-align: justify;
}

/* ── Print Styles ────────────────────────────── */
@media print {
    body * {
        visibility: hidden !important;
    }

    .rapport-preview-overlay,
    .rapport-preview-overlay * {
        visibility: visible !important;
    }

    .rapport-preview-toolbar {
        display: none !important;
    }

    .rapport-preview-overlay {
        position: absolute;
        inset: 0;
        background: none;
        backdrop-filter: none;
    }

    .rapport-preview-scroll {
        padding: 0;
        overflow: visible;
    }

    .rapport-a4 {
        box-shadow: none;
        width: 100%;
        min-height: auto;
        padding: 15mm;
        font-size: 11pt;
    }

    .rapport-a4-section {
        page-break-inside: avoid;
    }
}