/* ============================================================
   Monitoring Indikasi Asap - dashboard styles
   Prinsip: hierarki jelas, tipografi konsisten, warna status bermakna,
   responsif, tanpa dekorasi berlebihan.
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --gray-soft: #f2f4f7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd { margin: 0; }

button { font-family: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }

.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.topbar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- layout ---------- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* ---------- banner ---------- */

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13px;
}

.banner[hidden] { display: none; }

.banner--info { background: var(--accent-soft); border-color: #d1e0ff; color: #1d4ed8; }
.banner--warn { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }
.banner--danger { background: var(--danger-soft); border-color: #fecdca; color: var(--danger); }

/* ---------- kpi cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  min-height: 36px;
}
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.kpi-value--time { font-size: 20px; }
.kpi-value--time .kpi-value-day { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.kpi-meta { margin-top: 8px; font-size: 12.5px; color: var(--muted); min-height: 19px; }

.kpi-change { display: flex; align-items: baseline; gap: 6px; }
.kpi-change .arrow { font-size: 18px; }

/* ---------- panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.panel-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.panel-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.panel-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- chart ---------- */

.chart-wrap { position: relative; height: 320px; }

.chart-note { margin-top: 12px; font-size: 12px; color: var(--muted); }

.chart-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
  border-radius: 8px;
}
.chart-overlay[hidden] { display: none; }

/* ---------- segmented control ---------- */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.seg button:hover { color: var(--text); }

.seg button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.seg button:focus-visible,
.btn:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- badges & pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--live { background: var(--ok-soft); color: var(--ok); border-color: #a6f4c5; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.pill--ok { background: var(--ok-soft); color: var(--ok); border-color: #a6f4c5; }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.pill--gray { background: var(--gray-soft); color: var(--muted); border-color: var(--border); }
.pill--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }

.pill--dot-live .dot { animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .pill--dot-live .dot { animation: none; }
}

/* ---------- table ---------- */

.table-scroll { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: var(--surface-muted); }

.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.cell-time { color: var(--text); }
.cell-time small { display: block; color: var(--muted-2); font-size: 11.5px; }

.table-empty { padding: 36px 12px; text-align: center; color: var(--muted); }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.table-summary { font-size: 12.5px; color: var(--muted); }

.pager { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 550;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-muted); }
.btn:disabled { color: var(--muted-2); cursor: not-allowed; }

select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 8px;
}

.page-label { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- system panel ---------- */

.dl { display: flex; flex-direction: column; }

.dl-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f1f3;
  font-size: 13px;
}
.dl-row:last-child { border-bottom: 0; }

.dl-row dt { color: var(--muted); flex: 0 0 auto; }
.dl-row dd { text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; word-break: break-word; }

.dl-row--note { display: block; }
.dl-row--note dd { text-align: left; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.45; }

.status-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 14px; }
.status-line:not(:last-child) { border-bottom: 1px solid #f0f1f3; }

/* ---------- footer ---------- */

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 32px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.footer p + p { margin-top: 4px; }
.footer strong { color: var(--muted); font-weight: 600; }

/* ---------- loading / skeleton ---------- */

.is-loading .loading-bar {
  display: block;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.loading-bar { display: none; }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .is-loading .loading-bar { animation: none; }
}

/* ---------- responsive ---------- */

/* Cegah halaman melebar ke kanan; tabel punya scroll sendiri */
html, body { overflow-x: clip; }
.container > *, .panel, .card, .chart-wrap, .table-scroll { min-width: 0; }

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

@media (max-width: 600px) {
  /* Header ringkas: baris 1 judul, baris 2 badge + tombol */
  .topbar-inner { padding: 10px 16px; gap: 8px; }
  .brand { gap: 10px; min-width: 0; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-title { font-size: 14px; }
  .brand-sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-meta { width: 100%; gap: 6px; }
  .topbar-meta .badge, .topbar-meta .pill { font-size: 10.5px; padding: 4px 8px; }
  .topbar-meta .btn { margin-left: auto; padding: 5px 9px; font-size: 11.5px; }

  .container { padding: 12px 16px 0; gap: 12px; }
  .panel { padding: 16px; }
  .panel-head { margin-bottom: 12px; }
  .panel-title { font-size: 14px; }
  .panel-sub, .chart-note { font-size: 11.5px; }

  .kpi-grid { gap: 10px; }
  .card { padding: 12px 14px; }
  .kpi-label { font-size: 10.5px; letter-spacing: 0.04em; }
  .kpi-value { font-size: 22px; margin-top: 6px; min-height: 0; }
  .kpi-value--time { font-size: 16px; }
  .kpi-value .pill { font-size: 11px; padding: 4px 8px; white-space: normal; }
  .kpi-meta { font-size: 11px; margin-top: 6px; min-height: 0; }
  .kpi-change { flex-wrap: wrap; }

  .chart-wrap { height: 220px; }
  .panel-actions { width: 100%; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; padding: 6px 4px; font-size: 11.5px; }

  /* Tabel: geser di dalam panel saja, bukan seluruh halaman */
  .table-scroll {
    margin: 0 -16px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 500px; }

  .table-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .pager { flex-wrap: wrap; gap: 8px; }
  .pager .btn { padding: 6px 9px; font-size: 11.5px; }
  .page-label { font-size: 11.5px; }
  .table-summary { font-size: 11.5px; }
  .footer { padding: 4px 16px 28px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
