:root {
    /* Color Palette - Dark Mode (Default) */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-bg: #0f0f23;
    --dark-card: #1a1a2e;
    --dark-card-hover: #25254a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-purple: #667eea;
    --accent-pink: #f5576c;
    --accent-blue: #4facfe;

    /* Light Mode Colors */
    --light-bg: #f5f7fa;
    --light-card: #ffffff;
    --light-card-hover: #f0f4f8;
    --light-text-primary: #1a1a2e;
    --light-text-secondary: #5a5a7a;
    --light-border-color: rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Light Mode Theme */
html.light-mode,
body.light-mode {
    background: var(--light-bg);
    color: var(--light-text-primary);
}

html.light-mode .header,
body.light-mode .header {
    background: #ffffff;
    border-bottom-color: var(--light-border-color);
}

html.light-mode .card,
body.light-mode .card {
    background: var(--light-card);
    border-color: var(--light-border-color);
}

html.light-mode .card:hover,
body.light-mode .card:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

html.light-mode .form-control,
body.light-mode .form-control {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--light-border-color);
    color: var(--light-text-primary);
}

html.light-mode .form-control:focus,
body.light-mode .form-control:focus {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

html.light-mode .form-control::placeholder,
body.light-mode .form-control::placeholder {
    color: var(--light-text-secondary);
    opacity: 0.7;
}

html.light-mode .form-label,
body.light-mode .form-label {
    color: var(--light-text-secondary);
}

html.light-mode .nav-link,
body.light-mode .nav-link {
    color: var(--light-text-secondary);
}

html.light-mode .nav-link:hover,
html.light-mode .nav-link.active,
body.light-mode .nav-link:hover,
body.light-mode .nav-link.active {
    color: var(--light-text-primary);
    background: rgba(102, 126, 234, 0.08);
}

html.light-mode .text-muted,
body.light-mode .text-muted {
    color: var(--light-text-secondary);
}

html.light-mode .table thead,
body.light-mode .table thead {
    background: rgba(0, 0, 0, 0.02);
}

html.light-mode .table th,
body.light-mode .table th {
    color: var(--light-text-secondary);
    border-bottom-color: var(--light-border-color);
}

html.light-mode .table td,
body.light-mode .table td {
    border-bottom-color: var(--light-border-color);
}

html.light-mode .table tbody tr:hover,
body.light-mode .table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

html.light-mode .btn-secondary,
body.light-mode .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--light-text-primary);
    border-color: var(--light-border-color);
}

html.light-mode .btn-secondary:hover,
body.light-mode .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--accent-purple);
}

html.light-mode .signature-card,
body.light-mode .signature-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--light-border-color);
}

html.light-mode .signature-preview,
body.light-mode .signature-preview {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--light-border-color);
}

html.light-mode .table-container,
body.light-mode .table-container {
    border-color: var(--light-border-color);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-sm);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Header */
.header {
    /* Solid background — backdrop-filter removed (causes Chrome GPU compositor glitch) */
    background: #16162e;
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: var(--spacing-md);
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.1);
}

/* Cards */
.card {
    background: var(--dark-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
    border-color: var(--accent-purple);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-purple);
}

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

.btn-danger {
    background: var(--secondary-gradient);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

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

select.form-control {
    cursor: pointer;
}

/* Grid */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

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

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

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

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: rgba(255, 255, 255, 0.03);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.table th.text-right {
    text-align: right;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-draft {
    background: rgba(160, 160, 192, 0.2);
    color: var(--text-secondary);
}

.badge-sent {
    background: rgba(79, 172, 254, 0.2);
    color: var(--accent-blue);
}

.badge-paid {
    background: rgba(0, 242, 254, 0.2);
    color: #00f2fe;
}

.badge-cancelled {
    background: rgba(245, 87, 108, 0.2);
    color: var(--accent-pink);
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

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

.text-muted {
    color: var(--text-secondary);
}

.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mt-1 {
    margin-top: var(--spacing-xs);
}

.mt-2 {
    margin-top: var(--spacing-sm);
}

.mt-3 {
    margin-top: var(--spacing-md);
}

.mt-4 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-xs);
}

.mb-2 {
    margin-bottom: var(--spacing-sm);
}

.mb-3 {
    margin-bottom: var(--spacing-md);
}

.mb-4 {
    margin-bottom: var(--spacing-lg);
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gap-1 {
    gap: var(--spacing-xs);
}

.gap-2 {
    gap: var(--spacing-sm);
}

.gap-3 {
    gap: var(--spacing-md);
}

/* Mobile Navigation Toggle - defined BEFORE media queries so @media can correctly override display */
.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 0;
    gap: 5px;
    transition: all var(--transition-fast);
    z-index: 1000;
}

.mobile-nav-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent-purple);
}

.mobile-nav-toggle span {
    display: block;
    width: 22px;
    height: 3px;
    background: #ffffff;
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.mobile-nav-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-nav-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-nav-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Light mode mobile nav toggle */
html.light-mode .mobile-nav-toggle,
body.light-mode .mobile-nav-toggle {
    background: rgba(0, 0, 0, 0.1);
}

html.light-mode .mobile-nav-toggle span,
body.light-mode .mobile-nav-toggle span {
    background: #1a1a2e;
}

/* Responsive */
@media (max-width: 768px) {

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

    .header-content {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        position: relative;
    }

    .logo {
        flex: 1;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        order: 3;
    }

    /* Show mobile nav toggle on mobile */
    .mobile-nav-toggle {
        display: flex;
    }

    /* Hide desktop nav on mobile */
    .nav {
        display: none;
        width: 100%;
        order: 4;
        margin-top: var(--spacing-sm);
    }

    .nav.mobile-visible {
        display: flex;
        flex-direction: column;
    }

    .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .container {
        padding: var(--spacing-sm);
    }

    .card {
        padding: var(--spacing-md);
    }

    .flex-between {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: flex-start;
    }

    .flex-between .btn {
        width: 100%;
        justify-content: center;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .form-control {
        font-size: 0.9rem;
        padding: 0.7rem 0.9rem;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .summary-grid {
        grid-template-columns: 1fr !important;
    }

    .recent-section {
        grid-template-columns: 1fr !important;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .card-title {
        font-size: 1.1rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Mobile Navigation Toggle styles moved above @media query — see line ~607 */

/* Mobile Navigation Menu */
.mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--dark-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    box-shadow: var(--shadow-lg);
}

.mobile-nav.active {
    display: flex;
}

.mobile-nav .nav-link {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    text-align: left;
    width: 100%;
}

.mobile-nav .nav-link:hover,
.mobile-nav .nav-link.active {
    background: rgba(102, 126, 234, 0.15);
}

/* Light mode mobile nav */
html.light-mode .mobile-nav,
body.light-mode .mobile-nav {
    background: var(--light-card);
    border-color: var(--light-border-color);
}

html.light-mode .mobile-nav .nav-link:hover,
html.light-mode .mobile-nav .nav-link.active,
body.light-mode .mobile-nav .nav-link:hover,
body.light-mode .mobile-nav .nav-link.active {
    background: rgba(102, 126, 234, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

/* Glassmorphism Effect */
.glass {
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}