/* Invoices.Delivery System - Complete Styling System */
/* ===================================== */

/* CSS Variables */
:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --info-color: #3b82f6;
    --info-light: #dbeafe;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ===================== */
/* Mobile Touch Optimizations */
/* ===================== */

/* Ensure all interactive elements work on mobile */
@media (max-width: 768px) {
    /* Base touch optimization */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Minimum touch target size */
    button,
    input[type="submit"],
    input[type="button"],
    .btn {
        min-height: 44px;
    }
    
    /* Ensure inputs are focusable */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        touch-action: manipulation;
    }
    
    /* Fix for iOS safari input issues */
    input,
    textarea,
    select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: var(--radius);
    }
}

/* Page Management */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* ===================== */
/* Login Page Styles */
/* ===================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-header h1 {
    color: var(--text-primary);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-secondary);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.input-icon {
    position: relative;
    display: block;
}

.input-icon .input-icon-left {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 2;
    font-size: 14px;
}

.input-icon input,
.input-icon input[type="text"],
.input-icon input[type="email"],
.input-icon input[type="password"],
.input-icon input[type="number"],
.input-icon input[type="tel"] {
    padding-right: 45px !important;
}

.input-icon .input-icon-left ~ input,
.input-icon .input-icon-left ~ input[type="text"],
.input-icon .input-icon-left ~ input[type="email"],
.input-icon .input-icon-left ~ input[type="password"],
.input-icon .input-icon-left ~ input[type="number"],
.input-icon .input-icon-left ~ input[type="tel"] {
    padding-left: 45px !important;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 10px;
    font-size: 14px;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--primary-color);
}

.login-footer {
    margin-top: 30px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.login-footer small {
    color: var(--text-muted);
}

/* ===================== */
/* Form Elements */
/* ===================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--bg-color);
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Checkbox & Radio */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 0;
}

.checkbox-label input,
.radio-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-right: 10px;
    transition: var(--transition);
}

.toggle-label:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.toggle-label input {
    width: auto;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

/* ===================== */
/* Buttons */
/* ===================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-draft {
    background: #4338ca;
    color: #fff;
}

.btn-draft:hover {
    background: #3730a3;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* ===================== */
/* Navigation */
/* ===================== */

.navbar {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-brand span {
    text-decoration: none;
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.nav-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.nav-item.logout-btn {
    color: var(--danger-color);
}

.nav-item.logout-btn:hover {
    background: var(--danger-light);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 900px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--card-bg);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow-lg);
        display: none;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
        justify-content: flex-start;
    }
    
    .nav-actions {
        flex-wrap: wrap;
    }
}

/* ===================== */
/* Main Content */
/* ===================== */

.main-content {
    padding: 25px;
    max-width: 1400px;
    margin: 0 auto;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header h2 i {
    color: var(--primary-color);
}

.retention-disclaimer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -8px 0 16px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border: 1px solid #dbeafe;
    border-left: 4px solid #6366f1;
    border-radius: 12px;
    color: #334155;
    font-size: 0.86rem;
    line-height: 1.45;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.08);
}

.retention-disclaimer i {
    color: #4f46e5;
    flex-shrink: 0;
}

.retention-disclaimer strong {
    color: #3730a3;
    font-weight: 700;
}

/* ===================== */
/* Stats Cards */
/* ===================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 1.75rem;
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-blue .stat-icon { background: var(--info-light); color: var(--info-color); }
.stat-green .stat-icon { background: var(--success-light); color: var(--success-color); }
.stat-yellow .stat-icon { background: var(--warning-light); color: var(--warning-color); }
.stat-red .stat-icon { background: var(--danger-light); color: var(--danger-color); }
.stat-purple .stat-icon { background: #ede9fe; color: #8b5cf6; }
.stat-teal .stat-icon { background: #ccfbf1; color: #14b8a6; }
.stat-green-light .stat-icon { background: var(--success-light); color: var(--success-color); }
.stat-yellow-light .stat-icon { background: var(--warning-light); color: var(--warning-color); }

/* ===================== */
/* Charts */
/* ===================== */

.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.chart-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow);
}

.chart-box h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart-box canvas {
    max-height: 300px;
}

/* ===================== */
/* Tables */
/* ===================== */

.table-responsive {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th,
.data-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--bg-color);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-active, .status-paid {
    background: var(--success-light);
    color: var(--success-color);
}

.status-suspended, .status-unpaid {
    background: var(--warning-light);
    color: var(--warning-color);
}

.status-terminated, .status-overdue {
    background: var(--danger-light);
    color: var(--danger-color);
}

.status-valid {
    background: var(--success-light);
    color: var(--success-color);
}

.status-invalid {
    background: var(--danger-light);
    color: var(--danger-color);
}

.status-draft {
    background: #f1f5f9;
    color: var(--text-secondary);
}

.status-valid,
.status-invalid {
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 700;
}

.products-data-table {
    table-layout: fixed;
}

.products-data-table .products-col-name {
    width: 18%;
}

.products-data-table .products-col-type {
    width: 12%;
}

.products-data-table .products-col-description {
    width: 34%;
}

.products-data-table .products-col-price {
    width: 12%;
}

.products-data-table .products-col-unit {
    width: 10%;
}

.products-data-table .products-col-actions {
    width: 14%;
}

.products-data-table td {
    vertical-align: top;
}

.products-data-table .products-name-cell {
    font-weight: 600;
    color: var(--text-color);
    overflow-wrap: anywhere;
}

.products-data-table .products-type-cell,
.products-data-table .products-unit-cell {
    text-transform: capitalize;
    color: var(--text-secondary);
}

.products-data-table .products-description-cell {
    color: var(--text-secondary);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.products-data-table .products-price-cell {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
}

.products-data-table .products-actions-cell {
    white-space: nowrap;
}

.status-pinned-draft {
    margin-left: 6px;
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    text-transform: none;
    font-weight: 600;
}

.status-pinned-draft i {
    font-size: 10px;
    margin-right: 5px;
}

.data-table tbody tr.draft-pinned-row td {
    background: #f8faff;
}

.data-table tbody tr.draft-pinned-row {
    box-shadow: inset 3px 0 0 #4338ca;
}

.data-table tbody tr.draft-pinned-row td:first-child {
    border-left: 3px solid #4338ca;
}

.data-table tbody tr.draft-pinned-row:hover td {
    background: #eef4ff;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.view { background: var(--info-light); color: var(--info-color); }
.action-btn.edit { background: var(--warning-light); color: var(--warning-color); }
.action-btn.delete { background: var(--danger-light); color: var(--danger-color); }
.action-btn.success { background: var(--success-light); color: var(--success-color); }

.action-btn:hover {
    transform: scale(1.1);
}

/* ===================== */
/* Search & Filters */
/* ===================== */

.search-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-row-full {
    width: 100%;
}

.search-box {
    width: 100%;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding-left: 45px;
    width: 100%;
}

.filter-row-fields {
    display: flex;
    gap: 12px;
    width: 100%;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-status {
    flex: 0 0 40%;
}

.filter-date {
    flex: 0 0 calc(30% - 6px);
}

.filter-row-actions {
    display: flex;
    justify-content: flex-end;
}

/* ===================== */
/* Packages Grid */
/* ===================== */

.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.subscription-packages-grid {
    width: 100%;
    max-width: none;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 28px;
    align-items: stretch;
}

.package-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.package-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.package-card.featured {
    border: 2px solid var(--primary-color);
}

.package-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 25px;
    text-align: center;
}

.package-card.featured .package-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.package-header h3 {
    color: white;
    margin-bottom: 5px;
}

.package-price {
    font-size: 2rem;
    font-weight: 700;
}

.package-price span {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.8;
}

.package-body {
    padding: 25px;
}

.package-features {
    list-style: none;
    margin-bottom: 20px;
}

.package-features li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.package-features li:last-child {
    border-bottom: none;
}

.package-features li i {
    color: var(--success-color);
}

.package-actions {
    display: flex;
    gap: 10px;
}

.package-actions .btn {
    flex: 1;
}

/* ===================== */
/* Settings Tabs */
/* ===================== */

.settings-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.settings-form {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
}

.invoice-theme-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.invoice-theme-picker select {
    flex: 1;
    min-width: 220px;
}

.invoice-theme-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

#invoiceThemePreviewChip,
#estimateThemePreviewChip {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.16);
    background: #10b981;
    display: inline-block;
}

/* Logo Upload */
.logo-upload {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logo-upload img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
}

.logo-upload input[type="file"] {
    display: none;
}

/* Variable Tags */
.variable-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: var(--bg-color);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

/* ===================== */
/* Invoice Editor */
/* ===================== */

.invoice-editor {
    padding: 25px;
    max-width: 1060px;
    margin: 0 auto;
}

.invoice-form-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.invoice-form-container h2 {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.invoice-form-container h2 i {
    color: var(--primary-color);
}

.editor-action-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.invoice-template-presets {
    margin-bottom: 24px;
    background: linear-gradient(140deg, #fff7ed 0%, #ffffff 58%, #f0f9ff 100%);
    border: 1px solid #fed7aa;
    border-radius: var(--radius-lg);
    padding: 18px;
}

.invoice-template-presets .preset-head {
    margin-bottom: 12px;
}

.invoice-template-presets .preset-head h3 {
    margin: 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #9a3412;
}

.invoice-template-presets .preset-head h3 i {
    color: #ea580c;
}

.invoice-template-presets .preset-head p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #7c2d12;
}

.invoice-template-presets .preset-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.invoice-template-presets .template-preset-btn {
    border: 1px solid #fdba74;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    padding: 12px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.invoice-template-presets .template-preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(249, 115, 22, 0.12);
}

.invoice-template-presets .template-preset-btn .title {
    display: block;
    font-weight: 700;
    color: #9a3412;
    margin-bottom: 3px;
}

.invoice-template-presets .template-preset-btn .desc {
    display: block;
    font-size: 12px;
    color: #7c2d12;
    line-height: 1.35;
}

.invoice-template-presets .template-preset-btn.active {
    border-color: var(--primary-color);
    box-shadow: inset 0 0 0 1px var(--primary-color), 0 10px 22px rgba(2, 132, 199, 0.16);
    background: linear-gradient(150deg, #ffffff 0%, #f0f9ff 100%);
}

.invoice-intel-panel {
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border: 1px solid #dbeafe;
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 24px;
}

.invoice-intel-panel .intel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.invoice-intel-panel .intel-score-ring {
    --progress: 0;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-color) calc(var(--progress) * 1%), #cbd5e1 0);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    position: relative;
}

.invoice-intel-panel .intel-score-ring::before {
    content: '';
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    position: absolute;
}

.invoice-intel-panel .intel-score-ring span {
    position: relative;
    z-index: 1;
    font-weight: 700;
    color: #0f172a;
    font-size: 13px;
}

.invoice-intel-panel .intel-head-text h3 {
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
    font-size: 1rem;
}

.invoice-intel-panel .intel-head-text h3 i {
    color: var(--primary-color);
}

.invoice-intel-panel .intel-head-text p {
    margin: 0;
    color: #475569;
    font-size: 13px;
}

.invoice-intel-panel .intel-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.invoice-intel-panel .metric-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.invoice-intel-panel .metric-chip .label {
    color: #475569;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.invoice-intel-panel .metric-chip .value {
    color: #0f172a;
    font-weight: 600;
    font-size: 12px;
}

.invoice-health-checklist {
    list-style: none;
    padding: 0;
    margin: 0 0 14px 0;
    display: grid;
    gap: 8px;
}

.invoice-health-checklist li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 8px;
}

.invoice-health-checklist li.ok {
    background: #ecfdf5;
    color: #166534;
}

.invoice-health-checklist li.warn {
    background: #fff7ed;
    color: #9a3412;
}

.invoice-intel-panel .intel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.invoice-intel-panel .intel-shortcuts {
    margin: 0;
    font-size: 12px;
    color: #64748b;
}

.invoice-intel-panel .intel-shortcuts kbd {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 5px;
    font-size: 11px;
    color: #0f172a;
}

.invoice-header-section,
.customer-section,
.items-section,
.notes-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.customer-section h3,
.items-section h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.items-section .items-section-hint {
    margin: -8px 0 14px;
    font-size: 12px;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.customer-type-toggle {
    margin-bottom: 20px;
}

.customer-preview {
    background: var(--bg-color);
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 15px;
}

.customer-preview p {
    margin-bottom: 5px;
}

/* Items Table */
.items-table-wrapper {
    overflow-x: auto;
    margin-bottom: 15px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th,
.items-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.items-table th {
    background: var(--bg-color);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.items-table input,
.items-table select {
    padding: 8px;
    font-size: 13px;
}

.items-table .item-name {
    min-width: 150px;
}

.items-table .item-desc {
    min-width: 150px;
}

.items-table .item-qty,
.items-table .item-price,
.items-table .item-total {
    width: 100px;
}

.items-table .item-actions {
    width: 50px;
    text-align: center;
}

.items-table .item-row-actions {
    display: flex;
    gap: 6px;
}

.items-table .item-row-actions .btn {
    min-width: 30px;
    padding: 6px 8px;
}

.items-section .invoice-item-row.drag-over td {
    background: #e0f2fe;
}

.items-section .invoice-item-row.is-dragging {
    opacity: 0.45;
}

.items-section .drag-handle-btn {
    cursor: grab;
}

.items-section .drag-handle-btn:active {
    cursor: grabbing;
}

.add-item-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Invoice Summary */
.invoice-summary {
    margin-top: 20px;
    margin-left: auto;
    max-width: 400px;
}



.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total-row {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px solid var(--primary-color);
    margin-top: 10px;
    padding-top: 15px;
}

.adjustment-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.adjustment-input select {
    width: 80px;
    padding: 6px;
}

.adjustment-input input {
    width: 80px;
    padding: 6px;
    text-align: right;
}

/* ===================== */
/* Invoice Preview */
/* ===================== */

.invoice-preview-container {
    padding: 25px;
    max-width: 900px;
    margin: 0 auto;
}

.invoice-preview {
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    padding: 50px;
}

.invoice-template {
    font-size: 14px;
}

.invoice-template-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--primary-color);
}

.invoice-logo img {
    max-height: 80px;
    max-width: 200px;
}

.invoice-company-info {
    text-align: left;
}

.invoice-company-info h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.invoice-company-info p {
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.invoice-title-section {
    text-align: right;
}

.invoice-title-section h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.invoice-title-section p {
    margin-bottom: 5px;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.invoice-parties h4 {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.invoice-parties p {
    margin-bottom: 3px;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.invoice-items-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
}

.invoice-items-table th:last-child {
    text-align: right;
}

.invoice-items-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-items-table td:last-child {
    text-align: right;
}

.invoice-items-table tbody tr:nth-child(even) {
    background: var(--bg-color);
}

.invoice-totals {
    width: 300px;
    margin-left: auto;
}

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.invoice-totals-row.grand-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px solid var(--primary-color);
    border-bottom: none;
    padding-top: 15px;
}

.invoice-footer {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.invoice-footer h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.invoice-footer p {
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.invoice-payment-link {
    margin-top: 20px;
    text-align: center;
}

.invoice-payment-link a {
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
}

/* ===================== */
/* Public Invoice View */
/* ===================== */

.public-invoice-container {
    min-height: 100vh;
    padding: 25px;
    background: var(--bg-color);
}

.public-invoice-actions {
    max-width: 900px;
    margin: 20px auto;
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ===================== */
/* Modals */
/* ===================== */

.modal,
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active,
.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
    margin: auto;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: var(--primary-color);
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.close-btn:hover {
    background: var(--danger-light);
    color: var(--danger-color);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
}

.app-confirm-modal {
    max-width: 520px;
}

.app-confirm-modal .modal-body p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.app-confirm-modal .modal-footer {
    flex-wrap: wrap;
}

/* Items List Modal */
.items-list {
    max-height: 400px;
    overflow-y: auto;
}

.item-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.item-list-item:hover {
    background: var(--bg-color);
}

.item-list-info h4 {
    margin-bottom: 5px;
}

.item-list-info p {
    color: var(--text-secondary);
    font-size: 13px;
}

.item-list-price {
    font-weight: 600;
    color: var(--primary-color);
}

/* ===================== */
/* Toast Notifications */
/* ===================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--card-bg);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
}

.toast i {
    font-size: 1.25rem;
}

.toast.success i { color: var(--success-color); }
.toast.error i { color: var(--danger-color); }
.toast.warning i { color: var(--warning-color); }
.toast.info i { color: var(--info-color); }

/* ===================== */
/* Loading Overlay */
/* ===================== */

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================== */
/* Recent Section */
/* ===================== */

.recent-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow);
}

.recent-section h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-section h3 i {
    color: var(--primary-color);
}

/* ===================== */
/* Print Styles */
/* ===================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    #viewInvoicePage {
        padding: 0 !important;
    }
    
    .invoice-preview-container {
        padding: 0;
        max-width: none;
        margin: 0;
    }
    
    .invoice-preview {
        box-shadow: none;
        padding: 0;
        border-radius: 0;
        background: transparent;
    }
    
    .invoice-preview-content {
        width: 100% !important;
        max-width: none !important;
        min-height: var(--invoice-page-min-height) !important;
        border-radius: 0;
        margin: 0;
        padding: 4mm !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .invoice-preview-content .invoice-top-bar,
    .invoice-preview-content .invoice-detail-row,
    .invoice-preview-content .invoice-totals-wrap,
    .invoice-preview-content .invoice-notes-row,
    .invoice-preview-content .invoice-compliance-info,
    .invoice-preview-content .payment-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}

/* ===================== */
/* Responsive Adjustments */
/* ===================== */

@media (max-width: 1200px) {
    .invoice-editor {
        max-width: 1060px;
    }
}

/* Tablet & Mobile (768px and below) */
@media (max-width: 768px) {
    /* Main Layout */
    .main-content {
        padding: 15px;
    }
    
    /* Navigation */
    .navbar {
        padding: 12px 15px;
        flex-wrap: wrap;
    }
    
    .nav-brand {
        font-size: 1rem;
        gap: 8px;
    }
    
    .nav-brand i {
        font-size: 1.25rem;
    }
    
    .nav-brand span {
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
    }
    
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--card-bg);
        flex-direction: column;
        padding: 15px;
        box-shadow: var(--shadow-lg);
        display: none;
        z-index: 99;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 15px;
    }
    
    .nav-actions {
        gap: 5px;
        flex-wrap: wrap;
    }
    
    .nav-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .nav-actions .btn span {
        display: none;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .stat-info h3 {
        font-size: 1.35rem;
    }
    
    .stat-info p {
        font-size: 12px;
    }
    
    /* Charts */
    .chart-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chart-box {
        padding: 15px;
    }
    
    .chart-box canvas {
        max-height: 250px;
    }
    
    /* Section Headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    .section-header .btn {
        width: 100%;
    }

    .retention-disclaimer {
        margin: 0 0 12px;
        font-size: 0.8rem;
        line-height: 1.35;
    }
    
    /* Search & Filters */
    .filter-row-fields {
        flex-direction: column;
    }

    .filter-status,
    .filter-date {
        flex: 0 0 100%;
    }
    
    /* Tables */
    .table-responsive {
        margin: 0 -15px;
        border-radius: 0;
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 10px;
        font-size: 13px;
    }
    
    .data-table th {
        font-size: 11px;
    }
    
    .action-buttons {
        flex-direction: row;
        gap: 3px;
    }
    
    .action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    /* Packages Grid */
    .packages-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .package-header {
        padding: 20px;
    }
    
    .package-body {
        padding: 20px;
    }
    
    .package-actions {
        flex-direction: column;
    }
    
    /* Settings */
    .settings-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 5px;
    }
    
    .settings-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .settings-form {
        padding: 20px;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .logo-upload {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Invoice Editor */
    .invoice-editor {
        padding: 15px;
    }
    
    .invoice-form-container {
        padding: 20px;
    }
    
    .invoice-form-container h2 {
        font-size: 1.2rem;
    }
    
    .items-table th,
    .items-table td {
        padding: 8px;
        font-size: 12px;
    }
    
    .items-table .item-name,
    .items-table .item-desc {
        min-width: 100px;
    }
    
    .items-table .item-qty,
    .items-table .item-price,
    .items-table .item-total {
        width: 70px;
    }
    
    .add-item-buttons {
        flex-direction: column;
    }
    
    .add-item-buttons .btn {
        width: 100%;
    }
    
    .invoice-summary {
        max-width: 100%;
    }
    
    .invoice-template-presets .preset-buttons {
        grid-template-columns: 1fr;
    }

    .invoice-intel-panel .intel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .invoice-intel-panel .intel-metrics {
        grid-template-columns: 1fr;
    }

    .invoice-intel-panel .intel-actions .btn {
        width: 100%;
    }
    
    /* Invoice Preview */
    .invoice-preview-container {
        padding: 15px;
    }
    
    .invoice-preview {
        padding: 20px;
    }
    
    .invoice-template-header {
        flex-direction: column;
        gap: 20px;
    }
    
    .invoice-title-section {
        text-align: left;
    }
    
    .invoice-title-section h1 {
        font-size: 1.75rem;
    }
    
    .invoice-parties {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .invoice-totals {
        width: 100%;
    }
    
    .invoice-items-table th,
    .invoice-items-table td {
        padding: 10px;
        font-size: 12px;
    }
    
    /* Modals */
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        max-height: 85vh;
        margin: auto;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Toast Notifications */
    .toast-container {
        left: 15px;
        right: 15px;
        bottom: 15px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    /* Login Page */
    .login-box {
        padding: 25px;
    }
    
    .login-header h1 {
        font-size: 1.35rem;
    }
    
    .login-header .logo-icon {
        font-size: 2.5rem;
    }
    
    /* Demo Notification */
    .demo-notification-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 10px 15px;
    }
    
    .demo-notification-bar p {
        font-size: 12px;
    }
    
    /* Recent Section */
    .recent-section {
        padding: 15px;
    }
    
    /* Public Invoice */
    .public-invoice-actions {
        flex-direction: column;
    }
    
    .public-invoice-actions .btn {
        width: 100%;
    }
}

/* Mobile Small (480px and below) */
@media (max-width: 480px) {
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        text-align: left;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-info h3 {
        font-size: 1.25rem;
    }
    
    /* Navigation */
    .nav-brand span {
        max-width: 130px;
        font-size: 0.9rem;
    }
    
    /* Login Page */
    .login-box {
        padding: 20px;
    }
    
    .login-header h1 {
        font-size: 1.2rem;
    }
    
    .login-header .logo-icon {
        font-size: 2rem;
    }
    
    /* Modals */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        margin: 0;
    }
    
    /* Invoice Tables */
    .invoice-items-table {
        font-size: 11px;
    }
    
    .invoice-items-table th,
    .invoice-items-table td {
        padding: 6px;
    }
    
    /* Items Table Editor */
    .items-table-wrapper {
        margin: 0 -20px;
    }
    
    .items-table th,
    .items-table td {
        padding: 6px;
        font-size: 11px;
    }
    
    .items-table input,
    .items-table select {
        padding: 6px;
        font-size: 11px;
    }
    
    /* Invoice Preview */
    .invoice-preview {
        padding: 15px;
    }
    
    .invoice-title-section h1 {
        font-size: 1.5rem;
    }
    
    .invoice-logo img {
        max-height: 50px;
        max-width: 120px;
    }
    
    .invoice-totals-row {
        font-size: 13px;
        padding: 8px 0;
    }
    
    .invoice-totals-row.grand-total {
        font-size: 1.1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Form Elements */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .input-icon input,
    .input-icon input[type="text"],
    .input-icon input[type="email"],
    .input-icon input[type="password"],
    .input-icon input[type="number"],
    .input-icon input[type="tel"] {
        padding-right: 40px !important;
    }

    .input-icon .input-icon-left ~ input,
    .input-icon .input-icon-left ~ input[type="text"],
    .input-icon .input-icon-left ~ input[type="email"],
    .input-icon .input-icon-left ~ input[type="password"],
    .input-icon .input-icon-left ~ input[type="number"],
    .input-icon .input-icon-left ~ input[type="tel"] {
        padding-left: 40px !important;
    }
    
    .input-icon .input-icon-left {
        left: 12px;
        font-size: 13px;
    }
    
    /* Data Tables */
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .data-table th {
        font-size: 10px;
    }
    
    /* Status Badges */
    .status-badge {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    /* Demo Banner */
    .demo-banner {
        padding: 12px 15px;
        font-size: 12px;
        margin: -20px -20px 20px -20px;
    }
    
    /* Demo Watermark */
    .demo-watermark span {
        font-size: 100px;
        letter-spacing: 15px;
    }
    
    /* Demo Footer Warning */
    .demo-footer-warning {
        flex-direction: column;
        padding: 15px;
        gap: 10px;
    }
    
    .demo-footer-warning i {
        font-size: 20px;
    }
    
    .demo-footer-warning p {
        font-size: 12px;
    }
    
    /* ===================== */
    /* Mobile Touch Fixes - Login Page */
    /* ===================== */
    
    /* Ensure inputs are clickable on mobile */
    .login-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .login-box {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .login-form input,
    .login-form button {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    .input-icon {
        position: relative;
        z-index: 1;
    }
    
    .input-icon input {
        position: relative;
        z-index: 2;
        -webkit-user-select: text;
        user-select: text;
        touch-action: manipulation;
    }
    
    .input-icon .input-icon-left {
        z-index: 1;
        pointer-events: none;
    }
    
    /* Buttons touch fix */
    .btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    
    .password-toggle {
        z-index: 3;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===================== */
/* Utility Classes */
/* ===================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }

.hidden { display: none !important; }
.visible { display: block !important; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

/* ===================== */
/* Demo Mode Styling */
/* ===================== */

.invoice-preview-content.demo-mode {
    position: relative;
    overflow: hidden;
}

.demo-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    z-index: 10;
    pointer-events: none;
}

.demo-watermark span {
    font-size: 180px;
    font-weight: 900;
    color: rgba(239, 68, 68, 0.15);
    text-transform: uppercase;
    letter-spacing: 30px;
    white-space: nowrap;
    display: block;
    font-family: 'Arial Black', sans-serif;
}

.demo-banner {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
    margin: -30px -30px 30px -30px;
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 14px;
}

.demo-banner i {
    margin-right: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.demo-logo {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: white;
    padding: 20px 30px;
    border-radius: var(--radius);
    font-size: 24px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.demo-logo i {
    font-size: 32px;
}

.demo-tag {
    background: #ef4444;
    color: white;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 10px;
    vertical-align: middle;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.demo-label {
    background: #fef3c7;
    color: #d97706;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: normal;
}

.demo-item-tag {
    background: #fee2e2;
    color: #ef4444;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 5px;
    font-weight: bold;
}

.demo-footer-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px dashed #f59e0b;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 30px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.demo-footer-warning i {
    font-size: 24px;
    color: #f59e0b;
    flex-shrink: 0;
}

.demo-footer-warning p {
    margin: 0;
    color: #92400e;
    font-size: 13px;
    line-height: 1.6;
}

.demo-disabled {
    opacity: 0.6;
}

.demo-disabled button {
    cursor: not-allowed !important;
}

/* Demo notification bar for dashboard */
.demo-notification-bar {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 2px solid #f59e0b;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.demo-notification-bar i {
    color: #f59e0b;
    font-size: 18px;
}

.demo-notification-bar p {
    margin: 0;
    color: #92400e;
    font-size: 14px;
}

/* ===================== */
/* Invoice Preview Layout */
/* ===================== */

.invoice-preview-content.proforma-layout {
    --invoice-accent: #10b981;
    --invoice-accent-dark: #047857;
    --invoice-accent-soft: rgba(16, 185, 129, 0.16);
    --invoice-accent-muted: #8ad9bc;
    --invoice-accent-pale: #ecfdf5;
    --invoice-page-width: 794px;
    --invoice-page-min-height: 1122px;
    background: #fff;
    padding: 34px 36px;
    border-radius: var(--radius);
    font-family: 'Segoe UI', Arial, sans-serif;
    width: var(--invoice-page-width);
    max-width: 100%;
    min-height: var(--invoice-page-min-height);
    margin: 0 auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.invoice-preview-content.proforma-layout .invoice-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 18px;
    margin-bottom: 22px;
}

.invoice-preview-content.proforma-layout .invoice-logo-block {
    min-width: 78px;
    display: flex;
    align-items: flex-start;
}

.invoice-preview-content.proforma-layout .company-logo {
    max-width: 72px;
    max-height: 72px;
    object-fit: contain;
}

.invoice-preview-content.proforma-layout .company-logo-fallback {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--invoice-accent);
    color: #fff;
    font-size: 34px;
    font-weight: 800;
}

.invoice-preview-content.proforma-layout .invoice-company-info {
    margin-left: auto;
    text-align: right;
    max-width: 48%;
}

.invoice-preview-content.proforma-layout .invoice-company-info h1 {
    color: var(--invoice-accent);
    font-size: 1.25rem;
    margin: 0 0 6px 0;
    font-weight: 700;
}

.invoice-preview-content.proforma-layout .invoice-company-info p {
    margin: 0;
    color: #64748b;
    font-size: 0.86rem;
    line-height: 1.45;
}

.invoice-preview-content.proforma-layout .invoice-detail-row {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 320px);
    gap: 26px;
    margin-bottom: 24px;
}

.invoice-preview-content.proforma-layout .bill-to-card h3 {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.invoice-preview-content.proforma-layout .bill-to-card .name {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--invoice-accent-dark);
}

.invoice-preview-content.proforma-layout .bill-to-card p {
    margin: 0;
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.4;
}

.invoice-preview-content.proforma-layout .invoice-meta-card {
    border: 1px solid #dbe4ef;
}

.invoice-preview-content.proforma-layout .invoice-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 42px;
}

.invoice-preview-content.proforma-layout .invoice-meta-row + .invoice-meta-row {
    border-top: 1px solid #dbe4ef;
}

.invoice-preview-content.proforma-layout .invoice-meta-row .meta-label,
.invoice-preview-content.proforma-layout .invoice-meta-row .meta-value {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 0.84rem;
}

.invoice-preview-content.proforma-layout .invoice-meta-row .meta-label {
    background: var(--invoice-accent);
    color: #fff;
    font-weight: 600;
}

.invoice-preview-content.proforma-layout .invoice-meta-row .meta-value {
    color: #1e293b;
    justify-content: flex-end;
    font-weight: 600;
}

.invoice-preview-content.proforma-layout .invoice-status-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-paid {
    background: var(--success-light);
    color: var(--success-color);
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-unpaid {
    background: var(--warning-light);
    color: var(--warning-color);
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-overdue {
    background: var(--danger-light);
    color: var(--danger-color);
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-draft {
    background: #e2e8f0;
    color: #475569;
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-valid {
    background: var(--success-light);
    color: var(--success-color);
}

.invoice-preview-content.proforma-layout .invoice-status-chip.status-invalid {
    background: var(--danger-light);
    color: var(--danger-color);
}

.invoice-preview-content.proforma-layout .invoice-body {
    margin-bottom: 18px;
    flex: 1;
}

.invoice-preview-content.proforma-layout .items-table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-preview-content.proforma-layout .items-table th {
    background: var(--invoice-accent);
    color: #fff;
    padding: 10px 12px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-preview-content.proforma-layout .items-table td {
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    font-size: 0.88rem;
    color: #334155;
    vertical-align: top;
}

.invoice-preview-content.proforma-layout .items-table .col-sr {
    text-align: center;
    color: #64748b;
}

.invoice-preview-content.proforma-layout .items-table .item-subtext {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.35;
}

.invoice-preview-content.proforma-layout .items-table .amount-cell {
    color: #0f172a;
    font-weight: 700;
}

.invoice-preview-content.proforma-layout .items-table .empty-row {
    text-align: center;
    color: #64748b;
    padding: 18px 10px;
}

.invoice-preview-content.proforma-layout .invoice-totals-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.invoice-preview-content.proforma-layout .invoice-totals-table {
    width: min(360px, 100%);
    border-collapse: collapse;
}

.invoice-preview-content.proforma-layout .invoice-totals-table th,
.invoice-preview-content.proforma-layout .invoice-totals-table td {
    border: 1px solid #e2e8f0;
    padding: 9px 12px;
    font-size: 0.9rem;
}

.invoice-preview-content.proforma-layout .invoice-totals-table th {
    color: #475569;
    font-weight: 600;
    background: #f8fafc;
    text-align: left;
}

.invoice-preview-content.proforma-layout .invoice-totals-table td {
    text-align: right;
    color: #0f172a;
    font-weight: 700;
}

.invoice-preview-content.proforma-layout .invoice-totals-table .grand-total th,
.invoice-preview-content.proforma-layout .invoice-totals-table .grand-total td {
    background: var(--invoice-accent);
    color: #fff;
    font-size: 1rem;
}

.invoice-preview-content.proforma-layout .invoice-notes-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: auto;
    padding-top: 14px;
}

.invoice-preview-content.proforma-layout .invoice-note-block {
    border: 1px solid var(--invoice-accent-soft);
    background: var(--invoice-accent-pale);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.invoice-preview-content.proforma-layout .invoice-note-block h4 {
    margin: 0 0 6px 0;
    color: var(--invoice-accent-dark);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.invoice-preview-content.proforma-layout .invoice-note-block p {
    margin: 0;
    color: #334155;
    font-size: 0.88rem;
    line-height: 1.45;
}

.invoice-preview-content.proforma-layout .payment-section {
    margin-top: 20px;
    text-align: center;
    padding: 20px;
    border-radius: var(--radius-sm);
    background: var(--invoice-accent-pale);
    border: 1px solid var(--invoice-accent-soft);
}

.invoice-preview-content.proforma-layout .payment-section .btn {
    background: var(--invoice-accent);
    border: 1px solid var(--invoice-accent-dark);
    color: #fff;
}

.invoice-preview-content.proforma-layout .payment-section .btn:hover {
    background: var(--invoice-accent-dark);
}

.invoice-preview-content.proforma-layout .invoice-compliance-info {
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.35;
}

.invoice-preview-content.proforma-layout .invoice-compliance-info p {
    margin: 0;
    text-align: right;
}

.invoice-preview-content.proforma-layout .invoice-compliance-info p + p {
    margin-top: 2px;
}

.invoice-preview-content.proforma-layout .invoice-compliance-info span {
    font-weight: 600;
    color: #475569;
}

@media (max-width: 768px) {
    .invoice-preview-content.proforma-layout {
        padding: 20px;
        min-height: auto;
    }

    .invoice-preview-content.proforma-layout .invoice-top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .invoice-preview-content.proforma-layout .invoice-company-info {
        margin-left: 0;
        max-width: 100%;
        text-align: left;
    }

    .invoice-preview-content.proforma-layout .invoice-detail-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .invoice-preview-content.proforma-layout .invoice-meta-row {
        grid-template-columns: 1fr 1fr;
    }

    .invoice-preview-content.proforma-layout .invoice-totals-wrap {
        justify-content: stretch;
    }

    .invoice-preview-content.proforma-layout .invoice-totals-table {
        width: 100%;
    }

    .invoice-preview-content.proforma-layout .invoice-compliance-info p {
        text-align: left;
    }
}

.demo-notification-bar strong {
    color: #78350f;
}

.demo-limit-badge {
    background: #ef4444;
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

/* Print styles for demo */
@media print {
    .demo-watermark span {
        font-size: 200px !important;
        color: rgba(239, 68, 68, 0.2) !important;
    }
    
    .demo-banner {
        background: #ef4444 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .demo-footer-warning {
        background: #fef3c7 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
/* ===================== */
/* Advanced Filters Panel */
/* ===================== */

.advanced-filters-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 25px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.advanced-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group label i {
    color: var(--primary-color);
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    transition: var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    outline: none;
}

.filter-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.filter-total {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 16px;
}

/* ===================== */
/* Export Bar */
/* ===================== */

.export-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.export-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===================== */
/* Bulk Actions Bar */
/* ===================== */

.bulk-actions-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.bulk-actions-bar span {
    font-weight: 600;
    padding-right: 15px;
    border-right: 1px solid rgba(255,255,255,0.2);
}

/* ===================== */
/* Pagination Controls */
/* ===================== */

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.pagination-controls button {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.pagination-controls button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-controls button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-controls .page-info {
    padding: 0 15px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===================== */
/* Report Modal Styles */
/* ===================== */

.modal-lg .modal-content {
    max-width: 800px;
}

.modal-sm .modal-content {
    max-width: 420px;
}

.report-options {
    padding: 10px 0;
}

.report-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 15px;
    background: #f8fafc;
    border-radius: var(--radius);
    margin-top: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.report-preview {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.report-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: white;
}

.report-preview-header h4 {
    margin: 0;
    font-size: 16px;
    color: white;
}

.report-preview-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    background: white;
}

/* Report Preview Table Styles */
.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th {
    background: #f1f5f9;
    padding: 12px 15px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.report-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.report-table tr:hover {
    background: #f8fafc;
}

.report-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.report-summary-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
}

.report-summary-card.green {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.report-summary-card.orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.report-summary-card.red {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.report-summary-card h5 {
    font-size: 12px;
    opacity: 0.85;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    color: white;
}

.report-summary-card .value {
    font-size: 28px;
    font-weight: 700;
}

/* Input with Button */
.input-with-button {
    display: flex;
    gap: 10px;
}

.input-with-button input {
    flex: 1;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Interactive Element Animations */
.data-table tbody tr {
    transition: all 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.05);
    transform: translateX(3px);
}

/* Checkbox in table */
.data-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Mobile Responsive for new elements */
@media (max-width: 768px) {
    .advanced-filters-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .export-bar {
        justify-content: center;
    }
    
    .bulk-actions-bar {
        flex-wrap: wrap;
        justify-content: center;
        border-radius: var(--radius-lg);
        width: calc(100% - 40px);
        max-width: 400px;
    }
    
    .bulk-actions-bar span {
        width: 100%;
        text-align: center;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.2);
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
    
    .report-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .advanced-filters-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-summary {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Loading Pulse Animation for data */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-row td {
    animation: pulse 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Success Animation */
@keyframes successPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.success-animation {
    animation: successPop 0.4s ease;
}

/* Hover Card Effect */
.stat-card {
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

/* Interactive Button Ripple Effect */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* ===================== */
/* Global Responsive Hardening */
/* ===================== */

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

.page {
    width: 100%;
    overflow-x: hidden;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--info-light);
    color: var(--info-color);
    font-size: 12px;
    font-weight: 600;
}

@media (max-width: 1100px) {
    #createInvoicePage .navbar,
    #viewInvoicePage .navbar,
    #createEstimatePage .navbar,
    #viewEstimatePage .navbar {
        align-items: flex-start;
        gap: 10px;
    }
    
    #createInvoicePage .nav-actions,
    #viewInvoicePage .nav-actions,
    #createEstimatePage .nav-actions,
    #viewEstimatePage .nav-actions {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }
    
    #createInvoicePage .nav-actions .btn,
    #viewInvoicePage .nav-actions .btn,
    #createEstimatePage .nav-actions .btn,
    #viewEstimatePage .nav-actions .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    .section-header .section-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .section-header .section-actions .btn {
        flex: 1 1 170px;
    }
    
    #currentPlanInfo .current-plan-head {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    #currentPlanInfo .current-plan-stats {
        width: 100%;
        text-align: left !important;
    }
    
    #currentPlanInfo .progress-bar {
        width: 100% !important;
    }
    
    .report-preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .input-with-button {
        flex-direction: column;
    }
    
    .input-with-button .btn {
        width: 100%;
    }
    
    .header-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .header-actions .btn {
        flex: 1 1 140px;
    }
    
    .table-responsive {
        margin: 0;
        border-radius: var(--radius-lg);
        box-shadow: none;
        background: transparent;
        overflow: visible;
    }
    
    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }
    
    .data-table thead {
        display: none;
    }
    
    .data-table tbody {
        display: grid;
        gap: 12px;
    }
    
    .data-table tbody tr {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 10px 12px;
        box-shadow: var(--shadow-sm);
    }
    
    .data-table tbody tr:hover {
        background: var(--card-bg);
        transform: none;
    }
    
    .data-table td {
        padding: 8px 0;
        border-bottom: 1px dashed var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        text-align: right;
    }
    
    .data-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .data-table td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.55px;
        text-transform: uppercase;
        text-align: left;
        max-width: 45%;
    }
    
    .data-table td .action-buttons {
        justify-content: flex-end;
    }
    
    .items-table {
        min-width: 0;
    }
    
    .items-table,
    .items-table tbody,
    .items-table tr,
    .items-table td {
        display: block;
        width: 100%;
    }
    
    .items-table thead {
        display: none;
    }
    
    .items-table tbody {
        display: grid;
        gap: 12px;
    }
    
    .items-table .invoice-item-row {
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 12px;
        background: #ffffff;
        box-shadow: var(--shadow-sm);
    }
    
    .items-table td {
        width: 100% !important;
        padding: 8px 0 !important;
        border-bottom: 1px dashed var(--border-color);
    }
    
    .items-table td:last-child {
        border-bottom: none;
        padding-bottom: 0 !important;
    }
    
    .items-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.55px;
        text-transform: uppercase;
    }
    
    .items-table input,
    .items-table select {
        width: 100% !important;
    }
    
    .items-table .item-row-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .items-table .item-row-actions .btn {
        min-height: 38px;
    }
    
    .invoice-summary {
        width: 100%;
        max-width: none;
    }
    
    .report-table,
    .report-table tbody,
    .report-table tr,
    .report-table td {
        display: block;
        width: 100%;
    }
    
    .report-table thead {
        display: none;
    }
    
    .report-table tbody {
        display: grid;
        gap: 10px;
    }
    
    .report-table tr {
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 10px;
        background: #ffffff;
    }
    
    .report-table td {
        padding: 7px 0;
        border-bottom: 1px dashed var(--border-color);
        display: flex;
        justify-content: space-between;
        gap: 10px;
        text-align: right;
    }
    
    .report-table td:last-child {
        border-bottom: none;
    }
    
    .report-table td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.55px;
        text-transform: uppercase;
        text-align: left;
    }
}

@media (max-width: 480px) {
    #createInvoicePage .nav-actions .btn,
    #viewInvoicePage .nav-actions .btn,
    #createEstimatePage .nav-actions .btn,
    #viewEstimatePage .nav-actions .btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .editor-action-row {
        flex-wrap: wrap;
    }

    .editor-action-row .btn {
        flex: 1 1 100%;
    }
    
    .data-table td {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .invoice-preview-content.proforma-layout .items-table {
        display: table;
        width: 100%;
        border-collapse: collapse;
    }

    .invoice-preview-content.proforma-layout .items-table thead {
        display: table-header-group;
    }

    .invoice-preview-content.proforma-layout .items-table tbody {
        display: table-row-group;
    }

    .invoice-preview-content.proforma-layout .items-table tr {
        display: table-row;
    }

    .invoice-preview-content.proforma-layout .items-table th,
    .invoice-preview-content.proforma-layout .items-table td {
        display: table-cell;
        width: auto !important;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 8px !important;
    }

    .invoice-preview-content.proforma-layout .items-table td::before {
        content: none;
    }
}

/* ===================== */
/* Mobile Hardening */
/* ===================== */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

@media (max-width: 768px) {
    .editor-action-row {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .editor-action-row .btn {
        flex: 1 1 180px;
        min-height: 42px;
    }

    .invoice-form-container {
        padding: 16px;
    }

    .invoice-preview-content {
        width: 100% !important;
        min-height: auto !important;
        padding: 18px 14px;
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal-content {
        width: 100%;
        max-width: 640px;
    }
}

@media (max-width: 480px) {
    .invoice-preview-content {
        padding: 14px 12px;
    }

    .modal-overlay {
        padding: 8px;
    }
}
