/* ============================================================
   KPI OEE OPE vs OEE 365 — dua panel dengan tampilan berbeda
   OPE  : panel biru, garis solid
   365  : panel oranye, garis putus-putus
   ============================================================ */
.sheet-kpi-stack { gap: 12px; }

.sheet-kpi-stack .sheet-kpi-row-ope,
.sheet-kpi-stack .sheet-kpi-row-365 {
  grid-template-columns: 64px repeat(4, minmax(0, 1fr)) !important;
  gap: 12px !important;
  padding: 10px 12px;
  border-radius: 16px;
  align-items: stretch;
}

/* ---- panel ---- */
.sheet-kpi-stack .sheet-kpi-row-ope {
  background: #bfd8fb;
  border: 2px solid #3b82f6;
  --pc: #2563eb;
}
.sheet-kpi-stack .sheet-kpi-row-365 {
  background: #ffd5a8;
  border: 2px dashed #ea580c;
  --pc: #d97706;
}

/* ---- label OEE / OPE | OEE / 365 ---- */
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi-row-label,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi-row-label {
  flex-direction: column;
  gap: 1px;
  line-height: 1;
  border-radius: 12px;
  border: none;
  background: var(--pc);
  color: #fff;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--pc) 35%, transparent);
}
.sheet-kpi-stack .sheet-kpi-row-label b {
  font-size: 15px; font-weight: 900; letter-spacing: .3px; color: #fff;
}
.sheet-kpi-stack .sheet-kpi-row-label small {
  font-size: 9px; font-weight: 800; letter-spacing: .5px; color: rgba(255,255,255,.9);
}

/* ---- kartu A / P / Q / OEE ---- */
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--kb);
  border-radius: 12px;
  box-shadow: none;
  min-height: 46px;
  gap: 6px;
}
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi span,
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi b,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi span,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi b {
  color: #1c1e1d;
  position: relative;
  z-index: 1;
}
/* pojok berwarna */
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi::after,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi::after {
  content: '';
  position: absolute;
  top: -13px; right: -13px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--kc);
}
/* Health bar mengisi penuh tinggi kartu di belakang teks */
.sheet-kpi-stack .sheet-kpi {
  position: relative;
  overflow: hidden;
}

.sheet-kpi-stack .sheet-kpi span,
.sheet-kpi-stack .sheet-kpi b {
  position: relative;
  z-index: 2;
}

.sheet-kpi-stack .sheet-kpi .kpi-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  height: auto;
  z-index: 1;
  opacity: 1;
  pointer-events: none;
  transition: width 0.35s ease, background-color 0.25s ease;
}

/* Health bar coloring per data-state */
.sheet-kpi-stack .sheet-kpi[data-state="red"] .kpi-fill {
  background: rgba(238, 15, 15, 0.733) !important; /* Merah */
}

.sheet-kpi-stack .sheet-kpi[data-state="yellow"] .kpi-fill {
  background: rgba(236, 221, 4, 0.993) !important; /* Kuning */
}

.sheet-kpi-stack .sheet-kpi[data-state="green"] .kpi-fill {
  background: rgba(34, 197, 94, 0.877) !important; /* Hijau */
}

.sheet-kpi-stack .sheet-kpi[data-state="blue"] .kpi-fill {
  background: rgba(3, 46, 189, 0.932) !important; /* Biru */
}

/* Warna teks khusus saat data-state biru (putih) */
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi[data-state="blue"] span,
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi[data-state="blue"] b,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi[data-state="blue"] span,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi[data-state="blue"] b {
  color: #ffffff !important;
}

/* Warna teks khusus saat data-state kuning (hitam) */
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi[data-state="yellow"] span,
.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi[data-state="yellow"] b,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi[data-state="yellow"] span,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi[data-state="yellow"] b {
  color: #000000 !important;
}

/* Mode gelap */
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="red"] .kpi-fill {
  background: rgba(239, 68, 68, 0.36) !important;
}

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="yellow"] .kpi-fill {
  background: rgba(243, 239, 9, 0.87) !important;
}

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="green"] .kpi-fill {
  background: rgba(74, 222, 128, 0.30) !important;
}

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="blue"] .kpi-fill {
  background: rgba(96, 165, 250, 0.34) !important;
}

/* warna per metrik — OPE */
.sheet-kpi-row-ope .sheet-kpi[data-kpi="A"]   { --kt:#15803d; --kb:#86efac; --kc:#4ade80; }
.sheet-kpi-row-ope .sheet-kpi[data-kpi="P"]   { --kt:#1d4ed8; --kb:#bfdbfe; --kc:#60a5fa; }
.sheet-kpi-row-ope .sheet-kpi[data-kpi="Q"]   { --kt:#6d28d9; --kb:#ddd6fe; --kc:#a78bfa; }
.sheet-kpi-row-ope .sheet-kpi[data-kpi="OEE"] { --kt:#c2410c; --kb:#fdba74; --kc:#fb923c; background:#fff4ea; }

/* warna per metrik — 365 (nuansa hangat) */
.sheet-kpi-row-365 .sheet-kpi[data-kpi="A365"],
.sheet-kpi-row-365 .sheet-kpi[data-kpi="P365"],
.sheet-kpi-row-365 .sheet-kpi[data-kpi="Q365"] { --kt:#9a3412; --kb:#fed7aa; --kc:#fb923c; }
.sheet-kpi-row-365 .sheet-kpi[data-kpi="OEE365"] { --kt:#92400e; --kb:#fbbf24; --kc:#f59e0b; background:#fef3c7; }

.sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi span,
.sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi span { font-weight: 900; letter-spacing: .2px; }

/* ---- tema gelap ---- */
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi-row-ope { background: rgba(37,99,235,.20); border-color: #3b82f6; }
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi-row-365 { background: rgba(234,88,12,.18); border-color: #f97316; }
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi,
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi { background: #1c1c1f; border-color: rgba(255,255,255,.12); }
[data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="OEE"] { background: rgba(251,146,60,.16); }
[data-theme="dark"] .sheet-kpi-row-365 .sheet-kpi[data-kpi="OEE365"] { background: rgba(245,158,11,.18); }
[data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="A"] span, [data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="A"] b { color:#4ade80 !important; }
[data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="P"] span, [data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="P"] b { color:#93c5fd !important; }
[data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="Q"] span, [data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="Q"] b { color:#c4b5fd !important; }
[data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="OEE"] span, [data-theme="dark"] .sheet-kpi-row-ope .sheet-kpi[data-kpi="OEE"] b { color:#fdba74 !important; }
[data-theme="dark"] .sheet-kpi-row-365 .sheet-kpi span, [data-theme="dark"] .sheet-kpi-row-365 .sheet-kpi b { color:#fdba74 !important; }
[data-theme="dark"] .sheet-kpi-row-365 .sheet-kpi[data-kpi="OEE365"] span, [data-theme="dark"] .sheet-kpi-row-365 .sheet-kpi[data-kpi="OEE365"] b { color:#fcd34d !important; }

/* Border, tulisan angka, & pojok ikut warna status health bar */
.sheet-kpi-stack .sheet-kpi[data-state="red"] {
  --kt: #b91c1c;
  --kb: #f87171;
  --kc: #ef4444;
  border-color: #f87171 !important;
}

.sheet-kpi-stack .sheet-kpi[data-state="yellow"] {
  --kt: #a16207;
  --kb: #facc15;
  --kc: #eab308;
  border-color: #facc15 !important;
}

.sheet-kpi-stack .sheet-kpi[data-state="green"] {
  --kt: #15803d;
  --kb: #4ade80;
  --kc: #22c55e;
  border-color: #4ade80 !important;
}

.sheet-kpi-stack .sheet-kpi[data-state="blue"] {
  --kt: #1d4ed8;
  --kb: #60a5fa;
  --kc: #3b82f6;
  border-color: #60a5fa !important;
}

/* Penyesuaian tulisan angka saat Dark Mode */
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="red"] span,
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="red"] b { color: #0e0d0d !important; }

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="yellow"] span,
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="yellow"] b { color: #0e0d0d !important; }

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="green"] span,
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="green"] b { color: #0e0d0d !important; }

[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="blue"] span,
[data-theme="dark"] .sheet-kpi-stack .sheet-kpi[data-state="blue"] b { color: #93c5fd !important; }

/* ---- layar kecil ---- */
@media (max-width: 640px) {
  .sheet-kpi-stack .sheet-kpi-row-ope,
  .sheet-kpi-stack .sheet-kpi-row-365 {
    grid-template-columns: 38px repeat(4, minmax(0, 1fr)) !important;
    gap: 5px !important;
    padding: 6px;
    border-radius: 12px;
  }
  .sheet-kpi-stack .sheet-kpi-row-label { width: auto; min-height: 0; justify-content: center; }
  .sheet-kpi-stack .sheet-kpi-row-label b { font-size: 11px; }
  .sheet-kpi-stack .sheet-kpi-row-label small { font-size: 7px; }
  .sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi,
  .sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi { min-height: 36px; border-radius: 8px; }
  .sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi::after,
  .sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi::after { width: 18px; height: 18px; top: -9px; right: -9px; }
}
@media (min-width: 1200px) {
  .sheet-kpi-stack .sheet-kpi-row-ope .sheet-kpi,
  .sheet-kpi-stack .sheet-kpi-row-365 .sheet-kpi { min-height: 50px; }
  .sheet-kpi-stack .sheet-kpi-row-ope,
  .sheet-kpi-stack .sheet-kpi-row-365 { grid-template-columns: 72px repeat(4, minmax(0, 1fr)) !important; }
}

/* Label OEE OPE / OEE 365 sekarang <button> (klik → buka halaman) */
.sheet-kpi-stack button.sheet-kpi-row-label {
  appearance: none; -webkit-appearance: none;
  font-family: inherit; cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.sheet-kpi-stack button.sheet-kpi-row-label:hover { filter: brightness(1.08); transform: translateY(-1px); }
.sheet-kpi-stack button.sheet-kpi-row-label:active { transform: translateY(0) scale(.97); }
.sheet-kpi-stack button.sheet-kpi-row-label:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
