:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e3e6ec;
  --brand: #2f6feb;
  --brand-dark: #2456c4;
  --danger: #c0392b;
  --ok: #1f8a4c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a { color: var(--brand); text-decoration: none; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
}

.card-narrow { max-width: 420px; margin: 0 auto; }

h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 15px;
  background: #fbfcfd;
}

input:focus { outline: 2px solid rgba(47, 111, 235, .25); border-color: var(--brand); }

button, .button {
  display: inline-block;
  margin-top: 18px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

button.primary, .primary.button { background: var(--brand); color: #fff; }
button.primary:hover, .primary.button:hover { background: var(--brand-dark); }
button.secondary { background: #fff; border-color: var(--line); color: var(--text); }

.link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--brand);
  font-size: 15px;
  cursor: pointer;
}
.link-button.danger { color: var(--danger); }
.inline { display: inline; margin: 0; }

.alert {
  margin: 12px 0;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
}
.alert-error { background: #fdeceb; color: var(--danger); }
.flash-success { background: #e8f6ee; color: var(--ok); }
.flash-info { background: #eef3fd; color: var(--brand-dark); }

.flashes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 9px 12px; border-radius: 7px; font-size: 14px; }

.meta { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 12px 0 0; }
.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 0; font-size: 14px; word-break: break-all; }

.app-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.app-list li { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.app-list li:last-child { border-bottom: none; }

.scope-list { list-style: none; margin: 14px 0; padding: 0; }
.scope-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; }
pre.code {
  background: #f2f4f8;
  padding: 12px 14px;
  border-radius: 7px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 30px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 520px) {
  .meta { grid-template-columns: 1fr; }
  .page { padding: 18px 14px 36px; }
}

/* --- control console ---------------------------------------------------- */

.page-wide { max-width: 1080px; }

.control-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
}
.control-nav a {
  padding: 7px 13px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.control-nav a:hover { background: #f2f4f8; color: var(--text); }
.control-nav a.active { background: var(--brand); color: #fff; }
/* 「导航」离开控制台，靠右放，和这排选项卡分开 */
.control-nav a.nav-home { margin-left: auto; color: var(--brand); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.card-head h1, .card-head h2 { margin: 0; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-actions .button { margin-top: 0; }

.inline-form { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
.inline-form input[type="text"],
.inline-form input[type="search"],
.inline-form select { width: auto; min-width: 180px; }
.inline-form button { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 14px;
  align-items: end;
}
.form-grid .form-actions { grid-column: 1 / -1; }
.form-grid button { margin-top: 8px; }

input[type="email"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 15px;
  background: #fbfcfd;
  font-family: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
select { background: #fff; }

label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 14px;
  color: var(--text);
}
label.checkbox input { width: auto; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table td form { margin: 0; }
.table .link-button { font-size: 13px; }
.nowrap { white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.badge-ok { background: #e8f6ee; color: var(--ok); }
.badge-danger { background: #fdeceb; color: var(--danger); }
.badge-brand { background: #eef3fd; color: var(--brand-dark); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
}
a.stat:hover { border-color: var(--brand); }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-label { font-size: 13px; color: var(--muted); }

.chip-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-list li { display: flex; align-items: center; gap: 6px; }
.chip {
  background: #eef3fd;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
}

.code-chip, .selectable {
  user-select: all;
  background: #f2f4f8;
  padding: 1px 6px;
  border-radius: 4px;
}

.pager { display: flex; align-items: center; gap: 14px; margin-top: 14px; font-size: 14px; }
.pager .disabled { color: #c2c7d0; }

.alert-warn { background: #fff6e5; color: #8a5b00; }

.danger-zone { border-color: #f3c4be; }
.danger-zone h2 { color: var(--danger); }
.danger-button { background: var(--danger); color: #fff; }
.danger-button:hover { background: #a93226; }

@media (max-width: 640px) {
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 8px; }
  .control-nav { gap: 2px; }
  .control-nav a { padding: 6px 10px; font-size: 13px; }
}
