/* =====================================================================
   DESAIN TOKEN
   Subjek: stasiun pemantau partikulat udara — panel instrumen yang tenang,
   terbaca, dan dipercaya warga awam. Aksen warna mengikuti status baku
   mutu (Baik/Sedang/Tidak Sehat) agar sistem warna = sistem makna.
   ===================================================================== */
:root {
  /* -- warna dasar (atmosfer, bukan cream/terracotta template) -- */
  --bg:            #F6F4FC;
  --bg-panel:      #FFFFFF;
  --bg-sunken:     #EDEAF8;
  --ink:           #1A1630;
  --ink-soft:      #4A4468;
  --ink-faint:     #7A7399;
  --line:          #E2DDF2;
  --line-strong:   #C9C2E4;

  /* -- merek: deep purple, identitas visual utama -- */
  --brand:         #5B3CC4;
  --brand-ink:     #3F2A8F;
  --brand-soft:    #EAE5FF;

  /* -- status baku mutu (PP RI No. 22/2021) -- */
  --baik:          #2E9E5B;
  --baik-soft:     #E1F5E8;
  --sedang:        #D98A1E;
  --sedang-soft:   #FBEEDA;
  --tidak-sehat:   #D6473F;
  --tidak-sehat-soft: #FBE3E1;

  /* -- tipografi -- */
  --font-display: 'Sora', 'Segoe UI', sans-serif;
  --font-body:    'Inter', 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-panel: 0 1px 2px rgba(26, 22, 48, 0.04), 0 8px 24px -12px rgba(26, 22, 48, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 .4em;
  letter-spacing: -0.01em;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------------------------------------------
   NAVIGASI
   --------------------------------------------------------------------- */
.site-nav {
  position: sticky;
  top: 0;
  /* z-index di atas Leaflet map (maks 1000) agar navbar tidak tertutup peta
     saat scroll, namun tetap di bawah overlay (1050) & drawer (1100) */
  z-index: 1001;
  background: rgba(246, 244, 252, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--brand-ink);
}
.brand .brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff;
  font-size: 0.95rem;
}
.brand .brand-sub {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0; padding: 0;
}
.nav-links a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
.nav-links a:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-links a.active { background: var(--brand); color: #fff; }
.nav-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.4rem; color: var(--ink);
  cursor: pointer;
}

@media (max-width: 860px) {
  .nav-links {
    position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; background: var(--bg-panel);
    border-bottom: 1px solid var(--line);
    padding: 10px; gap: 2px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
}

/* ---------------------------------------------------------------------
   NAVIGASI MOBILE — DRAWER / SIDEBAR DARI KANAN
   Hanya aktif di layar mobile (<=860px). Desktop tetap memakai .nav-links.
   --------------------------------------------------------------------- */
/* Drawer navigasi mobile disembunyikan default; hanya ditampilkan di layar <=860px */
.nav-drawer {
  display: none;
}
.nav-overlay {
  display: none;
}

@media (max-width: 860px) {
  .nav-drawer {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background: var(--bg-panel);
    box-shadow: -12px 0 30px -8px rgba(26, 22, 48, 0.25);
    border-radius: 14px 0 0 14px;
    /* z-index di atas Leaflet map (maks 1000) agar drawer tidak tertutup peta */
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-drawer.open { transform: translateX(0); }

  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    /* z-index di atas Leaflet map (maks 1000) agar overlay menutupi peta */
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .nav-overlay.show { opacity: 1; pointer-events: auto; }

  /* Header drawer: logo + nama + tombol tutup */
  .nav-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 1;
  }
  .nav-drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--brand-ink);
  }
  .nav-drawer-brand .brand-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--brand);
    display: grid; place-items: center;
    color: #fff;
    font-size: 0.95rem;
    flex-shrink: 0;
  }
  .nav-drawer-brand .brand-sub {
    display: block;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--ink-faint);
  }
  .nav-drawer-close {
    background: var(--bg-sunken);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    color: var(--ink-soft);
    cursor: pointer;
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: background .15s ease;
  }
  .nav-drawer-close:hover { background: var(--line); }

  /* Daftar menu drawer */
  .nav-drawer-links {
    list-style: none;
    margin: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .nav-drawer-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 12px 14px;
    border-radius: 12px;
    min-height: 48px;
    transition: background .15s ease, color .15s ease;
  }
  .nav-drawer-links a:hover { background: var(--bg-sunken); color: var(--ink); }
  .nav-drawer-links a.active {
    background: var(--brand);
    color: #fff;
  }
  .nav-drawer-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
  }
  .nav-drawer-icon svg { display: block; }

  /* Lock scroll body saat drawer terbuka */
  body.nav-locked { overflow: hidden; }
}

/* ---------------------------------------------------------------------
   HERO / HEADER HALAMAN — elemen tanda tangan: partikel melayang
   (mewakili PM2.5/PM10) mengambang lambat di atas panel gelap.
   --------------------------------------------------------------------- */
.page-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #3F2A8F 0%, #5B3CC4 100%);
  color: #F0EDFF;
  padding: 46px 0 40px;
}

/* Compact hero for history page */
.hero-compact {
  padding: 28px 0 22px;
}
.hero-row { display:flex; align-items:center; }
.hero-title { display:flex; gap:12px; align-items:center; }
.hero-icon {
  width:56px; height:56px; border-radius:12px; background:rgba(255,255,255,0.08);
  display:grid; place-items:center; font-size:22px; color:#fff;
}
.hero-sub { margin:0; color: #D8D0F5; font-size:0.95rem; }
.page-hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #B8A8F0;
  margin-bottom: 10px;
}
.page-hero h1 {
  color: #fff;
  font-size: clamp(1.6rem, 2.6vw, 2.3rem);
  max-width: 720px;
}
.page-hero p {
  color: #D8D0F5;
  max-width: 620px;
  margin: 0;
}
.particle-field {
  position: absolute; inset: 0;
  pointer-events: none;
}
.particle-field span {
  position: absolute;
  border-radius: 50%;
  background: #C4B5F5;
  opacity: .35;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translate(0, 10px) scale(1); }
  50%  { transform: translate(14px, -12px) scale(1.15); }
  100% { transform: translate(0, 10px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .particle-field span { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------
   KARTU & GRID
   --------------------------------------------------------------------- */
main { padding: 34px 0 70px; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin: 40px 0 16px;
}
.section-title h2 { font-size: 1.25rem; }
.section-title .hint { color: var(--ink-faint); font-size: 0.85rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

/* Filter card (modern card under hero) */
.filter-card { margin-bottom: 18px; padding: 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); background: var(--bg-panel); display:block; }
.filter-row { display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; }
.filter-field { display:flex; flex-direction:column; gap:6px; }
.filter-actions { display:flex; align-items:center; }

/* summary cards (4) */
.summary-cards { margin: 10px 0 18px; }
.summary-card { text-align:left; padding:16px; transition:transform .15s ease, box-shadow .15s ease; }
.summary-card:hover { transform: translateY(-4px); box-shadow: 0 8px 22px rgba(91,60,196,0.08); }
.summary-card b { color: var(--ink); }
.card-pm25 b { color: #5B3CC4; }
.card-pm10 b { color: #2E7FBF; }
.card-temp b { color: #FF8A3D; }
.card-hum b { color: #4DAFE6; }

/* Chart controls */
.chart-panel { margin-top: 8px; }
.chart-top { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:8px; }
.chart-params label { margin-right:10px; font-weight:600; color:var(--ink-soft); }
.chart-params input[type="checkbox"] { margin-right:6px; }

/* Stats cards grid */
.stats-cards { margin-top: 6px; }
.metric-card { transition: transform .12s ease, box-shadow .12s ease; }
.metric-card:hover { transform: translateY(-6px); }

/* Insight list */
#insightCard ul { margin:0; padding-left:18px; color:var(--ink-soft); }

/* Mobile history cards */
.mobile-cards { display:none; }
.history-card { background:var(--bg-panel); border:1px solid var(--line); border-radius:var(--radius-lg); padding:12px; margin-bottom:12px; box-shadow: var(--shadow-panel); }
.history-card .row { display:flex; justify-content:space-between; gap:8px; }

/* Small animations */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }

.metric-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-panel);
  position: relative;
  min-width: 0;
}
.metric-card .metric-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.metric-card .metric-value {
  font-family: var(--font-mono);
  font-size: 2.15rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.metric-card .metric-unit {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink-faint);
  margin-left: 4px;
}
.metric-card .metric-meta {
  margin-top: 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-faint);
  flex-wrap: wrap;
}

/* badge status kualitas udara */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.badge.status-baik        { background: var(--baik-soft);        color: var(--baik); }
.badge.status-sedang      { background: var(--sedang-soft);      color: var(--sedang); }
.badge.status-tidak-sehat { background: var(--tidak-sehat-soft); color: var(--tidak-sehat); }
.badge.status-online      { background: var(--baik-soft); color: var(--baik); }
.badge.status-offline     { background: var(--tidak-sehat-soft); color: var(--tidak-sehat); }
.badge.status-unknown     { background: var(--bg-sunken); color: var(--ink-faint); }

/* banner peringatan di dashboard utama */
.alert-banner {
  display: none;
  align-items: flex-start; gap: 14px;
  background: var(--tidak-sehat-soft);
  border: 1px solid #F0BEB9;
  color: var(--brand-ink);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
}
.alert-banner.show { display: flex; }
.alert-banner .icon { font-size: 1.3rem; }
.alert-banner strong { color: var(--tidak-sehat); }

/* ---------------------------------------------------------------------
   PANEL / KOTAK KONTEN UMUM
   --------------------------------------------------------------------- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 22px;
}

/* ---------------------------------------------------------------------
   TAB & TOGGLE (halaman riwayat grafik)
   --------------------------------------------------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}

.range-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-controls select,
.range-controls input[type="date"] {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--bg-panel);
  color: var(--ink);
}
.range-controls .custom-range { display: none; align-items: center; gap: 8px; }
.range-controls .custom-range.show { display: flex; }

.chart-section {
  width: 100%;
  margin-top: 10px;
}

.summary-section {
  width: 100%;
  margin-top: 16px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 0;
}
.summary-chip {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  min-width: 0;
  box-sizing: border-box;
}
.summary-chip b {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.3;
  margin-top: 3px;
  word-break: break-word;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 340px;
  min-height: 240px;
  margin-top: 0;
  overflow: visible;
  display: block;
  padding-bottom: 8px;
  box-sizing: border-box;
}
.chart-toolbar {
  display: flex; justify-content: flex-end; margin-bottom: 8px;
}
.chart-reset-btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-panel);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.chart-reset-btn:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}
.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------------------------------------------------------------------
   TABEL
   --------------------------------------------------------------------- */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table tbody tr:hover { background: var(--bg-sunken); }
.table-scroll { overflow-x: auto; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.pagination button {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------------
   EDUKASI
   --------------------------------------------------------------------- */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.edu-card h3 { font-size: 1.05rem; color: var(--brand-ink); }
.edu-card p { color: var(--ink-soft); font-size: 0.92rem; }
.status-legend {
  display: grid; gap: 10px;
  margin-top: 8px;
}
.status-legend .row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------------
   LOKASI / PETA
   --------------------------------------------------------------------- */
#map { height: 420px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); }
.location-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.location-meta .item {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.location-meta .item span { display: block; font-size: 0.74rem; color: var(--ink-faint); margin-bottom: 3px; }
.location-meta .item b { font-family: var(--font-mono); font-size: 0.95rem; }

/* ---------------------------------------------------------------------
   FOOTER
   --------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 0;
  color: var(--ink-faint);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------------------------------------------------------------------
   FILTER TANGGAL (halaman Riwayat Peringatan)
   --------------------------------------------------------------------- */
.filter-panel { margin-bottom: 20px; }
.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; gap: 5px; }
.filter-field label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.filter-field input[type="date"] {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  background: var(--bg-panel);
  color: var(--ink);
}
.btn-filter {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-filter:hover { background: var(--brand-ink); }
.filter-shortcuts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.shortcut {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.shortcut:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------------------------------------------------------------
   RINGKASAN (halaman Riwayat Peringatan)
   --------------------------------------------------------------------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 18px 20px;
  text-align: center;
}
.summary-card b {
  display: block;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--brand);
  line-height: 1.1;
}
.summary-card span {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 500;
}

/* ---------------------------------------------------------------------
   TABEL DESKTOP — kolom angka
   --------------------------------------------------------------------- */
.data-table td.num { font-family: var(--font-mono); font-size: 0.9rem; }
.btn-detail {
  border: 1px solid var(--line-strong);
  background: var(--bg-panel);
  color: var(--brand);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-detail:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* status telegram */
.tg-ok { color: var(--baik); font-weight: 600; font-size: 0.85rem; }
.tg-fail { color: var(--tidak-sehat); font-weight: 600; font-size: 0.85rem; }

/* ---------------------------------------------------------------------
   CARD MOBILE (halaman Riwayat Peringatan)
   --------------------------------------------------------------------- */
.mobile-cards { display: none; }
.alert-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.alert-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.alert-card-time {
  font-size: 0.8rem;
  color: var(--ink-faint);
  font-weight: 500;
}
.alert-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.alert-card-grid > div {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.alert-card-grid span {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-bottom: 3px;
}
.alert-card-grid b {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--ink);
}
.alert-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.alert-card .btn-detail { width: 100%; padding: 9px; font-size: 0.85rem; }

/* ---------------------------------------------------------------------
   PAGINATION RINGKAS
   --------------------------------------------------------------------- */
.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.pagination button {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  min-width: 36px;
  text-align: center;
  transition: all .15s ease;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination button.pg-nav { min-width: auto; }
.pagination .pg-ellipsis { color: var(--ink-faint); padding: 0 2px; }

/* ---------------------------------------------------------------------
   MODAL DETAIL
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 48, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px -12px rgba(26, 22, 48, 0.35);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal h3 { font-size: 1.15rem; margin-bottom: 4px; }
.modal-time { color: var(--ink-faint); font-size: 0.85rem; margin: 0 0 18px; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--bg-sunken);
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s ease;
}
.modal-close:hover { background: var(--line); }
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.modal-item {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.modal-item span { display: block; font-size: 0.72rem; color: var(--ink-faint); margin-bottom: 3px; }
.modal-item b { font-family: var(--font-mono); font-size: 1.1rem; color: var(--ink); }
.modal-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.modal-detail-row span:first-child { color: var(--ink-soft); }
.modal-detail-row b { color: var(--ink); }

/* ---------------------------------------------------------------------
   RESPONSIVE — mobile
   --------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .page-hero { padding: 34px 0 30px; }
  .page-hero h1 { font-size: clamp(1.45rem, 3.8vw, 2rem); }
  .page-hero p { font-size: 0.95rem; }
  .toolbar { align-items: stretch; }
  .range-controls { width: 100%; }
  .range-controls .custom-range { flex-wrap: wrap; }
  .range-controls input[type="date"] { width: 100%; }
  .chart-wrap { height: 320px; }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
  main { padding: 24px 0 56px; }
  .section-title { flex-direction: column; align-items: flex-start; margin: 28px 0 12px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .summary-row { grid-template-columns: 1fr; gap: 8px; margin: 14px 0 10px; }
  .summary-chip { padding: 10px 12px; }
  .metric-card { padding: 16px 16px; }
  .metric-card .metric-value { font-size: 1.8rem; }
  .metric-card .metric-unit { font-size: 0.95rem; }
  .alert-banner { padding: 14px 16px; }
  .status-legend .row { flex-wrap: wrap; align-items: flex-start; }
  .desktop-table { display: none; }
  .mobile-cards { display: block; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-field input[type="date"] { width: 100%; min-height: 44px; }
  .btn-filter { width: 100%; min-height: 44px; }
  .summary-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .summary-card { padding: 14px 10px; }
  .summary-card b { font-size: 1.45rem; }
  .summary-card span { font-size: 0.7rem; }
  .pagination { gap: 4px; }
  .pagination button { padding: 6px 9px; min-width: 32px; font-size: 0.8rem; }
  .pagination button.pg-nav { padding: 6px 8px; }
  .chart-wrap { height: 280px; }
  .chart-reset-btn { min-height: 40px; }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .page-hero { padding: 30px 0 26px; }
  .page-hero h1 { font-size: 1.35rem; line-height: 1.25; }
  .page-hero p { font-size: 0.9rem; line-height: 1.6; }
  main { padding: 20px 0 52px; }
  .panel { padding: 16px; }
  .section-title { margin: 24px 0 12px; }
  .card-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { padding: 15px; }
  .metric-card .metric-value { font-size: 1.75rem; }
  .metric-card .metric-meta { flex-direction: column; align-items: flex-start; gap: 6px; }
  .alert-banner { flex-direction: column; padding: 13px 14px; gap: 8px; }
  .summary-cards { grid-template-columns: 1fr; gap: 8px; }
  .summary-card { padding: 12px 10px; }
  .summary-card b { font-size: 1.3rem; }
  .alert-card-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 20px; }
  .modal-grid { grid-template-columns: 1fr; }
  .tabs { gap: 6px; }
  .tabs button { flex: 1 1 calc(50% - 6px); justify-content: center; padding: 8px 10px; }
  .toolbar { gap: 10px; margin-bottom: 14px; }
  .range-controls { gap: 8px; }
  .range-controls select, .range-controls input[type="date"] { min-height: 44px; }
  .custom-range { width: 100%; gap: 8px; }
  .chart-wrap { height: 250px; margin-top: 8px; }
  .chart-toolbar { margin-bottom: 6px; }
  .chart-reset-btn { padding: 8px 12px; }
  .summary-row { margin: 12px 0 8px; }
  .summary-chip { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .history-page .history-panel {
    padding: 12px;
  }
  .history-page .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .history-page .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .history-page .tabs button {
    width: 100%;
    justify-content: center;
    padding: 7px 8px;
    font-size: 0.78rem;
  }
  .history-page .range-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .history-page .range-controls select,
  .history-page .range-controls input[type="date"],
  .history-page .range-controls .custom-range {
    width: 100%;
  }
  .history-page .range-controls .custom-range {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .history-page .chart-section {
    margin-top: 6px;
  }
  .history-page .chart-wrap {
    height: 250px;
    min-height: 250px;
    margin-top: 0;
    padding-bottom: 12px;
    box-sizing: border-box;
  }
  .history-page .chart-toolbar {
    justify-content: flex-start;
    margin-bottom: 6px;
  }
  .history-page .summary-section {
    margin-top: 24px;
  }
  .history-page .summary-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin: 0 !important;
  }
  .history-page .summary-chip {
    width: 100% !important;
    padding: 8px 10px;
    min-height: auto;
    font-size: 0.74rem;
    box-sizing: border-box;
  }
  .history-page .summary-chip b {
    font-size: 0.9rem;
    line-height: 1.25;
  }
  .history-page #historyUpdatedHint {
    font-size: 0.8rem;
    margin-top: 8px;
  }
}

/* ---------------------------------------------------------------------
   AKSESIBILITAS
   --------------------------------------------------------------------- */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
