* { box-sizing: border-box; }

:root {
  --accent: #ff7043;
  --accent-dark: #e05a2b;
  --accent-soft: #fff2ec;
  --border: #e8edf3;
  --text: #2b3440;
  --muted: #8b96a5;
  --bg: #f4f6fa;
  --green: #1fa35c;
  --red: #e5484d;
  --blue: #3f6ad8;
  --amber: #d48806;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: "Cascadia Code", Consolas, "Courier New", monospace; }

.shell { display: flex; min-height: 100vh; }

/* ── 侧栏 ── */
.sidebar {
  width: 208px;
  flex: none;
  background: #1f2733;
  color: #cdd6e2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand small { display: block; font-size: 11px; font-weight: 400; color: #8b96a5; margin-top: 4px; letter-spacing: 0; }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-title {
  font-size: 11px; color: #7c8798; padding: 14px 10px 6px; text-transform: uppercase; letter-spacing: 1px;
}
.nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: #cdd6e2;
  font-size: 13px; margin-bottom: 2px; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { background: linear-gradient(135deg, #ff7043, #ffab40); color: #fff; font-weight: 600; }

.sidebar-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #8b96a5;
}
.sidebar-foot a { color: #ffb199; }

/* ── 主区 ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 26px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar .who { font-size: 12px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.content { padding: 22px 26px 40px; max-width: 1280px; width: 100%; }

/* ── 通用 ── */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(31,39,51,.03);
}
.card h2 { font-size: 15px; margin: 0 0 4px; }
.card .sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .sidebar { width: 168px; }
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

label.field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #dbe2ea; border-radius: 8px;
  font-size: 13px; color: var(--text); background: #fff; outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,112,67,.12); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
textarea.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.inline-input { display: inline-block; width: auto; padding: 5px 8px; font-size: 12.5px; }
.input-mini { max-width: 110px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid #dbe2ea; background: #f6f8fb;
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  font-family: inherit; line-height: 1.2;
}
.btn:hover { background: #eef2f7; text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, #ff7043, #ffab40); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: #fff5f5; border-color: #ffccc7; color: var(--red); }
.btn.mini { padding: 4px 9px; font-size: 11.5px; border-radius: 6px; }
.btn.ghost { background: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.flash.ok { background: #eefbf3; border-color: #bde9cf; color: #187f47; }
.flash.error { background: #fff2f2; border-color: #ffc9c9; color: #c62f34; }
.key-reveal {
  background: #1f2733; color: #ffe0d3; border-radius: 10px; padding: 12px 16px;
  margin-bottom: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.key-reveal code { font-size: 13px; word-break: break-all; flex: 1; min-width: 200px; }
.key-reveal button {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  color: #fff; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12px;
}

/* ── 统计卡 ── */
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stat.accent .v { color: var(--accent-dark); }
.stat.green .v { color: var(--green); }
.stat.red .v { color: var(--red); }

/* ── 表格 ── */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 8px; border-bottom: 1px solid #eef2f6; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; background: #fafbfd; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: #f1f4f8; color: #66707d; white-space: nowrap;
}
.badge.sent { background: #e9f9ee; color: var(--green); }
.badge.failed { background: #fff1f0; color: var(--red); }
.badge.pending { background: #e8f0fe; color: var(--blue); }
.badge.sending { background: #fff7e6; color: var(--amber); }
.badge.no_template { background: #f4f4f5; color: #8c95a3; }
.badge.no_key { background: #fff7e6; color: #c77700; }
.badge.on { background: #e9f9ee; color: var(--green); }
.badge.off { background: #f4f4f5; color: #8c95a3; }

.chip {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  border: 1px solid #dbe2ea; background: #fff; color: #66707d; font-size: 11px;
  cursor: pointer; font-family: inherit; margin: 0 4px 4px 0;
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.chip-static { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #f1f4f8; color: #66707d; font-size: 10.5px; margin: 0 4px 4px 0; }

.list-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid #eef2f6;
}
.list-row:last-child { border-bottom: none; }
.list-row .body { flex: 1; min-width: 0; }

.pre-wrap {
  background: #fafbfd; border: 1px solid #eef2f6; border-radius: 8px; padding: 8px 10px;
  font-size: 11.5px; white-space: pre-wrap; word-break: break-word; color: #4b5563;
}

.empty { text-align: center; color: #b6bcc8; padding: 26px 0; font-size: 13px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters a {
  padding: 5px 12px; border-radius: 999px; border: 1px solid #dbe2ea; background: #fff;
  color: #66707d; font-size: 12px; text-decoration: none;
}
.filters a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

/* ── 登录页 ── */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f2733 0%, #333f52 55%, #4a332c 100%);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px 30px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.auth-card .logo { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-card .logo span { color: var(--accent); }
.auth-card .desc { font-size: 12px; color: var(--muted); margin-bottom: 20px; }
.auth-card .btn { width: 100%; margin-top: 6px; padding: 10px; }
.auth-card .foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ── 其他 ── */
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details[open] summary { margin-bottom: 8px; }
hr.sep { border: none; border-top: 1px dashed #e5eaf1; margin: 16px 0; }
details.batch { border: 1px solid var(--border); border-radius: 12px; padding: 0; margin-bottom: 14px; background: #fff; }
details.batch > summary {
  padding: 14px 18px; font-size: 14px; color: var(--text); display: flex; gap: 10px; align-items: center;
  list-style: none; cursor: pointer;
}
details.batch > summary::-webkit-details-marker { display: none; }
details.batch[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 0; }
details.batch .batch-body { padding: 14px 18px 18px; }
.batch-stats { font-size: 11px; color: var(--muted); }

/* ── 动态卡密 API ── */
.api-params { display: flex; flex-direction: column; gap: 8px; }
.param-row { display: flex; gap: 8px; align-items: center; }
.param-row input { flex: 1; min-width: 0; }
.param-row .p-key { flex: 0 0 180px; }
.param-row .btn { flex: none; }
.api-result {
  margin-top: 12px; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: #f8fafc; font-size: 12px;
}
.api-ok { color: var(--green); font-weight: 600; }
.api-err { color: var(--red); font-weight: 600; }
.api-ok code { background: #e9f9ee; padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.api-raw {
  margin: 8px 0 0; padding: 10px; max-height: 260px; overflow: auto;
  background: #0f1720; color: #d7e1ea; border-radius: 8px; font-size: 11px; white-space: pre-wrap;
}
