.monitor-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 20px;
  padding: 24px 28px;
  margin-bottom: 16px;
  background: var(--white);
  border: 1px solid #edf2f7;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  overflow: hidden;
}

.monitor-hero::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--white);
  pointer-events: none;
}

.monitor-hero::after {
  content: '';
  position: absolute;
  bottom: -70px; left: 30%;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: var(--white);
  pointer-events: none;
}

.monitor-hero-top {
  display: flex;
  justify-content: flex-start; 
  margin-bottom: 0;
}

.monitor-hero-top .monitor-hero-title {
  margin: 0;
} 

.monitor-hero-actions {
  position: relative;
  z-index: 1;
  margin-top: 0;
  display: flex;
  justify-content: flex-start;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: .2s;
}
.btn-ghost:hover { background: #eff6ff; color: var(--accent); border-color: #bfdbfe; }
.btn-ghost i { font-size: 12px; }

.monitor-hero-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.monitor-hero-icon {
  width: 56px; height: 56px;
  min-width: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: #fff;
  flex-shrink: 0;
}

.monitor-hero-body {
  display: flex;
  flex-direction: column;
  gap: 16px;              /* Jarak vertikal yang cukup untuk memisahkan setiap baris */
  width: 100%;
}

.monitor-hero-title {
  margin: 0 0 5px 0;
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -.3px;
}

.monitor-hero-desc {
  margin: 0;
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
}

.status-wrapper {
  display: flex;
  justify-content: left; 
  margin: 6px 0;          
}

.monitor-hero .status.online-bg {
  background: #dcfce7; color: #166534; border: 1px solid #bbf7d0;
}
.monitor-hero .status.online-bg .status-dot  { background: #16a34a; }
.monitor-hero .status.offline-bg {
  background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0;
}
.monitor-hero .status.offline-bg .status-dot { background: #94a3b8; animation: none; }

/* --- WARNA STATUS MESIN --- */
.monitor-hero .status.ms-aktif { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.monitor-hero .status.ms-mulai { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.monitor-hero .status.ms-standby { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.d-card {
  background: var(--white);
  border: 1px solid #edf2f7;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .2s, transform .2s;
}
.d-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
  transform: translateY(-2px);
}

.d-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.d-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.d-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 20px;
  background: #f1f5f9;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.d-badge.safe   { background: #dcfce7; color: #166534; }
.d-badge.warn   { background: #fef9c3; color: #854d0e; }
.d-badge.danger { background: #fee2e2; color: #991b1b; }

.d-title { font-size: 11px; font-weight: 700; color: #64748b; }
.d-value { font-size: 28px; font-weight: 800; color: #334155; line-height: 1; }
.d-unit  { font-size: 12px; font-weight: 600; color: #94a3b8; }

.chart-section { margin-bottom: 20px; }

.chart-card {
  background: var(--white);
  border: 1px solid #edf2f7;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.chart-header { text-align: center; margin-bottom: 16px; }
.chart-header h3 { font-size: 14px; font-weight: 800; color: #334155; margin-bottom: 2px; }
.chart-header p  { font-size: 10px; color: #94a3b8; }

.chart-wrap { width: 100%; height: 260px; }

.chart-controls {
  display: flex;
  flex-direction: row;
  justify-content: center; /* Ubah dari space-between menjadi center */
  align-items: center;
  gap: 16px;               /* Sedikit melebarkan gap agar dropdown dan tombol tidak terlalu nempel */
  margin-bottom: 16px;
  width: 100%;
  flex-wrap: wrap; 
}

.chart-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Optimasi tampilan responsif khusus untuk layar HP */
@media (max-width: 600px) {
  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .chart-filters {
    flex-direction: column;
    align-items: stretch;
  }
  #btnExportChart {
    width: 100%;
    justify-content: center;
  }
}

.chart-select, .chart-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-family: var(--font);
  font-size: 12px;
  color: #334155;
  background: #f8fafc;
  outline: none;
  transition: 0.2s;
}

.chart-select:focus, .chart-input:focus {
  border-color: var(--accent);
  background: #fff;
}

.custom-chart-range {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.custom-chart-range span {
  font-size: 14px;
  color: #94a3b8;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 11px;
  border-radius: 8px;
}

#btn-export { gap: 7px; }

.update-label {
  font-size: 10px;
  color: #9ca3af;
  margin-right: 4px;
}

@media (max-width: 900px) {
  .data-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .monitor-hero { padding: 16px 18px; gap: 10px; border-radius: 16px; }
  .monitor-hero-icon { width: 46px; height: 46px; min-width: 46px; font-size: 20px; border-radius: 13px; }
  .monitor-hero-title { font-size: 15px; }
  .monitor-hero-desc { font-size: 11px; }
}

@media (max-width: 480px) {
  .monitor-hero { padding: 14px 16px; gap: 8px; border-radius: 14px; }
  .monitor-hero::before { width: 130px; height: 130px; top: -35px; right: -35px; }
  .monitor-hero::after  { display: none; }
  .monitor-hero-main { gap: 12px; }
  .monitor-hero-icon { width: 40px; height: 40px; min-width: 40px; font-size: 18px; border-radius: 11px; }
  .monitor-hero-title { font-size: 13px; }
  .monitor-hero-desc { font-size: 10.5px; }

  .data-grid  { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .d-card     { padding: 12px; gap: 8px; border-radius: 12px; }
  .d-icon     { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
  .d-value    { font-size: 22px; }
  .chart-wrap { height: 240px; }
  .chart-card { padding: 12px; }
}

@media (max-width: 375px) {
  .monitor-hero { padding: 10px 12px; gap: 6px; border-radius: 12px; }
  .monitor-hero-icon { width: 32px; height: 32px; min-width: 32px; font-size: 14px; border-radius: 9px; }
  .monitor-hero-title { font-size: 11px; }
  .monitor-hero-desc { display: none; }
  .monitor-hero .status { font-size: 10px; padding: 3px 7px; }

  .data-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .d-card    { padding: 10px; gap: 6px; border-radius: 10px; }
  .d-icon    { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
  .d-value   { font-size: 18px; }
  .d-title   { font-size: 10px; }
  .d-badge   { font-size: 9px; padding: 2px 6px; }
  .update-label { display: none; }
  .chart-wrap { height: 200px; }
  .chart-card { padding: 10px; }
}

/* --- KONTROL RELAY DI DASHBOARD (KOTAK) --- */
.control-switches {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-control.square {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 76px;       /* Lebar kotak */
  height: 76px;      /* Tinggi kotak (presisi persegi) */
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  gap: 4px;
}

.btn-control.square i { font-size: 22px; margin-bottom: 2px; }
.btn-control.square span { font-size: 9px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-control.square strong { font-size: 14px; font-weight: 900; }

/* Desain Saat Tombol OFF */
.btn-control.off {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}
.btn-control.off:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.btn-control.off:hover span { color: #b91c1c; }

/* Desain Saat Tombol ON (Menyala Hijau) */
.btn-control.on {
  background: #22c55e;
  color: #ffffff;
  border-color: #16a34a;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
  transform: translateY(-2px); /* Efek tombol terangkat */
}
.btn-control.on span { color: #dcfce7; }

/* SEMBUNYIKAN KOTAK DI HP (< 768px) */
@media (max-width: 768px) {
  .control-switches {
    display: none; 
  }
}

/* --- SEMBUNYIKAN HERO KEDUA DI LAPTOP (Default) --- */
.mobile-controls-hero {
  display: none; 
}

/* --- ATURAN KHUSUS LAYAR KECIL / HP (Narrow Screen) --- */
@media (max-width: 768px) {
  /* 1. Sembunyikan tombol kotak di Hero Utama (Atas) */
  .control-switches {
    display: none !important;
  }
  
  /* 2. Tampilkan Hero Kedua (Bawah) */
  .mobile-controls-hero {
    display: flex;
    justify-content: center;
    padding: 12px 16px; /* Padding sedikit lebih kecil agar padat */
  }
  
  /* 3. Desain tombol membagi 2 layar */
  .control-switches-mobile {
    display: flex;
    gap: 12px;
    width: 100%; /* Lebar penuh */
  }
  
  .control-switches-mobile .btn-control.square {
    width: auto;
    flex: 1; /* Tombol membagi ruang 50:50 */
    height: 70px; /* Sedikit lebih pendek agar tidak makan tempat di HP */
  }
}

/* --- DESAIN TOMBOL KONTROL TERKUNCI (BELUM LOGIN) --- */
.btn-control.disabled {
  background: #e2e8f0 !important;
  color: #94a3b8 !important;
  border-color: #cbd5e1 !important;
  cursor: not-allowed !important;
  pointer-events: none !important; /* Mencegah tombol diklik */
  box-shadow: none !important;
  transform: none !important;
}

/* Menghilangkan bercak putih (hiasan lingkaran) pada Hero kedua di layar HP */
.mobile-controls-hero::before,
.mobile-controls-hero::after {
  display: none !important;
}