:root {
    --primary: #ff8a3d;
    --primary-dark: #e86f1f;
    --secondary: #2fa88a;
    --bg: #f6f7fb;
    --card-bg: #ffffff;
    --text: #24292f;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #e5484d;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 16px; }
img { max-width: 100%; display: block; }

/* ============ Header / Nav ============ */
.app-header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg);
    padding: 10px 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--primary-dark); margin-right: auto; }
.brand-icon { font-size: 26px; }
.main-nav { display: flex; gap: 6px; }
.main-nav a {
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 600;
    color: var(--muted);
}
.main-nav a.active, .main-nav a:hover { background: #fff1e6; color: var(--primary-dark); }
.user-box { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-weight: 600; color: var(--muted); font-size: 14px; }
.btn-logout { background: #fee2e2; color: var(--danger); padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.nav-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

.mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 49;
}
.mobile-nav a { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.mobile-nav a.active { color: var(--primary-dark); background: #fff1e6; }
.mobile-nav.open { display: flex; }

.app-main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }

/* ============ Login ============ */
.login-body { background: linear-gradient(160deg, var(--primary), var(--secondary)); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 36px 28px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.login-logo { font-size: 56px; }
.login-card h1 { margin: 6px 0 0; color: var(--primary-dark); }
.login-sub { color: var(--muted); margin-top: 0; margin-bottom: 20px; }
.login-form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.login-form input { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ============ Buttons ============ */
.btn { border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; transition: transform .05s ease; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-outline { background: #fff; color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px; font-size: 17px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ Alerts ============ */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.alert-success { background: #dcfce7; color: #15803d; }
.alert-error { background: #fee2e2; color: var(--danger); }

/* ============ Page head ============ */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Product grid (management page) ============ */
.produk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.produk-card { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.produk-card.is-inactive { opacity: .55; }
.produk-card-img { position: relative; aspect-ratio: 1/1; background: #f0f1f4; }
.produk-card-img img { width: 100%; height: 100%; object-fit: cover; }
.no-image { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 40px; color: #c4c8d0; }
.badge { position: absolute; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; top: 6px; }
.badge-topping { left: 6px; background: var(--secondary); color: #fff; }
.badge-off { right: 6px; background: var(--danger); color: #fff; }
.produk-card-body { padding: 10px 12px; flex: 1; }
.produk-card-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.produk-card-cat { color: var(--muted); font-size: 12px; margin-top: 2px; }
.produk-card-price { color: var(--primary-dark); font-weight: 800; margin-top: 6px; }
.produk-card-actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.produk-card-actions .btn { flex: 1; }
.empty-state { color: var(--muted); text-align: center; padding: 40px 10px; grid-column: 1/-1; }

/* ============ Modal ============ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(20,20,25,.5); z-index: 100; align-items: flex-end; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px; animation: slideUp .2s ease; }
@media (min-width: 640px) {
    .modal-overlay { align-items: center; }
    .modal-box { border-radius: 20px; }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-form, .item-modal-body { display: flex; flex-direction: column; gap: 4px; }
.modal-form label, .qty-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 10px; }
.modal-form input, .modal-form select, .modal-form textarea,
.item-modal-body input, .item-modal-body select, .item-modal-body textarea {
    padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; width: 100%;
}
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 600 !important; color: var(--text) !important; }
.checkbox-row input { width: auto !important; }
.img-preview { margin-top: 8px; width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.topping-box { background: #fafafa; border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.topping-box-title { font-weight: 700; font-size: 13px; margin: 0 0 6px; color: var(--muted); }
.topping-checklist { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.simple-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.simple-table th, .simple-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }

/* ============ Kasir layout ============ */
.kasir-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.kasir-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; position: sticky; top: 64px; background: var(--bg); padding: 6px 0; z-index: 10; }
.search-input { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: #fff; width: 100%; }
.kategori-filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex-shrink: 0; padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.kasir-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kasir-grid .produk-card { cursor: pointer; }
.kasir-grid .produk-card:active { transform: scale(.98); }

.kasir-right { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; position: sticky; top: 64px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; }
.cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.cart-head h2 { margin: 0; font-size: 17px; }
.cart-head-actions { display: flex; gap: 6px; }
.count-badge { background: var(--danger); color: #fff; border-radius: 20px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.field-inline { margin-bottom: 10px; }
.field-inline label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field-inline input { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 100px; }
.cart-item { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.cart-item-top { display: flex; justify-content: space-between; gap: 8px; }
.cart-item-name { font-weight: 700; font-size: 14px; }
.cart-item-remove { background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; }
.cart-item-topping { font-size: 12px; color: var(--secondary); margin-top: 2px; }
.cart-item-note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.cart-item-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.cart-item-qty-ctrl { display: flex; align-items: center; gap: 8px; }
.cart-item-qty-ctrl button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 700; }
.cart-item-price { font-weight: 700; color: var(--primary-dark); }
.cart-summary { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 10px; }
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; }
.summary-total { font-weight: 800; font-size: 18px; }
.cart-action-row { display: flex; gap: 8px; margin-top: 10px; }
.cart-action-row .btn { flex: 1; }
#checkoutBtn { margin-top: 8px; }

.cart-fab { display: none; position: fixed; bottom: 18px; right: 18px; background: var(--primary); color: #fff; border: none; border-radius: 30px; padding: 14px 22px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 60; }

/* Item detail modal */
.item-modal-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; margin-bottom: 10px; }
.item-modal-price { font-size: 20px; font-weight: 800; color: var(--primary-dark); margin-bottom: 6px; }
.qty-control { display: flex; align-items: center; gap: 16px; }
.qty-control button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: #fff; font-size: 20px; cursor: pointer; }
#itemQty { font-size: 18px; font-weight: 700; min-width: 24px; text-align: center; }

.pay-total-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.pay-total-amount { font-size: 20px; font-weight: 800; color: var(--primary-dark); }
.quick-cash { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.quick-cash button { flex: 1; min-width: 80px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-weight: 700; cursor: pointer; }

.receipt { font-family: 'Courier New', monospace; font-size: 13px; background: #fafafa; border-radius: 10px; padding: 16px; }
.receipt-line { display: flex; justify-content: space-between; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt-center { text-align: center; }
.receipt-footer-credit { font-size: 10px; color: #888; margin-top: 8px; }
.modal-actions-wrap { flex-wrap: wrap; }
.modal-actions-wrap .btn { flex: 1 1 auto; min-width: 110px; }
.bt-status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 8px 0 0; text-align: center; }

/* Saved orders list */
.order-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.order-row-title { font-weight: 700; font-size: 14px; }
.order-row-price { font-weight: 800; color: var(--primary-dark); text-align: right; }
.order-row-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

/* ============ Laporan ============ */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; background: var(--card-bg); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.filter-bar .field { display: flex; flex-direction: column; gap: 4px; }
.filter-bar label { font-size: 12px; font-weight: 700; color: var(--muted); }
.filter-bar input, .filter-bar select { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card .stat-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; color: var(--primary-dark); }
.report-table-wrap { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; padding: 6px; }
.report-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.report-table th, .report-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; text-align: left; }
.report-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.detail-toggle { color: var(--primary-dark); font-weight: 700; cursor: pointer; font-size: 13px; }
.report-actions { display: flex; flex-direction: column; gap: 4px; white-space: nowrap; }
.detail-row { background: #fafbfc; }
.detail-row td { padding: 10px 14px; }
.mini-list { margin: 0; padding-left: 18px; font-size: 13px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
    .main-nav, .user-box { display: none; }
    .nav-toggle { display: block; }
    .kasir-wrap { grid-template-columns: 1fr; }
    .kasir-right { position: fixed; bottom: 0; left: 0; right: 0; top: auto; max-height: 85vh; border-radius: 18px 18px 0 0; z-index: 70; transform: translateY(100%); transition: transform .25s ease; }
    .kasir-right.open { transform: translateY(0); }
    .cart-fab { display: block; }
    .app-main { padding: 12px; }
    .kasir-toolbar { top: 0; }
}
@media print {
    .app-header, .mobile-nav, .modal-actions, .cart-fab { display: none !important; }
}
