:root {
    /* Dark Theme Colors */
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-hover: #2c2c2c;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --primary: #4ade80; /* Green accent */
    --primary-hover: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #333333;
    
    --sidebar-width: 220px;
    --radius: 10px;
    --transition: 0.3s ease;
}

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

/* Fluid Typography Base */
html {
    font-size: 15px; /* Base size for large screens */
}

@media (max-width: 1200px) {
    html { font-size: 14px; }
}

@media (max-width: 992px) {
    html { font-size: 13.5px; }
}

@media (max-width: 768px) {
    html { font-size: 13px; }
}

@media (max-width: 480px) {
    html { font-size: 12px; }
}

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
}

#app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2rem;
    padding-left: 10px;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-header i {
    font-size: 1.2rem;
}

.text-primary {
    color: var(--primary);
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

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

.nav-links a:hover, .nav-links a.active {
    background-color: rgba(74, 222, 128, 0.1);
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0; /* Critical: prevents flex child from overflowing */
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
    position: relative;
    flex-wrap: nowrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.topbar-left h1 {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#page-title {
    font-size: 1.4rem;
    font-weight: 600;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

/* Pages */
.page {
    display: none;
    animation: fadeIn 0.4s ease;
    width: 100%;
    flex: 1;
}

.page.active {
    display: block;
}

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

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
}

.card-icon.income { background-color: rgba(74, 222, 128, 0.2); color: var(--primary); }
.card-icon.expense { background-color: rgba(239, 68, 68, 0.2); color: var(--danger); }
.card-icon.balance { background-color: rgba(245, 158, 11, 0.2); color: var(--warning); }

.card-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

/* Dashboard Lists */
.dashboard-lists {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-bottom: 15px; /* Space for scrollbar */
}

.dashboard-lists::-webkit-scrollbar {
    height: 8px;
}
.dashboard-lists::-webkit-scrollbar-track {
    background: var(--bg-main); 
    border-radius: 4px;
}
.dashboard-lists::-webkit-scrollbar-thumb {
    background: var(--border); 
    border-radius: 4px;
}
.dashboard-lists::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted); 
}

.dashboard-lists .list-card {
    flex: 0 0 calc(50% - 0.75rem); /* Exactly 2 columns visible */
    scroll-snap-align: start;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 500;
}

.table tbody tr:hover {
    background-color: var(--bg-hover);
}

.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.unpaid { background-color: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge.paid { background-color: rgba(74, 222, 128, 0.2); color: var(--primary); }

/* Forms & Buttons */
.input-control {
    width: 100%;
    padding: 10px 15px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.input-control:focus {
    border-color: var(--primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.filters .input-control {
    flex: 1;
    min-width: 150px;
}

/* Settings Layout */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.settings-group {
    background: var(--bg-hover);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.settings-group h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-group h4 i {
    color: var(--primary);
}

.settings-footer {
    text-align: right;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    height: 100%;
}
.file-input-button {
    border: 1px dashed var(--primary);
    background: rgba(74, 222, 128, 0.05);
    color: var(--primary);
    padding: 15px;
    text-align: center;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: all 0.3s ease;
}
.file-input-wrapper:hover .file-input-button {
    background: rgba(74, 222, 128, 0.15);
}

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

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

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: #000;
}

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

.btn-success {
    background-color: #10b981;
    color: white;
}

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-hover);
}

.btn-icon {
    padding: 6px 10px;
    font-size: 1rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 1rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 1rem 0;
}
.filters .input-control {
    flex: 1;
    min-width: 140px;
}

/* Report total rows - visible on both screen and print */
.report-total-row {
    background-color: var(--bg-hover) !important;
    border-top: 2px solid var(--border);
    font-weight: bold;
}
.report-total-row td {
    padding: 6px 12px !important;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

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

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    animation: scaleIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

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

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-modal:hover { color: var(--text-main); }

.modal-body {
    padding: 1.5rem;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Image Preview */
.image-preview {
    margin-top: 10px;
    max-width: 200px;
    max-height: 100px;
    border: 1px dashed var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 8px;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Invoice Layout */
.invoice-builder-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Left form panel: scrollable, sticky */
.invoice-controls.card {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    position: sticky;
    top: 0;
}

.invoice-controls.card::-webkit-scrollbar {
    width: 5px;
}
.invoice-controls.card::-webkit-scrollbar-track {
    background: transparent;
}
.invoice-controls.card::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

/* Right preview panel: always show full invoice */
.invoice-preview-container {
    background-color: #3a3d42;
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* The actual paper style that mimics the image */
.invoice-paper {
    background-color: white;
    color: black;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    margin: 0 auto; /* Center horizontally */
    position: relative;
    overflow: hidden;
}

/* Report Paper specific for screen */
.report-paper {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Always 3 columns inside report paper */
.report-paper .summary-cards {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
    margin-bottom: 1.5rem !important;
}

/* Override: Laba Bersih should NOT span full width inside report */
.report-paper .summary-card:last-child {
    grid-column: span 1 !important;
}

/* Report summary cards: centered text, no icon */
.report-paper .summary-card {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 1rem !important;
    gap: 0.4rem !important;
    justify-content: center !important;
}

.report-paper .card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.report-paper .card-info p {
    font-size: 0.8rem !important;
    margin-bottom: 4px !important;
}

.report-paper .card-info h3 {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
}

/* Report header */
.report-header {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.report-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.report-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.report-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Report section headings */
.report-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    padding-bottom: 6px;
    margin-bottom: 8px;
    margin-top: 8px;
}

/* Print utility classes */
.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block;
    }
}

.inv-header {
    text-align: center;
    padding: 15px 40px;
}

.inv-header img {
    max-height: 80px;
    max-width: 100%;
}

.inv-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    text-decoration: underline;
    margin: 30px 0;
}

.inv-top-section {
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    margin-bottom: 30px;
}

.inv-bill-to h4 {
    background-color: #d1f2eb;
    padding: 5px 10px;
    display: inline-block;
    margin-bottom: 10px;
    color: #117a65;
}

.inv-meta table {
    width: 300px;
}

.inv-meta table td {
    padding: 3px 0;
}

.inv-meta table td:first-child {
    width: 100px;
}

.inv-details {
    padding: 0 40px;
}

.inv-details h4 {
    margin-bottom: 10px;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.inv-table th {
    background-color: #d1f2eb;
    padding: 10px;
    text-align: left;
}

.inv-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.inv-summary {
    display: flex;
    justify-content: flex-end;
    padding: 0 40px;
    margin-bottom: 40px;
}

.inv-summary table {
    width: 300px;
}

.inv-summary td {
    padding: 5px 10px;
}

.inv-summary tr.grand-total {
    background-color: #fadbd8;
    font-weight: bold;
}

.inv-bottom-section {
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    margin-bottom: 100px; /* Space for footer */
}

.inv-terms {
    width: 50%;
}

.inv-terms h4 {
    background-color: #d1f2eb;
    padding: 5px 10px;
    display: inline-block;
    margin-bottom: 10px;
    color: #117a65;
}

.inv-terms ol {
    padding-left: 20px;
}

.inv-terms li {
    margin-bottom: 5px;
}

.inv-payment-box {
    background-color: #d1f2eb;
    padding: 15px;
    margin-top: 20px;
    text-align: center;
    border-left: 10px solid #2ecc71;
}

.inv-approval {
    text-align: center;
    width: 200px;
}

.inv-approval-sig {
    height: 80px;
    margin: 10px 0;
}

.inv-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
}

.inv-footer img {
    width: 100%;
    display: block;
}

.inv-footer-default {
    background-color: #2ecc71;
    color: white;
    padding: 20px;
    text-align: center;
    display: flex;
    justify-content: space-around;
}

/* Invoice Builder Layout */
.invoice-builder-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.invoice-controls {
    flex: 0 0 380px;
    max-width: 380px;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

.invoice-preview-container {
    flex: 1;
    overflow-x: auto;
}

/* Mobile Navigation */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   RESPONSIVE LAYOUTS - Comprehensive Mobile Fix
   ============================================ */
@media (max-width: 768px) {

    /* --- Sidebar Offcanvas --- */
    .sidebar {
        transform: translateX(-100%);
        z-index: 100;
        transition: transform 0.3s ease;
        box-shadow: 4px 0 15px rgba(0,0,0,0.6);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .menu-toggle {
        display: block;
    }

    /* --- Main Content: full width, no sidebar margin --- */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem;
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* --- Topbar: single row hamburger | title | logout --- */
    .topbar {
        flex-wrap: nowrap;
        gap: 8px;
        margin-bottom: 1rem;
        align-items: center;
    }
    .topbar-left {
        flex: 1;
        min-width: 0;
        gap: 8px;
    }
    .topbar-left h1 {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #page-title { font-size: 1.1rem; }
    .period-selector {
        flex-shrink: 1;
        min-width: 0;
    }
    .period-selector input {
        min-width: 0;
        width: 110px;
        font-size: 0.8rem;
    }
    #company-name-display { display: none; }
    .user-info {
        position: static;
        flex-shrink: 0;
    }
    .avatar {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    /* --- Cards & Summary --- */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 1rem;
    }
    .summary-card {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem 0.4rem;
        gap: 0.4rem;
    }
    .summary-card:last-child {
        grid-column: span 2;
    }
    .card-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    .card-info h3 {
        font-size: 1rem;
    }
    .card-info p, .card-info small {
        font-size: 0.75rem;
    }
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* --- Dashboard Lists --- */
    .dashboard-lists .list-card {
        flex: 0 0 calc(100% - 1rem);
    }

    /* --- Card Headers (title + buttons row) --- */
    .card-header.flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .card-header.flex-between > div {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .card-header.flex-between .btn {
        flex: 1;
        min-width: 120px;
        font-size: 0.8rem;
        padding: 8px 10px;
        text-align: center;
        white-space: nowrap;
    }

    /* --- Flex Layouts --- */
    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .flex-between > div {
        width: 100%;
    }

    /* --- Filters --- */
    .filters {
        flex-direction: column;
        gap: 8px;
    }
    .filters .input-control {
        width: 100%;
    }

    /* --- Tables --- */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table th, .table td {
        padding: 8px 10px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .table td button {
        margin-bottom: 4px;
        font-size: 0.75rem;
        padding: 5px 8px;
    }

    /* --- Modals --- */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5% auto;
        padding: 1.25rem;
        overflow-y: auto;
    }
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- Settings --- */
    .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 0;
    }

    /* --- Invoice Builder --- */
    .invoice-builder-layout {
        flex-direction: column !important;
    }
    .invoice-controls {
        flex: unset !important;
        max-width: 100% !important;
        position: static !important;
        max-height: unset !important;
        width: 100%;
    }
    .invoice-preview-container {
        display: none !important; /* hide preview on mobile, use print button */
    }

    /* --- Laporan (Reports) --- */
    .report-paper {
        padding: 1rem !important;
        overflow-x: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .report-paper .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Print Styles - Optimized for A4 */
@media print {
    @page {
        size: A4 portrait;
        margin: 8mm 10mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }

    body, html {
        background-color: white !important;
        color: black !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        font-size: 10pt !important;
    }

    /* Hide non-print elements */
    .no-print,
    .sidebar,
    .topbar,
    .table-responsive > ::-webkit-scrollbar {
        display: none !important;
    }

    /* Main layout reset for print */
    #app-wrapper {
        display: block !important;
        width: 100% !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        background: white !important;
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }

    .pages-container {
        padding: 0 !important;
        width: 100% !important;
    }

    /* Show only active page */
    .page {
        display: none !important;
    }
    #invoice.page.active,
    #reports.page.active {
        display: block !important;
        width: 100% !important;
    }

    /* ---- REPORT PAPER A4 FIT ---- */
    .report-paper {
        margin: 0 !important;
        padding: 5mm !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
        border: none !important;
        overflow: visible !important;
        page-break-after: always;
    }

    /* Remove scrollable wrapper for print */
    .report-paper .table-responsive {
        overflow: visible !important;
        width: 100% !important;
    }

    /* Report tables: smaller font, fit all columns */
    .report-paper table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8pt !important;
        table-layout: auto !important;
        page-break-inside: auto !important;
        overflow: visible !important;
    }
    .report-paper th,
    .report-paper td {
        padding: 3px 5px !important;
        font-size: 8pt !important;
        white-space: normal !important;
        word-break: break-word !important;
        border: 1px solid #999 !important;
        color: black !important;
        background: transparent !important;
    }
    .report-paper th {
        background-color: #e0e0e0 !important;
        font-weight: bold !important;
    }
    .report-paper tr {
        page-break-inside: avoid !important;
    }
    /* Total rows (tfoot) - light background so text is visible */
    .report-paper tfoot tr,
    .report-paper tfoot td,
    .report-total-row,
    .report-total-row td {
        background-color: #d5d5d5 !important;
        color: #000 !important;
        font-weight: bold !important;
        border-top: 2px solid #555 !important;
    }
    /* Highlight amounts in tfoot */
    .report-paper tfoot td:last-child,
    .report-paper tfoot td[style*="right"] {
        color: #000 !important;
    }
    thead { display: table-header-group !important; }
    tfoot { display: table-row-group !important; }

    /* Summary cards in report - 3 equal columns, centered */
    .report-paper .summary-cards {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        margin-bottom: 12px !important;
    }
    .report-paper .summary-card {
        background: #f0f0f0 !important;
        border: 1px solid #ccc !important;
        padding: 8px !important;
        color: black !important;
        border-radius: 4px !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        justify-content: center !important;
        grid-column: span 1 !important; /* override last-child span */
    }
    /* Override: Laba Bersih card (3rd) should NOT span full width */
    .report-paper .summary-card:last-child {
        grid-column: span 1 !important;
    }
    .report-paper .card-info {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .report-paper .card-info h3 {
        font-size: 11pt !important;
        color: black !important;
        font-weight: bold !important;
        margin: 0 !important;
    }
    .report-paper .card-info p {
        font-size: 7pt !important;
        color: #555 !important;
        margin-bottom: 2px !important;
    }

    /* Report header */
    .report-header {
        text-align: center !important;
        padding-bottom: 10px !important;
        margin-bottom: 12px !important;
        border-bottom: 2px solid #000 !important;
    }

    /* Report headings */
    .report-paper h2 { font-size: 14pt !important; font-weight: bold !important; margin-bottom: 2px !important; }
    .report-paper h3 { font-size: 10pt !important; letter-spacing: 1px !important; margin-bottom: 2px !important; }
    .report-paper p { font-size: 9pt !important; }
    .report-paper h4 { font-size: 9pt !important; margin: 6px 0 3px !important; font-weight: bold !important; }

    .report-section {
        page-break-inside: auto !important;
        margin-bottom: 12px !important;
    }

    /* Reset color classes for black print */
    .report-paper .text-danger,
    .report-paper .text-primary,
    .report-paper .text-muted {
        color: black !important;
    }

    /* ---- INVOICE PAPER A4 FIT ---- */
    .invoice-controls,
    .invoice-builder-panel {
        display: none !important;
    }
    .invoice-preview-container {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        background: white !important;
        overflow: visible !important;
    }
    .invoice-paper {
        margin: 0 !important;
        padding: 10mm !important;
        width: 190mm !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
        border: none !important;
        overflow: visible !important;
        font-size: 9pt !important;
        page-break-after: always;
    }
    .invoice-paper * { font-size: inherit !important; }
}

/* Login Screen Styles */
#login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-dark);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}
