:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f766e;
  --brand-dark: #0b5b55;
  --danger: #b42318;
  --warn: #b45309;
  --ok: #047857;
  --sidebar: #111827;
}

* { box-sizing: border-box; }
body.admin {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  font-family: "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; }

.sidebar {
  background: var(--sidebar);
  color: #e5e7eb;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  font-weight: 800;
}
.brand strong { display: block; font-size: 14px; }
.brand span { font-size: 12px; color: #9ca3af; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  color: #d1d5db;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(20, 184, 166, .16);
  color: #fff;
}
.sidebar-foot {
  margin-top: auto;
  font-size: 12px;
  color: #9ca3af;
  padding: 10px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px 8px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.content { padding: 12px 28px 40px; }

.flash {
  margin: 0 28px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.flash-ok { background: #ecfdf5; color: var(--ok); border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.flash-warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin: 0 0 14px; font-size: 16px; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; }

.btn, button.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef2f7; color: var(--ink); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.filters input, .filters select, form label input, form label select, form label textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.filters input { min-width: 220px; }
.filters select { min-width: 140px; }
form.grid { display: grid; gap: 14px; }
form.grid.two { grid-template-columns: 1fr 1fr; gap: 14px; }
form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #374151; }
form .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
form .full { grid-column: 1 / -1; }
.expire-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.remark {
  max-width: 220px;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-ok { background: #ecfdf5; color: var(--ok); }
.badge-expired { background: #fffbeb; color: var(--warn); }
.badge-disabled { background: #f3f4f6; color: #6b7280; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 16px;
}
.kv { display: grid; gap: 10px; }
.kv-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}
.kv-row span { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0 10px 14px;
  border-left: 2px solid #d1d5db;
  margin-left: 6px;
}
.timeline .at { font-size: 12px; color: var(--muted); }
.timeline .act { font-weight: 700; margin-top: 2px; }
.timeline .detail { font-size: 13px; color: #4b5563; margin-top: 2px; }

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

@media (max-width: 960px) {
  body.admin { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; }
  .stats, .detail-grid, form.grid.two { grid-template-columns: 1fr; }
  .topbar, .content, .flash { padding-left: 16px; padding-right: 16px; }
}
