:root {
    --bg: #f4f5f7; --fg: #1d2330; --muted: #6b7280; --card: #fff; --line: #d9dce1; --accent: #1f6feb;
    --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; }
.kecil { font-size: .85rem; color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* ---------- admin/leader ---------- */
.topnav { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: .75rem 16px; background: var(--fg); color: #fff; }
.topnav a { color: #cfd6e3; text-decoration: none; }
.topnav a:hover { color: #fff; }
.topnav .kanan { margin-left: auto; }
.topnav button { background: none; border: 1px solid #556; color: #cfd6e3; border-radius: 6px; padding: .3rem .7rem; cursor: pointer; }
.isi { padding: 1rem 16px; max-width: 1400px; margin: 0 auto; }
.filter { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin-bottom: 1rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
label:has(input[type=checkbox]) { flex-direction: row; align-items: center; }
input, select { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 0; }
input[type=number] { width: 7rem; }
.btn { display: inline-block; font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: .55rem 1rem; cursor: pointer; text-decoration: none; }
.btn.kecil { padding: .3rem .7rem; font-size: .85rem; }
.btn.besar { font-size: 1.15rem; padding: .9rem 1.5rem; margin-top: 1rem; width: 100%; max-width: 420px; }
.btn:disabled { opacity: .5; }
.pesan { padding: .6rem .9rem; border-radius: 6px; background: var(--card); border-left: 4px solid currentColor; }
.tabel { border-collapse: collapse; background: var(--card); width: 100%; }
.tabel th, .tabel td { border: 1px solid var(--line); padding: .4rem .5rem; text-align: left; }
.tabel th { background: #eceef2; }
.scroll { overflow-x: auto; }
.rekap td, .rekap th { text-align: center; font-size: .85rem; white-space: nowrap; }
.rekap td:first-child { text-align: left; font-weight: 600; }
.input-list { display: grid; gap: .75rem; }
.input-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem .75rem; background: var(--card); padding: .75rem; border-radius: 8px; border: 1px solid var(--line); }
.input-row .judul { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.input-row input, .input-row select { width: 100%; font-size: 1.1rem; }
.master-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.master-grid input:not([type=checkbox]) { width: 100%; }
.kartu-form { max-width: 360px; margin: 3rem auto; background: var(--card); padding: 1.5rem; border-radius: 10px; display: grid; gap: 1rem; }
.kartu-form form { display: grid; gap: 1rem; }

/* ---------- monitor TV ---------- */
.tv { --bg: #0b1020; --card: #151c33; --fg: #e8ecf5; --muted: #8a94ad; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444;
      min-height: 100vh; background: var(--bg); color: var(--fg); padding: 1.2vw 1.5vw; font-size: clamp(14px, 1.15vw, 32px);
      display: flex; flex-direction: column; gap: 1vw; }
.tv-kosong { font-size: 2.5em; text-align: center; margin-top: 30vh; color: var(--muted); }
.tv-head { display: flex; justify-content: space-between; align-items: center; gap: 2vw; }
.tv-judul { font-size: 1.8em; font-weight: 800; letter-spacing: .05em; }
.tv-total { font-size: 2.6em; font-weight: 800; text-align: center; }
.tv-total .kecil { font-size: .4em; font-weight: 400; }
.tv-jam { font-size: 3em; font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-error { background: var(--bad); color: #fff; paddingclaude: .4em .8em; border-radius: 6px; }
.tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(240px, 18vw), 1fr)); gap: 1vw; flex: 1; align-content: start; }
.tv-kartu { background: var(--card); border-radius: 12px; padding: .9em 1em; border-top: 6px solid var(--muted); }
.tv-kartu.ok { border-top-color: var(--ok); } .tv-kartu.warn { border-top-color: var(--warn); } .tv-kartu.bad { border-top-color: var(--bad); }
.tv-kartu.loss { animation: kedip 1.2s infinite; }
@keyframes kedip { 50% { box-shadow: 0 0 0 4px var(--bad); } }
@media (prefers-reduced-motion: reduce) { .tv-kartu.loss { animation: none; box-shadow: 0 0 0 4px var(--bad); } }
.tv-nama { display: flex; justify-content: space-between; font-size: 1.6em; font-weight: 800; margin-bottom: .3em; }
.tv-kartu.ok .tv-pct { color: var(--ok); } .tv-kartu.warn .tv-pct { color: var(--warn); } .tv-kartu.bad .tv-pct { color: var(--bad); }
.tv-baris { display: flex; justify-content: space-between; margin-top: .5em; color: var(--muted); }
.tv-baris b { color: var(--fg); font-size: 1.3em; }
.tv-loss { color: var(--bad); font-weight: 700; margin-top: .2em; }
.bar { position: relative; height: .7em; background: #263052; border-radius: 99px; overflow: hidden; margin-top: .25em; flex: 1; }
.bar-isi { height: 100%; background: var(--muted); border-radius: 99px; transition: width .6s; }
.bar-isi.ok { background: var(--ok); } .bar-isi.warn { background: var(--warn); } .bar-isi.bad { background: var(--bad); }
.bar-target { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; }
.tv-perjam { display: flex; gap: .6vw; height: 22vh; background: var(--card); border-radius: 12px; padding: .8em 1em; }
.tv-perjam .kol { flex: 1; display: flex; flex-direction: column; align-items: center; color: var(--muted); }
.tv-perjam .kol.kini { color: var(--fg); font-weight: 700; }
.tv-perjam .angka { height: 1.4em; color: var(--fg); }
.batang-wrap { position: relative; flex: 1; width: 60%; }
.batang { position: absolute; bottom: 0; width: 100%; background: var(--accent, #3b82f6); border-radius: 4px 4px 0 0; transition: height .6s; }
.batang.ok { background: var(--ok); } .batang.warn { background: var(--warn); } .batang.bad { background: var(--bad); }
.garis-target { position: absolute; left: -15%; right: -15%; border-top: 3px dashed #fff; }
.legenda { color: var(--muted); font-size: .85em; }
.tv-dua { display: grid; grid-template-columns: 2fr 1fr; gap: 2vw; flex: 1; }
.tv-dua > div { background: var(--card); border-radius: 12px; padding: 1em 1.5em; }
.tv-dua h2 { font-size: 1.8em; margin: 0 0 .6em; }
.rank { display: flex; align-items: center; gap: 1em; font-size: 1.5em; padding: .3em 0; }
.rank .no { width: 1.5em; color: var(--muted); }
.rank .nama { width: 7em; }
.rank .bar { height: .6em; }
.rank b { margin-left: auto; min-width: 4.5em; text-align: right; }
@media (max-width: 800px) { .tv-head, .tv-dua { flex-direction: column; grid-template-columns: 1fr; } }
.tv-pilih { position: fixed; top: .5vw; right: .5vw; display: flex; gap: .4em; opacity: .25; transition: opacity .2s; z-index: 5; font-size: 14px; }
.tv-pilih:hover, .tv-pilih:focus-within { opacity: 1; }
.tv-pilih input, .tv-pilih select, .tv-pilih button { background: var(--card); color: var(--fg); border: 1px solid #334; border-radius: 6px; padding: .3em .5em; font: inherit; color-scheme: dark; }
.tv-pilih button { cursor: pointer; color: var(--ok); }
.tv-arsip { font-size: .5em; vertical-align: middle; background: var(--warn); color: #000; padding: .15em .5em; border-radius: 6px; letter-spacing: .1em; }

/* ---------- chart rekap ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; min-width: 0; }
.chart-card.lebar { grid-column: 1 / -1; }
.chart-card h2 { margin: 0; font-size: 1.05rem; }
.chart-card > .kecil { margin: .15rem 0 .9rem; }
.chart-scroll { overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; min-width: 560px; }
.chart-svg text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart-svg .ytick { text-anchor: end; font-variant-numeric: tabular-nums; }
.chart-svg .xtick, .chart-svg .nilai { text-anchor: middle; }
.chart-svg .nilai { fill: var(--fg); font-weight: 600; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .ref { stroke: var(--muted); stroke-width: 1.5; }
.chart-svg .garis { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .titik { fill: var(--accent); stroke: var(--card); stroke-width: 2; pointer-events: none; }
.chart-svg .hit { fill: transparent; }
.chart-svg .hit:hover { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.barh { display: grid; grid-template-columns: minmax(4.5rem, max-content) minmax(0, 1fr) max-content; gap: .45rem .75rem; align-items: center; }
.barh.ada-ref { padding-top: 1.1rem; }
.barh-label { grid-column: 1; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barh-track { grid-column: 2; position: relative; height: 18px; }
.barh-bar { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 0 4px 4px 0; }
.barh-bar.neg { border-radius: 4px 0 0 4px; }
.barh-val { grid-column: 3; font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.barh-ref-wrap { grid-column: 2; position: relative; align-self: stretch; pointer-events: none; }
.barh-ref { position: absolute; top: -.2rem; bottom: -.2rem; border-left: 1.5px solid var(--muted); }
.barh-ref span { position: absolute; top: -1.15rem; transform: translateX(-50%); font-size: .75rem; color: var(--muted); }
