/* Dashboard petugas: tema lingkungan; grid ringkas mengikuti referensi PERPETUGAS. */
:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #20372c;
  background: #f5f7f3;
  --green: #174d3c;
  --muted: #758578;
  --line: #e1e8de;
  --approved: #238b57;
  --submitted: #2f6fed;
  --rejected: #c4473a;
  --pending: #a58336;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #a7ca9c;
  outline-offset: 2px;
}
.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;
}
.skip-link { position: absolute; left: 20px; top: -60px; background: white; padding: 12px; z-index: 31; }
.skip-link:focus { top: 10px; }

/* Satu viewport dinamis: toolbar, pesan, header, semua petugas, lalu total wilayah.
   Total berada dalam alur flex sehingga tidak menutupi baris terakhir. */
body.ranking-page { height: 100vh; height: 100dvh; overflow: hidden; }
.ranking-page main {
  width: 100%; max-width: 1280px; height: 100%; min-height: 0;
  margin: 0 auto; padding: 68px 20px max(8px, env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column;
}
.ranking-page .sitasi-controls { flex-wrap: wrap; max-width: calc(100vw - 86px); }
#dashboard-content { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.ranking-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.officer-table { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; width: 100%; }
.officer-table-head { flex: none; border-bottom: 1px solid #dfe8d8; }
/* Jumlah baris diisi fitRankingRows(). Tidak ada slice, pagination, atau baris disembunyikan.
   Maksimum 48px per baris; layar pendek membagi sisa ruang ke semua baris. */
#ranking-body {
  --row-gap: 4px;
  display: grid; grid-template-rows: repeat(var(--officer-count, 1), minmax(0, 1fr));
  gap: var(--row-gap); flex: 1 1 0; min-height: 0;
  max-height: calc(var(--officer-count, 1) * 48px + (var(--officer-count, 1) - 1) * var(--row-gap));
}
#county-body { flex: 0 0 44px; min-height: 0; margin-top: auto; }

/* Empat area tetap. Hanya area ketiga (strip status) yang dapat digeser. */
.officer-grid {
  display: grid;
  grid-template-columns: clamp(24px, 6.6vw, 36px) minmax(0, 45fr) minmax(0, 39fr) clamp(48px, 15vw, 78px);
  align-items: center; gap: clamp(3px, .9vw, 10px); padding: 4px clamp(6px, 2vw, 12px);
}
.officer-header { font-size: clamp(9px, 1.8vw, 11px); font-weight: 650; color: #788b6d; border: 1px solid transparent; }
.officer-name-heading { min-width: 0; text-align: left; }
.officer-progress-heading { text-align: center; white-space: nowrap; }
.officer-row {
  position: relative; min-height: 0; height: 100%; margin: 0;
  border: 1px solid #e1e8dc; border-radius: 8px; background: #fff;
}
.officer-row::before { content: ""; position: absolute; inset: 7px auto 7px 0; width: 3px; background: #c0d1af; border-radius: 3px; }
.officer-row.top-rank { background: #f8fbf3; border-color: #d4e3c6; }
.officer-row.top-rank::before { background: #709b53; }
.officer-row.officer-complete { background: #edf7eb; border-color: #b8d5b0; }
.officer-row.officer-complete::before { background: #40854c; }
.rank-cell { min-width: 0; text-align: center; }
.rank-badge { display: block; color: #7c916c; font-size: clamp(11px, 2.4vw, 14px); font-weight: 650; }
.officer-name, .officer-name > div { min-width: 0; }
/* Avatar disembunyikan seperti aturan aktif PERPETUGAS; ruang nama lebih lebar. */
.officer-avatar { display: none; }
.name-button {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  width: 100%; max-height: 2.3em; overflow: hidden; overflow-wrap: anywhere;
  background: transparent; border: 0; padding: 0; text-align: left;
  font-size: clamp(10px, 2.25vw, 13px); font-weight: 650; line-height: 1.15; color: #344c2c;
}
.name-button:hover { text-decoration: underline; text-underline-offset: 2px; }
.officer-meta { display: block; margin-top: 2px; color: #809170; font-size: clamp(8px, 1.7vw, 10px); line-height: 1.1; }
.officer-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tiga metrik terlihat sekaligus, seluruh header/baris/total disinkronkan metric-scroll.js.
   Scroll tetap native agar swipe, roda horizontal, dan keyboard header berfungsi. */
.metric-strip {
  min-width: 0; width: 100%; display: flex; gap: clamp(2px, .9vw, 6px);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.metric-strip::-webkit-scrollbar { display: none; }
.metric-strip:focus-visible { outline: 2px solid #91b57e; outline-offset: 2px; border-radius: 4px; }
.strip-cell {
  flex: 0 0 calc((100% - 2 * clamp(2px, .9vw, 6px)) / 3); min-width: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  scroll-snap-align: start; font-variant-numeric: tabular-nums;
}
.metric-strip-header .strip-cell { padding: 3px 0; white-space: nowrap; }
.metric-toggle { border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: 5px; }
.metric-toggle:hover { background: #eaf1e1; }
.metric-toggle:focus-visible { outline: 2px solid #8bac76; outline-offset: -2px; }
.officer-row .metric-toggle, .officer-row .strip-value {
  padding: 3px 1px; min-width: 0; width: 100%; font-size: clamp(10px, 2.2vw, 13px);
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.2;
}
.status-open { color: #819078; }
.status-draft { color: #8b7da2; }
.status-submitted { color: var(--submitted); }
.status-rejected { color: var(--rejected); }
.status-approved { color: var(--approved); }
.status-pending { color: var(--pending); }
.status-approved .metric-toggle { font-weight: 700; }
.officer-progress { min-width: 0; text-align: center; color: #577d3d; font-size: clamp(11px, 2.35vw, 15px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.officer-progress strong { font-weight: 700; }
.officer-county-total { border-color: #a9c79b; background: linear-gradient(180deg, #edf7e8, #f8fcf4); }
.officer-county-total::before { background: #538347; }
.officer-county-total .rank-cell, .county-name strong, .officer-county-total .officer-progress { color: #285d3c; font-weight: 750; }
.county-name strong { font-size: clamp(10px, 2.25vw, 13px); line-height: 1.15; }

/* Pesan sumber lama mengambil ruang nyata sebelum tabel, bukan menimpa nama. */
.notice { flex: none; border: 1px solid #e9dfb8; background: #fbf8ec; border-radius: 8px; padding: 6px 8px; font-size: 11px; line-height: 1.4; color: #8b7748; margin: 0 0 6px; }
.notice.error { color: #9e483c; background: #fff2ee; border-color: #efd8d0; }
#workflow-note { margin: 0; }
/* Satu baris sumber/waktu; tetap dalam alur agar seluruh petugas muat di viewport. */
.cache-status { flex: none; margin: 0 0 5px; color: #60745c; font-size: 10px; line-height: 1.3; }
.cache-status[data-stale="true"] { color: #8b6a32; }
.empty-panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px 16px; text-align: center; overflow: auto; }
.empty-panel h2 { margin: 0; font-size: 20px; }
.empty-panel p { font-size: 12px; line-height: 1.7; color: var(--muted); max-width: 480px; margin: 12px auto 20px; }
.primary-button { display: inline-flex; padding: 11px 14px; border: 1px solid var(--green); border-radius: 8px; background: var(--green); color: white; font-size: 11px; text-decoration: none; }
.no-results { flex: none; text-align: center; color: var(--muted); font-size: 12px; padding: 8px; margin: 0; }

/* Rincian terpisah boleh bergulir; tinggi tabel utama tidak terpengaruh modal. */
dialog { border: 1px solid #dce6d3; border-radius: 16px; max-width: 560px; width: calc(100% - 30px); padding: 25px; color: #304b29; background: #fcfdf9; max-height: 85vh; max-height: 85dvh; overflow: auto; box-shadow: 0 30px 100px #18322025; }
dialog::backdrop { background: #16322160; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.eyebrow { font-size: 10px; letter-spacing: .16em; font-weight: 750; color: #6d8965; margin: 0; }
.icon-button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: #677d66; font-size: 20px; display: grid; place-items: center; }
.dialog-name { font-size: 25px; letter-spacing: -.04em; margin: 0 0 8px; }
.dialog-subtitle { font-size: 11px; color: #8a9c7a; line-height: 1.8; margin-bottom: 24px; }
.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail-summary > div { padding: 15px; background: #eef4e6; border-radius: 9px; }
.detail-summary span { display: block; font-size: 10px; color: #8b9c7a; }
.detail-summary strong { display: block; font-size: 24px; margin-top: 7px; letter-spacing: -.04em; }
.detail-statuses { margin-top: 22px; border-top: 1px solid var(--line); }
.detail-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.detail-note { font-size: 11px; line-height: 1.9; color: #829573; margin-top: 20px; }

/* Pada telepon, switch membungkus menjadi dua baris. Sisakan ruang kontrol di atas. */
@media (max-width: 560px) {
  .ranking-page main { padding: 108px 10px max(8px, env(safe-area-inset-bottom, 0px)); }
  .ranking-page .sitasi-controls { max-width: calc(100vw - 78px); gap: 6px; }
  .officer-grid { gap: 3px; padding-left: 6px; padding-right: 6px; }
  #workflow-note { font-size: 10px; }
}
/* Nama panjang tetap utuh di title/label aksesibilitas/rincian saat ruang vertikal kecil. */
@media (max-height: 680px) {
  .officer-table { gap: 4px; }
  #ranking-body { --row-gap: 3px; }
  #county-body { flex-basis: 38px; }
  .officer-row { padding-top: 2px; padding-bottom: 2px; }
  .name-button { display: block; white-space: nowrap; text-overflow: ellipsis; line-height: 1.1; }
  .officer-meta { font-size: 8px; margin-top: 1px; }
  .officer-row .metric-toggle, .officer-row .strip-value { padding-top: 2px; padding-bottom: 2px; }
}
/* Lanskap pendek: prioritaskan nama dan angka; pengawas tetap tersedia dalam rincian. */
@media (max-height: 440px) {
  #county-body { flex-basis: 30px; }
  .officer-name .officer-meta { display: none; }
  .officer-grid { padding-top: 1px; padding-bottom: 1px; }
  .officer-row .metric-toggle, .officer-row .strip-value { padding-top: 1px; padding-bottom: 1px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
