:root {
  --bg: #0b0f14;
  --bg-soft: #11161d;
  --panel: #141b24;
  --panel-2: #1a2330;
  --line: #24303d;
  --text: #e6edf3;
  --muted: #8b9bad;
  --accent: #38d6c4;
  --accent-dim: #1f7f75;
  --warn: #f0b34a;
  --danger: #f26d6d;
  --ok: #5bd07a;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 12% -10%, #12313a 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2330 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 14px;
  transition: border-color .15s, background .15s, transform .05s;
}
button:hover { border-color: var(--accent-dim); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; }
button.primary {
  background: linear-gradient(180deg, #2ba99b, #1c7d72);
  border-color: #2ba99b;
  color: #04120f;
  font-weight: 600;
}

input {
  font: inherit;
  color: var(--text);
  background: #0d1319;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  outline: none;
}
input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(56, 214, 196, .12); }

/* ------------------------------------------------------------ 登录 */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--panel), #101720);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.login-brand { font-size: 18px; font-weight: 650; letter-spacing: .2px; margin-bottom: 6px; }
.login-hint { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 6px; }
.login-card button { width: 100%; margin-top: 6px; background: linear-gradient(180deg, #2ba99b, #1c7d72); border-color: #2ba99b; color: #04120f; font-weight: 650; }
.login-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 10px; }

.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  margin-right: 8px;
  vertical-align: middle;
}

/* ------------------------------------------------------------ 顶栏 */
.app { max-width: 1560px; margin: 0 auto; padding: 18px 22px 40px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 4px 18px;
  flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 650; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.search { width: min(340px, 46vw); }

/* ------------------------------------------------------------ 统计卡 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: linear-gradient(180deg, var(--panel), #101720);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-weight: 680; letter-spacing: .4px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ------------------------------------------------------------ 布局 */
.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(480px, 1.35fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, var(--panel), #0f151d);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 620; }

.table-wrap { max-height: calc(100vh - 300px); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  background: #101720;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(36, 48, 61, .6); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: rgba(56, 214, 196, .06); }
tbody tr.active { background: rgba(56, 214, 196, .1); box-shadow: inset 3px 0 0 var(--accent); }
.model-cell .m { font-weight: 600; }
.model-cell .s { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.emulator { color: var(--warn); border-color: rgba(240, 179, 74, .4); }

/* ------------------------------------------------------------ 详情 */
.detail-panel { padding: 0; }
.detail-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-title h1 { font-size: 18px; margin: 0; font-weight: 650; }
.detail-sub { color: var(--muted); font-size: 12px; margin-top: 6px; font-family: var(--mono); word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; margin-left: 4px; }
.chip.on { border-color: rgba(56, 214, 196, .45); color: var(--accent); }
.chip.on b { color: var(--accent); }

.detail-body { padding: 8px 18px 22px; max-height: calc(100vh - 240px); overflow: auto; }

.section-title {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

table.items td:first-child { color: var(--muted); width: 32%; }
table.items td:nth-child(2) { font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
table.items tr.missing td:nth-child(2) { color: #5d6b7a; font-style: italic; }
table.items tr.inferred td:first-child::after { content: " · 推断"; color: var(--accent-dim); }

.gate {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.gate.g-none { color: var(--ok); background: rgba(91, 208, 122, .1); border-color: rgba(91, 208, 122, .3); }
.gate.g-normal { color: var(--muted); background: rgba(139, 155, 173, .1); border-color: rgba(139, 155, 173, .25); }
.gate.g-runtime { color: var(--warn); background: rgba(240, 179, 74, .1); border-color: rgba(240, 179, 74, .3); }
.gate.g-special, .gate.g-blocked { color: var(--danger); background: rgba(242, 109, 109, .1); border-color: rgba(242, 109, 109, .3); }
.gate.g-manifest { color: var(--muted); background: rgba(139, 155, 173, .1); border-color: rgba(139, 155, 173, .25); }

.cat { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.cat > summary {
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  list-style: none;
}
.cat > summary::-webkit-details-marker { display: none; }
.cat[open] > summary { border-bottom: 1px solid var(--line); }
.cat table { table-layout: fixed; }
.cat td { font-size: 13px; }

.history { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.history-row span:first-child { font-family: var(--mono); color: var(--text); }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #16202b;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1e2a37; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #2a3a4b; background-clip: content-box; }
