:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --good: #0ca30c;
  --critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --good: #0ca30c;
    --critical: #e66767;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-block: 16px;
  padding-inline: 16px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.app-header {
  max-width: 1400px;
  margin: 0 auto 16px;
}
.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}
.subtitle {
  margin: 0;
  color: var(--text-secondary);
}

.app-main {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.status-box {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.status-box.status-error {
  color: var(--critical);
  border-color: var(--critical);
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  flex: 1 1 auto;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-item label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.filter-item select,
.filter-item input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
}
.search-item {
  max-width: 360px;
  margin: 12px 0 16px;
}
.btn-secondary {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--gridline);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-secondary:hover {
  background: var(--gridline);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: default;
}
.result-count {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.indicator-card h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}
.stacked-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--gridline);
  gap: 2px;
}
.bar-seg {
  height: 100%;
}
.legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.muted {
  color: var(--text-muted);
}
.small {
  font-size: 0.8rem;
}

.table-scroll {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 820px;
  font-size: 0.85rem;
}
th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  text-align: left;
  white-space: nowrap;
}
.col-nama {
  white-space: normal;
  min-width: 200px;
}
th {
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface-1);
}

/* Di layar lebar (laptop ke atas), padatkan tabel dengan lebar kolom
   tetap (lihat <colgroup> di index.html) supaya semua kolom muat dalam
   satu layar tanpa perlu scroll horizontal. */
@media (min-width: 960px) {
  table {
    table-layout: fixed;
    min-width: 0;
    font-size: 0.78rem;
  }
  th,
  td {
    padding: 6px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .col-nama {
    white-space: nowrap;
    min-width: 0;
  }
  th {
    font-size: 0.72rem;
    white-space: normal;
    line-height: 1.25;
    vertical-align: bottom;
  }
}
tbody tr {
  cursor: pointer;
}
tbody tr:hover {
  background: var(--surface-2);
}
tr.row-expanded {
  background: var(--surface-2);
  font-weight: 600;
}

.chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.chip-muted {
  background: transparent;
  color: var(--text-muted);
  padding: 0;
}
.trend {
  font-size: 0.75rem;
}
.col-indicator {
  text-align: center;
}

.detail-row td {
  background: var(--surface-2);
  cursor: default;
}
.detail-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 8px 0;
}
.detail-indicator h4 {
  margin: 0 0 6px;
  font-size: 0.85rem;
}
.detail-indicator dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  font-size: 0.8rem;
}
.detail-indicator dt {
  color: var(--text-secondary);
}
.detail-indicator dd {
  margin: 0;
  font-weight: 600;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.app-footer {
  max-width: 1400px;
  margin: 16px auto 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.app-footer a {
  color: var(--accent);
}
