/* DNS Monitor v2 — tampilan ala aplikasi. Tema gelap/terang lewat [data-theme]. */

:root {
  --bg: #0b1220;
  --bar: rgba(11, 18, 32, .82);
  --surface: #131c30;
  --surface2: #182339;
  --border: #25324d;
  --text: #e8edf7;
  --muted: #93a0b8;
  --accent: #4cc3ff;
  --accent-ink: #04121f;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --ok-bg: rgba(52, 211, 153, .14);
  --bad-bg: rgba(248, 113, 113, .15);
  --warn-bg: rgba(251, 191, 36, .15);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f3f6fb;
  --bar: rgba(243, 246, 251, .85);
  --surface: #ffffff;
  --surface2: #f5f8fc;
  --border: #dbe3f0;
  --text: #0f1a2e;
  --muted: #5b6b86;
  --accent: #0b73c9;
  --accent-ink: #ffffff;
  --ok: #0b7a55;
  --bad: #c42b2b;
  --warn: #8f5f00;
  --ok-bg: rgba(15, 157, 107, .12);
  --bad-bg: rgba(196, 43, 43, .1);
  --warn-bg: rgba(200, 140, 0, .14);
  --shadow: 0 10px 30px rgba(20, 40, 80, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ app bar */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface2); color: var(--muted); margin-right: 4px;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------------ halaman */
.page {
  max-width: 1120px; margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
}
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .val.ok { color: var(--ok); } .stat .val.bad { color: var(--bad); } .stat .val.warn { color: var(--warn); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px; }

.card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card.bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.card.off { opacity: .92; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-title { flex: 1; min-width: 0; }
.card-title strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title span { font-size: 12.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); animation: pulse 1.6s ease-in-out infinite; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  background: var(--surface2); color: var(--muted);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.alert {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 9px 11px; border-radius: 10px; font-size: 13px;
  background: var(--bad-bg); color: var(--bad);
}
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--surface2); color: var(--muted); }
.alert svg.i { width: 18px; height: 18px; margin-top: 1px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--surface2); border-radius: 12px; padding: 9px 11px; min-width: 0; }
.metric .lbl { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.metric .val small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.metric .val.ok { color: var(--ok); } .metric .val.warn { color: var(--warn); } .metric .val.bad { color: var(--bad); }
.metric svg.spark { display: block; width: 100%; height: 22px; margin-top: 2px; }

.chart { background: var(--surface2); border-radius: 12px; padding: 8px 10px 4px; }
.chart .chart-title { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg.c-compact { height: 64px; }
.chart svg.c-full { height: 150px; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .gl { stroke: var(--border); stroke-width: 1; }
.chart-empty { color: var(--muted); font-size: 12px; padding: 8px 0 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface2); color: var(--muted);
}
.chip.ok { color: var(--ok); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip svg.i { width: 13px; height: 13px; stroke-width: 2.6; }

.card-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 2px; }
.card-foot .btn { flex: 1; }
.card-time { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------ tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn.danger { color: #1a0505; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn.primary.loading::after { border-color: var(--accent-ink); border-right-color: transparent; }
.btn.danger.loading::after { border-color: #fff; border-right-color: transparent; }

/* ------------------------------------------------------------ sheet */
dialog { color: var(--text); }
dialog:focus { outline: none; }
dialog.sheet {
  border: 0; padding: 0; background: var(--surface);
  width: min(660px, 100%); max-width: 100%; max-height: min(90dvh, 820px);
  margin: auto; border-radius: 22px; box-shadow: var(--shadow); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
dialog::backdrop { background: rgba(3, 8, 18, .62); }
.sheet-grip { display: none; width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 8px 18px; }
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-title span { font-size: 12.5px; }
.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.sheet-body > * { flex-shrink: 0; }
.sheet-body { overflow-y: auto; padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }

.group-title { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.group-title.danger { color: var(--bad); }
.actions { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.action {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; min-height: 56px;
}
.action:last-child { border-bottom: 0; }
.action:hover:not(:disabled) { background: var(--surface2); }
.action:disabled { opacity: .5; cursor: not-allowed; }
.action .a-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); color: var(--accent); flex: none; }
.action.danger .a-ico { background: var(--bad-bg); color: var(--bad); }
.action .a-txt { flex: 1; min-width: 0; }
.action .a-txt strong { display: block; font-size: 14.5px; }
.action .a-txt span { display: block; font-size: 12.5px; color: var(--muted); }
.action .a-go { color: var(--muted); }
.action.loading .a-go { animation: spin .8s linear infinite; }

.step-head { display: flex; align-items: center; gap: 6px; }
.step-head .icon-btn { margin-left: -8px; }
.step-head h3 { font-size: 17px; }
.step-text { color: var(--muted); font-size: 14px; }
.step-text b { color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
input[type="text"], input[type="password"] {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
input[type="text"]:focus, input[type="password"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
pre.out {
  margin: 0; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border);
  font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto;
}
.result-head { display: flex; align-items: center; gap: 12px; }
.result-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex: none; }
.result-ico.ok { background: var(--ok-bg); color: var(--ok); }
.result-ico.bad { background: var(--bad-bg); color: var(--bad); }
.result-ico svg.i { width: 24px; height: 24px; }

.nta-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.nta-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.nta-item:last-child { border-bottom: 0; }
.nta-item .btn { min-height: 36px; padding: 0 12px; }

.rows { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row:nth-child(even) { background: color-mix(in srgb, var(--surface2) 55%, transparent); }
.row .k { color: var(--muted); }
.row .v { text-align: right; font-variant-numeric: tabular-nums; }

.log { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.log-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.log-item:last-child { border-bottom: 0; }
.log-item .l-sub { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; }

/* ------------------------------------------------------------ menu akun */
dialog.menu {
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  padding: 14px; width: min(300px, calc(100% - 32px)); margin: 64px 16px auto auto; box-shadow: var(--shadow);
}
dialog.menu[open] { display: flex; flex-direction: column; gap: 10px; }
.menu-user { display: flex; flex-direction: column; padding: 2px 4px 6px; }

/* ------------------------------------------------------------ toast */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 460px; width: fit-content; padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  animation: pop .18s ease-out;
}
.toast.ok { background: var(--ok); color: #04150e; }
:root[data-theme="light"] .toast.ok { color: #fff; }
.toast.bad { background: var(--bad); color: #1a0505; }
:root[data-theme="light"] .toast.bad { color: #fff; }

/* ------------------------------------------------------------ login */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow);
}
.login-logo { border-radius: 16px; align-self: flex-start; }
.login h1 { font-size: 24px; letter-spacing: -.01em; }
.login form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.login label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.login .btn { margin-top: 12px; }
.login-error { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
.login-note { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 8px 11px; margin-top: 6px; }

.skeleton { height: 330px; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface) 30%, var(--surface2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--border); }
.page-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }

/* ------------------------------------------------------------ responsif */
@media (max-width: 640px) {
  .brand-text span { display: none; }
  .summary { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 10px; }
  .stat .val { font-size: 18px; }
  dialog.sheet { width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  dialog.sheet[open] { animation: slide .22s ease-out; }
  .sheet-grip { display: block; }
  dialog.menu { margin: 58px 12px auto auto; }
  .pill { padding: 5px 10px; }
}
@media (max-width: 460px) {
  .brand-text { display: none; }
}
@media (max-width: 400px) {
  .metrics { gap: 6px; }
  .metric { padding: 8px; }
  .metric .val { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateY(40px); opacity: .4; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- akun: ubah sandi & kelola akun ---- */
dialog.acct {
  width: min(440px, calc(100vw - 24px)); max-height: 86vh; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: auto;
}
dialog.acct[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.acct .sheet-head { padding: 14px 16px 6px; }
.acct-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.acct-body form { display: flex; flex-direction: column; gap: 6px; }
.acct-body label { font-size: 13px; font-weight: 600; margin-top: 6px; }
.acct-body label.chk { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.acct-body input[type="text"], .acct-body input[type="password"], .acct-body select {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px;
}
.acct-body input:focus, .acct-body select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.acct-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.acct-actions .btn { flex: 0 0 auto; }
.acct-msg { min-height: 0; margin: 6px 0 0; font-size: 13px; }
.acct-msg.bad { color: var(--bad); }
.acct-msg.ok { color: var(--ok); }
.acct-list { display: flex; flex-direction: column; gap: 6px; }
.acct-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; text-align: left;
}
.acct-row:hover, .acct-row:focus-visible { border-color: var(--accent); outline: none; }
.acct-name { font-weight: 600; overflow-wrap: anywhere; }
.small { font-size: 12px; }
[hidden] { display: none !important; }
