:root {
  --bg: #0b0f14;
  --panel: #111821;
  --panel2: #161f2a;
  --line: #233040;
  --text: #d8e0ea;
  --muted: #7d8b9c;
  --accent: #7ee787;
  --accent-d: #3fb950;
  --warn: #e3b341;
  --err: #f85149;
  --info: #58a6ff;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--info); text-decoration: none; }
code, pre, .mono { font-family: var(--mono); }
pre { margin: 0; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 18px; padding: 4px 10px 14px; letter-spacing: .5px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 8px 10px; border-radius: 6px; font-size: 13.5px; }
.nav a:hover { background: var(--panel2); }
.nav a.active { background: #1c2a1f; color: var(--accent); }
.nav .ico { width: 18px; text-align: center; font-family: var(--mono); color: var(--muted); }
.nav a.active .ico { color: var(--accent); }
.side .foot { margin-top: auto; padding: 10px; color: var(--muted); font-size: 12px; }
.main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side .foot { display: none; } .g3, .g4, .split, .g2 { grid-template-columns: 1fr; } }

.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 400; }

label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font: inherit; outline: none;
}
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-d); }
input[type=checkbox] { accent-color: var(--accent-d); width: 15px; height: 15px; vertical-align: middle; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; }

button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 7px 14px; border-radius: 6px; font: inherit; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
button:hover { border-color: #3a4b60; }
button.primary { background: var(--accent-d); border-color: var(--accent-d); color: #04130a; font-weight: 600; }
button.primary:hover { background: var(--accent); }
button.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); }
button.sm { padding: 3px 9px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #1a2430; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
.matrix td, .matrix th { text-align: center; padding: 6px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }

.badge { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); }
.badge.ok { color: var(--accent); border-color: #2a4a30; background: #11201480; }
.badge.warn { color: var(--warn); border-color: #4d3d15; }
.badge.err { color: var(--err); border-color: #5a2422; }
.badge.info { color: var(--info); border-color: #1e3a5f; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 26px; }

.alert { border: 1px solid; border-radius: var(--r); padding: 10px 14px; margin-bottom: 12px; font-size: 13.5px; }
.alert.warn { border-color: #4d3d15; background: #2a2109; color: #f0d48a; }
.alert.err { border-color: #5a2422; background: #2a0f0f; color: #ffb3ad; }
.alert.ok { border-color: #2a4a30; background: #0f2214; color: #b6f0bd; }

.progress { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 4px; min-width: 120px; }
.progress > div { height: 100%; background: var(--accent-d); }

.tree { font-family: var(--mono); font-size: 13px; max-height: 520px; overflow: auto; }
.tree .node { padding: 3px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tree .node:hover { background: var(--panel2); }
.tree .node.sel { background: #1c2a1f; color: var(--accent); }
.tree .tw { width: 12px; color: var(--muted); display: inline-block; }
.tree .kids { padding-left: 14px; }

.term { background: #05080b; border: 1px solid var(--line); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 12.5px; color: #b9f6c0; white-space: pre; overflow: auto; }

.modal-bg { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 100%; max-width: 760px; padding: 22px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent-d); padding: 10px 14px; border-radius: 6px; max-width: 420px; box-shadow: 0 6px 20px #0008; font-size: 13.5px; }
.toast.err { border-left-color: var(--err); }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth .box { width: 100%; max-width: 420px; }
.auth .logo { font-family: var(--mono); color: var(--accent); font-size: 10.5px; line-height: 1.15; white-space: pre; text-align: center; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: transparent; }
.tabs button.on { background: var(--panel2); border-color: var(--accent-d); color: var(--accent); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 4px; display: flex; gap: 10px; justify-content: flex-end; }
