:root {
    --primary: #4F46E5; --primary-light: #818CF8;
    --bg-color: #F3F4F6; --surface: #FFFFFF;
    --text-main: #1F2937; --text-muted: #6B7280;
    --success: #10B981; --warning: #F59E0B; --danger: #EF4444; --info: #3B82F6;
    --radius: 16px; --shadow: 0 4px 20px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
html, body { background-color: var(--bg-color); color: var(--text-main); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Print Area */
#printArea { display: none; }
@media print {
    @page { margin: 0; }
    html, body { height: auto !important; overflow: visible !important; background: white; margin: 0; padding: 0; }
    #loginScreen, #mainApp, .global-header, .modal-overlay { display: none !important; }
    #printArea { display: block !important; position: static; width: 100%; max-width: 80mm; font-family: 'Courier New', Courier, monospace; font-size: 12px; color: black; background: white; padding: 15px; margin: 0 auto; }
    #printArea * { visibility: visible; }
    #printArea h2 { font-size: 18px; text-align: center; margin-bottom: 2px; }
    #printArea .text-center { text-align: center; }
    #printArea .divider { border-top: 1px dashed black; margin: 8px 0; }
    #printArea .flex-between { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px;}
    #printArea .right-align { text-align: right; }
    #printArea img.logo-nota { max-width: 100px; display: block; margin: 0 auto 10px; }
}

/* Login Screen */
#loginScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-color); z-index: 9999; display: flex; align-items: center; justify-content: center; transition: opacity 0.4s ease; }
.auth-card { background: var(--surface); padding: 40px 30px; border-radius: 24px; box-shadow: var(--shadow); width: 90%; max-width: 400px; text-align: center; }
.auth-card .icon { font-size: 48px; color: var(--primary); margin-bottom: 10px; }
.auth-card h2 { font-size: 22px; margin-bottom: 8px; font-weight: 700; }
.auth-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* App Layout */
#mainApp { flex: 1; display: flex; height: 100vh; overflow: hidden; }
nav { background: var(--surface); box-shadow: var(--shadow); z-index: 100; transition: all 0.3s ease; }
.nav-items { display: flex; list-style: none; overflow-x: auto; scrollbar-width: none; }
.nav-items::-webkit-scrollbar { display: none; }
.nav-item { flex: 1; min-width: 65px; text-align: center; padding: 12px 6px; cursor: pointer; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-item .material-icons-round { font-size: 24px; }
.nav-item span { font-size: 11px; font-weight: 600; white-space: nowrap; }

main { flex: 1; overflow-y: auto; padding: 20px; padding-bottom: 90px; }

.global-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; background: var(--surface); padding: 16px 20px; border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow); gap: 10px; }
.header-title-area { display: flex; align-items: center; gap: 10px; }
.date-filter { display: flex; gap: 8px; align-items: center; background: var(--bg-color); padding: 6px 12px; border-radius: 8px; }
.date-filter input { border: none; background: transparent; outline: none; font-size: 13px; font-weight: 600; color: var(--text-main); }
.user-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; background: #EEF2FF; color: var(--primary); padding: 6px 12px; border-radius: 20px; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap:10px;}
header h1 { font-size: 20px; font-weight: 700; }

/* Cards & Grid */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; margin-bottom: 20px; }
.grid-item { background: var(--surface); border: 1px solid #E5E7EB; border-radius: var(--radius); padding: 16px 8px; text-align: center; cursor: pointer; transition: 0.2s; }
.grid-item:active { transform: scale(0.95); border-color: var(--primary); }
.grid-item .icon-wrapper { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; background: #EEF2FF; color: var(--primary); }
.grid-item h3 { font-size: 11px; font-weight: 600; }

/* Forms */
.form-group { margin-bottom: 12px; position: relative; text-align: left;}
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.form-control { width: 100%; padding: 12px 14px; border: 1.5px solid #E5E7EB; border-radius: 12px; font-size: 14px; outline: none; transition: 0.2s; background: #F9FAFB; }
.form-control:focus { border-color: var(--primary); background: var(--surface); }
.row-form { display: flex; gap: 12px; flex-wrap: wrap;}
.row-form .form-group { flex: 1; min-width: 120px; }

.dropdown-content { display: none; position: absolute; background-color: var(--surface); width: 100%; box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-radius: 12px; z-index: 10; max-height: 200px; overflow-y: auto; border: 1px solid #E5E7EB; top: 100%; margin-top: 4px; }
.dropdown-content.show { display: block; }
.dropdown-item { padding: 10px 14px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #F3F4F6; display: flex; justify-content: space-between;}
.dropdown-item:hover { background-color: #F3F4F6; }

.list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #E5E7EB; font-size: 14px; flex-wrap: wrap; gap: 10px;}
.list-item:last-child { border-bottom: none; }
.list-actions { display: flex; gap: 6px; }

.btn { padding: 10px 14px; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 6px; transition: 0.2s; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid #E5E7EB; color: var(--text-main); }

.btn-icon { padding: 6px; border-radius: 8px; cursor: pointer; border: none; display: flex; align-items: center; justify-content: center; }
.btn-icon.edit { background: #EFF6FF; color: var(--info); }
.btn-icon.delete { background: #FEF2F2; color: var(--danger); }
.btn-icon.print { background: #ECFDF5; color: var(--success); }
.btn-icon.fullscreen { background: #F3F4F6; color: var(--primary); }
.btn-icon.logout { background: #FEF2F2; color: var(--danger); }

.badge { padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.lunas { background: #ECFDF5; color: var(--success); }
.badge.dp { background: #FFFBEB; color: var(--warning); }
.badge.nanti { background: #FEF2F2; color: var(--danger); }
.badge.batal { background: #FEF2F2; color: var(--danger); border: 1px solid var(--danger); }
.badge.role-owner { background: #EEF2FF; color: var(--primary); }
.badge.role-kasir { background: #F3F4F6; color: var(--text-muted); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid #E5E7EB; border-radius: 16px; padding: 16px; text-align: center; }
.stat-card h3 { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.stat-card h2 { font-size: 18px; font-weight: 700;}

/* Cart */
.cart-container { background: #F9FAFB; border: 1px dashed #E5E7EB; border-radius: 12px; padding: 12px; margin-bottom: 12px; max-height: 250px; overflow-y: auto;}
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #E5E7EB; }
.cart-item:last-child { border-bottom: none; }
.qty-control { display: flex; align-items: center; gap: 4px; background: white; border: 1px solid #E5E7EB; border-radius: 8px; overflow: hidden; }
.qty-control button { border: none; background: #F3F4F6; width: 28px; height: 28px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-main); }
.qty-control input { width: 40px; text-align: center; border: none; outline: none; font-size: 13px; font-weight: 600; -moz-appearance: textfield; }
.qty-control input::-webkit-outer-spin-button, .qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Pagination & Image Preview */
.pagination-container { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; }
.pagination-container button { padding: 6px 12px; border: 1px solid #E5E7EB; background: white; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.pagination-container button:disabled { opacity: 0.5; cursor: not-allowed; }
.logo-preview { max-width: 120px; max-height: 120px; border-radius: 12px; border: 1px dashed #ccc; padding: 4px; display: block; margin-top: 10px; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: 0.3s; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content { background: var(--surface); width: 90%; max-width: 400px; border-radius: 20px; padding: 24px; transform: translateY(20px); transition: 0.3s; max-height: 90vh; overflow-y: auto; }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.page-section { display: none; animation: fadeIn 0.3s ease; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 767px) {
    #mainApp { flex-direction: column; }
    nav { position: fixed; bottom: 0; left: 0; right: 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); box-shadow: 0 -4px 20px rgba(0,0,0,0.05);}
    .global-header { border-radius: 0 0 20px 20px; margin-top: -20px; margin-left: -20px; margin-right: -20px; padding-top: 20px; }
}
@media (min-width: 768px) {
    #mainApp { flex-direction: row; }
    nav { width: 90px; height: 100vh; flex-direction: column; padding-top: 20px; }
    .nav-items { flex-direction: column; gap: 12px; overflow: visible;}
    main { padding: 30px; }
}

/* Tracking Screen Style */
#trackerScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-color); z-index: 10000; display: none; align-items: center; justify-content: center; overflow-y: auto; padding: 20px; }
.track-card { background: var(--surface); padding: 30px; border-radius: 24px; box-shadow: var(--shadow); width: 100%; max-width: 450px; text-align: center; }
.status-progress { margin-top: 20px; padding: 15px; border-radius: 12px; background: #F9FAFB; border: 1px solid #E5E7EB; }
.track-btn-back { margin-top: 20px; color: var(--text-muted); cursor: pointer; font-size: 13px; text-decoration: underline; }