:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-muted: #eef2f7;
  --text: #172033;
  --muted: #667085;
  --border: #d9e0ea;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --indigo: #4f46e5;
  --blue: #2563eb;
  --slate: #475569;
  --shadow: 0 10px 28px rgba(31, 41, 55, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover {
  border-color: #98a2b3;
  background: #f8fafc;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

select,
input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 10px;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 184, 166, 0.2);
  border-color: var(--teal);
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1.12;
}

h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.header-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--bg);
}

main {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 32px) 28px;
}

.filter-panel,
.panel,
.table-panel,
.summary-card,
.loading-state,
.error-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filter-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 0.8rem;
  font-weight: 800;
}

.filter-actions {
  display: grid;
  grid-column: span 2;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#exportButton {
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
}

#exportButton:hover {
  background: #0d665f;
}

.loading-state,
.error-state {
  margin-bottom: 16px;
  padding: 16px;
  color: var(--muted);
}

.error-state {
  color: var(--red);
  border-color: rgba(185, 28, 28, 0.3);
  background: #fff5f5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  position: relative;
  min-height: 122px;
  overflow: hidden;
  padding: 14px;
}

.summary-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--teal);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  line-height: 1;
}

.summary-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.accent-teal::before {
  background: var(--teal);
}

.accent-green::before {
  background: var(--green);
}

.accent-amber::before {
  background: var(--amber);
}

.accent-slate::before {
  background: var(--slate);
}

.accent-indigo::before {
  background: var(--indigo);
}

.accent-red::before {
  background: var(--red);
}

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

.panel {
  min-height: 310px;
  padding: 16px;
}

.panel-status {
  grid-column: span 2;
}

.wide-panel {
  grid-column: span 2;
}

.panel-header,
.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header span,
.table-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-visual {
  display: grid;
  grid-template-columns: minmax(180px, 0.85fr) 1fr;
  gap: 12px;
  align-items: center;
}

#statusDonut {
  width: 100%;
  height: 230px;
}

.legend-list,
.bar-list,
.ranking-list {
  display: grid;
  gap: 9px;
}

.legend-item,
.bar-item,
.ranking-item {
  display: grid;
  gap: 6px;
}

.legend-row,
.bar-row,
.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: #344054;
  font-size: 0.85rem;
  font-weight: 800;
}

.legend-name,
.ranking-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-count,
.bar-value,
.ranking-value {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 999px;
  vertical-align: middle;
}

.track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--teal);
}

.ranking-meta {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

#officerBars {
  max-height: 620px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

#officerBars::-webkit-scrollbar {
  width: 8px;
}

#officerBars::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 999px;
}

#officerBars::-webkit-scrollbar-thumb {
  background: #b7c3d4;
  border-radius: 999px;
}

.table-panel {
  overflow: hidden;
}

.table-header {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.table-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  min-width: min(520px, 100%);
}

.table-search-label {
  width: min(360px, 100%);
}

.page-size-label {
  width: 120px;
}

.table-wrap {
  overflow: auto;
  max-height: 620px;
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e8edf3;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #344054;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

td.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.petugas-cell,
.region-cell,
.respondent-cell {
  min-width: 170px;
  max-width: 280px;
}

.cell-main {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.cell-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.76rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge-open {
  color: #334155;
  background: #e2e8f0;
}

.badge-draft {
  color: #92400e;
  background: #fef3c7;
}

.badge-submitted {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge-approved,
.badge-edited {
  color: #166534;
  background: #dcfce7;
}

.badge-rejected {
  color: #991b1b;
  background: #fee2e2;
}

.badge-revoked {
  color: #4b5563;
  background: #e5e7eb;
}

.badge-default {
  color: #344054;
  background: #eef2f7;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.pagination span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.app-footer {
  padding: 0 clamp(18px, 4vw, 44px) 28px;
  color: var(--muted);
  font-size: 0.8rem;
}

code {
  border-radius: 4px;
  background: #e8edf3;
  padding: 2px 5px;
}

@media (max-width: 1240px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .visual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-meta {
    justify-content: flex-start;
  }

  .filter-grid,
  .summary-grid,
  .visual-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .panel-status,
  .wide-panel {
    grid-column: auto;
  }

  .status-visual {
    grid-template-columns: 1fr;
  }

  .table-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-tools {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .table-search-label,
  .page-size-label {
    width: 100%;
  }

  .pagination {
    justify-content: space-between;
  }
}
