:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1d2430;
  --line: #262d38;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #5b8cff;
  --accent-2: #a06bff;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .45);
  --chrome-h: 46px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, 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: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
body { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3442; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4557; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

#app { height: 100%; }
.boot-loading { display: flex; align-items: center; gap: 10px; justify-content: center; height: 100%; color: var(--muted); }
.boot-loading span { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 外壳 ---------- */
.shell { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 10px; height: var(--chrome-h); flex: 0 0 var(--chrome-h);
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 30;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .2px; }
.topbar .brand img { height: 22px; width: auto; max-width: 168px; object-fit: contain; }
.topbar .brand .tagline { font-weight: 400; color: var(--muted); font-size: 12px; }
.spacer { flex: 1 1 auto; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 5px 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.view { flex: 1 1 auto; min-height: 0; position: relative; }
.page { height: 100%; overflow: auto; padding: 22px 26px; }
.page h1 { font-size: 20px; margin: 0 0 4px; }
.page h2 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.sub { color: var(--muted); font-size: 13px; }

/* ---------- 控件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); border-radius: var(--radius-sm); cursor: pointer;
  transition: background .14s, border-color .14s, transform .06s; white-space: nowrap;
}
.btn:hover { background: #263041; border-color: #38455b; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: #ffdede; border-color: #5b2a2a; background: #2a1416; }
.btn.danger:hover { background: #3a1b1e; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.icon { padding: 5px 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn kbd { font: 11px var(--mono); color: var(--muted); background: #0e131b; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; background: #0e131b; border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
label.field { display: block; margin: 10px 0; }
label.field > b { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pill.ok { color: #c8f5d1; border-color: #1f5c2e; background: #132a18; }
.pill.err { color: #ffd0cf; border-color: #6a2b2b; background: #2b1516; }
.pill.warn { color: #ffe6b8; border-color: #6b5220; background: #2a2114; }
.pill.run { color: #cfe2ff; border-color: #274a75; background: #12202f; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #12161d; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #171d26; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- 浮层 ---------- */
.toast-host { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 900; max-width: 380px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 9px 12px; box-shadow: var(--shadow); animation: pop .16s ease-out; font-size: 13px; }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

.modal-back { position: fixed; inset: 0; background: rgba(5, 7, 11, .62); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 800; animation: fade .14s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 320px; max-width: min(760px, 92vw); max-height: 88vh; overflow: auto; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 15px; flex: 1; }
.modal .body { padding: 16px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }

.menu {
  position: fixed; z-index: 950; min-width: 216px; padding: 5px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: pop .1s ease-out; user-select: none;
}
.menu .item {
  display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.menu .item:hover, .menu .item.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.menu .item.disabled { color: #5d6a7a; cursor: not-allowed; background: none; }
.menu .item.danger:hover { background: #3a1b1e; color: #ffd0cf; }
.menu .item .key { margin-left: auto; font: 11px var(--mono); color: var(--muted); padding-left: 18px; }
.menu .item .glyph { width: 16px; text-align: center; opacity: .85; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu .head { padding: 5px 9px 6px; font-size: 11px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.menu .sub-arrow::after { content: '▸'; margin-left: auto; color: var(--muted); }
.menu .submenu { position: absolute; left: calc(100% - 4px); top: -6px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); }
.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat .card { padding: 12px 14px; }
.stat .n { font-size: 21px; font-weight: 650; font-family: var(--mono); }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); }
.badge-lock { font-size: 11px; color: var(--warn); }

/* 系统级「减少动态效果」：转场退化成瞬时，功能不受影响 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
