/* WarungKu - gaya dasar. Mobile-first: aturan default untuk layar kecil (>= 360px),
   penyesuaian untuk tablet/desktop ada di media query min-width di bagian bawah. */

:root {
    --bg: #f3f6f4;
    --surface: #ffffff;
    --text: #1b2420;
    --muted: #55625b;
    --border: #d3dcd7;

    --primary: #176b45;
    --primary-hover: #0f5535;
    --primary-soft: #e4f2ea;

    --danger: #b3261e;
    --danger-soft: #fdecea;
    --warning: #7a4600;
    --warning-soft: #fff3dc;
    --success: #1b6e3c;
    --success-soft: #e5f4ea;
    --info: #0b5cad;
    --info-soft: #e7f0fb;

    --focus: #0b5cad;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 2px 8px rgba(20, 40, 30, .05);

    --topbar-h: 56px;
    --nav-h: 60px;
    --nav-w: 232px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
p { margin: 0; }
a { color: var(--primary); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 8px; top: -64px; z-index: 100;
    background: var(--surface); color: var(--text); padding: 10px 14px;
    border-radius: 8px; box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }

.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ---------------------------------------------------------------- tombol */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    border: 1px solid transparent; border-radius: 10px;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: .9375rem; }
.btn-lg { min-height: 52px; font-size: 1.0625rem; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- kerangka */

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: var(--topbar-h); padding: 0 12px 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    color: var(--primary); font-weight: 700; font-size: 1.125rem; text-decoration: none;
}
.brand .icon { width: 1.5em; height: 1.5em; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-user { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar-who { display: none; flex-direction: column; text-align: right; line-height: 1.2; }
.topbar-name { font-weight: 600; }
.topbar-role { font-size: .8125rem; color: var(--muted); }

/* Menu: bar bawah di HP, sidebar di layar lebar. Satu markup untuk keduanya. */
.nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: var(--nav-h); padding: 6px 4px;
    color: var(--muted); font-size: .8125rem; font-weight: 600; text-decoration: none;
}
.nav-link .icon { width: 1.5em; height: 1.5em; }
.nav-link.is-active { color: var(--primary); background: var(--primary-soft); }

.main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.container { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head-row { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back-link { color: var(--muted); text-decoration: none; font-size: .9375rem; padding: 4px 0; }
.back-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ panel */

.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px;
}
.panel-flush { padding: 0; overflow: hidden; }
.panel-form { max-width: 640px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-head h2, .panel-title { display: flex; align-items: center; gap: 8px; }
.panel-title { margin-bottom: 12px; }
.panel-foot { margin-top: 8px; font-size: .9375rem; }
.empty { color: var(--muted); padding: 8px 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px; min-width: 0;
}
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .875rem; font-weight: 600; }
.stat-value { margin-top: 6px; font-size: 1.375rem; font-weight: 700; overflow-wrap: anywhere; }
.stat-note { margin-top: 2px; font-size: .8125rem; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; border-top: 1px solid var(--border);
}
.list li:first-child { border-top: 0; }
.list-main { display: flex; flex-direction: column; min-width: 0; }
.list-main .muted { font-size: .875rem; }
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.list-qty { font-weight: 600; font-size: .9375rem; }

.details { display: grid; gap: 10px; margin: 0; }
.details div { display: flex; flex-direction: column; }
.details dt { color: var(--muted); font-size: .875rem; font-weight: 600; }
.details dd { margin: 0; }

/* ------------------------------------------------------------------ badge */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap;
    background: var(--primary-soft); color: var(--primary);
}
.badge .icon { width: 1em; height: 1em; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #e9edeb; color: var(--muted); }

/* ------------------------------------------------------------------ alert */

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: 10px; border: 1px solid transparent;
}
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #b9dfc7; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #bcd5f1; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f1d9a6; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f2bcb8; }

/* ---------------------------------------------------------------- formulir */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.req { color: var(--danger); }

.input {
    width: 100%; min-height: 46px; padding: 10px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid #8a9890; border-radius: 10px;
    font: inherit; font-size: 1rem; /* 16px: mencegah zoom otomatis di iOS */
}
select.input { appearance: auto; }
.input:disabled { background: #eef1ef; color: var(--muted); }
.has-error .input { border-color: var(--danger); border-width: 2px; }

.input-group { position: relative; }
.input-group .input { padding-right: 52px; }
.input-toggle {
    position: absolute; top: 0; right: 0; width: 48px; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 0 10px 10px 0; color: var(--muted); cursor: pointer;
}
.input-toggle[aria-pressed="true"] { color: var(--primary); }

.field-hint { color: var(--muted); font-size: .875rem; }
.field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--danger); font-size: .9375rem; font-weight: 600; }
.field-error .icon { margin-top: 2px; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.form-actions .btn { flex: 1 1 140px; }

/* ----------------------------------------------------------------- tabel */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; }
.table thead th { background: #f0f4f2; color: var(--muted); font-size: .875rem; border-bottom: 1px solid var(--border); }
.table tbody td { border-top: 1px solid var(--border); }
.table tbody tr:first-child td { border-top: 0; }
.table .badge-info { margin-left: 6px; }

/* Di layar kecil, setiap baris tabel menjadi kartu agar tidak perlu menggeser layar. */
@media (max-width: 639px) {
    .table-cards thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
    }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { padding: 12px 16px; border-top: 1px solid var(--border); }
    .table-cards tr:first-child { border-top: 0; }
    .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; border: 0 !important; text-align: right; }
    .table-cards td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: .875rem; font-weight: 600; text-align: left; }
    .table-cards td.cell-actions { justify-content: flex-end; padding-top: 10px; }
    .table-cards td.cell-actions::before { content: none; }
}

/* ----------------------------------------------------------- login & galat */

body.guest { min-height: 100vh; }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card {
    width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow); padding: 24px 20px;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 16px; background: var(--primary); color: #fff;
}
.auth-mark .icon { width: 30px; height: 30px; }
.error-card { text-align: center; align-items: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; }
.debug {
    width: 100%; max-height: 260px; overflow: auto; margin: 0; padding: 12px; text-align: left;
    background: #f0f4f2; border-radius: 8px; font-size: .75rem; white-space: pre-wrap; word-break: break-word;
}

/* ----------------------------------------------------- tablet dan desktop */

@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .topbar-who { display: flex; }
    .auth-card { padding: 32px; }
}

@media (min-width: 900px) {
    .main { margin-left: var(--nav-w); padding: 28px 32px 40px; }

    .nav {
        top: var(--topbar-h); right: auto; bottom: 0; width: var(--nav-w);
        flex-direction: column; justify-content: flex-start; gap: 4px;
        padding: 12px; border-top: 0; border-right: 1px solid var(--border);
    }
    .nav-link {
        flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
        min-height: 44px; padding: 10px 14px; border-radius: 10px; font-size: 1rem;
    }
    .nav-link .icon { width: 1.25em; height: 1.25em; }

    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* =====================================================================
   Tahap 2: produk, pembelian, stok
   ===================================================================== */

/* Menu bawah (HP): item sekunder pindah ke halaman "Lainnya". */
.nav-secondary { display: none; }
.nav-more { text-decoration: none; }

@media (min-width: 900px) {
    .nav-secondary { display: flex; }
    .nav-more { display: none; }
}

.menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.menu-item {
    display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.menu-item:hover { border-color: var(--primary); }
.menu-icon {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary);
}
.menu-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.menu-text .muted { font-size: .875rem; }
.menu-chevron { color: var(--muted); }

/* Utilitas */
.num { text-align: right; }
.small { font-size: .8125rem; }
.strong-link { font-weight: 600; }
.empty-pad { padding: 20px 16px; }
.panel-head-pad { padding: 16px 16px 8px; margin-bottom: 0; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form-actions-page { max-width: 640px; }
.field-error-block { margin-bottom: 8px; }
.badge-lg { font-size: .9375rem; padding: 4px 14px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1d17; }
.table td .small { display: block; }
.table td .badge { margin-top: 2px; }

/* Filter pencarian */
.filters { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: end; }
.filters-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters-actions .btn { flex: 1 1 120px; }
.filter-chip {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--primary-soft); border-radius: 10px; color: var(--primary);
}
.filter-chip span { color: var(--text); }

/* Paginasi */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pager-info { font-size: .9375rem; }
.pager-links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pager-page { font-weight: 600; font-size: .9375rem; }

/* Detail dua kolom */
.details-grid { grid-template-columns: 1fr; }
.details-wide { grid-column: 1 / -1; }

.stock-banner {
    display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; margin-bottom: 16px;
    background: var(--success-soft); border-radius: 10px; border: 1px solid #b9dfc7;
}
.stock-banner.is-low { background: var(--warning-soft); border-color: #f1d9a6; }
.stock-banner.is-empty { background: var(--danger-soft); border-color: #f2bcb8; }
.stock-banner-value { font-size: 1.75rem; font-weight: 800; }
.stock-banner-value small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.stock-banner-note { color: var(--muted); font-size: .9375rem; }

/* Mutasi stok: tanda masuk/keluar memakai ikon + teks, bukan warna saja */
.qty-in, .qty-out { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.qty-in { color: var(--success); }
.qty-out { color: var(--danger); }
.qty-in .icon, .qty-out .icon { width: 1em; height: 1em; }

/* Formulir pembelian: baris barang */
.item-rows { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.item-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 12px;
    background: #f7faf8; border: 1px solid var(--border); border-radius: 10px;
}
.item-row .item-product { grid-column: 1 / -1; }
.item-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-subtotal { color: var(--muted); font-size: .9375rem; }
.item-subtotal strong { color: var(--text); }
[data-add-row][hidden], [data-summary-box][hidden] { display: none; }

/* Ringkasan total */
.summary-list { display: grid; gap: 6px; margin: 0; }
.summary-list > div { display: flex; justify-content: space-between; gap: 12px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 600; text-align: right; }
.summary-total { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 1.125rem; }
.summary-total dt { color: var(--text); font-weight: 700; }
.summary-total dd { font-weight: 800; }
.summary-pad { padding: 16px; border-top: 1px solid var(--border); }

/* Zona bahaya (pembatalan) */
.danger-zone { border-color: #f2bcb8; }
.danger-zone summary {
    display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer;
    color: var(--danger); font-weight: 700;
}
.danger-zone details[open] summary { margin-bottom: 8px; }
.danger-zone .form { margin-top: 12px; }

/* Kartu di HP: sel pertama menjadi judul kartu; sel kompleks dibungkus .cell-value */
@media (max-width: 639px) {
    .table-cards td:first-child {
        display: block; text-align: left; padding-bottom: 8px; margin-bottom: 4px;
        border-bottom: 1px dashed var(--border) !important;
    }
    .table-cards td:first-child::before { content: none; }
    .table-cards td .cell-value { text-align: right; }
}

@media (min-width: 640px) {
    .filters { grid-template-columns: repeat(2, 1fr); }
    .item-row { grid-template-columns: 2fr 1fr 1.4fr; }
    .item-row .item-product { grid-column: auto; }
    .details-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
    .filters { grid-template-columns: repeat(4, 1fr); }
    .filters .field-wide { grid-column: span 2; }
    .item-row { grid-template-columns: 2.4fr 1fr 1.4fr; }
    .item-foot { grid-column: 1 / -1; }
}

.panel-link { margin: -2px 0 6px; font-size: .9375rem; }

/* =====================================================================
   Tahap 3: kasir dan struk
   ===================================================================== */

/* Atribut hidden harus selalu menang atas display bawaan komponen. */
[hidden] { display: none !important; }

.input-lg { min-height: 54px; font-size: 1.125rem; }
.input-sm { min-height: 40px; max-width: 150px; text-align: right; }

.pos { display: grid; grid-template-columns: 1fr; gap: 16px; padding-bottom: 76px; }
.pos-status { min-height: 1.5em; margin-top: 6px; color: var(--muted); font-size: .9375rem; }

.pos-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pos-result {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 64px; padding: 10px 14px; text-align: left;
    background: var(--surface); color: inherit; border: 1px solid var(--border); border-radius: 10px;
    font: inherit; cursor: pointer;
}
.pos-result:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.pos-result:disabled { opacity: .65; cursor: not-allowed; }
.pos-result-main { display: flex; flex-direction: column; min-width: 0; }
.pos-result-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.pos-add { color: var(--primary); font-weight: 700; font-size: .875rem; }
.pos-noresult { padding: 12px 4px; color: var(--muted); }

.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-item {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px;
    padding: 12px 0; border-top: 1px solid var(--border);
}
.cart-main { display: flex; flex-direction: column; min-width: 0; }
.cart-name { overflow-wrap: anywhere; }
.cart-qty { display: flex; align-items: center; gap: 4px; }
.qty-btn {
    width: 44px; height: 44px; flex: none; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.qty-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.qty-input {
    width: 64px; height: 44px; padding: 0 4px; text-align: center; font: inherit; font-size: 1.0625rem; font-weight: 700;
    color: var(--text); background: var(--surface); border: 1px solid #8a9890; border-radius: 10px;
}
.cart-line { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.pos-summary { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.pos-discount dd { margin: 0; }
.pos-total {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    margin: 12px 0; padding: 14px 16px; background: var(--primary-soft); border-radius: 12px;
}
.pos-total span { font-weight: 700; }
.pos-total strong { font-size: 2rem; font-weight: 800; color: var(--primary-hover); overflow-wrap: anywhere; }

.pos-pay { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.pos-pay legend { margin-bottom: 8px; padding: 0; font-weight: 700; }
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin-bottom: 12px; }
.segmented label { position: relative; display: block; }
.segmented input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented span {
    display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 8px;
    border: 1px solid #8a9890; border-radius: 10px; background: var(--surface); font-weight: 600;
}
.segmented input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.quick-amounts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.pos-change { margin-top: 6px; font-size: 1.25rem; font-weight: 800; }
.pos-change.is-short { color: var(--danger); }
.pos-problem { margin: 8px 0 0; color: var(--danger); font-weight: 600; }
.pos-actions {
    display: flex; flex-direction: column; align-items: stretch; gap: 14px;
    margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--border);
}
.pos-actions .btn-sm { align-self: center; }

/* Ringkasan keranjang yang selalu terlihat di HP, tepat di atas menu bawah */
.pos-bar {
    position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 25;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; background: var(--primary); color: #fff; border-radius: 14px;
    text-decoration: none; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
.pos-bar > span:first-child { display: flex; align-items: center; gap: 8px; }
.pos-bar strong { font-size: 1.125rem; }
.pos-bar-go { font-size: .875rem; opacity: .95; }

/* Struk */
.change-banner {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px;
    background: var(--success-soft); border: 1px solid #b9dfc7; border-radius: 12px; color: var(--success); font-weight: 700;
}
.change-banner strong { font-size: 2.25rem; font-weight: 800; }

.receipt {
    width: 100%; max-width: 400px; margin: 0 auto; padding: 20px 18px;
    background: #fff; color: #111; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
    font-family: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace; font-size: .9375rem;
}
.receipt.is-void { opacity: .7; }
.receipt-head { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed #777; text-align: center; }
.receipt-head h2 { font-size: 1.125rem; }
.receipt-void-mark { margin-top: 6px; font-weight: 800; }
.receipt-meta, .receipt-totals { display: grid; gap: 2px; margin: 0; }
.receipt-meta { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed #777; }
.receipt-meta > div, .receipt-totals > div { display: flex; justify-content: space-between; gap: 12px; }
.receipt-meta dd, .receipt-totals dd { margin: 0; text-align: right; }
.receipt-items { list-style: none; margin: 0; padding: 0 0 10px; border-bottom: 1px dashed #777; }
.receipt-items li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 5px 0; }
.receipt-name { grid-column: 1 / -1; font-weight: 700; overflow-wrap: anywhere; }
.receipt-calc { color: #444; }
.receipt-line { text-align: right; }
.receipt-totals { margin-top: 10px; }
.receipt-grand { margin-top: 4px; padding-top: 4px; border-top: 1px solid #111; font-size: 1.125rem; font-weight: 800; }
.receipt-foot { margin-top: 14px; padding-top: 10px; border-top: 1px dashed #777; text-align: center; }

@media (min-width: 900px) {
    .pos { grid-template-columns: minmax(0, 1fr) 430px; align-items: start; padding-bottom: 0; }
    .pos-cart { position: sticky; top: calc(var(--topbar-h) + 16px); }
    .pos-bar { display: none !important; }
    .cart-item { grid-template-columns: 1fr auto auto; }
    .cart-line { grid-column: auto; flex-direction: column; align-items: flex-end; }
}

/* Cetak: hanya struk, lebar kertas termal 80 mm. */
@page { margin: 6mm; }
@media print {
    body { background: #fff; }
    .topbar, .nav, .no-print, .skip-link, .alert, .pager { display: none !important; }
    .main { margin: 0 !important; padding: 0 !important; }
    .container { max-width: none; gap: 0; }
    .receipt { max-width: 80mm; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; opacity: 1; }
}

/* =====================================================================
   Tahap 4: keuangan dan laporan
   ===================================================================== */

.presets { display: flex; flex-wrap: wrap; gap: 4px; }
.table tfoot td { border-top: 2px solid var(--border); background: #f0f4f2; font-weight: 700; }
.table tfoot tr:first-child td { border-top: 2px solid var(--border); }

.cash-balance {
    display: flex; flex-direction: column; gap: 4px; padding: 18px 20px;
    background: var(--success-soft); border: 1px solid #b9dfc7; border-radius: var(--radius);
}
.cash-balance-label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--success); }
.cash-balance-value { font-size: 2.25rem; font-weight: 800; color: var(--primary-hover); overflow-wrap: anywhere; }
.cash-balance.is-negative { background: var(--danger-soft); border-color: #f2bcb8; }
.cash-balance.is-negative .cash-balance-label, .cash-balance.is-negative .cash-balance-value { color: var(--danger); }

.statement dt { flex: 1; }
.summary-total.is-negative dd, .summary-total.is-negative dt { color: var(--danger); }
.summary-list dt a { font-weight: 600; }

.receipt-photo { display: block; max-width: 100%; max-height: 480px; border: 1px solid var(--border); border-radius: 10px; }

@media (max-width: 639px) {
    .table-cards tfoot { display: block; }
    .table-cards tfoot tr { display: block; padding: 12px 16px; border-top: 2px solid var(--border); background: #f0f4f2; }
}

@media print {
    .filters, .presets, .head-actions, .back-link { display: none !important; }
    .panel { box-shadow: none; border-color: #999; break-inside: avoid; }
    .table thead th { background: #eee !important; }
}

/* Grafik omzet dashboard (SVG dari server). Satu seri; grid dan sumbu dibuat recessive. */
.chart { display: block; width: 100%; height: auto; max-height: 260px; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-bar { fill: var(--primary); opacity: .55; }
.chart-bar.is-today { opacity: 1; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { opacity: 1; }
.chart-hit { fill: transparent; }
.chart-label, .chart-sub { fill: var(--muted); font-size: 13px; }
.chart-label.is-today { fill: var(--text); font-weight: 700; }
.chart-sub { font-size: 11px; }
.chart-value { fill: var(--text); font-size: 13px; font-weight: 700; }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; color: var(--primary); }

/* Batch & kedaluwarsa per baris pembelian */
.item-batch { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .item-batch { grid-template-columns: 1fr; } }

/* Stok opname */
.opname-product { padding: 8px 16px 16px; border-top: 1px solid var(--border); }
.opname-product h3 { font-size: 1rem; margin: 12px 0 6px; }
.opname-new td { background: var(--primary-soft); }

/* Utang pemasok */
.inline-void { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.inline-void .input { max-width: 220px; }
