:root {
  --bg: #f5f7fa; --panel: #fff; --fg: #1f2937; --muted: #6b7280; --border: #e5e7eb;
  --primary: #2563eb; --primary-d: #1d4ed8; --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #0284c7;
  --side: #111827; --side-fg: #cbd5e1; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--primary); text-decoration: none; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
button { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 20px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side { width: 200px; background: var(--side); color: var(--side-fg); flex-shrink: 0; display: flex; flex-direction: column; }
.side .brand { padding: 18px 20px; font-weight: 600; color: #fff; font-size: 15px; border-bottom: 1px solid #1f2937; }
.side nav { padding: 8px 0; flex: 1; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 20px; color: var(--side-fg); }
.side nav a:hover { background: #1f2937; color: #fff; }
.side nav a.active { background: var(--primary); color: #fff; }
.side .user { padding: 14px 20px; border-top: 1px solid #1f2937; font-size: 12px; }
.side .user a { color: var(--side-fg); margin-left: 8px; }
.badge-count { background: var(--err); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-head h1 { margin: 0; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }

/* table */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f9fafb; font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--fg); cursor: pointer; font-size: 13px; line-height: 1.4; }
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { width: 100%; resize: vertical; }
.form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.form label > input:not([type=checkbox]):not([type=radio]), .form label > select, .form label > textarea { display: block; width: 100%; margin-top: 4px; color: var(--fg); }
.form input[type=checkbox], .form input[type=radio] { width: auto; margin: 0; }
.form .row { display: flex; gap: 12px; }
.form .row > label { flex: 1; }
.form .check { display: flex; align-items: center; gap: 6px; color: var(--fg); }
.form .check input { width: auto; margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.radio-group { display: flex; gap: 16px; margin: 4px 0 8px; color: var(--fg); }
.radio-group label { display: flex; gap: 4px; align-items: center; margin: 0; color: var(--fg); }
.check-list { max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
.check-list label { display: flex; gap: 6px; align-items: center; margin: 4px 0; color: var(--fg); }

/* tags */
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #f3f4f6; color: var(--muted); white-space: nowrap; }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.err { background: #fee2e2; color: #991b1b; }
.tag.info { background: #e0f2fe; color: #075985; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; margin-right: 5px; vertical-align: middle; }
.dot.on { background: var(--ok); }

/* code block */
.cmd { position: relative; background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 10px 70px 10px 12px; margin: 6px 0 12px; word-break: break-all; white-space: pre-wrap; }
.cmd .copy { position: absolute; right: 8px; top: 8px; background: #334155; color: #e2e8f0; border: none; }
.cmd .copy:hover { background: #475569; }
pre.block { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 6px; overflow-x: auto; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs a { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* steps */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 38px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; text-align: center; line-height: 26px; font-weight: 600; font-size: 13px; }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; }
.modal-head .x { cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* toast */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* notice */
.notice { padding: 10px 14px; border-radius: 6px; margin: 10px 0; background: #f3f4f6; }
.notice.ok { background: #dcfce7; color: #166534; }
.notice.warn { background: #fef3c7; color: #92400e; }
.notice.error { background: #fee2e2; color: #991b1b; }
.notice.info { background: #e0f2fe; color: #075985; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.login h1 { text-align: center; }

/* apply page */
.apply-body { display: flex; justify-content: center; padding: 40px 16px; }
.apply-card { width: 100%; max-width: 480px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.ip-box { background: #f9fafb; border: 1px dashed var(--border); border-radius: 8px; padding: 14px; margin: 16px 0; text-align: center; }
.ip-box .ip { font-size: 26px; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; margin: 4px 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: 100%; }
  .side nav { display: flex; flex-wrap: wrap; }
  .side nav a { padding: 6px 12px; }
  .main { padding: 16px; }
}
