:root {
  --bg: #f2f8f4;
  --surface: #ffffff;
  --surface-2: #f6faf7;
  --surface-3: #ecf4ee;
  --line: #e1ebe4;
  --line-soft: #edf3ef;
  --text: #12261a;
  --text-2: #4a5e51;
  --muted: #869789;
  --primary: #22a35a;
  --primary-600: #17894a;
  --primary-700: #116b3a;
  --primary-soft: #e2f6e9;
  --primary-soft-2: #c9eed7;
  --online: #16a34a;
  --offline: #dc2626;
  --warn: #d98a06;
  --crit: #ea580c;
  --dead: #b91c1c;
  --none: #a6b4aa;
  --pon-1: #22a35a;
  --pon-2: #0e7490;
  --shadow: 0 1px 2px rgb(16 40 24 / .04), 0 4px 16px rgb(16 40 24 / .05);
  --shadow-lg: 0 10px 40px rgb(16 40 24 / .16);
  --r: 14px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-600); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
.muted { color: var(--muted); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- tombol & form ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 550; font-size: 13.5px; transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #d3e2d8; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgb(34 163 90 / .28); }
.btn.primary:hover { background: var(--primary-600); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-700); }
.btn.soft:hover { background: var(--primary-soft-2); }
.btn.danger { color: var(--offline); }
.btn.danger:hover { background: #fdf0f0; border-color: #f5cccc; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn:disabled { opacity: .55; cursor: progress; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .field input, .field select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgb(34 163 90 / .13); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; font-size: 13.5px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #d5ded8; position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .2); transition: transform .2s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid; }
.alert.err { background: #fef2f2; border-color: #f8d0d0; color: #9b1c1c; }
.alert.warn { background: #fff8eb; border-color: #f6dfb0; color: #8a5300; }
.alert.ok { background: var(--primary-soft); border-color: var(--primary-soft-2); color: var(--primary-700); }
details.adv { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
details.adv summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); }
details.adv[open] summary { margin-bottom: 12px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { position: relative; overflow: hidden; background: linear-gradient(150deg, #d9f5e3 0%, #b9ebcc 45%, #8fdcae 100%); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::before { content: ""; position: absolute; inset: -20% -10% auto auto; width: 560px; height: 560px; border-radius: 50%; background: radial-gradient(circle, rgb(255 255 255 / .55), transparent 65%); }
.login-art .brand-lg { position: relative; display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; color: var(--primary-700); }
.login-art h1 { position: relative; font-size: 38px; line-height: 1.12; color: #0e3a22; max-width: 460px; letter-spacing: -0.03em; }
.login-art p { position: relative; color: #2c5a3e; max-width: 430px; font-size: 15px; }
.fiber { position: absolute; right: -40px; bottom: 40px; width: 520px; opacity: .9; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(380px, 100%); }
.login-card h2 { font-size: 26px; letter-spacing: -0.02em; }
.login-card .sub { color: var(--muted); margin: 6px 0 28px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card .btn.primary { justify-content: center; padding: 11px; font-size: 14.5px; border-radius: 11px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; font-size: 12px; font-weight: 600; }
.login-foot { margin-top: 28px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- layout app ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, #e6f7ec 0%, #f4fbf6 38%, #ffffff 100%); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand .logo { width: 36px; height: 36px; border-radius: 11px; background: var(--primary); display: grid; place-items: center; box-shadow: 0 4px 12px rgb(34 163 90 / .35); flex: none; }
.brand .logo svg { width: 22px; height: 22px; color: #fff; }
.brand b { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand span { font-size: 11.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 550; transition: background .15s, color .15s; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: rgb(34 163 90 / .08); color: var(--text); }
.nav a.on { background: var(--surface); color: var(--primary-700); box-shadow: var(--shadow); }
.nav a.on svg { color: var(--primary); }
.nav .count { margin-left: auto; font: 600 11px var(--mono); background: var(--primary-soft); color: var(--primary-700); padding: 1px 7px; border-radius: 99px; }
.nav-title { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; padding: 16px 12px 6px; }
.nav-olt a { font-weight: 500; font-size: 13px; padding: 7px 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--none); flex: none; }
.dot.ok { background: var(--online); box-shadow: 0 0 0 3px rgb(22 163 74 / .15); }
.dot.err { background: var(--offline); box-shadow: 0 0 0 3px rgb(220 38 38 / .14); }
.dot.wait { background: var(--warn); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-700); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; font-size: 13px; }
.side-foot .who span { font-size: 11.5px; color: var(--muted); }
.mobile-bar { display: none; }

.main { padding: 26px 32px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 23px; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; gap: 10px; }
.card-head h2 { font-size: 15px; }
.card-body { padding: 16px 18px 18px; }

/* status chip */
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); }
.chip.ok { background: var(--primary-soft); border-color: transparent; color: var(--primary-700); }
.chip.err { background: #fdeeee; border-color: transparent; color: #a11d1d; }
.chip .pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(22 163 74 / .5); } 100% { box-shadow: 0 0 0 7px transparent; } }

/* OLT switcher */
.olt-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.olt-tab { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap; transition: all .15s; }
.olt-tab:hover { border-color: var(--primary-soft-2); }
.olt-tab.on { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(34 163 90 / .12); }
.olt-tab b { font-size: 13.5px; }
.olt-tab span { font: 12px var(--mono); color: var(--muted); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 7px; }
.kpi .val { font: 650 30px/1.15 var(--mono); letter-spacing: -0.03em; margin-top: 8px; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; letter-spacing: 0; }
.kpi .ft { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kpi.hero { background: linear-gradient(140deg, #22a35a, #17894a); color: #fff; border: 0; }
.kpi.hero .lbl, .kpi.hero .ft, .kpi.hero .val small { color: rgb(255 255 255 / .85); }
.kpi .ring { position: absolute; right: -24px; top: -24px; width: 96px; height: 96px; border-radius: 50%; background: rgb(255 255 255 / .12); }
.sw { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex: none; }

/* PON */
.pons { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; margin-top: 14px; }
.pon .top { display: flex; justify-content: space-between; align-items: center; }
.pon h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pon .row { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; margin-top: 12px; }
.big { font: 650 34px/1 var(--mono); letter-spacing: -0.03em; }
.big small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.bar { display: flex; gap: 2px; height: 9px; margin-top: 12px; }
.bar span { border-radius: 3px; min-width: 3px; transition: flex-grow .4s; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12.5px; margin: 0; align-content: start; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); }
.spark-box { position: relative; margin-top: 14px; }
.spark-box .cap { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
svg.spark { width: 100%; height: 48px; display: block; overflow: visible; }
.tip { position: absolute; pointer-events: none; background: #12261a; color: #fff; border-radius: 7px; padding: 4px 8px; font: 11.5px var(--mono); white-space: nowrap; transform: translate(-50%, -115%); display: none; z-index: 5; }
.pill { font: 700 10.5px var(--mono); letter-spacing: .05em; padding: 3px 9px; border-radius: 99px; display: inline-flex; align-items: center; gap: 5px; text-transform: uppercase; }
.pill.up { background: var(--primary-soft); color: var(--primary-700); }
.pill.down { background: #fdeeee; color: #a11d1d; }
.pill.na { background: var(--surface-3); color: var(--muted); }

/* tabel ONU + log */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; margin-top: 14px; align-items: start; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.seg { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(16 40 24 / .1); }
.seg button .c { font: 11px var(--mono); color: var(--muted); margin-left: 4px; }
.search { margin-left: auto; position: relative; }
.search input { padding-left: 32px; min-width: 230px; background: var(--surface-2); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.table-wrap { overflow: auto; max-height: calc(100vh - 180px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
thead th.sorted { color: var(--primary-700); }
thead th.sorted::after { content: " ↓"; }
thead th.sorted.asc::after { content: " ↑"; }
th.r, td.r { text-align: right; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr { transition: background .15s; }
tbody tr.click { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.off td { color: var(--muted); }
tbody tr.flash { animation: flash 2.2s ease-out; }
@keyframes flash { from { background: #fff4d6; } to { background: transparent; } }
td.id { font-family: var(--mono); color: var(--text-2); }
td.id b { color: var(--text); }
td.nm { max-width: 230px; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
td.nm i { color: var(--muted); font-weight: 400; }
td.mac { font: 12px var(--mono); color: var(--text-2); }
.st { display: inline-flex; align-items: center; gap: 7px; font-weight: 550; font-size: 12.5px; padding: 3px 10px 3px 8px; border-radius: 99px; }
.st i { width: 7px; height: 7px; border-radius: 50%; }
.st.online { background: #e7f7ed; color: #13703a; }
.st.online i { background: var(--online); }
.st.offline { background: #fdeeee; color: #a11d1d; }
.st.offline i { background: var(--offline); }
.st.unknown { background: var(--surface-3); color: var(--muted); }
.st.unknown i { background: var(--none); }
.rx { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); }
.rx .b { width: 44px; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.rx .b span { display: block; height: 100%; border-radius: 3px; background: var(--c); }
.c-good { --c: var(--online); } .c-warn { --c: var(--warn); } .c-crit { --c: var(--crit); } .c-dead { --c: var(--dead); } .c-none { --c: var(--none); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--primary-soft-2); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

.events ol { list-style: none; margin: 0; padding: 6px 10px 12px; max-height: calc(100vh - 200px); overflow: auto; }
.events li { display: grid; grid-template-columns: 26px 1fr; gap: 1px 10px; padding: 9px 8px; border-radius: 10px; font-size: 12.5px; }
.events li:hover { background: var(--surface-2); }
.events li .ic { grid-row: span 2; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.events li .t { color: var(--muted); font: 11px var(--mono); }
.events li.new { animation: flash 2.5s ease-out; }
.ev-down .ic, .ev-error .ic { background: #fdeeee; color: var(--offline); }
.ev-up .ic { background: #e7f7ed; color: var(--online); }
.ev-warn .ic { background: #fff4df; color: var(--warn); }
.ev-info .ic { background: var(--surface-3); color: var(--text-2); }
.foot-info { margin-top: 14px; font: 12px var(--mono); color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }

/* OLT list */
.olt-list td .acts { display: flex; gap: 6px; justify-content: flex-end; }
.olt-name b { display: block; font-size: 14px; }
.olt-name span { font: 12px var(--mono); color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.settings-grid .card-body { display: flex; flex-direction: column; gap: 14px; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* modal & drawer */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgb(18 38 26 / .38); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; padding: 20px; }
.overlay.open { display: flex; }
.modal { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.wide { width: min(860px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.x { border: 0; background: var(--surface-3); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 18px; color: var(--text-2); }
.x:hover { background: var(--line); }
.overlay.drawer { justify-content: flex-end; padding: 0; align-items: stretch; }
.drawer .modal { border-radius: 0; height: 100vh; max-height: none; width: min(540px, 100vw); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
pre.term { margin: 0; background: #0f2418; color: #c9f0d6; border-radius: 12px; padding: 14px 16px; font: 12px/1.55 var(--mono); max-height: 420px; overflow: auto; white-space: pre; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 9px; font: 11.5px var(--mono); cursor: pointer; }
.quick button:hover { border-color: var(--primary); color: var(--primary-700); }
.d-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.d-grid div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.d-grid span { display: block; font-size: 11.5px; color: var(--muted); }
.d-grid b { font: 600 15px var(--mono); }
svg.chart { width: 100%; height: 230px; display: block; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--primary-soft-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.test-res { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.test-res div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.test-res span { display: block; font-size: 11px; color: var(--muted); }
.test-res b { font: 600 15px var(--mono); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--primary)); border-radius: 12px; padding: 11px 15px; font-size: 13px; min-width: 260px; max-width: 380px; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; }
.toast b { display: block; font-size: 13px; }

@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .events ol { max-height: 380px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 260px; left: 0; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
  .main { padding: 18px 14px 32px; }
  .form-grid, .pon .row { grid-template-columns: 1fr; }
  .pons, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .search { margin-left: 0; width: 100%; }
  .search input { min-width: 0; width: 100%; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .test-res { grid-template-columns: repeat(2, 1fr); }
}
a.btn, a.olt-tab { text-decoration: none; color: inherit; }
.app > div { min-width: 0; }
.search input { min-width: 0; width: 220px; }
@media (max-width: 860px) { .search input { width: 100%; } .page-head .actions { width: 100%; } }
