/* Panel Gerbang — one stylesheet, dark by default, light by system setting or the theme button. */
:root {
  color-scheme: dark;
  --bg: #0a0e1d;
  --bg2: #0e1329;
  --card: #121834;
  --card2: #172044;
  --line: #222b52;
  --line2: #2d3866;
  --text: #e9ecf8;
  --muted: #8d97bd;
  --accent: #93a6ff;
  --accent-ink: #0b1230;
  --accent-soft: rgba(147, 166, 255, .14);
  --ok: #4fd1c0;
  --ok-soft: rgba(79, 209, 192, .14);
  --warn: #ffc857;
  --warn-soft: rgba(255, 200, 87, .14);
  --bad: #ff8a8f;
  --bad-soft: rgba(255, 138, 143, .14);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .7);
  --radius: 16px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f5fb; --bg2: #eaeef8; --card: #ffffff; --card2: #f7f8fd; --line: #e2e6f2; --line2: #cfd6ea;
    --text: #141a33; --muted: #5b6585; --accent: #3f55d4; --accent-ink: #ffffff; --accent-soft: rgba(63, 85, 212, .10);
    --ok: #0c8f7f; --ok-soft: rgba(12, 143, 127, .12); --warn: #a8670a; --warn-soft: rgba(168, 103, 10, .12);
    --bad: #cf2f3a; --bad-soft: rgba(207, 47, 58, .10);
    --shadow: 0 1px 2px rgba(20, 26, 51, .05), 0 12px 28px -20px rgba(20, 26, 51, .25);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fb; --bg2: #eaeef8; --card: #ffffff; --card2: #f7f8fd; --line: #e2e6f2; --line2: #cfd6ea;
  --text: #141a33; --muted: #5b6585; --accent: #3f55d4; --accent-ink: #ffffff; --accent-soft: rgba(63, 85, 212, .10);
  --ok: #0c8f7f; --ok-soft: rgba(12, 143, 127, .12); --warn: #a8670a; --warn-soft: rgba(168, 103, 10, .12);
  --bad: #cf2f3a; --bad-soft: rgba(207, 47, 58, .10);
  --shadow: 0 1px 2px rgba(20, 26, 51, .05), 0 12px 28px -20px rgba(20, 26, 51, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
::selection { background: var(--accent-soft); }

/* ---------- shell: sidebar on wide screens, top bar on narrow ones ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 22px 16px;
  background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; color: var(--text); text-decoration: none; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; letter-spacing: -.02em;
  color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), #6f86ff); box-shadow: 0 8px 20px -10px var(--accent);
}
.brand b { display: block; font-size: 14.5px; letter-spacing: -.01em; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted);
  text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.menu a svg, .tool svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu a:hover { background: var(--accent-soft); color: var(--text); }
.menu a.on { background: var(--accent-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.menu a.on svg { color: var(--accent); }
.side-foot { display: flex; gap: 8px; }
.tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
}
.tool:hover { color: var(--text); border-color: var(--line2); background: var(--card); }
.side-foot form { margin: 0; flex: 1; }
.side-foot .tool { width: 100%; }
.content { padding: 34px clamp(18px, 4vw, 48px) 60px; max-width: 1180px; width: 100%; }

@media (max-width: 880px) {
  .shell { display: block; }
  .side {
    position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 12px;
    padding: 12px 14px 0; border-right: 0; border-bottom: 1px solid var(--line); background: var(--bg2);
  }
  .brand { padding: 0; flex: 1; }
  .logo { width: 34px; height: 34px; border-radius: 11px; }
  .brand small { display: none; }
  .side-foot { order: 2; }
  .side-foot .tool span { display: none; }
  .menu {
    order: 3; flex-direction: row; flex: 1 0 100%; gap: 4px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none;
    margin: 0 -14px; padding-left: 14px; padding-right: 14px;
  }
  .menu::-webkit-scrollbar { display: none; }
  .menu a { white-space: nowrap; padding: 8px 12px; border-radius: 999px; flex: none; }
  .menu a.on { box-shadow: none; }
  .content { padding-top: 22px; }
}

/* ---------- guest pages (login, installer, privacy) ---------- */
.bare-head { display: flex; align-items: center; justify-content: space-between; padding: 18px clamp(16px, 4vw, 40px); }
.narrow { max-width: 820px; margin: 0 auto; padding: 8px 18px 60px; }

/* ---------- type ---------- */
h1 { font-size: 26px; letter-spacing: -.02em; line-height: 1.2; margin: 0 0 6px; }
h1 + p.muted, h1 + p { margin-top: 0; }
h2 { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; margin: 26px 0 10px; color: var(--muted); font-weight: 700; }
.card > h2:first-child { margin-top: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
code { background: var(--card2); border: 1px solid var(--line); padding: 1px 7px; border-radius: 7px; font: 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; }

/* ---------- surfaces ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 880px) { .grid > .card.stat { padding: 16px 18px; } .stat b { font-size: 26px; } }
.grid > .card { margin-bottom: 0; }
.stat b { display: block; font-size: 30px; line-height: 1.1; letter-spacing: -.03em; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=checkbox] { width: 18px; height: 18px; margin: 0 10px 0 0; vertical-align: -4px; accent-color: var(--accent); }
input[type=file] { padding: 9px; }
textarea { resize: vertical; }
.row { display: flex; gap: 14px; flex-wrap: wrap; } .row > * { flex: 1; min-width: 150px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  transition: transform .1s, filter .15s, box-shadow .15s; box-shadow: 0 8px 20px -12px var(--accent);
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost { background: transparent; border: 1px solid var(--line2); color: var(--text); box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--accent-soft); }
button.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); box-shadow: none; }
button.danger:hover { background: var(--bad-soft); }
.actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }

/* ---------- tags & notices ---------- */
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.tag.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.tag.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.tag.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.err, .okbox { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; border: 1px solid; }
.err { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.okbox { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
ol.steps { padding-left: 20px; } ol.steps li { margin: 8px 0; }

/* ---------- small charts ---------- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 30px; min-width: 170px; }
.spark i { flex: 1; min-height: 3px; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: .85; }
.spark i.z { background: var(--line2); opacity: .6; }
.spark i:last-child { opacity: 1; box-shadow: 0 0 0 1px var(--accent-soft); }
.stack { display: flex; height: 9px; min-width: 140px; border-radius: 999px; overflow: hidden; background: var(--line); }
.stack i { display: block; height: 100%; }
.stack i.ok { background: var(--ok); } .stack i.warn { background: var(--warn); } .stack i.bad { background: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.scroll-x { overflow-x: auto; }

/* ---------- map modal ---------- */
.modal {
  width: min(920px, 94vw); padding: 0; border: 1px solid var(--line2); border-radius: 20px; background: var(--card); color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); overflow: hidden;
}
.modal::backdrop { background: rgba(5, 8, 20, .62); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head b { font-size: 15px; }
.modal iframe { display: block; width: 100%; height: min(64vh, 540px); border: 0; background: var(--bg2); }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); text-align: right; font-size: 13.5px; }

/* ---------- quieter motion for those who ask ---------- */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
