@import url("https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/style.min.css");
@import url("https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-mono/style.min.css");

:root {
  --bg: #fafafa;
  --panel: #fff;
  --line: #eaeaea;
  --text: #171717;
  --muted: #666;
  --ok: #0070f3;
  --warn: #f5a623;
  --bad: #e00;
  --font: "Geist Sans", "Geist", ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; color: var(--muted); }

.btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #fafafa; border-color: #999; }
.btn.solid { background: #000; border-color: #000; color: #fff; }
.btn.solid:hover { background: #333; border-color: #333; }
.btn.ghost { background: transparent; }
.btn.ok { color: var(--ok); border-color: #cce0ff; background: #f5f9ff; }
.btn.danger { color: var(--bad); border-color: #f7c5c5; background: #fff8f8; }
.btn.danger:hover { background: #ffeaea; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(#eaeaea 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, #eaeaea 1px, transparent 1px) 0 0 / 40px 40px,
    #fff;
}
.login-box {
  width: min(380px, 94vw);
  padding: 36px 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.login-brand {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.04em;
}
.login-brand span { color: var(--muted); font-weight: 500; }
.login-box > p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.login-box label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 500; }
.login-box input {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  outline: none;
}
.login-box input:focus { border-color: #000; }
.login-box .btn.solid { width: 100%; margin-top: 20px; height: 40px; }
.err { color: var(--bad); min-height: 1.2em; font-size: 13px; margin: 10px 0 0; }
.err.ok { color: var(--ok); }

.layout { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.04em;
}
.brand em {
  font-style: normal;
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
}
.top-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bad);
}
.dot.on { background: #0cce6b; }

.body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 200px 1fr;
}
.side {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fafafa;
}
.nav {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: 500 13px/1.2 var(--font);
}
.nav:hover { background: #f0f0f0; color: var(--text); }
.nav.active { background: #fff; color: #000; border: 1px solid var(--line); }

.main { min-width: 0; overflow: auto; padding: 24px 28px 48px; background: #fff; }
.panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.panel .lead { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.panel .lead a { color: #000; }
.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.head-row.compact { margin-bottom: 8px; align-items: center; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head-actions input, .head-actions select,
.gen-bar input, .gen-bar select,
.form-grid input, .form-grid select, .form-grid textarea,
.toolbar input, .toolbar select,
.dialog-body input, .dialog-body select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.head-actions input, .dialog-body input { width: 220px; }
.form-grid textarea { height: auto; padding: 10px; }
.head-actions input:focus, .head-actions select:focus,
.gen-bar input:focus, .form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.dialog-body input:focus, .dialog-body select:focus {
  border-color: #000;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}
.kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
}
.kpi b {
  display: block;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.04em;
}
.kpi span { color: var(--muted); font-size: 12px; }
.kpi.warn b { color: var(--warn); }
.kpi.ok b { color: var(--ok); }

.split { display: grid; grid-template-columns: 1fr 1.35fr; gap: 14px; }
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.log, pre.mono-block {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #444;
  white-space: pre-wrap;
}

.toolbar, .gen-bar, .batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
}
.toolbar label, .gen-bar label, .batch-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #333;
  font: 500 12px/26px var(--font);
  cursor: pointer;
}
.chip:hover { border-color: #000; }
.chip.hot { border-color: #000; background: #000; color: #fff; }

.last-gen {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
}
.last-gen pre {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: #333;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 500;
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 12px;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfcfc; }
.ops { display: flex; flex-wrap: wrap; gap: 5px; min-width: 220px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: #f2f2f2;
  color: #444;
  border: 1px solid var(--line);
}
.tag.beta { background: #f0f7ff; color: #0070f3; border-color: #cce0ff; }
.tag.friend { background: #111; color: #fff; border-color: #111; }
.tag.banned { background: #fff5f5; color: #e00; border-color: #f7c5c5; }
.tag.expired { background: #f5f5f5; color: #888; }
.tag.active { background: #f0fff6; color: #0a7a3e; border-color: #c6f0d6; }
.tag.pending { background: #fff8eb; color: #a15c00; border-color: #ffe2ad; }
.tag.approved { background: #f0fff6; color: #0a7a3e; border-color: #c6f0d6; }
.tag.rejected { background: #fff5f5; color: #e00; border-color: #f7c5c5; }

.form-grid { display: grid; gap: 12px; max-width: 640px; }
.form-grid.two { grid-template-columns: 1fr 1fr; max-width: none; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.sheet, .dialog {
  width: min(520px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.sheet h3, .dialog h3 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dialog-msg {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.dialog-body { display: grid; gap: 12px; margin-bottom: 16px; }
.dialog-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.dialog-body input, .dialog-body select { width: 100%; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 200px;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: rise .2s ease;
}
.toast.ok { background: #111; }
.toast.bad { background: #e00; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 960px) {
  .body { grid-template-columns: 1fr; }
  .side {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .split { grid-template-columns: 1fr; }
}
