:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --text: #1d1d1f;
    --muted: #6b6b70;
    --line: #e4e4e0;
    --accent: #1f6f5c;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141416;
        --surface: #1e1e21;
        --text: #f2f2f2;
        --muted: #a0a0a6;
        --line: #2e2e33;
        --accent: #4fb89a;
        --accent-text: #0c1a16;
        --danger: #f2867e;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.search { flex: 1; }
.search input {
    width: 100%; max-width: 420px; padding: 9px 14px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
.cart-link { text-decoration: none; font-weight: 600; white-space: nowrap; }
.badge {
    display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
    background: var(--accent); color: var(--accent-text); font-size: 13px; text-align: center;
}

/* Umum */
.page-title { font-size: 26px; margin: 0 0 20px; }
.empty { color: var(--muted); }
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-success { border-color: var(--accent); }

.btn {
    display: inline-block; padding: 11px 20px; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }

.price { font-weight: 700; margin: 4px 0 0; }
.price s { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: .8em; }
.price.big { font-size: 26px; margin: 12px 0 20px; }

/* Katalog */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgb(0 0 0 / .08); }
.card-img { position: relative; aspect-ratio: 1; background: var(--bg); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 16px; }
.card-body h2 { font-size: 15px; font-weight: 500; margin: 0; }
.ribbon, .soldout {
    position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; background: var(--accent); color: var(--accent-text);
}
.soldout { left: auto; right: 10px; background: var(--text); color: var(--bg); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 32px; }
.pager a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; }
.pager a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Detail produk */
.product { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.gallery-main { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: var(--surface); }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs button { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: none; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; }
.info h1 { margin: 0; font-size: 28px; line-height: 1.25; }
.subtitle { color: var(--muted); margin: 6px 0 0; }
.buy { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 24px; }
.buy label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.buy select, .buy input, .cart-line input {
    padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--text); font: inherit;
}
.buy input { width: 80px; }
.soldout-text { color: var(--danger); font-weight: 600; }
.desc { color: var(--text); border-top: 1px solid var(--line); padding-top: 20px; }

/* Keranjang */
.cart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cart-line { display: grid; grid-template-columns: 72px 1fr 72px 130px 32px; gap: 14px; align-items: center; padding: 14px 16px; }
.cart-line + .cart-line { border-top: 1px solid var(--line); }
.cart-img img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.cart-info { display: flex; flex-direction: column; }
.cart-info a { text-decoration: none; font-weight: 600; }
.cart-info small { color: var(--muted); }
.cart-line input { width: 72px; }
.cart-sub { text-align: right; }
.cart-footer { display: flex; justify-content: space-between; align-items: center; margin: 20px 0; gap: 12px; flex-wrap: wrap; }
.total { font-size: 20px; }
.checkout { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.checkout small { color: var(--muted); }

.notice { text-align: center; padding: 60px 0; }
.notice p { color: var(--muted); }

.footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: 14px; }

@media (max-width: 720px) {
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
    .search { order: 3; flex-basis: 100%; }
    .search input { max-width: none; }
    .product { grid-template-columns: 1fr; gap: 24px; }
    .cart-line { grid-template-columns: 56px 1fr 60px 28px; }
    .cart-img img { width: 56px; height: 56px; }
    .cart-sub { grid-column: 2 / 4; text-align: left; }
    .cart-line input { width: 60px; }
}

/* ------------------------------------------------------------------ Admin */
.spacer { flex: 1; }
.inline { display: inline; margin: 0; }
.btn-sm { padding: 7px 14px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; }
.muted { color: var(--muted); }
.warn { color: var(--danger); font-size: 14px; margin: 0 0 8px; }

.login-box { max-width: 360px; margin: 48px auto; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form input[type=text], .form input[type=password], .form input[type=url], .filters input, .filters select {
    padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--text); font: inherit;
}

.admin-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.admin-head .page-title { margin-bottom: 8px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; }
.filters input { flex: 1; min-width: 200px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr { cursor: pointer; }
.table-wrap tbody tr:hover { background: var(--bg); }
.table a { font-weight: 600; text-decoration: none; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: #dcf3e7; color: #156b43; }
.pill-wait { background: #fdf0d5; color: #8a5a00; }
.pill-bad { background: #fbe1df; color: #a1261d; }
.pill-info { background: #e3ecfb; color: #1e4fa3; }
@media (prefers-color-scheme: dark) {
    .pill-ok { background: #173a2a; color: #7fdcac; }
    .pill-wait { background: #3d2f12; color: #f3c56b; }
    .pill-bad { background: #45201d; color: #f5a29b; }
    .pill-info { background: #1c2c47; color: #93b6f2; }
}

.admin-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; margin-top: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel .table th, .panel .table td { padding: 8px 6px; white-space: normal; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; max-width: 320px; margin: 16px 0 0 auto; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-weight: 700; color: var(--text); font-size: 17px; }
.address { margin: 0; line-height: 1.6; }
.plain { padding-left: 18px; margin: 0; }

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