:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f9fafb;
    --danger: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.narrow { max-width: 460px; margin: 32px auto; }

/* Header & footer */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--primary-dark); }
.nav nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav nav a.active { font-weight: 600; }
.site-footer { margin-top: 48px; padding: 24px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
main { padding-top: 24px; min-height: 60vh; }

/* Buttons & forms */
.btn { display: inline-block; background: var(--primary); color: #fff; border: 1px solid var(--primary); padding: 9px 18px; border-radius: 6px; cursor: pointer; font-size: 1rem; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-outline { background: transparent; color: var(--primary); }
.btn-outline:hover { background: #eff6ff; }
button.link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
button.link.danger, .danger { color: var(--danger); }
form.inline { display: inline; }
.form { display: grid; gap: 14px; }
.form.wide { max-width: 640px; }
.form label { display: grid; gap: 4px; font-weight: 500; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff;
}
input.qty { width: 80px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Home */
.hero { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: #fff; border-radius: 10px; padding: 48px 28px; margin-bottom: 32px; }
.hero h1 { margin-top: 0; }
.hero .btn { background: #fff; color: var(--primary-dark); border-color: #fff; margin-right: 8px; }
.hero .btn-outline { background: transparent; color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }

/* Catalog */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; color: inherit; }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); text-decoration: none; }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--border); }
.card-body { padding: 12px 14px; }
.card-body h3 { margin: 2px 0 6px; font-size: 1.05rem; }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.detail > img { width: 100%; border-radius: 8px; background: var(--border); }
.price { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.pagination { display: flex; gap: 6px; margin-top: 24px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { background: #f3f4f6; font-size: .9rem; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.thumb.large { width: 140px; height: 140px; }
.actions { white-space: nowrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 8px; flex-wrap: wrap; }

/* Admin */
.admin-wrap { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #111827; color: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.sidebar .brand { color: #fff; }
.sidebar nav { display: grid; gap: 4px; flex: 1; align-content: start; }
.sidebar nav a { color: #d1d5db; padding: 8px 10px; border-radius: 6px; }
.sidebar nav a.active, .sidebar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.admin-main { padding: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px; color: var(--muted); }
.stat span { display: block; font-size: 1.5rem; font-weight: 700; color: var(--text); }

/* WhatsApp */
.wa-float { position: fixed; right: 16px; bottom: 16px; background: #16a34a; color: #fff; padding: 12px 18px; border-radius: 999px; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 20; }
.wa-float:hover { text-decoration: none; background: #15803d; }

/* ===== Seluler (HP Android) ===== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: rgba(29, 78, 216, .15); }
.admin-main { min-width: 0; } /* cegah tabel/filter melebar keluar layar di kolom grid */
.nav-toggle, .nav-cart, .admin-topbar, .nav-backdrop { display: none; }
.nav-cart { position: relative; color: var(--text); padding: 10px; margin-left: auto; }
.nav-cart-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
    background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.nav-toggle { width: 44px; height: 44px; padding: 11px 10px; border: 0; background: none; cursor: pointer; border-radius: 8px;
    flex-direction: column; justify-content: space-between; color: inherit; }
.nav-toggle span { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s, opacity .2s; }
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
.wa-float { display: inline-flex; align-items: center; gap: 8px; bottom: calc(16px + env(safe-area-inset-bottom)); }
.install-btn { position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; background: #fff; color: var(--primary-dark);
    border: 1px solid var(--border); border-radius: 999px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.install-btn[hidden] { display: none; }

@media (max-width: 760px) {
    .detail { grid-template-columns: 1fr; gap: 20px; }

    /* Input 16px agar peramban seluler tidak memperbesar halaman saat mengetik; target sentuh >= 44px. */
    input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input[type=date], select, textarea { font-size: 16px; min-height: 44px; }
    .btn { min-height: 44px; padding: 10px 18px; }
    .btn-sm { min-height: 36px; }
    .filters > * { flex: 1 1 140px; }
    .filters input[type=search] { flex-basis: 100%; }
    .inline-form input, .inline-form select { width: 100%; }
    .inline-form label { flex: 1 1 140px; }
    .toolbar > .btn { flex: 0 0 auto; }

    /* Header publik: brand + keranjang + tombol menu; menu jadi panel tarik-turun */
    .nav { flex-wrap: nowrap; gap: 4px; min-height: 56px; }
    .brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
    .js .nav-toggle { display: flex; }
    .js .nav-cart { display: block; }
    .js .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--border);
        box-shadow: 0 8px 20px rgba(0,0,0,.08); flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px 16px;
        max-height: calc(100vh - 56px); overflow-y: auto; }
    .js .nav-open .site-nav { display: flex; }
    .site-nav a, .site-nav button.link { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 4px; border-bottom: 1px solid var(--border); font-size: 1rem; }
    .site-nav a.btn { justify-content: center; margin-top: 12px; border-bottom: 0; color: #fff; }
    .site-nav form.inline { display: contents; }
    .site-nav button.link { width: 100%; text-align: left; color: var(--danger); border-bottom: 0; }

    .hero { padding: 32px 20px; margin-bottom: 24px; }
    .hero h1 { font-size: 1.75rem; line-height: 1.25; }
    .hero .btn { display: block; width: 100%; text-align: center; margin: 0 0 10px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .card-body { padding: 10px 12px; }
    .card-body h3 { font-size: .95rem; }
    .panel { padding: 14px 16px; }
    .price { font-size: 1.3rem; }
    .table th, .table td { padding: 8px 10px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
    .table-wrap > .table { min-width: 520px; }
    .pagination { flex-wrap: wrap; }
    .pagination a { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
    .site-footer { padding-bottom: calc(80px + env(safe-area-inset-bottom)); } /* ruang untuk tombol WhatsApp */

    /* Tombol WhatsApp: ikon bulat saja */
    .wa-float { width: 56px; height: 56px; padding: 0; justify-content: center; }
    .wa-float span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .install-btn { padding: 10px 16px; }

    /* Admin: bilah atas + sidebar laci (drawer) */
    .admin-topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 8px; min-height: 56px; padding: 0 8px;
        background: #111827; color: #fff; }
    .admin-topbar .brand { color: #fff; }
    .admin-wrap { grid-template-columns: 1fr; min-height: 0; }
    .js .admin-wrap .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(280px, 85vw); overflow-y: auto;
        transform: translateX(-100%); transition: transform .25s ease; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
    .js .nav-open .admin-wrap .sidebar { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
    .sidebar nav a { min-height: 44px; display: flex; align-items: center; }
    .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); }
    .nav-backdrop[hidden] { display: none; }
    .nav-open { overflow: hidden; }
    .admin-main { padding: 16px; }
    .admin-main h1 { font-size: 1.5rem; margin-top: 4px; }
    .admin-main .table-wrap { margin: 0 -16px; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat { padding: 12px; }
    .stat span { font-size: 1.25rem; }
    .thumb.large { width: 100px; height: 100px; }
}

@media (prefers-reduced-motion: reduce) {
    .nav-toggle span, .sidebar { transition: none !important; }
}

/* Tampilan saat dipasang sebagai aplikasi (PWA standalone) */
@media (display-mode: standalone) {
    .install-btn { display: none !important; }
    .site-header, .admin-topbar { padding-top: env(safe-area-inset-top); }
}

/* Pesanan */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; vertical-align: middle; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.timeline { list-style: none; padding: 0; margin: 16px 0 24px; display: flex; flex-wrap: wrap; gap: 6px; }
.timeline li { padding: 4px 10px; border-radius: 6px; background: #e5e7eb; color: var(--muted); font-size: .85rem; }
.timeline li.done { background: #d1fae5; color: #065f46; }
.timeline li.current { background: var(--primary); color: #fff; font-weight: 600; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin: 20px 0; }
.panel h2 { margin-top: 0; }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
fieldset.form { padding: 16px; }
legend { font-weight: 600; padding: 0 6px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 12px 0; }
.inline-form label { display: grid; gap: 4px; }
.inline-form input, .inline-form select { width: auto; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }

/* Produksi */
.progress { background: #e5e7eb; border-radius: 999px; height: 10px; overflow: hidden; margin: 6px 0; }
.progress span { display: block; height: 100%; background: #16a34a; border-radius: 999px; }
.stat-warn span { color: var(--danger); }
.stage-list { list-style: none; padding: 0; margin: 8px 0 20px; display: grid; gap: 4px; }
.stage-list li { padding: 6px 10px; border-radius: 6px; background: #f3f4f6; color: var(--muted); }
.stage-list li.berjalan { background: #dbeafe; color: #1e40af; font-weight: 600; }
.stage-list li.selesai { background: #d1fae5; color: #065f46; }
.stage-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stage-form select, .stage-form input[type=text] { width: auto; min-width: 140px; flex: 1 1 140px; }
.stage-actions { display: inline-flex; gap: 6px; }

/* Stok & notifikasi */
a.stat { display: block; text-decoration: none; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notif-list li { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.notif-list li.unread { border-left: 4px solid var(--primary); background: #eff6ff; font-weight: 600; }
.filters label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
@media (max-width: 760px) { .cols-2 { grid-template-columns: 1fr; } }

/* Laporan */
.cols-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
a.report-card { display: block; color: inherit; text-decoration: none; }
a.report-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.presets { display: inline-flex; gap: 10px; flex-wrap: wrap; margin-left: 8px; }
.export-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bar-col { width: 40%; }
.bar { background: #e5e7eb; border-radius: 4px; height: 14px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
@media print {
    .sidebar, .no-print, .wa-float, .install-btn, .admin-topbar, .nav-backdrop, .site-header, .site-footer { display: none !important; }
    .admin-wrap { display: block; }
    .admin-main { padding: 0; }
    body { background: #fff; }
}
