/* Tema aplikasi, mengacu pada desain Figma (hijau). Warna diatur lewat variabel di bawah. */
:root {
    --hijau-gelap: #263f2b;
    --hijau: #3a8049;
    --hijau-hover: #2f6a3c;
    --hijau-muda: #edf5eb;
    --teks: #263d2a;
    --abu: #6b7a6e;
    --garis: #dfe7dd;
    --kepala-tabel: #f4f6f3;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--teks);
    background: var(--hijau-muda);
}

/* ---------- Tombol dan form (menimpa warna bawaan Bootstrap) ---------- */
.btn-primary {
    --bs-btn-bg: var(--hijau);
    --bs-btn-border-color: var(--hijau);
    --bs-btn-hover-bg: var(--hijau-hover);
    --bs-btn-hover-border-color: var(--hijau-hover);
    --bs-btn-active-bg: var(--hijau-hover);
    --bs-btn-active-border-color: var(--hijau-hover);
    --bs-btn-disabled-bg: var(--hijau);
    --bs-btn-disabled-border-color: var(--hijau);
    font-weight: 500;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--hijau);
    box-shadow: 0 0 0 .2rem rgba(58, 128, 73, .2);
}
.badge.bg-success { background-color: var(--hijau) !important; }

/* ---------- Tata letak aplikasi ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--hijau-gelap);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 12px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .merek { padding: 0 8px; margin-bottom: 24px; }
.sidebar .merek .nama {
    font-weight: 700;
    font-size: .95rem;
    text-transform: uppercase;
    line-height: 1.3;
    margin-top: 14px;
}
.logo-bulat {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--hijau-muda);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}
.sidebar .label-menu {
    font-size: .65rem;
    letter-spacing: .04em;
    color: #9db3a0;
    padding: 0 8px;
    margin-bottom: 8px;
}
.sidebar .menu { list-style: none; padding: 0; margin: 0; flex-grow: 1; }
.sidebar .menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: #c9d8cb;
    text-decoration: none;
    font-size: .875rem;
}
.sidebar .menu a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar .menu a.aktif { background: var(--hijau); color: #fff; }
.sidebar .menu a.aktif::after {
    content: '';
    margin-left: auto;
    width: 3px;
    height: 16px;
    background: #fff;
    border-radius: 2px;
}
.sidebar .keluar {
    border-top: 1px solid rgba(255, 255, 255, .15);
    padding-top: 14px;
}
.sidebar .keluar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #c9d8cb;
    text-decoration: none;
    font-size: .875rem;
    border-radius: 8px;
}
.sidebar .keluar a:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.utama { flex-grow: 1; min-width: 0; }

.topbar {
    background: #fff;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--garis);
}
.topbar .remah { font-size: .72rem; color: var(--abu); }
.topbar h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.topbar .pengguna { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--hijau-muda);
    color: var(--hijau);
    font-weight: 600;
    font-size: .8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.topbar .pengguna .nama { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.topbar .pengguna .peran { font-size: .68rem; color: var(--abu); line-height: 1.2; }

.isi { padding: 24px 28px; }

/* ---------- Tab, kartu, tabel ---------- */
.tab-master { border-bottom: 1px solid var(--garis); margin-bottom: 18px; }
.tab-master .nav-link {
    color: var(--abu);
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    font-size: .85rem;
    padding: 8px 18px;
}
.tab-master .nav-link:hover { color: var(--hijau); }
.tab-master .nav-link.active {
    color: var(--hijau);
    background: #fff;
    border-bottom-color: var(--hijau);
    font-weight: 500;
}

.kartu {
    background: #fff;
    border: 1px solid var(--garis);
    border-radius: 14px;
    overflow: hidden;
}
.kartu-kepala {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
}
.kartu-kepala h6 { margin: 0; font-weight: 600; font-size: 1rem; }
.kartu .catatan {
    font-size: .72rem;
    color: var(--abu);
    padding: 12px 20px;
    border-top: 1px solid var(--garis);
    margin: 0;
}
.tabel-master { margin: 0; }
.tabel-master th {
    background: var(--kepala-tabel);
    font-size: .78rem;
    font-weight: 600;
    color: var(--teks);
    padding: 10px 20px;
    border: 0;
}
.tabel-master td {
    padding: 14px 20px;
    font-size: .82rem;
    border-color: var(--garis);
}

/* ---------- Halaman masuk ---------- */
body.halaman-login {
    background: var(--hijau-muda);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.kartu-login {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(38, 63, 43, .10);
    padding: 36px 32px 32px;
    width: 100%;
    max-width: 400px;
}
.kartu-login .logo-bulat { width: 52px; height: 52px; margin: 0 auto 16px; font-size: 1.5rem; }
.kartu-login h1 { font-size: 1.3rem; font-weight: 700; text-align: center; margin: 0 0 6px; }
.kartu-login .sub { font-size: .78rem; color: var(--abu); text-align: center; margin-bottom: 24px; }
.kartu-login label { font-size: .8rem; font-weight: 500; margin-bottom: 6px; }
.input-ikon { position: relative; margin-bottom: 16px; }
.input-ikon .bi-ikon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--abu);
}
.input-ikon .form-control { padding-left: 38px; padding-right: 40px; background: #fcfcfc; height: 42px; font-size: .85rem; }
.input-ikon .tombol-mata {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--abu);
    padding: 4px 6px;
}
.kartu-login .btn-primary { height: 42px; margin-top: 4px; }

/* ---------- Kolom aksi di tabel (Ubah | Hapus) ---------- */
.aksi { white-space: nowrap; }
.aksi form { display: inline; }
.aksi .link-aksi {
    background: none;
    border: 0;
    padding: 0;
    color: var(--hijau);
    font-size: .82rem;
    text-decoration: none;
    cursor: pointer;
}
.aksi .link-aksi:hover { text-decoration: underline; }
.aksi .pemisah { color: #b9c7b9; margin: 0 6px; }

/* ---------- Dashboard ---------- */
.judul-ringkasan h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.judul-ringkasan p { font-size: .8rem; color: var(--abu); margin: 2px 0 16px; }

.kartu-stat {
    background: #fff;
    border: 1px solid var(--garis);
    border-radius: 14px;
    padding: 16px 18px;
    height: 100%;
}
.kartu-stat .stat-atas {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    margin-bottom: 10px;
}
.kartu-stat .stat-ikon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--hijau-muda);
    color: var(--hijau);
    display: flex;
    align-items: center;
    justify-content: center;
}
.kartu-stat .stat-nilai { font-size: 1.55rem; font-weight: 700; }
.kartu-stat .stat-ket { font-size: .72rem; color: var(--abu); margin-top: 6px; }
.kartu-stat.bahaya .stat-nilai,
.kartu-stat.bahaya .stat-ket { color: #b7414f; }
.kartu-stat.bahaya .stat-ikon { background: #fbe9ea; color: #b7414f; }

.kartu-isi { padding: 18px 20px; height: 100%; }
.kartu-isi h6 { font-weight: 600; margin: 0 0 2px; }
.kartu-isi .sub { font-size: .75rem; color: var(--abu); margin-bottom: 14px; }
.kartu-isi .ket-bawah { font-size: .72rem; color: var(--abu); margin: 6px 0 0; }
.kartu-isi .ket-bawah.merah { color: #b7414f; }
.kartu-isi .ket-bawah.hijau { color: var(--hijau); }
.garis-atas { border-top: 1px solid var(--garis); margin-top: 14px; padding-top: 10px; }

.peringatan-item {
    border: 1px solid var(--garis);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.peringatan-item.menipis { background: #fcf1f1; border-color: #f0cfd1; }
.peringatan-item .baris { display: flex; justify-content: space-between; align-items: center; }
.peringatan-item .nama { font-size: .8rem; font-weight: 600; }
.peringatan-item .stok { font-size: .95rem; font-weight: 600; margin-top: 4px; }
.peringatan-item .min { font-size: .7rem; color: var(--abu); }
.peringatan-item.menipis .stok { color: #b7414f; }
.chip { font-size: .66rem; padding: 2px 10px; border-radius: 999px; }
.chip.aman { background: #e3efe2; color: var(--hijau); }
.chip.menipis { background: #f9dcdd; color: #b7414f; }
.bar-stok { height: 5px; border-radius: 3px; background: #e6ece5; margin-top: 8px; overflow: hidden; }
.bar-stok > span { display: block; height: 100%; background: var(--hijau); }
.peringatan-item.menipis .bar-stok > span { background: #b7414f; }
.lencana-jumlah {
    background: #f9dcdd;
    color: #b7414f;
    font-size: .7rem;
    font-weight: 600;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Laporan ---------- */
.kertas { padding: 24px 28px; }
.kertas-kepala { text-align: center; margin-bottom: 18px; }
.kertas-kepala .nama-usaha { font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--abu); }
.kertas-kepala h5 { font-weight: 700; margin: 4px 0; }
.kertas-kepala .periode { font-size: .8rem; color: var(--abu); }
.kertas .sub-bagian { font-size: .9rem; font-weight: 600; margin: 20px 0 8px; }
.kertas table { margin-bottom: 6px; }
.kertas table th,
.kertas table td { font-size: .8rem; padding: 8px 10px; }
.kertas table th { background: var(--kepala-tabel); }
.kertas tfoot td { font-weight: 600; background: var(--kepala-tabel); }
.kertas .catatan-laporan { font-size: .78rem; margin: 4px 0 0; }
.kertas .info-cetak { font-size: .7rem; color: var(--abu); margin: 22px 0 0; }

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .tidak-cetak { display: none !important; }
    .layout { display: block; }
    .isi { padding: 0; }
    .kartu { border: 0; border-radius: 0; }
    .kertas { padding: 0; }
}
