.home-scroll {
  /* Palet beranda: permukaan terang, tinta gelap, aksen hijau tua. */
  --home-paper: #f8f9fa;
  --home-surface: #ffffff;
  --home-ink: #1e293b;
  --home-leaf: #0f5229;
  --home-slate: #64748b;
  --home-line: #e2e8f0;

  /* Warna batang ringkasan: hijau, abu, biru, dan oranye yang tetap kalem. */
  --home-bar-green: #2f855a;
  --home-bar-grey: #94a3b8;
  --home-bar-blue: #3b82f6;
  --home-bar-orange: #f59e0b;

  --home-shadow:
    0 1px 2px rgb(15 23 42 / 4%),
    0 6px 16px rgb(15 23 42 / 5%);
  padding: 0 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--home-paper);
}

/* --- Header + Hero background --- */
.app-header {
  display: block;
  position: sticky;
  z-index: 30;
  top: 0;
  width: calc(100% + 40px);
  margin: 0 -20px;
  padding: calc(20px + env(safe-area-inset-top)) 20px 20px;
  overflow: hidden;
  border-bottom: 1px solid var(--home-line);
  /* Putih solid: mencegah judul kartu (mis. "KERJA HARIAN") menembus header
     saat halaman di-scroll. */
  background: #ffffff;
  box-shadow: 0 1px 0 rgb(15 23 42 / 4%);
  isolation: isolate;
}

/* Foto kebun sawit yang bergerak sangat pelan. Overlay gradien putih menjaga
   teks tetap gelap dan kontras, lalu memudar menjadi putih solid di bawahnya
   agar menyatu dengan header dan kartu kategori. */
.header-hero {
  position: absolute;
  inset: -6%;
  z-index: 0;
  background:
    linear-gradient(
      to bottom,
      rgb(255 255 255 / 78%) 0%,
      rgb(255 255 255 / 92%) 52%,
      #ffffff 100%
    ),
    url("../assets/bg-sawit.jpg") center 32% / cover no-repeat;
  transform: scale(1.06);
  transform-origin: center 35%;
  animation: header-hero-pan 26s ease-in-out infinite alternate;
  pointer-events: none;
  will-change: transform;
}

/* Isi header selalu di atas foto agar tombol dan judul tidak tertutup. */
.header-top,
.header-title {
  position: relative;
  z-index: 1;
}

.header-top {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--home-slate);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  line-height: 1.3;
  text-shadow: 0 1px 0 rgb(255 255 255 / 45%);
  text-transform: uppercase;
}

.header-title {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 0;
  color: var(--home-ink);
  font-family: var(--font-sans);
  letter-spacing: -0.8px;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgb(255 255 255 / 55%);
}

.header-title-main {
  font-size: 30px;
  font-weight: 800;
}

.header-title-year {
  color: var(--home-leaf);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 8px;
}

.header-action-button {
  display: flex;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--home-line);
  border-radius: 50%;
  background: var(--home-surface);
  box-shadow: var(--home-shadow);
  color: var(--home-ink);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.header-action-button:hover,
.header-action-button:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--home-leaf);
}

.header-action-button:active {
  transform: scale(0.96);
}

.header-action-button:focus-visible {
  outline: 3px solid rgb(15 82 41 / 30%);
  outline-offset: 2px;
}

.header-action-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.header-action-button svg,
.header-action-button .icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.home-import-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

/* --- Kartu ringkasan (PUTIH BERSIH, bukan hijau gelap) --- */
.overview-card {
  margin-top: 32px;
  padding: 24px;
  border-radius: var(--radius);
}

.home-summary-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--home-line);
  border-radius: var(--radius);
  background: var(--home-surface);
  box-shadow: var(--home-shadow);
  color: var(--home-ink);
}

.home-summary-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.home-summary-stack .home-summary-card {
  margin-top: 0;
}

.home-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-summary-title {
  margin: 0;
  color: var(--home-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.section-title h2 {
  margin: 0;
  color: var(--home-ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

/* --- Grafik batang horizontal --- */
.home-bar-chart {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.bar-row:last-child .bar-track {
  margin-bottom: 0;
}

.bar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  color: var(--home-slate);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-value {
  flex: 0 0 auto;
  color: var(--home-ink);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
}

.bar-track {
  width: 100%;
  height: 8px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 4px;
  background: #e2e8f0;
}

/* Lebar target berasal dari JS (`--target-width`), sedangkan animasi hanya
   memutar skala dari 0 ke 1 agar panjang akhirnya tetap sesuai data. */
.bar-fill {
  width: var(--target-width, 100%);
  height: 100%;
  border-radius: 4px;
  background: var(--bar-color, var(--home-leaf));
  transform: scaleX(0);
  transform-origin: left;
  animation: grow-loop 4.2s cubic-bezier(0.4, 0, 0.2, 1) infinite both;
  will-change: transform;
}

.bar-row:nth-child(1) .bar-fill { animation-delay: 0s; }
.bar-row:nth-child(2) .bar-fill { animation-delay: 0.12s; }
.bar-row:nth-child(3) .bar-fill { animation-delay: 0.24s; }
.bar-row:nth-child(4) .bar-fill { animation-delay: 0.36s; }

/* Total ringkasan di bawah grafik batang. */
.chart-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--home-line);
  text-align: center;
}

.chart-total-value {
  color: var(--home-ink);
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
}

.chart-total-value.is-compact {
  font-size: 30px;
}

.chart-total-label {
  color: var(--label);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  line-height: 1.4;
  text-transform: uppercase;
}

/* --- Carousel Ringkasan Pupuk (4 slide) --- */
.home-carousel-badge {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--home-leaf);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4px;
  line-height: 1.4;
}

.home-carousel {
  position: relative;
  margin-top: 12px;
  overflow: hidden;
}

.home-carousel-track {
  display: flex;
  align-items: stretch;
  transition: transform 380ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.home-carousel-slide {
  display: flex;
  min-width: 0;
  flex: 0 0 100%;
  flex-direction: column;
}

.home-slide-title {
  margin: 0;
  color: var(--home-slate);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.9px;
  line-height: 1.4;
  text-transform: uppercase;
}

.home-carousel-slide .home-bar-chart {
  margin-top: 14px;
}

/* Angka besar per slide. Slide "top" menaruhnya di atas grafik sebagai
   headline; slide "bottom" menaruhnya di dasar kartu agar tidak melompat
   saat berpindah antar slide. */
.home-slide-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  text-align: center;
}

.home-slide-figure--bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--home-line);
}

.home-slide-figure-value {
  color: var(--home-ink);
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.8px;
  line-height: 1.05;
}

/* Nominal rupiah yang panjang dikecilkan agar tetap satu baris. */
.home-slide-figure-value.is-compact {
  font-size: 26px;
}

.home-slide-figure-label {
  color: var(--home-slate);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.4;
  text-transform: uppercase;
}

/* Placeholder aman saat tabel masih kosong. */
.home-chart-empty {
  display: grid;
  min-height: 116px;
  margin: 0;
  padding: 16px;
  place-items: center;
  border: 1px dashed var(--home-line);
  border-radius: 12px;
  color: var(--home-slate);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.home-carousel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

/* Panah navigasi: minimal 48px agar nyaman disentuh jempol. */
.home-carousel-arrow {
  display: flex;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--home-line);
  border-radius: 50%;
  background: var(--home-surface);
  color: var(--home-ink);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.home-carousel-arrow:hover,
.home-carousel-arrow:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--home-leaf);
}

.home-carousel-arrow:active {
  transform: scale(0.95);
}

.home-carousel-arrow:focus-visible {
  outline: 3px solid rgb(15 82 41 / 30%);
  outline-offset: 2px;
}

.home-carousel-arrow .icon {
  display: block;
  width: 22px;
  height: 22px;
}

.home-carousel-dots {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.home-carousel-dot {
  display: grid;
  width: 28px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  place-items: center;
}

.home-carousel-dot::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: width 220ms ease, background-color 220ms ease;
}

.home-carousel-dot.is-active::before {
  width: 20px;
  background: var(--home-leaf);
}

.home-carousel-dot:focus-visible {
  border-radius: 50%;
  outline: 3px solid rgb(15 82 41 / 30%);
  outline-offset: 0;
}

/* --- Menu kategori --- */
.home-menu-title {
  margin: 0 0 16px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: 16px;
}

.menu-tile {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: center;
}

.menu-card {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  place-items: center;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--home-line);
  border-radius: var(--radius);
  background: var(--home-surface);
  box-shadow: var(--home-shadow);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.menu-tile:active .menu-card {
  transform: scale(0.97);
  border-color: var(--line-strong);
}

.menu-tile:hover .menu-card {
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgb(15 23 42 / 8%);
}

.menu-icon {
  display: grid;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  place-items: center;
  border-radius: var(--radius-sm);
}

.menu-icon--green {
  background: var(--green-soft);
  color: var(--green);
}

.menu-icon--sand {
  background: #eef2f0;
  color: #3f6250;
}

.menu-icon--gold {
  background: var(--amber-soft);
  color: var(--amber);
}

.menu-icon .icon,
.menu-icon svg {
  display: block;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.menu-card .menu-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
}

.menu-card .menu-icon .icon,
.menu-card .menu-icon svg {
  width: 32px;
  height: 32px;
}

/* Gambar asli untuk card kategori utama. `object-fit: cover` membuat gambar
   persegi panjang (mis. icon-sawit.jpg) terpotong rapi memenuhi kotak. */
.category-img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  background-color: #F8F9FA;
}

.menu-tile.btn-bounce.is-bouncing {
  animation: bounce-click 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-tile-name {
  display: block;
  margin-top: 10px;
  color: var(--home-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.menu-copy {
  display: block;
  width: 100%;
  min-width: 0;
}

.menu-name {
  display: block;
  color: var(--home-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.home-footnote {
  margin: 24px 0 8px;
  color: var(--home-slate);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* Growth loop: batang tumbuh dari kiri, menahan sejenak di panjang penuh,
   lalu menyusut kembali sebelum siklus berikutnya. */
@keyframes grow-loop {
  0% { transform: scaleX(0); }
  16% { transform: scaleX(1); }
  68% { transform: scaleX(1); }
  86% { transform: scaleX(0); }
  100% { transform: scaleX(0); }
}

@keyframes bounce-click {
  0% { transform: scale(1); }
  40% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Melayang lembut: gambar kategori naik-turun 6px. Kartu dan judul tetap
   diam agar teks mudah dibaca; hanya gambar yang bergerak. */
@keyframes float-soft {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Animasi hanya dijalankan bila pengguna tidak meminta pengurangan gerak. */
@media (prefers-reduced-motion: no-preference) {
  .menu-tile .category-img {
    animation: float-soft 3.6s ease-in-out infinite;
    will-change: transform;
  }

  /* Jeda bertingkat agar ketiga gambar bergerak seperti gelombang. */
  .menu-tile:nth-child(1) .category-img {
    animation-delay: 0s;
  }

  .menu-tile:nth-child(2) .category-img {
    animation-delay: 0.5s;
  }

  .menu-tile:nth-child(3) .category-img {
    animation-delay: 1s;
  }
}

/* Slow pan: zoom + geser halus, 26 detik, berulang tanpa henti. */
@keyframes header-hero-pan {
  0% { transform: scale(1.05) translate3d(0, 0, 0); }
  100% { transform: scale(1.14) translate3d(-1.5%, 0.8%, 0); }
}

@media (max-width: 360px) {
  .overview-card {
    padding: 16px;
  }

  .home-summary-card {
    padding: 20px;
  }

  .home-slide-figure-value {
    font-size: 30px;
  }

  .home-slide-figure-value.is-compact {
    font-size: 22px;
  }

  .bar-label,
  .bar-value {
    font-size: 12px;
  }

  .menu-card .menu-icon {
    width: 56px;
    height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-tile.btn-bounce.is-bouncing {
    animation-duration: 1ms;
  }

  .header-hero {
    animation: none;
    transform: scale(1.06);
  }

  .bar-fill {
    animation: none;
    transform: scaleX(1);
  }

  .home-carousel-track,
  .home-carousel-dot::before {
    transition: none;
  }
}
