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

/* ── Light Theme ──────────────────────────────────────── */
body.light-theme {
    --bg-dark: #f0f2f5;
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --bg-hover: #e8eaed;
    --bg-panel: #ffffff;
    --text-main: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #16a34a;
    --primary-hover: #15803d;
    --danger: #dc2626;
    --warning: #d97706;
    --border: #d1d5db;
    background-color: var(--bg-dark);
    color: var(--text-main);
}
body.light-theme .sidebar {
    background-color: #ffffff;
    border-right: 1px solid #e5e7eb;
    box-shadow: 2px 0 8px rgba(0,0,0,0.06);
}
body.light-theme .sidebar .sidebar-header h2,
body.light-theme .sidebar .sidebar-header i {
    color: #1a1a2e;
}
body.light-theme .sidebar .nav-category {
    color: #9ca3af;
}
body.light-theme .sidebar .nav-links a {
    color: #4b5563;
}
body.light-theme .sidebar .nav-links a:hover,
body.light-theme .sidebar .nav-links a.active {
    background-color: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}
body.light-theme .sidebar .nav-links a.active i,
body.light-theme .sidebar .nav-links a:hover i {
    color: #16a34a;
}
body.light-theme .topbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body.light-theme .card {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body.light-theme .table thead th {
    background-color: #f8fafc;
    color: #374151;
}
body.light-theme .table tbody tr:hover {
    background-color: #f1f5f9;
}
body.light-theme .modal-content {
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
body.light-theme #btn-theme-toggle {
    border-color: #d1d5db;
    color: #374151;
}
body.light-theme .badge {
    background-color: #e5e7eb;
    color: #374151;
}
body.light-theme input, body.light-theme select, body.light-theme textarea {
    background-color: #f9fafb;
    color: #1a1a2e;
    border-color: #d1d5db;
}
body.light-theme input:focus, body.light-theme select:focus, body.light-theme textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
body.light-theme .dropdown-menu {
    background-color: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
body.light-theme .summary-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e5e7eb;
}

/* Light Theme - Login Page Overrides */
body.light-theme #login-wrapper::before,
body.light-theme #login-wrapper::after {
    opacity: 0.15;
}
body.light-theme .login-box {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(22, 163, 74, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0,0,0,0.05);
}
body.light-theme .login-header h2 {
    background: linear-gradient(135deg, #1a1a2e 0%, #16a34a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.light-theme #login-form .input-control {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1a1a2e;
}
body.light-theme #login-form .input-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
body.light-theme #login-form .form-group label {
    color: #4b5563;
}
body.light-theme #login-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

* {
    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);
}
.text-danger {
    color: var(--danger) !important;
}

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

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

.nav-category {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    padding-left: 15px;
}
.nav-category:first-child {
    margin-top: 0;
}

.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;
}

.period-select {
    padding: 6px 8px !important;
    font-size: 0.85rem !important;
    font-weight: 600;
    cursor: pointer;
    min-width: 0;
    flex-shrink: 0;
}

#period-month-select { width: 110px; }
#period-year-select  { width: 80px; }

.period-nav-btn {
    padding: 6px 9px !important;
    font-size: 0.8rem !important;
    flex-shrink: 0;
    line-height: 1;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    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(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-left: 3px solid transparent;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.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: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: rgba(0,0,0,0.08);
}

.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); }

/* Dropdown wrapper HARUS position: relative agar menu absolute ter-anchor ke tombolnya */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    z-index: 1000;
    min-width: 140px;
    display: none;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.5);
}
.dropdown-menu.show {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
}
.dropdown-item {
    width: 100%;
    text-align: left;
    background-color: transparent !important;
    color: var(--text-main);
    border: none !important;
    padding: 8px 12px;
    justify-content: flex-start;
    font-size: 0.9rem;
    border-radius: 4px;
}
.dropdown-item:hover {
    background-color: var(--bg-hover) !important;
}
.dropdown-item.text-danger:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Fix dropdown di baris bawah tabel — buka ke atas */
.table tbody tr:nth-last-child(-n+3) .dropdown-menu {
    top: auto;
    bottom: calc(100% + 4px);
    margin-top: 0;
}

/* 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: 2000; /* Above sidebar (200) and dropdown (1000) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

#confirm-modal,
#pin-auth-modal {
    z-index: 3000; /* Above regular modals */
}


.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; }
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--bg-card);
    color: var(--text-main);
    border-left: 4px solid var(--primary);
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    animation: toastSlideIn 0.3s ease forwards;
    opacity: 0;
    transform: translateX(100%);
    min-width: 250px;
    max-width: 350px;
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: #f59e0b; /* Amber */
}

.toast-icon {
    font-size: 1.2rem;
}
.toast.success .toast-icon { color: var(--primary); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: #f59e0b; }

@keyframes toastSlideIn {
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    to { opacity: 0; transform: translateX(100%); }
}

/* 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 */
/* Watermark LUNAS pada Invoice */
.inv-watermark-lunas {
    position: absolute;
    top: 32px;
    right: 36px;
    transform: rotate(-15deg);
    font-size: 1.6rem;
    font-weight: 900;
    color: rgba(22, 163, 74, 0.70);
    border: 3px solid rgba(22, 163, 74, 0.60);
    border-radius: 6px;
    padding: 3px 16px;
    letter-spacing: 5px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}
@media print {
    .inv-watermark-lunas {
        color: rgba(22, 163, 74, 0.80) !important;
        border-color: rgba(22, 163, 74, 0.75) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.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 !important; /* Force A4 width */
    min-width: 210mm !important; /* PREVENT SHRINKING ON MOBILE */
    max-width: none !important;
    min-height: 297mm; /* A4 height */
    margin: 0 auto; /* Center horizontally */
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Receipt / BKM Layout */
.receipt-paper {
    background-color: white;
    color: black;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    width: 210mm !important; /* Force A4 width */
    min-width: 210mm !important;
    max-width: none !important;
    min-height: 148mm; /* Half A4 approx */
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px double #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
}
.receipt-logo img {
    max-height: 60px;
}
.receipt-logo h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}
.receipt-title {
    text-align: right;
}
.receipt-title h1 {
    font-size: 1.8rem;
    margin: 0 0 5px 0;
    letter-spacing: 2px;
}
.receipt-title p {
    margin: 0;
    color: #555;
    font-weight: bold;
}
.receipt-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 1.1rem;
    line-height: 1.6;
    flex: 1;
}
.receipt-row {
    display: flex;
    align-items: flex-end;
}
.receipt-label {
    width: 200px;
    font-weight: 600;
    font-style: italic;
    color: #444;
}
.receipt-value {
    flex: 1;
    border-bottom: 1px dashed #777;
    padding-bottom: 2px;
    padding-left: 10px;
    font-weight: bold;
}
.receipt-value-box {
    background-color: #f8f9fa;
    border: 2px solid #ccc;
    padding: 10px 20px;
    font-size: 1.3rem;
    font-weight: bold;
    display: inline-block;
    border-radius: 4px;
    color: #333;
}
.receipt-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    align-items: flex-end;
}
.receipt-signature {
    text-align: center;
    width: 220px;
}
.receipt-sig-img {
    height: 80px;
    margin: 10px 0;
}
.receipt-sig-img img {
    max-height: 100%;
}

/* 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: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 7px 10px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.2s;
}
.menu-toggle:hover {
    background: var(--bg-hover);
}

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

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

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

    /* --- Sidebar Offcanvas --- */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        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;
    }
    /* Hanya untuk section dengan jumlah GANJIL (dashboard 5 cards) */
    /* Section 4-card (Piutang, Hutang, Transaksi, dll) TIDAK span 2 */
    .summary-card:last-child {
        grid-column: span 2;
    }
    /* Override span 2 untuk section yang 4-card (even number = no orphan) */
    #piutang .summary-cards .summary-card:last-child,
    #hutang .summary-cards .summary-card:last-child,
    #transactions .summary-cards .summary-card:last-child,
    #customers .summary-cards .summary-card:last-child,
    #packages .summary-cards .summary-card:last-child {
        grid-column: auto;
    }
    .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%;
    }

    /* --- PROTECT INVOICE PAPER FROM MOBILE OVERRIDES --- */
    .invoice-paper .flex-between,
    .invoice-paper .gw-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    .invoice-paper .flex-between > div {
        width: auto !important;
    }
    .invoice-paper .inv-top-section {
        flex-direction: row !important;
        align-items: flex-start !important;
    }
    .invoice-paper .inv-top-section > div {
        width: auto !important;
    }
    .invoice-paper .inv-bottom-section {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
    }
    .invoice-paper .inv-bottom-section > div {
        width: auto !important;
    }

    /* --- 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 & Toasts --- */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5% auto;
        padding: 1.25rem;
        overflow-y: auto;
    }
    #toast-container {
        bottom: 20px;
        right: 10px;
        left: 10px;
        align-items: center;
    }
    .toast {
        min-width: unset;
        width: 100%;
        max-width: 400px;
        font-size: 0.85rem;
    }
    .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 {
        width: 100%;
        margin-top: 20px;
        padding: 0;
        overflow-x: hidden;
    }
    .invoice-preview-container .invoice-paper,
    .invoice-preview-container .receipt-paper {
        transform: scale(0.45);
        transform-origin: top center;
        margin-bottom: -160mm; /* A4 height is 296mm, 45% is ~133mm. This removes the empty space */
    }

    /* --- 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;
    }
}


/* --- Form Clean Modes --- */
#transaction-form.mode-clean-income .group-master-data,
#transaction-form.mode-clean-income .group-qty,
#transaction-form.mode-clean-income .group-ppn,
#transaction-form.mode-clean-income .tx-due-date-group,
#transaction-form.mode-clean-income #tx-customer-group {
    display: none !important;
}

#transaction-form.mode-clean-expense .group-master-data,
#transaction-form.mode-clean-expense .group-qty,
#transaction-form.mode-clean-expense .group-ppn {
    display: none !important;
}

#transaction-form.mode-semi-expense .group-master-data {
    display: none !important;
}

/* Print Styles - Optimized for A4 */
@media print {
    @page {
        size: A4 portrait;
        margin: 15mm 12mm 15mm 12mm; /* Default margins for multi-page reports */
    }

    @page invoice-page {
        size: A4 portrait;
        margin: 0; /* Zero margin for full-bleed A4 invoice designs */
    }

    * {
        -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;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        font-size: 10pt !important;
    }

    .invoice-preview-container .invoice-paper,
    .invoice-paper,
    .receipt-paper {
        transform: none !important;
        margin: 0 auto !important;
        page: invoice-page !important; /* Assign named page layout to strip margins */
    }

    /* 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;
        height: auto !important;
        min-height: 0 !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 invoice/report page */
    .page {
        display: none !important;
    }
    #invoice.page.active {
        display: block !important;
        width: 210mm !important;
        height: 296mm !important;
        max-height: 296mm !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #reports.page.active {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ---- REPORT PAPER A4 FIT ---- */
    .report-paper {
        margin: 0 !important;
        padding: 0 !important; /* Rely on @page margin instead */
        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;

        /* Force light theme variables for print, even if active theme is dark */
        --bg-hover: #f3f4f6 !important; /* light grey for section headers */
        --bg-card: #ffffff !important;  /* white for tables/cards */
        --text-main: #111827 !important; /* dark text */
        --text-muted: #4b5563 !important; /* medium text */
        --border: #d1d5db !important;   /* light border */
    }

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

    /* Report tables: clean, professional accounting layout without vertical borders */
    .report-paper table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
        table-layout: auto !important;
        page-break-inside: auto !important;
        overflow: visible !important;
        margin-top: 15px !important;
        margin-bottom: 15px !important;
    }
    .report-paper th,
    .report-paper td {
        padding: 8px 10px !important;
        font-size: 9pt !important;
        white-space: normal !important;
        word-break: break-word !important;
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        color: #374151 !important;
        background: transparent !important;
    }
    .report-paper tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
        page-break-before: auto !important;
    }
    .report-paper th {
        background-color: #f3f4f6 !important;
        color: #1f2937 !important;
        font-weight: 600 !important;
        border-bottom: 2px solid #d1d5db !important;
    }
    
    /* Total rows (tfoot / .report-total-row) - elegant accounting double underline style */
    .report-paper tfoot tr,
    .report-paper tfoot td,
    .report-total-row,
    .report-total-row td {
        background-color: #f9fafb !important;
        color: #111827 !important;
        font-weight: bold !important;
        border-top: 2px solid #9ca3af !important;
        border-bottom: 2px double #9ca3af !important;
    }
    .report-paper tfoot td:last-child,
    .report-paper tfoot td[style*="right"] {
        color: #111827 !important;
        white-space: nowrap !important;
    }
    .report-paper tfoot td {
        white-space: nowrap !important;
    }
    
    /* Native table behavior usually handles footers best, but we moved totals to tbody */
    .report-paper tfoot {
        display: none !important;
    }

    /* Summary cards in report - 3 equal columns, centered, print-optimized */
    .report-paper .summary-cards {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 15px !important;
    }
    .report-paper .summary-card {
        background: #f9fafb !important;
        border: 1px solid #e5e7eb !important;
        padding: 10px 12px !important;
        color: #111827 !important;
        border-radius: 6px !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        justify-content: center !important;
        grid-column: span 1 !important;
    }
    .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: 12pt !important;
        color: #111827 !important;
        font-weight: 700 !important;
        margin: 0 !important;
    }
    .report-paper .card-info p {
        font-size: 7.5pt !important;
        color: #6b7280 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        font-weight: 500 !important;
        margin-bottom: 4px !important;
    }

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

    /* Report headings */
    .report-paper h2 { font-size: 14pt !important; font-weight: bold !important; margin-bottom: 4px !important; color: #111827 !important; }
    .report-paper h3 { font-size: 10pt !important; letter-spacing: 1px !important; margin-bottom: 4px !important; color: #4b5563 !important; }
    .report-paper p { font-size: 9pt !important; color: #4b5563 !important; }
    .report-paper h4 { font-size: 9.5pt !important; margin: 12px 0 5px !important; font-weight: bold !important; color: #111827 !important; }

    /* === PAGE BREAK CONTROLS === */
    /* Let content flow naturally — fill current page first, overflow to next */
    .report-section {
        margin-top: 12px !important;
        margin-bottom: 0 !important;
    }
    
    /* Allow table bodies to break across pages */
    .report-paper tbody {
        page-break-inside: auto !important;
    }

    /* High-contrast brand colors preservation for premium printing */
    .report-paper .text-primary,
    .report-paper td[style*="color:var(--primary)"],
    .report-paper span[style*="color:var(--primary)"],
    .report-paper td[style*="color: rgb(74, 222, 128)"],
    .report-paper td[style*="color:rgb(74, 222, 128)"] {
        color: #15803d !important; /* High-contrast print-friendly green */
        font-weight: 600 !important;
    }
    .report-paper .text-danger,
    .report-paper td[style*="color:var(--danger)"],
    .report-paper span[style*="color:var(--danger)"],
    .report-paper td[style*="color: rgb(239, 68, 68)"],
    .report-paper td[style*="color:rgb(239, 68, 68)"] {
        color: #b91c1c !important; /* High-contrast print-friendly red */
        font-weight: 600 !important;
    }
    .report-paper .text-warning,
    .report-paper td[style*="color:#fbbf24"],
    .report-paper td[style*="color:var(--warning)"],
    .report-paper span[style*="color:#f59e0b"] {
        color: #b45309 !important; /* High-contrast print-friendly amber */
        font-weight: 600 !important;
    }
    .report-paper .text-muted,
    .report-paper span[style*="color:var(--text-muted)"] {
        color: #4b5563 !important; /* Legible dark grey for print */
    }

    /* ---- INVOICE PAPER A4 FIT ---- */

    /* Step 1: Reset ALL wrappers to zero */
    .invoice-builder-layout {
        display: block !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .invoice-controls,
    .invoice-builder-panel {
        display: none !important;
    }
    .invoice-preview-container {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        overflow: visible !important;
    }
    #invoice.page.active {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Step 2: The invoice paper — fill entire A4 page */
    .invoice-paper,
    .invoice-paper.template-green-wave {
        display: flex !important;
        flex-direction: column !important;
        margin: 0 !important;
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 0 !important;
        height: 296mm !important;
        max-height: 296mm !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
        border: none !important;
        border-radius: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        position: relative !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* ===== PRINT: DEFAULT template ===== */
    .invoice-paper:not(.template-green-wave) {
        padding: 8mm 12mm !important;
    }
    .invoice-paper:not(.template-green-wave) .inv-header { padding: 5px 20px !important; flex-shrink: 0 !important; }
    .invoice-paper:not(.template-green-wave) .inv-title { margin: 12px 0 !important; font-size: 1.4rem !important; flex-shrink: 0 !important; }
    .invoice-paper:not(.template-green-wave) .inv-top-section { margin-bottom: 10px !important; padding: 0 20px !important; flex-shrink: 0 !important; }
    .invoice-paper:not(.template-green-wave) .inv-details { padding: 0 20px !important; flex-shrink: 0 !important; }
    .invoice-paper:not(.template-green-wave) .inv-table { margin-bottom: 5px !important; }
    .invoice-paper:not(.template-green-wave) .inv-table th,
    .invoice-paper:not(.template-green-wave) .inv-table td { padding: 4px 6px !important; font-size: 0.8rem !important; }
    .invoice-paper:not(.template-green-wave) .inv-summary { padding: 0 20px !important; margin-bottom: 10px !important; flex-shrink: 0 !important; display: flex !important; justify-content: flex-end !important; }
    .invoice-paper:not(.template-green-wave) .inv-summary td { padding: 3px 6px !important; font-size: 0.85rem !important; }
    .invoice-paper:not(.template-green-wave) .inv-bottom-section {
        margin-bottom: 0 !important;
        padding: 0 20px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
    }
    .invoice-paper:not(.template-green-wave) .inv-bottom-section > div { width: auto !important; }
    .invoice-paper:not(.template-green-wave) .inv-terms { width: 50% !important; }
    .invoice-paper:not(.template-green-wave) .inv-terms ol { font-size: 0.75rem !important; }
    .invoice-paper:not(.template-green-wave) .inv-payment-box { padding: 8px !important; margin-top: 8px !important; font-size: 0.8rem !important; }
    .invoice-paper:not(.template-green-wave) .inv-approval-sig { height: 50px !important; margin: 3px 0 !important; }
    .invoice-paper:not(.template-green-wave) .inv-footer {
        position: static !important;
        margin-top: auto !important;
        flex-shrink: 0 !important;
        margin-left: -12mm !important;
        margin-right: -12mm !important;
        margin-bottom: -8mm !important;
        width: calc(100% + 24mm) !important;
    }
    .invoice-paper:not(.template-green-wave) .inv-footer img {
        width: 100% !important;
        display: block !important;
    }
    .invoice-paper:not(.template-green-wave) .inv-footer-default {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
    }

    /* ===== PRINT: GREEN WAVE template ===== */
    .template-green-wave { padding: 0 !important; }
    .template-green-wave .gw-content {
        padding: 40px 50px 180px 50px !important;
        flex: 1 !important;
        position: relative !important;
        z-index: 2 !important;
    }
    /* Waves stay absolute (decorative overlay) so they DON'T waste A4 space */
    .template-green-wave .green-wave-bg.top-wave {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 1 !important;
    }
    .template-green-wave .green-wave-bg.bottom-wave {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        z-index: 1 !important;
        width: 100% !important;
    }
    .template-green-wave .gw-header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    .template-green-wave .gw-header > div { width: auto !important; }
    .template-green-wave .gw-title-container { margin-top: 40px !important; margin-bottom: 8px !important; }
    .template-green-wave .gw-title-container h1 { font-size: 1.8rem !important; }
    .template-green-wave .gw-meta-grid { margin-bottom: 8px !important; gap: 8px !important; font-size: 0.8rem !important; }
    .template-green-wave .gw-table { margin-bottom: 8px !important; }
    .template-green-wave .gw-table th,
    .template-green-wave .gw-table td { padding: 4px 6px !important; font-size: 0.8rem !important; }
    .template-green-wave .gw-bottom-grid { margin-bottom: 5px !important; gap: 8px !important; }
    .template-green-wave .gw-payment-info { font-size: 0.75rem !important; }
    .template-green-wave .gw-summary-table td { padding: 3px 6px !important; font-size: 0.8rem !important; }
    .template-green-wave .gw-footer-grid { margin-bottom: 0 !important; font-size: 0.8rem !important; }

    /* PROTECT INVOICE FROM MOBILE OVERRIDES IN PRINT */
    .invoice-paper .flex-between,
    .invoice-paper .gw-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    .invoice-paper .flex-between > div { width: auto !important; }
    .invoice-paper .inv-top-section {
        flex-direction: row !important;
        align-items: flex-start !important;
    }
    .invoice-paper .inv-top-section > div { width: auto !important; }

}

/* ============================================
   LOGIN SCREEN - Fully Responsive & Premium
   ============================================ */
#login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;

    /* Animated gradient background */
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a2e 30%, #16213e 60%, #0f3460 100%);
    background-size: 400% 400%;
    animation: loginBgShift 12s ease infinite;
}

@keyframes loginBgShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Decorative glowing orbs */
#login-wrapper::before,
#login-wrapper::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    pointer-events: none;
    animation: orbFloat 8s ease-in-out infinite alternate;
}

#login-wrapper::before {
    width: min(400px, 60vw);
    height: min(400px, 60vw);
    background: radial-gradient(circle, #4ade80 0%, transparent 70%);
    top: -15%;
    left: -10%;
}

#login-wrapper::after {
    width: min(350px, 50vw);
    height: min(350px, 50vw);
    background: radial-gradient(circle, #22d3ee 0%, transparent 70%);
    bottom: -15%;
    right: -10%;
    animation-delay: -4s;
}

@keyframes orbFloat {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(20px, -20px) scale(1.08); }
}

/* The login card box */
.login-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    margin: 0 auto;

    /* Glassmorphism */
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(74, 222, 128, 0.18);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255,255,255,0.04) inset;

    animation: loginSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes loginSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* Login header / branding */
.login-header {
    text-align: center;
    margin-bottom: clamp(1.25rem, 4vw, 2rem);
}

.login-header i.fa-wallet {
    display: block;
    font-size: clamp(2rem, 8vw, 2.8rem);
    margin-bottom: 12px;
    color: var(--primary);
    filter: drop-shadow(0 0 12px rgba(74, 222, 128, 0.5));
    animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { filter: drop-shadow(0 0 8px  rgba(74, 222, 128, 0.4)); }
    50%       { filter: drop-shadow(0 0 18px rgba(74, 222, 128, 0.75)); }
}

.login-header h2 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff 40%, #4ade80 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p.text-muted {
    font-size: clamp(0.8rem, 3vw, 0.95rem);
    color: var(--text-muted);
    margin: 0;
}

/* Login form inputs */
#login-form .form-group {
    margin-bottom: clamp(0.75rem, 2.5vw, 1rem);
}

#login-form .input-control {
    padding: clamp(10px, 2.5vw, 13px) clamp(12px, 3vw, 16px);
    font-size: clamp(0.85rem, 3vw, 1rem);
    background: rgba(18, 18, 18, 0.8);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 10px;
    transition: border-color 0.25s, box-shadow 0.25s;
}

#login-form .input-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

#login-form .form-group label {
    font-size: clamp(0.78rem, 2.5vw, 0.88rem);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Login button */
#login-form .btn-primary {
    width: 100%;
    padding: clamp(11px, 3vw, 14px);
    font-size: clamp(0.9rem, 3vw, 1rem);
    font-weight: 700;
    border-radius: 10px;
    letter-spacing: 0.5px;
    margin-top: clamp(0.25rem, 1.5vw, 0.5rem);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#login-form .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.45);
}

#login-form .btn-primary:active {
    transform: translateY(0);
}

/* Error message */
#login-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    color: var(--danger);
    text-align: center;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}

/* --- Responsive overrides for very small phones --- */
@media (max-width: 360px) {
    .login-box {
        padding: 1.25rem 1rem;
        border-radius: 14px;
    }
    .login-header h2 {
        font-size: 1.3rem;
    }
}

/* --- Landscape phones (short height) --- */
@media (max-height: 600px) and (orientation: landscape) {
    #login-wrapper {
        align-items: flex-start;
        padding: 0.75rem 1rem;
    }
    .login-box {
        padding: 1.25rem 1.5rem;
    }
    .login-header {
        margin-bottom: 0.75rem;
    }
    .login-header i.fa-wallet {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }
    #login-form .form-group {
        margin-bottom: 0.6rem;
    }
}

/* --- Tablets (768px+) --- */
@media (min-width: 768px) {
    .login-box {
        max-width: 440px;
    }
}

/* --- Large screens --- */
@media (min-width: 1200px) {
    .login-box {
        max-width: 460px;
    }
}

/* ============================================
   ROLE BADGES
   ============================================ */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.role-admin {
    background: rgba(74, 222, 128, 0.15);
    color: var(--primary);
    border: 1px solid rgba(74, 222, 128, 0.35);
}

.role-staff {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.role-viewer {
    background: rgba(160, 160, 160, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(160, 160, 160, 0.3);
}

/* ============================================
   TOPBAR USER INFO (company + user badge)
   ============================================ */
.topbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
}

.company-name-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.topbar-user-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-user-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Hide company name on small mobile, keep user name */
@media (max-width: 480px) {
    .company-name-display { display: none; }
    .topbar-user-name { max-width: 80px; }
}
@media (max-width: 360px) {
    .topbar-user-name { display: none; }
}

/* ============================================
   ALERT MESSAGES (success / danger)
   ============================================ */
.alert-msg {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 12px;
    font-weight: 500;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--danger);
}

.alert-success {
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.35);
    color: var(--primary);
}

/* ============================================
   ROLE LEGEND (on users page)
   ============================================ */
.role-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ============================================
   BTN-SM (small button variant)
   ============================================ */
.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* ============================================
   SETTINGS TABS
   ============================================ */
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.settings-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    white-space: nowrap;
}

.settings-tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.settings-tab-btn.active {
    background: rgba(74, 222, 128, 0.15);
    color: var(--primary);
}

.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-tab-content.active {
    display: block;
}


/* ============================================
   ROLE-BASED ACCESS CONTROL (RBAC)
   ============================================ */
/* Viewers cannot see staff-level action buttons (add/edit/delete/generate) */
body.role-viewer .action-require-staff {
    display: none !important;
}

/* Viewers cannot see staff-level navigation */
body.role-viewer .nav-require-staff {
    display: none !important;
}

/* Viewers and Staff cannot see admin-only navigation/sections */
body.role-viewer .nav-admin-only,
body.role-staff .nav-admin-only {
    display: none !important;
}

/* ============================================
   INVOICE TEMPLATES
   ============================================ */
/* TEMPLATE 2: GREEN WAVE */
.template-green-wave {
    padding: 0 !important;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
    position: relative;
    overflow: hidden;
    background: #fff;
    min-height: 297mm; /* A4 size */
}

.template-green-wave .gw-content {
    padding: 40px 50px 180px 50px; /* 180px bottom padding protects the bottom wave */
    position: relative;
    z-index: 2;
}

.green-wave-bg {
    position: absolute;
    left: 0;
    width: 100%;
    z-index: 1;
}

.green-wave-bg.top-wave {
    top: 0;
    height: 250px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1000 300' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23f3f4f6' d='M0,0 L1000,0 L1000,200 Q500,300 0,280 Z'/%3E%3Cpath fill='%23e5e7eb' opacity='0.5' d='M0,0 L1000,0 L1000,120 Q500,200 0,260 Z'/%3E%3Cpath fill='%2300B050' d='M0,0 L950,0 Q400,80 0,280 Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: top center;
}

.green-wave-bg.bottom-wave {
    bottom: 0;
    height: 160px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1000 200' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23f3f4f6' d='M0,0 C200,0 250,150 0,200 Z'/%3E%3Cpath fill='%2300B050' d='M0,170 Q400,210 1000,0 L1000,200 L0,200 Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: bottom center;
    display: flex;
    align-items: flex-end;
    padding: 25px 50px;
    box-sizing: border-box;
}

.gw-bottom-contact {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    color: white;
    width: 100%;
    font-size: 0.95rem;
    z-index: 2;
}

.gw-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}
.gw-logo {
    max-height: 80px;
}
.gw-title-container {
    text-align: center;
    margin-top: 70px;
    margin-bottom: 30px;
}
.gw-title-container h1 {
    font-size: 2.8rem;
    color: #111827;
    margin: 0;
    letter-spacing: 1px;
}
.gw-title-container p {
    font-size: 1.2rem;
    margin: 5px 0 0 0;
    color: #4b5563;
}

.gw-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.gw-label {
    font-weight: bold;
    margin: 0 0 5px 0;
    color: #111827;
}

.gw-bill-to h3 {
    margin: 0 0 15px 0;
    color: #4b5563;
    font-weight: normal;
}

.gw-address {
    margin: 0;
    color: #4b5563;
    line-height: 1.5;
}

.gw-meta-table {
    border-collapse: collapse;
}
.gw-meta-table td {
    padding: 6px 15px 6px 0;
    color: #111827;
}

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

.gw-table th {
    background-color: #d1d5db;
    color: #111827;
    padding: 12px;
    border: 1px solid #9ca3af;
    font-weight: bold;
}

.gw-table td {
    padding: 12px;
    border: 1px solid #d1d5db;
    color: #111827;
}

.gw-table tbody tr:nth-child(even) {
    background-color: #f3f4f6;
}

.gw-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

.gw-payment-info {
    font-size: 0.85rem;
    color: #111827;
    padding-right: 20px;
}
.gw-payment-info ol {
    margin: 10px 0 0 0;
    padding-left: 20px;
}
.gw-payment-info li {
    margin-bottom: 5px;
}

.gw-summary-table {
    width: 100%;
    border-collapse: collapse;
}
.gw-summary-table td {
    padding: 10px;
    border: 1px solid #e5e7eb;
    color: #111827;
}

.gw-grand-total {
    background-color: #f3f4f6;
    font-size: 1.1rem;
}

.gw-footer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    font-size: 0.9rem;
    margin-bottom: 0; 
}

.gw-bank-info {
    color: #111827;
}

.gw-signature {
    text-align: right;
    padding-right: 50px;
}
.gw-signature p {
    margin: 0;
    color: #111827;
}

/* Force backgrounds to print */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* --- Mobile Specific Fixes --- */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    #sync-status-indicator {
        font-size: 0 !important;
        padding: 6px !important;
        width: 32px;
        height: 32px;
        border-radius: 50% !important;
        justify-content: center;
        gap: 0 !important;
    }
    #sync-status-indicator i {
        font-size: 0.9rem;
        margin: 0 !important;
    }
    #btn-push-cloud {
        font-size: 0 !important;
        padding: 6px !important;
        width: 32px;
        height: 32px;
        border-radius: 50% !important;
        justify-content: center;
        gap: 0 !important;
    }
    #btn-push-cloud i {
        font-size: 0.9rem;
        margin: 0 !important;
    }
}

@media (max-width: 900px) {
    /* Fix Invoice Builder Mobile Layout */
    .invoice-builder-layout {
        flex-direction: column;
    }
    .invoice-controls {
        flex: 1 1 100%;
        max-width: 100%;
        position: relative;
        max-height: none;
    }
    .invoice-preview-container {
        width: 100%;
        padding: 10px;
    }
}

/* BKM Mode Form Toggles */
form#invoice-form.bkm-mode .hide-on-bkm {
    display: none !important;
}

/* Hide save-settings footer when backup tab is active */
#tab-backup.active ~ .tab-save-footer,
#tab-backup.active + .tab-save-footer {
    display: none !important;
}
/* Hide save footer when on backup tab (sibling check via JS class on form) */
.settings-form-backup-mode .tab-save-footer {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE — Full Coverage
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 1024px) ─────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --sidebar-width: 200px; }
    .main-content { padding: 1.25rem; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-lists .list-card { flex: 0 0 calc(100% - 0rem); }
}

/* ── Mobile Breakpoint (≤ 768px) ───────────────────────── */
@media (max-width: 768px) {
    /* Sidebar becomes slide-in drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        width: 260px;
    }
    /* Dua class: .active (dari toggleSidebar) dan .mobile-open (legacy) */
    .sidebar.active,
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 150;
        backdrop-filter: blur(2px);
    }
    #sidebar-overlay.show,
    #sidebar-overlay.active {
        display: block;
    }

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

    /* ── Hamburger: tampil di mobile ── */
    .menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* ── Topbar compact ── */
    /* ── Topbar: Grid 2 Baris di Mobile agar tidak overlap ── */
    .topbar {
        display: grid !important;
        grid-template-columns: 1fr auto;
        row-gap: 8px;
        column-gap: 8px;
        margin-bottom: 0.85rem;
        align-items: center;
        overflow: visible;
    }
    .topbar-left {
        grid-column: 1;
        grid-row: 1;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        overflow: visible;
    }
    #page-title {
        font-size: 1.15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: none;
    }

    /* ── Period selector: Baris kedua, membentang penuh ── */
    .period-selector {
        grid-column: 1 / span 2;
        grid-row: 2;
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 6px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        padding: 5px;
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    #period-month-select { 
        width: 100px !important; 
        font-size: 0.82rem !important; 
        padding: 4px 6px !important; 
        height: 30px !important;
    }
    #period-year-select  { 
        width: 70px !important; 
        font-size: 0.82rem !important; 
        padding: 4px 6px !important; 
        height: 30px !important;
    }
    .period-nav-btn { 
        padding: 4px 8px !important; 
        font-size: 0.8rem !important; 
        height: 30px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ── Sembunyikan tombol non-esensial di HP ── */
    #btn-theme-toggle      { display: none !important; }
    .topbar-user-info      { display: none !important; }
    #topbar-role-badge     { display: none !important; }
    .company-name-display  { display: none !important; }

    /* ── Topbar right: Baris pertama sebelah kanan ── */
    .topbar-right { 
        grid-column: 2;
        grid-row: 1;
        display: flex;
        align-items: center;
        gap: 6px; 
        flex-shrink: 0; 
        justify-content: flex-end;
    }

    /* Sync jadi dot kecil */
    #sync-status-indicator {
        font-size: 0 !important;
        padding: 5px !important;
        width: 28px; height: 28px;
        border-radius: 50% !important;
        justify-content: center;
        gap: 0 !important;
        flex-shrink: 0;
        box-sizing: border-box;
    }
    #sync-status-indicator i { font-size: 0.8rem; }

    /* Cloud push jadi dot kecil */
    #btn-push-cloud {
        font-size: 0 !important;
        padding: 5px !important;
        width: 28px; height: 28px;
        border-radius: 50% !important;
        justify-content: center;
        gap: 0 !important;
        flex-shrink: 0;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
    }
    #btn-push-cloud i { font-size: 0.8rem; }

    /* Avatar logout */
    .avatar { 
        width: 28px; 
        height: 28px; 
        font-size: 0.85rem; 
        flex-shrink: 0; 
        display: flex;
        align-items: center;
        justify-content: center;
    }


    /* Summary cards - 2 col on mobile */
    .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .summary-card { padding: 0.75rem 0.5rem; }
    .card-icon { width: 40px; height: 40px; font-size: 1.1rem; }
    .card-info h3 { font-size: 1rem; }
    .card-info p { font-size: 0.78rem; }
    .card-info small { font-size: 0.7rem; }

    /* Dashboard lists stack — NO horizontal scroll */
    .dashboard-lists {
        flex-direction: column;
        overflow-x: hidden;
        scroll-snap-type: none;
        gap: 0.75rem;
        padding-bottom: 0;
    }
    .dashboard-lists .list-card {
        flex: 1 1 100%;
        width: 100%;
        scroll-snap-align: none;
    }

    /* Tables - horizontal scroll */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table th, .table td { padding: 8px 8px; font-size: 0.78rem; }
    .table th { white-space: nowrap; }
    .table td { white-space: nowrap; }

    /* Cards */
    .card { padding: 0.85rem; margin-bottom: 0.85rem; }

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

    /* Modals */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 92vh;
        margin: auto;
    }
    .modal-header { padding: 1rem; }
    .modal-body { padding: 1rem; }

    /* Form grids collapse */
    .form-grid { grid-template-columns: 1fr !important; }
    .settings-grid { grid-template-columns: 1fr !important; }

    /* Topbar period selector compact */
    .period-selector { gap: 2px; }
    .period-selector .btn { padding: 6px 8px; font-size: 0.8rem; }
    #current-period-display { font-size: 0.8rem; }

    /* Pagination */
    .pagination-controls { flex-wrap: wrap; gap: 4px; }

    /* Settings tabs */
    .settings-tabs { flex-wrap: wrap; gap: 4px; }
    .settings-tab-btn { font-size: 0.75rem; padding: 6px 10px; }

    /* Toast position */
    #toast-container { bottom: 10px; right: 10px; left: 10px; }
    .toast { min-width: unset; width: 100%; }

    /* Report tables */
    #rep-cashflow-body td, #rep-piutang-body td, #rep-hutang-body td {
        font-size: 0.78rem;
        padding: 6px 8px;
    }

    /* Btn sm on mobile */
    .btn-sm { padding: 4px 8px; font-size: 0.72rem; }
    .btn { font-size: 0.88rem; }

    /* Stat cards section topbar compact */
    .card-header { flex-direction: column; align-items: flex-start; }
    .card-header .btn { align-self: stretch; }

    /* Invoice builder */
    .invoice-builder-layout { flex-direction: column; }
    .invoice-controls { max-width: 100%; position: static; max-height: none; }

    /* PIN modal */
    #pin-auth-modal .modal-content { max-width: 95vw !important; }
}

/* ── Small Mobile (≤ 480px) ─────────────────────────────── */
@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .card-info p { font-size: 0.72rem; margin-bottom: 2px; }
    .card-info h3 { font-size: 1rem; }
    .card-icon { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }

    #page-title { font-size: 1rem; }

    /* Action buttons in table wrap */
    .btn-group-action { flex-wrap: wrap; }

    /* Topbar compact */
    .topbar { gap: 6px; }
    .avatar { width: 32px; height: 32px; font-size: 0.9rem; }

    /* Modal full height on very small */
    .modal-content { max-height: 95vh; }

    /* Period selector compact */
    /* Period nav: sembunyikan teks jika ada (tidak relevan untuk dropdown) */
}

/* ═══════════════════════════════════════════════════════════
   MOBILE TABLE — Piutang & Hutang Column Hiding
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ─── PIUTANG: sembunyikan Kategori(3), Terbayar(6), Jatuh Tempo(8) ─── */
    #piutang .table thead th:nth-child(3),
    #piutang .table tbody td:nth-child(3),
    #piutang .table thead th:nth-child(6),
    #piutang .table tbody td:nth-child(6),
    #piutang .table thead th:nth-child(8),
    #piutang .table tbody td:nth-child(8) {
        display: none !important;
    }

    /* ─── HUTANG: sembunyikan kolom non-esensial ─── */
    /* Cek kolom Hutang: Tanggal, Keterangan, Vendor/Kategori, Jumlah, PPN, Jatuh Tempo, Terbayar, Sisa, Status, Aksi */
    #hutang .table thead th:nth-child(3),
    #hutang .table tbody td:nth-child(3),
    #hutang .table thead th:nth-child(5),
    #hutang .table tbody td:nth-child(5),
    #hutang .table thead th:nth-child(8),
    #hutang .table tbody td:nth-child(8) {
        display: none !important;
    }

    /* ─── RIWAYAT: sembunyikan Kategori(3) ─── */
    #transactions .table thead th:nth-child(3),
    #transactions .table tbody td:nth-child(3) {
        display: none !important;
    }

    /* ─── Action buttons kompak ─── */
    .table td .btn-icon {
        padding: 5px 6px;
        font-size: 0.75rem;
    }

    /* ─── Card header Piutang & Hutang: TIDAK flex-direction column ─── */
    /* Override global .card-header { flex-direction: column } untuk section ini */
    #piutang .card-header,
    #hutang .card-header {
        flex-direction: row !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    #piutang .card-header > div:first-child,
    #hutang .card-header > div:first-child {
        flex: 1;
        min-width: 0;
    }
    #piutang .card-header > div:last-child,
    #hutang .card-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        flex-shrink: 0;
    }
    #piutang .card-header > div:last-child .btn,
    #hutang .card-header > div:last-child .btn {
        font-size: 0.78rem;
        padding: 7px 10px;
    }
}

@media (max-width: 480px) {
    /* Tombol card header: hanya ikon */
    #piutang .card-header .btn span,
    #hutang .card-header .btn span {
        display: none !important;
    }
    #piutang .card-header .btn,
    #hutang .card-header .btn {
        padding: 8px 10px;
        min-width: 36px;
    }
}

/* ========================================================
   REPORTS PAGE CUSTOM OVERRIDES (Clean Alignments & Print)
   ======================================================== */

/* Prevent wrapping of currency values on reports page (both screen and print) */
.report-paper td[style*="text-align: right"],
.report-paper td[style*="text-align:right"],
.report-paper th[style*="text-align: right"],
.report-paper th[style*="text-align:right"] {
    white-space: nowrap !important;
    word-break: normal !important;
}

/* Force hide all non-print elements at the very end of stylesheet
   This ensures it overrides any screen rules (like mobile topbar grid display) during print */
@media print {
    .no-print,
    .sidebar,
    .topbar,
    #sidebar-overlay,
    .table-responsive > ::-webkit-scrollbar {
        display: none !important;
    }
}

