:root {
  --bg: #0a0d14; --surface: #111621; --surface-2: #161c29; --line: #232c3d;
  --text: #e8ecf4; --muted: #94a0b6; --blue: #2f6bff; --blue-soft: #1b2f66; --violet: #8b5cf6;
  --ok: #2fbf86; --warn: #e2a63b; --bad: #ee5d6c; --radius: 10px; --sidebar: 248px; --sidebar-min: 68px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-text-size-adjust: 100%; }
a { color: #7fa4ff; text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: .9em; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.boot { display: grid; place-items: center; height: 100%; } .boot-text { color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100%; transition: grid-template-columns .18s ease; }
.shell.collapsed { grid-template-columns: var(--sidebar-min) 1fr; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; z-index: 30; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem; font-weight: 700; font-size: 1.05rem; height: 60px; }
.brand-mark { flex: none; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), var(--violet)); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: .8rem; padding: .6rem .7rem; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--blue-soft); color: #fff; box-shadow: inset 3px 0 0 var(--blue); }
.nav svg { width: 18px; height: 18px; flex: none; }
.collapsed .nav .label, .collapsed .brand .label, .collapsed .side-foot .label { display: none; }
.side-foot { border-top: 1px solid var(--line); padding: .6rem; display: grid; gap: .4rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; height: 60px; border-bottom: 1px solid var(--line); background: rgba(10,13,20,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .3rem; z-index: 40; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.search-results a { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .6rem; border-radius: 6px; color: var(--text); }
.search-results a:hover, .search-results a:focus { background: var(--blue-soft); text-decoration: none; }
.spacer { flex: 1; }
.content { padding: 1.5rem 1.25rem 3rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.menu-btn { display: none; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat .num { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.hl { border-color: var(--blue); background: linear-gradient(160deg, var(--blue-soft), var(--surface) 70%); }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; transition: background .12s, border-color .12s; min-height: 38px; }
.btn:hover { background: #1d2536; border-color: #34405a; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; } .btn.primary:hover { background: #4a7fff; }
.btn.danger { color: #ffb3bb; border-color: #5a2a33; } .btn.danger:hover { background: #3a1a21; }
.btn.sm { padding: .25rem .6rem; min-height: 30px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(47,107,255,.25); }
label { display: grid; gap: .3rem; font-size: .88rem; color: var(--muted); }
.form { display: grid; gap: .9rem; max-width: 520px; }
.form.wide { max-width: none; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.ok { color: #8be7c3; border-color: #1d5c47; } .badge.ok::before { background: var(--ok); }
.badge.warn { color: #f1cf8a; border-color: #66501f; } .badge.warn::before { background: var(--warn); }
.badge.bad { color: #ffb3bb; border-color: #5a2a33; } .badge.bad::before { background: var(--bad); }
.badge.info { color: #a9c1ff; border-color: #2a437f; } .badge.info::before { background: var(--blue); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.codebox { position: relative; background: #070a10; border: 1px solid var(--line); border-radius: 8px; padding: .8rem 3.5rem .8rem .9rem; font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; word-break: break-all; }
.codebox .btn { position: absolute; top: .4rem; right: .4rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin-bottom: .35rem; }
.notice { border-left: 3px solid var(--blue); background: var(--surface-2); padding: .7rem .9rem; border-radius: 0 8px 8px 0; margin-bottom: 1rem; }
.notice.warn { border-color: var(--warn); } .notice.bad { border-color: var(--bad); } .notice.violet { border-color: var(--violet); }
.skel { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; height: 84px; }
.skel.line { height: 16px; margin-bottom: .6rem; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .65rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; }
.list li:last-child { border-bottom: 0; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button { background: none; border: 1px solid var(--line); padding: .35rem .8rem; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--blue-soft); color: #fff; border-color: var(--blue); }

/* Overlay */
.overlay { position: fixed; inset: 0; background: rgba(3,5,9,.7); display: grid; place-items: center; z-index: 100; padding: 1rem; animation: fade .12s ease; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 1.3rem; animation: rise .16s ease; }
.dialog h2 { margin-bottom: .6rem; } .dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 200; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--blue); padding: .7rem .9rem; border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.45); animation: rise .16s ease; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--bad); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(900px 500px at 15% -10%, rgba(47,107,255,.18), transparent), radial-gradient(700px 400px at 100% 110%, rgba(139,92,246,.14), transparent); }
.login .card { width: min(420px, 100%); padding: 1.8rem; }
.login .brand { padding: 0 0 1.2rem; height: auto; }

/* Docs */
.docs { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; align-items: start; }
.docs-nav { position: sticky; top: 76px; display: grid; gap: 2px; }
.docs-nav a { padding: .35rem .6rem; border-radius: 6px; color: var(--muted); } .docs-nav a.active { color: #fff; background: var(--blue-soft); }
.prose { max-width: 74ch; } .prose h2 { margin: 0 0 .8rem; } .prose h3 { margin: 1.2rem 0 .4rem; } .prose ol, .prose ul { padding-left: 1.3rem; } .prose li { margin-bottom: .3rem; }
.prose pre { background: #070a10; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; overflow-x: auto; }
.prose code { background: #0d121c; padding: .05rem .3rem; border-radius: 4px; } .prose pre code { background: none; padding: 0; }
.prose table { min-width: 0; }

.dialog.wide { width: min(920px, 100%); }
.editor { min-height: 55vh; font-family: var(--mono); font-size: .88rem; line-height: 1.5; resize: vertical; white-space: pre; tab-size: 2; }
.crumbs { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-bottom: .8rem; }
.crumbs button { background: none; border: 0; color: #7fa4ff; cursor: pointer; padding: .2rem .35rem; border-radius: 6px; }
.crumbs button:hover { background: var(--surface-2); }
.fname { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-align: left; font-weight: 500; }
.fname:hover { color: #7fa4ff; }
.drop { border: 1px dashed var(--line); border-radius: var(--radius); padding: .8rem; text-align: center; color: var(--muted); margin-bottom: .8rem; }
.drop.over { border-color: var(--blue); background: var(--blue-soft); color: var(--text); }
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(80vw, 290px); transform: translateX(-100%); transition: transform .18s ease; }
  .shell.open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(3,5,9,.6); }
  .shell.collapsed .nav .label, .shell.collapsed .brand .label { display: inline; }
  .menu-btn { display: inline-flex; } .collapse-btn { display: none; }
  .docs { grid-template-columns: 1fr; } .docs-nav { position: static; grid-auto-flow: column; overflow-x: auto; }
  .kv { grid-template-columns: 1fr; }
  .content { padding: 1rem .9rem 3rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
