:root {
  --ink: #1c1914;
  --muted: #6f675d;
  --line: #e4dccf;
  --paper: #f3efe6;
  --panel: #fffdf8;
  --nav: #17211c;
  --nav-text: #e6efe8;
  --accent: #1d6b4a;
  --warn: #8a5a12;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.55 "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: var(--nav-text);
  padding: 22px 16px;
}

.brand {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.04em;
  margin-bottom: 22px;
}

nav { display: flex; flex-direction: column; gap: 4px; }

nav a {
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 10px;
}

nav a:hover, nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.08); }

.aside-note {
  margin-top: auto;
  color: #b7c4bb;
  font-size: 12px;
}

.exit { margin-top: 12px; }
.exit button {
  width: 100%;
  color: var(--nav-text);
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
}

body.gate {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }

main { margin-left: 220px; padding: 28px 32px 72px; max-width: 1180px; }
main:has(.stage) { max-width: none; }

header h1 { margin: 0 0 4px; font-size: 28px; font-weight: 650; }
header p, .hint, .empty { color: var(--muted); }
.kicker { margin: 0; font-size: 13px; letter-spacing: 0.08em; color: var(--accent); }

.notice {
  background: #e7f3ec;
  border: 1px solid #b7d8c6;
  border-radius: 10px;
  padding: 10px 12px;
}
.notice.bad {
  background: #fdecec;
  border-color: #f0c2c2;
  color: #8d2d2d;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stats article, .panel, .site-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.stats article { padding: 14px 16px; }
.stats span, .stats em { color: var(--muted); font-style: normal; font-size: 13px; }
.stats strong { display: block; margin-top: 6px; font-size: 28px; font-variant-numeric: tabular-nums; }

.panel { padding: 16px 18px; margin: 14px 0; }
.panel h2, .article h2 { margin: 0 0 10px; font-size: 18px; }

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.sheet {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}
.sheet h2 { margin: 0; }
.sheet.ips { max-width: none; }
.sheet.ips textarea { min-height: 72px; }
.ip-board ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.ip-board li { margin: 0; }

label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.wide { grid-column: 1 / -1; }
.check { flex-direction: row; align-items: center; }

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
}

input, select, textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { min-height: 120px; resize: vertical; }

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.quiet { border: 0; background: transparent; color: var(--warn); padding: 0; }
button.cert-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 112px;
  height: 34px;
  padding: 0 12px;
}
button.cert-bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #cfe8d8;
  transition: width .35s linear;
}
button.cert-bar span { position: relative; z-index: 1; white-space: nowrap; }
button.cert-bar.done i { background: #1f7a4d; }
button.cert-bar.done span { color: #fff; }
button.cert-bar.failed i { background: #a33b32; }
button.cert-bar.failed span { color: #fff; }
.actions { display: flex; gap: 8px; align-items: end; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  background: #efeae1;
}
.pill.online { background: #e5f4eb; color: #14643d; }
.pill.paused { background: #f8ead3; color: #8a5a12; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.site-card, .article-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.site-card { padding: 14px 16px; }
.site-card h3, .site-card p { margin: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { width: 110px; }

.split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; align-items: start; }
.models-layout { grid-template-columns: 320px minmax(0, 1fr); }
.models-layout > .panel { margin: 0; }
.models-panel { display: flex; flex-direction: column; gap: 18px; }
.models-form { grid-template-columns: 1fr; }
.models-panel input, .models-panel select { width: 100%; }
.meter { height: 10px; border-radius: 99px; background: #efe6d6; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter span.warn { background: #b86a12; }
.meter span.hot { background: #a33b32; }
.quota-pct { margin: 10px 0 0; font-size: 32px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quota-sub { margin: 2px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.quota-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.quota-stats span { color: var(--muted); font-size: 13px; }
.quota-stats strong { display: block; margin-top: 2px; font-size: 22px; font-variant-numeric: tabular-nums; }
.day-list { margin-top: 16px; }
.day-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.day-head { color: var(--muted); border-top: 0; padding-bottom: 2px; }

pre {
  white-space: pre-wrap;
  background: #17211c;
  color: #e7efe9;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
}

code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92em; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 52px 1fr 90px; gap: 8px; align-items: center; }
.bar { display: block; height: 8px; border-radius: 99px; background: var(--accent); }
.article h3 { margin: 14px 0 4px; font-size: 16px; }
.ip-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.ip-board article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.ip-board strong { display: block; margin-top: 6px; font-size: 28px; font-variant-numeric: tabular-nums; }
.ip-board em { color: var(--muted); font-style: normal; font-size: 13px; }
.picks { display: flex; gap: 16px; border: 0; margin: 0; padding: 0; }
.picks legend { margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.picks label { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }

.stage {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}
.stage-card {
  display: flex;
  flex-direction: column;
  min-height: 78vh;
  background: #14110e;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #2a241c;
}
.stage .stage-card {
  width: 390px;
  flex: 0 0 390px;
  min-height: 0;
  border-radius: 28px;
}
.stage-detail { min-height: 82vh; margin-bottom: 16px; }
.stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  color: #f4efe6;
  background: #1c1814;
}
.stage-bar a { color: #f4efe6; }
.sync-state { margin-left: auto; margin-right: 12px; color: #b7c4bb; font-size: 12px; }
.back {
  display: inline-flex;
  margin: 0 0 14px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.back:hover { text-decoration: underline; }
.stage-card iframe {
  flex: 1;
  width: 100%;
  min-height: 72vh;
  border: 0;
  background: #fff;
  scrollbar-width: none;
}
.stage .stage-card iframe {
  flex: none;
  height: 760px;
  min-height: 0;
}
.stage-wait {
  margin: 0;
  padding: 48px 20px;
  color: #d9d0c3;
}
.source-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.source-layout .panel, .meta-grid .panel { margin: 0; }
.route-list, .api-list { list-style: none; margin: 0; padding: 0; }
.route-list li {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.route-list code { white-space: nowrap; }
.api-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.api-head { display: flex; gap: 8px; align-items: center; }
.api-list code {
  display: block;
  margin-top: 6px;
  white-space: normal;
  overflow-wrap: break-word;
}
.api-list p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 560px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.file-list a {
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  padding: 5px 8px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.file-list a[aria-current="true"], .file-list a:hover { background: #efe6d6; }
.code-view { min-height: 320px; }
.code-view pre { max-height: 560px; margin: 0; }

@media (max-width: 900px) {
  aside { position: static; width: auto; }
  main { margin-left: 0; }
  .stats, .form, .split, .models-layout, .stage, .source-layout, .meta-grid { grid-template-columns: 1fr; }
  .site-card { flex-direction: column; align-items: stretch; }
}
