:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #f8fafc; --line: #e3e8f0; --text: #0f172a; --muted: #64748b;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #e8efff; --ok: #16a34a; --ok-soft: #e7f7ec;
  --warn: #d97706; --warn-soft: #fff4e0; --bad: #dc2626; --bad-soft: #fde8e8; --code: #0b1220; --code-text: #d6e2ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06); --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 14px; } .grid > * { min-width: 0; } .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)); }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* buttons & inputs */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-2); }
.danger { color: var(--bad); } .danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.ghost { background: transparent; border-color: transparent; } .ghost:hover { background: var(--panel-2); border-color: var(--line); }
.sm { padding: 4px 9px; font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; min-height: 220px; background: var(--code); color: var(--code-text); border-color: var(--code); }
label.f { display: block; } label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.check { display: flex; gap: 8px; align-items: flex-start; } .check input { margin-top: 3px; }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; font-weight: 700; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); } .nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav .badge { margin-left: auto; }
.side .me { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 8px 0; font-size: 12.5px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.content { padding: 20px 24px 40px; max-width: 1600px; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; } .top { padding: 12px 16px; }
}

/* cards & tables */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flush { padding: 0; } .card > .hd { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h2, .card > .hd h3 { margin: 0; }
.stat .n { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12.5px; }
.tbl-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
td.wrap { word-break: break-word; max-width: 520px; }
.kv { display: grid; grid-template-columns: minmax(80px, 34%) minmax(0, 1fr); gap: 6px 12px; } .kv > div { overflow-wrap: anywhere; } .kv > div:nth-child(odd) { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); } .dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); } .bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
pre.out { background: var(--code); color: var(--code-text); padding: 12px; border-radius: 8px; overflow: auto; max-height: 460px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.os { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); }
.os.windows { color: #0ea5e9; } .os.linux { color: #f59e0b; } .os.macos { color: #a855f7; } .os.android { color: #22c55e; } .os.ios { color: #64748b; }
.alert-box { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.alert-box.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.alert-box.warn { background: var(--warn-soft); border-color: transparent; }
.alert-box.ok { background: var(--ok-soft); border-color: transparent; }
.copy { display: flex; gap: 6px; min-width: 0; } .copy input { min-width: 0; flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .card.wide { max-width: 560px; }
.auth h1 { margin-bottom: 4px; } .auth .sub { color: var(--muted); margin-bottom: 18px; }
.otp { font-size: 24px; letter-spacing: 10px; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 8px; width: fit-content; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; } .steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); } .steps i.on { background: var(--accent); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: ui-monospace, Consolas, monospace; background: var(--panel-2); padding: 12px; border-radius: 8px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal.lg { max-width: 920px; }
.modal .hd { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal .hd h2 { margin: 0; }
.modal .bd { padding: 18px; } .modal .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); }
.toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }

/* remote viewer */
.rv { position: fixed; inset: 0; z-index: 60; background: #05070d; display: flex; flex-direction: column; color: #e6ecf8; }
.rv .bar2 { display: flex; gap: 6px; align-items: center; padding: 6px 10px; background: #0e1424; border-bottom: 1px solid #1f2a44; flex-wrap: wrap; }
.rv .bar2 button, .rv .bar2 select { background: #18213a; color: #e6ecf8; border-color: #2a3758; padding: 5px 10px; font-size: 12.5px; width: auto; }
.rv .bar2 button.on { background: var(--accent); border-color: var(--accent); }
.rv .bar2 .sep { width: 1px; height: 22px; background: #2a3758; margin: 0 4px; }
.rv .stage { flex: 1; overflow: auto; display: grid; place-items: center; outline: none; position: relative; }
.rv canvas { background: #000; display: block; cursor: default; }
.rv .stage.fit canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.rv .status { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(14, 20, 36, .9); padding: 6px 12px; border-radius: 6px; font-size: 12.5px; }
.rv .meta { font-size: 12px; color: #8b9bbd; }
