:root {
    /* Brand Colors - Sophisticated Apple-like Palette */
    --primary: #0066cc;
    --primary-hover: #005bb5;
    --primary-light: rgba(0, 102, 204, 0.1);
    
    /* Backgrounds */
    --bg-main: #f5f5f7;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-solid: #ffffff;
    --bg-sidebar: rgba(255, 255, 255, 0.9);
    
    /* Text Colors */
    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --text-light: #ffffff;
    
    /* Status Colors */
    --status-pending-bg: #fff5e6;
    --status-pending-text: #ff9900;
    --status-progress-bg: #e6f0ff;
    --status-progress-text: #0066cc;
    --status-ready-bg: #e6ffe6;
    --status-ready-text: #00cc00;
    --status-completed-bg: #f5f5f7;
    --status-completed-text: #86868b;
    
    /* Aesthetics */
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
    
    /* Glassmorphism */
    --glass-blur: blur(20px);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(circle at 50% 0%, #ffffff 0%, #f5f5f7 100%);
    min-height: 100vh;
}

/* Base Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Glassmorphism Utilities */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    color: var(--primary);
}

.logo h2 {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: var(--text-light);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.sync-icon {
    font-size: 18px;
    color: var(--status-ready-text);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-main);
}

.top-header h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.content-wrapper {
    padding: 0 40px 40px;
    flex: 1;
}

/* Views Section */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon span {
    font-size: 24px;
}

.stat-icon.pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.stat-icon.progress { background: var(--status-progress-bg); color: var(--status-progress-text); }
.stat-icon.completed { background: var(--status-completed-bg); color: var(--status-completed-text); }
.stat-icon.revenue { background: #e6fffa; color: #00cc99; }

.stat-details h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 102, 204, 0.3);
}

.btn-secondary {
    background: var(--bg-card-solid);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f0f0f5;
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 8px 12px;
}

.btn-text:hover {
    background: var(--primary-light);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
}

.btn-icon.danger:hover {
    background: #ffeeee;
    color: #cc0000;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

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

.premium-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

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

.premium-table tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.status-badge.in_progress { background: var(--status-progress-bg); color: var(--status-progress-text); }
.status-badge.ready { background: var(--status-ready-bg); color: var(--status-ready-text); }
.status-badge.completed { background: var(--status-completed-bg); color: var(--status-completed-text); }

/* Forms & Inputs */
.premium-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.premium-form label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.premium-input, .premium-select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-card-solid);
    font-size: 14px;
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.premium-input:focus, .premium-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.small-input {
    width: 80px;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card-solid);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-body {
    padding: 24px;
}

/* Invoice Section Specifics */
.invoice-item-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.item-desc { flex: 3; }
.item-cost { flex: 1; }

.invoice-summary {
    background: var(--bg-main);
    padding: 16px;
    border-radius: var(--border-radius-sm);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-main);
    background-image: radial-gradient(circle at 50% 0%, #ffffff 0%, #f5f5f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.login-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

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

.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-line.total {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #333;
    color: white;
    padding: 16px 24px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Utilities */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.my-4 { margin-top: 16px; margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.max-w-2xl { max-width: 800px; margin: 0 auto; }
.empty-state { padding: 40px !important; color: var(--text-muted); font-style: italic; }

/* WhatsApp Button styling */
.btn-whatsapp {
    background: #25D366;
    color: white;
    border: none;
}
.btn-whatsapp:hover {
    background: #128C7E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    #printInvoiceArea, #printInvoiceArea * {
        visibility: visible;
    }
    #printInvoiceArea {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        padding: 40px;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 40px;
        border-bottom: 2px solid #eee;
        padding-bottom: 20px;
    }
    .print-header h1 { font-size: 28px; margin-bottom: 8px; }
    .print-header p { color: #666; font-size: 14px; }
    
    .print-details {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 30px;
    }
    .print-table th, .print-table td {
        border: 1px solid #ddd;
        padding: 12px;
        text-align: left;
    }
    .print-table th { background-color: #f9f9f9; }
    
    .print-totals {
        width: 300px;
        margin-left: auto;
    }
    .print-total-line {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    .print-total-line.final {
        font-weight: bold;
        font-size: 18px;
        border-bottom: 2px solid #333;
        border-top: 2px solid #333;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100vh;
    }
    .sidebar.open {
        left: 0;
    }
    .mobile-menu-btn {
        display: block;
    }
    .content-wrapper {
        padding: 0 20px 20px;
    }
    .top-header {
        padding: 20px;
    }
    .grid-form {
        grid-template-columns: 1fr;
    }
    .invoice-item-row {
        flex-direction: column;
        align-items: stretch;
    }
}
