:root {
    --bs-primary: #16a34a;
    --bs-primary-rgb: 22, 163, 74;
    --sidebar-width: 260px;
    --sidebar-bg: #0f3d24;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(255, 255, 255, 0.14);
    --content-bg: #f4f7f5;
    --card-radius: 14px;
    --text-muted: #64748b;
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--content-bg);
    color: #1e293b;
    font-size: 0.95rem;
}

/* ─── Sidebar ─── */
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #0f3d24 0%, #14532d 100%);
    color: #ecfdf5;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1040;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.sidebar-brand-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    color: #fff;
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-section {
    padding: 1rem 1rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-nav { padding: 0.25rem 0.75rem 1rem; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 2px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 1.35rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 #4ade80;
}

.sidebar-nav .nav-link.sub {
    padding-left: 2.5rem;
    font-size: 0.85rem;
    font-weight: 450;
}

.sidebar-nav button.nav-link {
    color: rgba(255, 255, 255, 0.82);
}

.sidebar-nav button.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
    background: #22c55e;
    color: #052e16;
    border-radius: 6px;
    font-weight: 700;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #22c55e;
    color: #052e16;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ─── Main area ─── */
.app-wrapper { min-height: 100vh; }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-topbar-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

@media (max-width: 991.98px) {
    .app-content { padding: 1rem; }
}

/* ─── Page header ─── */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

/* ─── Cards ─── */
.card {
    border: 1px solid #e8eeeb;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(15, 61, 36, 0.04);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eef2f0;
    font-weight: 600;
    padding: 0.9rem 1.15rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

.card-header-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─── Stat cards ─── */
.stat-card {
    border: none;
    border-radius: var(--card-radius);
    overflow: hidden;
    height: 100%;
}

.stat-card .card-body {
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-card-icon.green { background: #dcfce7; color: #16a34a; }
.stat-card-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card-icon.amber { background: #fef3c7; color: #d97706; }
.stat-card-icon.teal { background: #ccfbf1; color: #0d9488; }

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.stat-card-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.stat-card-value.sm { font-size: 1.1rem; }

/* ─── Quick actions ─── */
.quick-action {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.quick-action:hover {
    border-color: #86efac;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.1);
    color: inherit;
    transform: translateY(-1px);
}

.quick-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #dcfce7;
    color: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.quick-action-title { font-weight: 600; font-size: 0.95rem; }
.quick-action-desc { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* ─── Tables ─── */
.table { font-size: 0.9rem; }
.table thead th {
    background: #f8faf9;
    color: #475569;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
}
.table tbody td { padding: 0.85rem 1rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fdf9; }

.rekap-sesi-table {
    table-layout: fixed;
    width: 100%;
}

.rekap-sesi-table .rekap-col-no { width: 3.5rem; }
.rekap-sesi-table .rekap-col-rtrw { width: 5.5rem; }
.rekap-sesi-table .rekap-col-berat { width: 7.5rem; }
.rekap-sesi-table .rekap-col-nilai { width: 9rem; }

.rekap-sesi-table .rekap-num {
    font-variant-numeric: tabular-nums;
}

.col-berat {
    text-align: center;
}

.col-uang {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.rekap-sesi-table .rekap-sesi-sum-label {
    text-align: center;
}

.rekap-sesi-table .rekap-sesi-subtotal-row td,
.rekap-sesi-table .rekap-sesi-total-row td {
    border-top: 1px solid #dee2e6;
}

.rekap-sesi-table .rekap-sesi-total-row td {
    border-top-width: 2px;
}

.rekap-sesi-table .rekap-sesi-total-gap {
    padding: 0;
    border-top: none !important;
}

/* ─── Buttons ─── */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* btn-success — solid hijau */
.btn-success {
    --bs-btn-bg: #16a34a;
    --bs-btn-border-color: #16a34a;
    --bs-btn-hover-bg: #15803d;
    --bs-btn-hover-border-color: #15803d;
}
.btn-success:hover,
.btn-success:focus-visible {
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

/* btn-outline-success — Detail, Kelola Harga, Ubah Data */
.btn-outline-success {
    --bs-btn-color: #16a34a;
    --bs-btn-border-color: #4ade80;   /* border lebih tegas dari #bbf7d0 */
    --bs-btn-hover-bg: #16a34a;       /* hover → solid hijau */
    --bs-btn-hover-border-color: #15803d;
    --bs-btn-hover-color: #fff;
}
.btn-outline-success:hover,
.btn-outline-success:focus-visible {
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.28);
}

/* btn-outline-secondary — Kembali, Filter */
.btn-outline-secondary {
    --bs-btn-color: #475569;
    --bs-btn-border-color: #94a3b8;   /* border lebih tegas */
    --bs-btn-hover-bg: #475569;       /* hover → solid slate */
    --bs-btn-hover-border-color: #334155;
    --bs-btn-hover-color: #fff;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
    box-shadow: 0 4px 12px rgba(71, 85, 105, 0.22);
}

/* btn-outline-danger — Nonaktifkan, Hapus */
.btn-outline-danger {
    --bs-btn-color: #dc2626;
    --bs-btn-border-color: #fca5a5;   /* border lebih tegas */
    --bs-btn-hover-bg: #dc2626;       /* hover → solid merah */
    --bs-btn-hover-border-color: #b91c1c;
    --bs-btn-hover-color: #fff;
}
.btn-outline-danger:hover,
.btn-outline-danger:focus-visible {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28);
}

/* btn-light border — Ubah, Kembali: hanya tambah shadow saat hover, warna tetap default Bootstrap */
.btn-light:hover,
.btn-light:focus-visible {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Export Excel / PDF — warna lebih tegas + hover solid */
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    border-width: 1.5px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-export-excel {
    --bs-btn-color: #15803d;
    --bs-btn-bg: #ecfdf5;
    --bs-btn-border-color: #16a34a;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #16a34a;
    --bs-btn-hover-border-color: #15803d;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #15803d;
    --bs-btn-active-border-color: #166534;
    --bs-btn-disabled-color: #15803d;
    --bs-btn-disabled-bg: #ecfdf5;
    --bs-btn-disabled-border-color: #86efac;
}

.btn-export-excel:hover,
.btn-export-excel:focus-visible {
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
}

.btn-export-pdf {
    --bs-btn-color: #b91c1c;
    --bs-btn-bg: #fef2f2;
    --bs-btn-border-color: #dc2626;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #dc2626;
    --bs-btn-hover-border-color: #b91c1c;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #b91c1c;
    --bs-btn-active-border-color: #991b1b;
    --bs-btn-disabled-color: #b91c1c;
    --bs-btn-disabled-bg: #fef2f2;
    --bs-btn-disabled-border-color: #fca5a5;
}

.btn-export-pdf:hover,
.btn-export-pdf:focus-visible {
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}

/* ─── Forms ─── */
.form-control, .form-select {
    border-radius: 10px;
    border-color: #d1ddd6;
    padding: 0.55rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: #86efac;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.form-label { font-weight: 600; font-size: 0.875rem; color: #334155; }

/* ─── Badges ─── */
.badge { font-weight: 600; border-radius: 8px; padding: 0.4em 0.65em; }

/* ─── Alerts ─── */
.alert { border-radius: 12px; border: none; }

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; opacity: 0.35; display: block; margin-bottom: 0.75rem; }

/* ─── Login page ─── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #0f3d24 0%, #166534 50%, #14532d 100%);
}

.auth-panel-left {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #fff;
}

@media (min-width: 992px) {
    .auth-panel-left { display: flex; }
}

.auth-panel-right {
    width: 100%;
    max-width: 480px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

@media (min-width: 992px) {
    .auth-panel-right {
        max-width: 520px;
        border-radius: 24px 0 0 24px;
        min-height: 100vh;
        box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
    }
    .auth-wrapper { padding: 0; }
}

.auth-brand-icon {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

/* ─── Offcanvas mobile sidebar ─── */
.offcanvas-sidebar {
    background: linear-gradient(180deg, #0f3d24 0%, #14532d 100%);
    color: #fff;
    width: var(--sidebar-width) !important;
}

.offcanvas-sidebar .btn-close {
    filter: invert(1);
    opacity: 0.7;
}

/* ─── Filter bar ─── */
.filter-bar {
    background: #fff;
    border: 1px solid #e8eeeb;
    border-radius: 12px;
    padding: 1rem 1.15rem;
    margin-bottom: 1.25rem;
}

.filter-bar .form-select {
    min-width: 220px;
    width: 100%;
    max-width: 360px;
    padding-right: 2.5rem;
    background-position: right 0.75rem center;
}

.filter-bar .row .form-select {
    max-width: 100%;
}

/* ─── Mobile polish ─── */
@media (max-width: 991.98px) {
    .app-topbar {
        padding: 0.65rem 0.85rem;
        gap: 0.65rem;
    }

    .app-topbar-title {
        font-size: 0.98rem;
        line-height: 1.25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
        flex: 1;
    }

    .app-content {
        padding: 0.85rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .page-subtitle {
        font-size: 0.85rem;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .offcanvas-sidebar {
        width: min(88vw, 300px) !important;
    }

    .stat-card .card-body {
        padding: 1rem;
        gap: 0.75rem;
    }

    .stat-card-icon {
        width: 42px;
        height: 42px;
        font-size: 1.15rem;
    }

    .stat-card-value {
        font-size: 1.15rem;
        word-break: break-word;
    }

    .stat-card-value.sm {
        font-size: 0.98rem;
    }

    .card-header {
        padding: 0.8rem 0.95rem;
        font-size: 0.92rem;
    }

    .card-body {
        padding: 0.95rem;
    }

    .quick-action {
        padding: 0.85rem 0.95rem;
        gap: 0.75rem;
    }

    .quick-action-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .filter-bar {
        padding: 0.85rem;
    }

    .filter-bar .form-select,
    .filter-bar .form-control {
        min-width: 0;
        max-width: 100%;
    }

    .filter-bar .btn {
        width: 100%;
    }

    .filter-bar .col-auto {
        width: 100%;
    }

    .filter-bar .col-auto.d-flex {
        display: flex !important;
        flex-direction: column;
    }

    .table {
        font-size: 0.82rem;
    }

    .table thead th {
        font-size: 0.7rem;
        padding: 0.6rem 0.65rem;
        white-space: nowrap;
    }

    .table tbody td {
        padding: 0.65rem;
    }

    .table-responsive {
        margin: 0 -0.15rem;
        -webkit-overflow-scrolling: touch;
    }

    .rekap-sesi-table {
        table-layout: auto;
        min-width: 560px;
    }

    .rekap-sesi-table .rekap-col-no,
    .rekap-sesi-table .rekap-col-rtrw,
    .rekap-sesi-table .rekap-col-berat,
    .rekap-sesi-table .rekap-col-nilai {
        width: auto;
    }

    .empty-state {
        padding: 1.75rem 1rem;
    }

    .empty-state i {
        font-size: 2rem;
    }

    /* Cegah zoom otomatis di iOS saat fokus input */
    .form-control,
    .form-select {
        font-size: 16px;
    }

    .auth-wrapper {
        background: #fff;
    }

    .auth-panel-right {
        max-width: none;
        min-height: 100vh;
        padding: 1.5rem 1.15rem;
        box-shadow: none;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 0.75rem;
    }

    .btn {
        padding: 0.55rem 0.85rem;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .sidebar-nav .nav-link {
        padding: 0.7rem 0.85rem;
    }
}
