* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.main-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.logo {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-menu {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.nav-item {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item .icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.current-period {
    margin-bottom: 0.75rem;
}

.current-period label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.current-period input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.btn-small {
    width: 100%;
    padding: 0.5rem;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #1d4ed8;
}

.period-display {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    text-align: center;
}

/* Main Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.stat-card h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.stat-sales .stat-value {
    color: var(--success-color);
}

.stat-costs .stat-value {
    color: var(--danger-color);
}

.stat-profit .stat-value {
    color: var(--primary-color);
}

.btn-view {
    padding: 0.5rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-view:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Upload */
.upload-container {
    margin-bottom: 2rem;
}

#pdf-upload {
    display: none;
}

.upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-box:hover {
    border-color: var(--primary-color);
    background: #f0f9ff;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-box p {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Form Card */
.form-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.form-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input[readonly] {
    background: var(--bg-color);
    color: var(--text-secondary);
}

/* Exchange Info */
.exchange-info {
    background: transparent;
    color: #000;
    padding: 10px 0;
    margin-bottom: 1rem;
    display: none;
}

.exchange-rate-box {
    font-weight: bold;
    font-size: 14px;
    color: #000;
}

.exchange-rate-box strong {
    color: #000;
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 1rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: white;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.table-container h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--bg-color);
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

table tr:hover {
    background: var(--bg-color);
}

.delete-btn {
    padding: 0.375rem 0.75rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.delete-btn:hover {
    background: #dc2626;
}

/* Fixed Costs Items */
#fixed-costs-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fixed-cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.fixed-cost-item button {
    padding: 0.375rem 0.75rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.fixed-cost-item button:hover {
    background: #dc2626;
}

.recent-invoices {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.recent-invoices h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Reports */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.report-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.report-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.report-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.report-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

.summary-item {
    padding: 0.5rem 0.75rem;
    background: var(--bg-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary-color);
    font-size: 14px;
    line-height: 1.6;
}

.summary-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #f0f9ff;
    border-radius: 8px;
    text-align: center;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */

/* Hamburger button — hidden on desktop */
.hamburger {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Overlay behind sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Hamburger visible */
    .hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar: off-screen drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    .sidebar.open {
        left: 0;
    }

    /* Content: full width */
    .content {
        padding: 60px 12px 16px 12px;
        overflow-y: auto;
        width: 100%;
    }

    .section-header {
        margin-bottom: 1rem;
    }
    .section-header h1 {
        font-size: 1.25rem;
    }

    /* Dashboard stat cards */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
        word-break: break-all;
    }

    .stat-card h3 {
        font-size: 0.8rem;
    }

    /* Buttons inside stat cards — stack */
    .stat-card div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 6px !important;
    }

    .btn-view {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
        width: 100%;
        text-align: center;
    }

    /* Form grid single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-group[style*="max-width"] {
        max-width: 100% !important;
    }

    .form-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .form-card h3 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    /* Form action buttons */
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }

    /* Upload box */
    .upload-box {
        padding: 1.5rem 1rem;
    }
    .upload-icon {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    .upload-box p {
        font-size: 0.9rem;
        text-align: center;
    }

    /* Queue bar */
    .pdf-queue-bar {
        padding: 10px 12px;
    }
    .queue-filename {
        font-size: 0.75rem;
        max-width: 150px;
    }

    /* Payment account buttons */
    div[style*="display: flex"][style*="gap: 15px"] {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Table horizontal scroll */
    .table-container {
        padding: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-container h2 {
        font-size: 1rem;
    }
    table {
        min-width: 500px;
    }
    table th, table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Fixed cost items */
    .fixed-cost-item {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    /* Reports grid */
    .reports-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .report-card {
        padding: 1rem;
    }
    .report-card h3 {
        font-size: 1rem;
    }
    .report-card div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 6px !important;
    }

    /* Sales section buttons */
    #sales-section div[style*="display: flex"][style*="gap: 10px"] {
        flex-direction: column !important;
    }
    #sales-section .btn-primary {
        width: 100%;
        text-align: center;
    }

    /* Sales summary cards */
    #sales-summary .stat-value {
        font-size: 1.3rem;
    }

    /* Recent invoices */
    .recent-invoices {
        padding: 0.75rem;
    }

    /* Modal full-screen on mobile */
    .modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 1rem;
    }
    .modal-content h2 {
        font-size: 1.1rem;
    }
    .modal-content div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Summary items */
    .summary-item {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        line-height: 1.4;
    }
    .summary-total {
        font-size: 1.1rem;
        padding: 1rem;
    }

    /* Period display in sidebar */
    .sidebar-footer {
        padding: 0.75rem;
    }
}

/* ====== PDF Queue Bar ====== */
.pdf-queue-bar {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}
.pdf-queue-bar .queue-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.queue-counter {
    background: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}
.queue-filename {
    font-size: 0.85rem;
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.queue-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.btn-skip, .btn-cancel-queue {
    padding: 5px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-skip {
    background: #f59e0b;
    color: #1e293b;
}
.btn-skip:hover { background: #d97706; }
.btn-cancel-queue {
    background: rgba(255,255,255,0.15);
    color: white;
}
.btn-cancel-queue:hover { background: rgba(255,255,255,0.25); }
.queue-progress {
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}
.queue-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 2px;
    transition: width 0.3s ease;
}
