:root, [data-bs-theme=light] {
  --bs-success: #2d6a4f; --bs-success-rgb: 45, 106, 79;
  --bs-link-color: #2d6a4f; --bs-link-color-rgb: 45, 106, 79; --bs-link-hover-color: #1f4d3a; --bs-link-hover-color-rgb: 31, 77, 58;
  --base: #c3c2b7; --grid: #e6e5df; --muted: #6f6d68;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --f: #d55181; --m: #2a78d6;
}
[data-bs-theme=dark] {
  --bs-success: #3f9a73; --bs-success-rgb: 63, 154, 115;
  --bs-link-color: #6fcaa2; --bs-link-color-rgb: 111, 202, 162; --bs-link-hover-color: #93dcbb; --bs-link-hover-color-rgb: 147, 220, 187;
  --base: #55554f; --grid: #33332f; --muted: #a3a198;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --f: #e87ba4; --m: #6da7ec;
}
[hidden] { display: none !important; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* Warna hijau peternakan menggantikan hijau bawaan Bootstrap */
.btn-success { --bs-btn-bg: var(--bs-success); --bs-btn-border-color: var(--bs-success); --bs-btn-hover-bg: #245a42; --bs-btn-hover-border-color: #245a42; --bs-btn-active-bg: #1f4d3a; --bs-btn-active-border-color: #1f4d3a; --bs-btn-disabled-bg: var(--bs-success); --bs-btn-disabled-border-color: var(--bs-success); }
.btn-outline-success { --bs-btn-color: var(--bs-link-color); --bs-btn-border-color: var(--bs-success); --bs-btn-hover-bg: var(--bs-success); --bs-btn-hover-border-color: var(--bs-success); --bs-btn-active-bg: var(--bs-success); --bs-btn-active-border-color: var(--bs-success); }
.form-control:focus, .form-select:focus { border-color: var(--bs-success); box-shadow: 0 0 0 .2rem rgba(var(--bs-success-rgb), .2); }
.card-success.card-outline { border-top: 3px solid var(--bs-success); }

/* Sidebar */
.app-sidebar { background: linear-gradient(180deg, #16382b 0%, #0f2a20 100%) !important; }
.sidebar-brand { border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-text { color: #fff; font-size: 1.05rem; }
.logo-ikon { display: inline-flex !important; align-items: center; justify-content: center; width: 34px !important; height: 34px !important; max-height: 34px; flex: none; border-radius: 10px; background: linear-gradient(135deg, #52b788, #2d6a4f); color: #fff; font-size: 18px; box-shadow: none !important; }
.sidebar-menu .nav-header { font-size: 11px; letter-spacing: .08em; color: rgba(255,255,255,.45); padding-top: 14px; }
.sidebar-menu .nav-link { color: rgba(255,255,255,.78); border-radius: 8px; }
.sidebar-menu .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar-menu .nav-link.active { background: linear-gradient(90deg, #40916c, #2d6a4f) !important; color: #fff !important; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.nav-badge { font-size: 11px; background-color: rgba(255,255,255,.18) !important; color: #fff !important; }

/* Bilah atas */
#ganti-tema { background: none; border: 0; }
.foto-akun { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #52b788, #2d6a4f); color: #fff; font-size: 13px; font-weight: 700; }
.kepala-halaman { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.remah { font-size: 13px; color: var(--bs-secondary-color); margin-bottom: 2px; }

/* Small box bergradasi */
.small-box { border-radius: 12px; overflow: hidden; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.row > [class*=col-] > .small-box { display: flex; flex-direction: column; height: calc(100% - 1rem); }
.small-box .inner { flex: 1; position: relative; z-index: 1; }
.small-box > .inner h3 { font-weight: 700; font-size: 1.5rem; white-space: nowrap; }
.small-box h3 small { font-size: .9rem; font-weight: 500; }
.small-box .small-box-icon { top: 10px; right: 10px; color: rgba(255,255,255,.14); font-size: 54px; height: 54px; line-height: 1; }
.small-box-footer { display: block; margin-top: auto; z-index: 1; padding: 4px 10px; text-align: center; color: rgba(255,255,255,.92); background: rgba(0,0,0,.14); font-size: 13px; text-decoration: none; position: relative; }
a.small-box-footer:hover { color: #fff; background: rgba(0,0,0,.24); text-decoration: none; }
.kotak-hijau { background: linear-gradient(135deg, #40916c, #1f5c44); }
.kotak-biru { background: linear-gradient(135deg, #3a86d8, #1d5aa6); }
.kotak-jingga { background: linear-gradient(135deg, #d9722f, #a84c15); }
.kotak-ungu { background: linear-gradient(135deg, #7b5fd0, #4f3aa0); }
.kotak-merah { background: linear-gradient(135deg, #d0453f, #982a26); }
.info-box { border-radius: 12px; }
.info-box-icon { border-radius: 10px; }
.info-box-number { font-size: 1.05rem; }
.card { border-radius: 12px; }

/* Filter */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .form-control, .filters .form-select, .filters-inline .form-control, .filters-inline .form-select { width: auto; }
.filters-inline { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.cari-pohon { width: 260px; margin-left: auto; }
.chip { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-secondary-color); font-size: 14px; white-space: nowrap; text-decoration: none; transition: background .15s, color .15s; }
.chip span { opacity: .75; }
.chip:hover { color: var(--bs-body-color); text-decoration: none; border-color: var(--bs-success); }
.chip[aria-current] { background: var(--bs-success); border-color: var(--bs-success); color: #fff; font-weight: 600; }

/* Formulir */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid label, .form-stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--bs-secondary-color); }
.form-grid .form-control, .form-grid .form-select, .form-stack .form-control, .form-stack .form-select { font-weight: 400; font-size: 15px; color: var(--bs-body-color); }
.form-act { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.jk-f { color: var(--f); font-weight: 700; }
.jk-m { color: var(--m); font-weight: 700; }

/* Tabel dan aksi */
th { color: var(--bs-secondary-color); font-weight: 600; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.baris-aksi { white-space: nowrap; text-align: right; }
.baris-aksi form, .riwayat-aksi form { display: inline; }
.baris-aksi a { margin-right: 10px; }
.link-hapus { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--bs-danger); }
.link-hapus:hover { text-decoration: underline; }
.kosong { text-align: center; padding: 48px 20px; color: var(--bs-secondary-color); }
.kosong > i { font-size: 40px; display: block; margin-bottom: 8px; opacity: .6; }
.tempel { position: sticky; top: 76px; }

/* Pohon keturunan */
.hutan { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.pohon { max-width: 100%; min-width: 0; margin-bottom: 0; }
.pohon .card-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.pohon .card-header::after { display: none; }
.pohon .card-tools { margin-left: auto; }
.tree { overflow-x: auto; --garis: var(--base); }
.tree ul { display: flex; justify-content: center; margin: 0; padding: 22px 0 0; list-style: none; position: relative; width: max-content; min-width: 100%; }
.tree > ul { padding-top: 0; }
.tree li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 7px 0; scroll-margin: 80px; }
.tree > ul > li { padding-top: 0; }
.tree li::before, .tree li::after { content: ""; position: absolute; top: 0; width: 50%; height: 22px; border-top: 2px solid var(--garis); }
.tree li::before { right: 50%; }
.tree li::after { left: 50%; border-left: 2px solid var(--garis); }
.tree li:first-child::before, .tree li:last-child::after { border-top: 0; }
.tree li:only-child::before { display: none; }
.tree li:last-child:not(:only-child)::before { border-right: 2px solid var(--garis); }
.tree li:last-child:not(:only-child)::after { display: none; }
.tree li:first-child:not(:only-child)::after { border-radius: 6px 0 0 0; }
.tree li:last-child:not(:only-child)::before { border-radius: 0 6px 0 0; }
.tree > ul > li::before, .tree > ul > li::after { display: none; }
.tree ul ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid var(--garis); }
.tree li.terlipat > ul { display: none; }
.node { width: 172px; padding: 9px 11px; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-top: 3px solid var(--m); border-radius: 10px; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: box-shadow .15s, transform .15s; }
.node:hover { box-shadow: 0 6px 16px rgba(0,0,0,.14); transform: translateY(-1px); }
.node-betina { border-top-color: var(--f); }
.node-dijual, .node-mati { background: var(--bs-tertiary-bg); }
.node-ref a { white-space: nowrap; }
.node-top { display: flex; justify-content: space-between; align-items: baseline; }
.node-kode { font-weight: 700; color: var(--bs-body-color); text-decoration: none; }
.node .badge { font-size: 11px; margin-top: 3px; }
.node-nama { color: var(--bs-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-meta { color: var(--bs-secondary-color); font-size: 12px; }
.node-ref { font-size: 11px; color: var(--bs-secondary-color); margin-top: 4px; }
.node-act { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.btn-lipat { margin-left: auto; }
.btn-mini { font: inherit; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--base); background: transparent; color: var(--bs-secondary-color); cursor: pointer; white-space: nowrap; }
.btn-anak { color: var(--bs-success); border-color: var(--bs-success); }
.btn-anak:hover { background: var(--bs-success-bg-subtle); }
li:target > .node { outline: 3px solid var(--s4, #eda100); outline-offset: 2px; }


dialog { border: 0; border-radius: 14px; background: var(--bs-body-bg); color: var(--bs-body-color); padding: 22px; width: min(540px, calc(100vw - 32px)); box-shadow: 0 16px 48px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(10,25,18,.55); }

/* Detail hewan */
.profil-foto { width: 84px; height: 84px; border-radius: 50%; margin: 4px auto 10px; display: flex; align-items: center; justify-content: center; font-size: 38px; background: var(--bs-tertiary-bg); border: 3px solid var(--m); }
.profil-betina { border-color: var(--f); }
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; border-top: 1px solid var(--bs-border-color); padding-top: 12px; }
.dl dt { color: var(--bs-secondary-color); font-weight: 500; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.riwayat { margin: 0; padding: 0; list-style: none; position: relative; }
.riwayat::before { content: ""; position: absolute; top: 6px; bottom: 6px; left: 15px; width: 2px; background: var(--bs-border-color); }
.riwayat li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.riwayat li:last-child { padding-bottom: 0; }
.riwayat-ikon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; position: relative; }
.riwayat-isi { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--bs-border-color); border-radius: 10px; background: var(--bs-tertiary-bg); }
.riwayat-kepala { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.riwayat-aksi { margin-left: auto; display: flex; gap: 10px; font-size: 13px; }
[data-bs-theme=dark] .riwayat .text-bg-light { background-color: var(--bs-body-bg) !important; color: var(--bs-body-color) !important; }

/* Halaman masuk */
.halaman-masuk { background: radial-gradient(1200px 700px at 20% 10%, #2d6a4f 0%, #16382b 55%, #0c2019 100%) fixed; }
.halaman-masuk .login-logo { color: #fff; }
.logo-besar { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 18px; margin-bottom: 8px; background: linear-gradient(135deg, #52b788, #2d6a4f); font-size: 32px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.login-card-body { border-radius: 12px; }

/* Grafik */
.kas-wadah { container-type: inline-size; }
.sempit-saja { display: none; }
@container (max-width: 520px) { .lebar-saja { display: none; } .sempit-saja { display: block; } }
.chart { display: block; width: 100%; height: auto; }
.grid { stroke: var(--grid); stroke-width: 1; }
.base { stroke: var(--base); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--bs-secondary-color); font-size: 12px; font-weight: 600; }
path.s1 { fill: var(--s1); } path.s2 { fill: var(--s2); } path.s3 { fill: var(--s3); }
.key.s1, .seg.s1 { background: var(--s1); } .key.s2, .seg.s2 { background: var(--s2); } .key.s3, .seg.s3 { background: var(--s3); }
.mark .hit, .pt .hit { fill: transparent; }
.mark:hover path, .mark:focus path { filter: brightness(1.12); }
.mark:focus, .pt:focus { outline: none; }
.line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--s1); stroke: var(--bs-body-bg); stroke-width: 2; }
.xh { stroke: var(--base); stroke-width: 1; opacity: 0; }
.pt:hover .xh, .pt:focus .xh { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--bs-secondary-color); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { width: 11px; height: 11px; border-radius: 3px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: center; font-size: 13px; }
.hbar-l { color: var(--bs-secondary-color); overflow-wrap: anywhere; }
.hbar-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track { display: block; height: 12px; grid-column: 1 / -1; grid-row: 2; }
.hbar-fill { display: block; height: 100%; min-width: 2px; background: var(--s1); border-radius: 0 4px 4px 0; }
.stack { display: flex; gap: 2px; height: 12px; grid-column: 1 / -1; grid-row: 2; justify-self: start; min-width: 0; }
.seg { display: block; min-width: 3px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:hover, .hbar:hover .hbar-fill { filter: brightness(1.12); }
.tabel-data { margin-top: 10px; font-size: 13px; }
.tabel-data summary { cursor: pointer; color: var(--bs-secondary-color); }
.tip { position: fixed; z-index: 2000; pointer-events: none; display: flex; flex-direction: column; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); box-shadow: 0 4px 16px rgba(0,0,0,.18); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.tip span { color: var(--bs-secondary-color); font-size: 12px; }

@media (max-width: 1199px) { .tempel { position: static; } }
@media (max-width: 600px) {
  .bep-angka { font-size: 1.5rem; }
  .form-grid, .form-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
  .filters-inline, .cari-pohon { margin-left: 0; width: 100%; }
  .filters .form-select, .filters .form-control, .filters-inline .form-control, .filters-inline .form-select { width: 100%; }
  .small-box > .inner h3 { font-size: 1.25rem; }
  .small-box .small-box-icon { display: none; }
}

/* Kelola pengguna */
.link-aktif { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--bs-success); }
.baris-mati td { opacity: .55; }

/* Hasil pencarian pohon */
.hasil-kartu { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
a.btn-mini { text-decoration: none; }
.btn-jual { color: var(--bs-primary); border-color: var(--bs-primary); }
.btn-jual:hover { background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }

/* Laporan */
.nol { stroke: var(--bs-secondary-color); stroke-width: 1.5; }
.lr td { padding: .4rem .75rem; }
.lr td:last-child { white-space: nowrap; }
.lr .judul td { font-weight: 600; background: var(--bs-tertiary-bg); }
.lr .anak td:first-child { padding-left: 1.5rem; color: var(--bs-secondary-color); }
.lr .total td { font-weight: 700; border-top: 2px solid var(--bs-border-color); }
.bep-angka { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.bep-status { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.bep-status > i { font-size: 34px; line-height: 1; }
.bep-rinci { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 14px 0 0; }
.bep-rinci dt { font-size: 12px; font-weight: 500; color: var(--bs-secondary-color); }
.bep-rinci dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.small-box > .inner h3.angka-prediksi { font-size: 2rem; white-space: normal; overflow-wrap: anywhere; }
.form-harga th { white-space: nowrap; }
.form-harga .input-group { flex-wrap: nowrap; min-width: 150px; }
.form-harga .form-control { min-width: 0; }
@media print {
  .no-print { display: none !important; }
  .app-sidebar, .app-header, .app-footer, .filters, .tabel-data, .tip, .kepala-halaman .d-flex { display: none !important; }
  .app-wrapper { display: block !important; }
  .app-main { margin: 0 !important; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* Isian dengan label terpisah; Tom Select tidak boleh dibungkus label */
.kolom-isian { display: flex; flex-direction: column; gap: 5px; }
.ts-wrapper .ts-control, .ts-dropdown { font-size: 15px; font-weight: 400; }

/* Tabel silsilah */
#grid-pohon { scroll-margin-top: 72px; }
.kolom-silsilah { position: relative; white-space: nowrap; padding-left: calc(var(--lvl) * 24px + 12px) !important; }
.kolom-silsilah::before { content: ""; position: absolute; top: 0; bottom: 0; left: 24px; width: calc(var(--lvl) * 24px); background: repeating-linear-gradient(90deg, var(--base) 0 1px, transparent 1px 24px); }
.isi-silsilah { display: inline-flex; align-items: center; gap: 6px; }
.grid-lipat, .grid-lipat-kosong { display: inline-flex; flex: none; width: 24px; height: 24px; align-items: center; justify-content: center; }
.grid-lipat { border: 0; border-radius: 6px; background: transparent; color: var(--bs-secondary-color); cursor: pointer; }
.grid-lipat:hover { background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.grid-lipat i { transition: transform .15s; }
.grid-lipat[aria-expanded=false] i { transform: rotate(-90deg); }
.grid-aksi { white-space: nowrap; }
.grid-aksi .btn-mini { margin-right: 4px; display: inline-block; }
.tabel-silsilah tr.silsilah-dijual td, .tabel-silsilah tr.silsilah-mati td { background-color: var(--bs-tertiary-bg); }
@media print { .grid-aksi, #grid-buka, #grid-tutup { display: none !important; } }
