:root {
  --bg: #121212; --panel: #1b1b1b; --panel2: #222; --border: #2c2c2c; --text: #ececec; --muted: #9a9a9a;
  --accent: #3b82f6; --accent-soft: #1e3a5f; --green: #22c55e; --yellow: #eab308; --red: #ef4444; --orange: #f97316;
  --warn-bg: #2a2110; --warn-border: #a16207;
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --panel: #fff; --panel2: #f1f3f6; --border: #e3e6ea; --text: #16181d; --muted: #667085;
  --accent-soft: #e0ecff; --warn-bg: #fff7e6; --warn-border: #f0b429;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--bg); }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 12px; }
.brand .logo { background: var(--accent); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
nav { flex: 1; overflow-y: auto; }
nav .group { color: var(--muted); font-size: 11px; letter-spacing: .06em; margin: 14px 8px 6px; }
nav a { display: block; color: var(--text); padding: 7px 10px; border-radius: 7px; margin-bottom: 2px; }
nav a:hover { background: var(--panel2); }
nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.side-foot small { color: var(--muted); display: block; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; }
main { flex: 1; padding: 28px 32px; max-width: 1180px; margin: 0 auto; width: 100%; }
.menu-btn { display: none; }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: 2fr 1fr; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .val { font-size: 24px; font-weight: 700; margin: 4px 0 2px; }
.stat .hint { color: var(--muted); font-size: 12px; }
.up { color: var(--green); } .down { color: var(--red); }
.alert { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.hijau { background: var(--green); } .dot.kuning { background: var(--yellow); } .dot.merah { background: var(--red); } .dot.abu { background: #555; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--green); border-color: #14532d; } .badge.bad { color: var(--red); border-color: #7f1d1d; } .badge.info { color: var(--accent); border-color: var(--accent-soft); }
.badge.mode-AUTO { color: var(--green); } .badge.mode-LAPOR { color: var(--yellow); } .badge.mode-STOP { color: var(--red); }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }
.chart-box { position: relative; height: 260px; }
.bars .bar { margin-bottom: 10px; } .bars .bar-top { display: flex; justify-content: space-between; font-size: 13px; }
.bars .track { height: 6px; background: var(--panel2); border-radius: 4px; margin-top: 4px; } .bars .fill { height: 6px; background: var(--accent); border-radius: 4px; }
.rule { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rule + .rule { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.rule .conds { color: var(--muted); font-size: 13px; margin-top: 4px; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #444; border-radius: 22px; cursor: pointer; transition: .2s; }
.switch span:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span:before { transform: translateX(16px); }
.cond-row { display: grid; grid-template-columns: 1.4fr .6fr .7fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal .card { width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 30; max-width: 360px; }
.toast.show { opacity: 1; }
.err { color: var(--red); min-height: 1em; }
.muted { color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
pre.report { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }
details summary { cursor: pointer; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -230px; z-index: 10; transition: .2s; } .sidebar.open { left: 0; }
  .menu-btn { display: inline-block; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; margin-bottom: 12px; font-size: 16px; }
  main { padding: 16px; }
  .cond-row { grid-template-columns: 1fr 1fr; }
}
.rule > .row { flex-wrap: nowrap; }
