:root {
    --bs-primary: #2e9e34;
    --bs-primary-rgb: 46, 158, 52;
    --bs-link-color: #1f7a27;
    --bs-link-hover-color: #064e1f;
    --ik-dark: #064e1f;
    --ik-soft: #eaf7ea;
}

body { background: #f4f8f4; }

.btn-primary {
    --bs-btn-bg: #2e9e34; --bs-btn-border-color: #2e9e34;
    --bs-btn-hover-bg: #27872c; --bs-btn-hover-border-color: #27872c;
    --bs-btn-active-bg: #1f7a27; --bs-btn-active-border-color: #1f7a27;
    --bs-btn-disabled-bg: #2e9e34; --bs-btn-disabled-border-color: #2e9e34;
}
.btn-outline-primary {
    --bs-btn-color: #1f7a27; --bs-btn-border-color: #2e9e34;
    --bs-btn-hover-bg: #2e9e34; --bs-btn-hover-border-color: #2e9e34;
    --bs-btn-active-bg: #2e9e34; --bs-btn-active-border-color: #2e9e34;
    --bs-btn-disabled-color: #2e9e34; --bs-btn-disabled-border-color: #2e9e34;
}
.btn-lg { min-height: 52px; font-weight: 600; border-radius: .8rem; }
.form-control-lg, .form-select-lg, .input-group-lg > .form-control, .input-group-lg > .btn {
    min-height: 52px;
}
.form-control-lg, .form-select-lg { border-radius: .8rem; }
.form-control:focus, .form-select:focus {
    border-color: #2e9e34;
    box-shadow: 0 0 0 .25rem rgba(46, 158, 52, .2);
}

/* ---------- Auth ---------- */
.auth-body { background: linear-gradient(180deg, #eaf7ea 0%, #f4f8f4 60%); min-height: 100vh; }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.auth-card { background: #fff; border-radius: 1.25rem; padding: 1.5rem 1.25rem; box-shadow: 0 8px 28px rgba(6, 78, 31, .1); }
.auth-logo { width: 200px; max-width: 70%; height: auto; }

/* ---------- App shell ---------- */
.app-sidebar { --bs-offcanvas-width: 280px; }
.app-sidebar .offcanvas-body { padding: 1rem; }
.side-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1rem; margin-bottom: .25rem;
    color: #263; text-decoration: none; border-radius: .8rem; font-weight: 600;
}
.side-link i { font-size: 1.25rem; }
.side-link:hover { background: var(--ik-soft); color: var(--ik-dark); }
.side-link.active { background: #2e9e34; color: #fff; }
.side-link.disabled { opacity: .55; cursor: default; }
.side-link.disabled:hover { background: transparent; color: #263; }

.app-main { min-width: 0; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1rem; background: #fff; border-bottom: 1px solid #e3ece3;
}
.app-content { padding: 1rem 1rem 6rem; max-width: 1100px; }

@media (min-width: 992px) {
    .app-sidebar { width: 280px; flex-shrink: 0; min-height: 100vh; background: #fff; border-right: 1px solid #e3ece3; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
    .app-content { padding: 1.5rem 2rem 2rem; }
}

/* ---------- Bottom nav (HP) ---------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; background: #fff; border-top: 1px solid #e3ece3;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav > a, .bottom-nav > span, .bottom-nav > button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: .55rem 0; min-height: 60px;
    font-size: .72rem; font-weight: 600; color: #6b7a6b; text-decoration: none;
    background: transparent; border: 0;
}
.bottom-nav i { font-size: 1.4rem; line-height: 1; }
.bottom-nav .active { color: #2e9e34; }
.bottom-nav .disabled { opacity: .45; }

/* ---------- Kartu & statistik ---------- */
.stat-card { background: #fff; border-radius: 1rem; padding: 1rem; box-shadow: 0 2px 10px rgba(6, 78, 31, .06); height: 100%; }
.stat-label { color: #5a6b5a; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.stat-label i { color: #2e9e34; margin-right: .25rem; }
.stat-value { font-size: 1.2rem; font-weight: 800; color: var(--ik-dark); word-break: break-word; }
.stat-note { font-size: .72rem; color: #7b8a7b; margin-top: .15rem; }

/* ---------- Grafik batang ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: .4rem; height: 190px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-value { font-size: .65rem; color: #5a6b5a; height: 1.1rem; white-space: nowrap; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: 70%; max-width: 38px; background: linear-gradient(180deg, #3aaa35, #2e9e34); border-radius: .4rem .4rem 0 0; min-height: 3px; }
.bar-label { font-size: .75rem; font-weight: 600; color: #4a5a4a; margin-top: .3rem; }

/* ---------- Daftar transaksi ---------- */
.trx-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid #edf3ed; }
.trx-row:last-child { border-bottom: 0; }
.trx-icon { width: 42px; height: 42px; border-radius: .8rem; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.min-w-0 { min-width: 0; }

/* ---------- Tahap 2: Produk ---------- */
.form-narrow { max-width: 640px; }

.product-row {
    display: flex; align-items: flex-start; gap: .5rem;
    background: #fff; border-radius: 1rem; padding: .85rem .85rem .85rem 1rem;
    box-shadow: 0 2px 10px rgba(6, 78, 31, .06);
}
.product-row.is-inactive { opacity: .65; }
.product-prices { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .85rem; }
.product-prices small { color: #7b8a7b; font-size: .7rem; text-transform: uppercase; letter-spacing: .02em; }

.margin-info { font-size: .85rem; font-weight: 600; min-height: 1.2rem; }
.margin-info.ok { color: #1f7a27; }
.margin-info.bad { color: #dc3545; }

.stock-box { background: var(--ik-soft); border-radius: 1rem; padding: 1rem; }
.stock-box .form-switch .form-check-input { width: 3em; height: 1.5em; }
.stock-box .form-check-input:checked { background-color: #2e9e34; border-color: #2e9e34; }

.btn-check:checked + .btn-outline-primary { background: #2e9e34; border-color: #2e9e34; color: #fff; }

.category-item { padding-bottom: .75rem; border-bottom: 1px solid #edf3ed; }
.category-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------- Tahap 3: Penjualan / Kasir ---------- */
.chip-row { scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .btn { white-space: nowrap; border-radius: 2rem; }

.pos-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 576px) { .pos-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .pos-grid { grid-template-columns: repeat(4, 1fr); } }

.pos-tile {
    display: flex; flex-direction: column; justify-content: space-between; text-align: left;
    min-height: 92px; padding: .65rem .75rem; border: 1px solid #dfeadf; border-radius: .9rem;
    background: #fff; color: #1e2b1e; position: relative;
}
.pos-tile:active:not(:disabled) { background: var(--ik-soft); border-color: #2e9e34; }
.pos-tile:disabled { opacity: .5; }
.pos-tile .pt-name { font-weight: 700; font-size: .92rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pos-tile .pt-price { color: #1f7a27; font-weight: 800; margin-top: .25rem; }
.pos-tile .pt-stock { font-size: .72rem; color: #7b8a7b; }
.pos-tile .pt-qty {
    position: absolute; top: -.4rem; right: -.4rem; min-width: 1.6rem; height: 1.6rem; padding: 0 .35rem;
    background: #2e9e34; color: #fff; border-radius: 1rem; font-size: .75rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.pos-cart { height: auto; }
@media (min-width: 992px) { .pos-cart { position: sticky; top: 5rem; } }

.cart-item { padding: .6rem 0; border-bottom: 1px solid #edf3ed; }
.cart-item:last-child { border-bottom: 0; }
.cart-item .ci-name { font-weight: 700; }
.cart-item .ci-qty { display: inline-flex; align-items: center; gap: .35rem; }
.cart-item .ci-qty .btn { width: 40px; height: 40px; padding: 0; font-size: 1.1rem; line-height: 1; }
.cart-item .ci-qty input { width: 64px; height: 40px; text-align: center; font-weight: 700; }

.pos-bar {
    position: fixed; left: 0; right: 0; z-index: 1025;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    background: #fff; border-top: 1px solid #e3ece3; padding: .6rem 1rem;
    box-shadow: 0 -4px 14px rgba(6, 78, 31, .08);
}
.pos-page { padding-bottom: 4.5rem; }
@media (min-width: 992px) { .pos-page { padding-bottom: 0; } }

.pos-toast {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 1060;
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
    background: #1e2b1e; color: #fff; padding: .6rem 1rem; border-radius: 2rem; font-size: .85rem; max-width: 90vw;
}

.totals { background: var(--ik-soft); border-radius: .8rem; padding: .75rem 1rem; }
.btn-outline-warning.btn-check:checked + label,
.btn-check:checked + .btn-outline-warning { background: #ffc107; border-color: #ffc107; color: #000; }

/* ---------- Tahap 4: Kas & Pengeluaran ---------- */
.account-card {
    background: #fff; border-radius: 1rem; padding: .9rem 1rem;
    box-shadow: 0 2px 10px rgba(6, 78, 31, .06);
}
.account-card.is-inactive { opacity: .6; }

/* ---------- Tahap 5: Laporan ---------- */
.kv-row { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; }
.kv-row > span:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kv-row.indent { padding-left: 1rem; }
.kv-row.sub { font-weight: 700; }
.kv-row.muted { color: #7b8a7b; font-size: .85rem; }
.kv-row.total { font-weight: 800; border-top: 1px solid #dfeadf; margin-top: .25rem; padding-top: .5rem; }

.report-table th { font-size: .78rem; color: #4a5a4a; white-space: nowrap; }
.report-table td { font-size: .85rem; font-variant-numeric: tabular-nums; }
.report-table tfoot th { border-top: 2px solid #cfe0cf; font-size: .85rem; color: #1e2b1e; }

/* ---------- Tahap 6: sidebar mengecil, mode kasir, langganan ---------- */
@media (min-width: 992px) {
    html.sidebar-collapsed .app-sidebar { width: 76px; }
    html.sidebar-collapsed .app-sidebar .offcanvas-body { padding: .75rem .5rem; }
    html.sidebar-collapsed .app-sidebar img { display: none; }
    html.sidebar-collapsed .side-link { justify-content: center; padding: .85rem 0; }
    html.sidebar-collapsed .side-link span,
    html.sidebar-collapsed .side-link .badge { display: none; }
    html.sidebar-collapsed .app-content { max-width: none; }
}
.app-sidebar, .side-link { transition: width .15s ease; }

.kasir-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem 1rem; background: #fff; border-bottom: 1px solid #e3ece3;
}
.kasir-main { padding: 1rem 1rem 6rem; max-width: 1600px; margin: 0 auto; }
.kasir-body .pos-bar { bottom: env(safe-area-inset-bottom, 0px); }
.kasir-body .pos-toast { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 992px) {
    .kasir-main { padding: 1.25rem 2rem 2rem; }
    .kasir-body .pos-cart { top: 5rem; }
}

.admin-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    padding: .55rem 1rem; background: #fff; border-bottom: 1px solid #e3ece3;
}
.admin-main { padding: 1rem 1rem 3rem; max-width: 1100px; margin: 0 auto; }

.plan-card {
    height: 100%; background: #fff; border: 2px solid #dfeadf; border-radius: 1rem; padding: 1.1rem;
}
.plan-card.is-featured { border-color: #2e9e34; box-shadow: 0 4px 16px rgba(46, 158, 52, .15); }
.bank-box { background: var(--ik-soft); border: 1px dashed #2e9e34; border-radius: .9rem; padding: .85rem 1rem; }
.proof-img { max-width: 100%; max-height: 420px; border-radius: .75rem; border: 1px solid #dfeadf; display: block; }

/* ---------- Tahap 7: Super Admin ---------- */
.hbar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .45rem; font-size: .85rem; }
.hbar-label { flex: 0 0 8.5rem; color: #4a5a4a; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; background: #edf3ed; border-radius: .4rem; height: 1.1rem; overflow: hidden; }
.hbar { height: 100%; background: linear-gradient(90deg, #3aaa35, #2e9e34); border-radius: .4rem; }
.hbar.hbar-money { background: linear-gradient(90deg, #f0b429, #e08e0b); }
.hbar-value { flex: 0 0 2.6rem; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-value.hbar-wide { flex-basis: 4.6rem; }
.stat-card.h-auto { height: auto; }

/* ---------- Tahap 8: foto profil ---------- */
.avatar-xs { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid #dfeadf; }
.avatar-empty { display: flex; align-items: center; justify-content: center; background: var(--ik-soft); color: #2e9e34; font-size: 2.6rem; }
