:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe7f2;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 8px;
  font-family:
    Inter,
    "PingFang SC",
    "Microsoft YaHei",
    "Noto Sans SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.admin-header p,
.admin-header h1 {
  margin: 0;
}

.admin-header p {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.admin-header h1 {
  margin-top: 3px;
  font-size: 20px;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.header-actions a,
.header-actions button,
.panel-head button,
.inline-form button,
.row-actions button {
  min-height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
}

.header-actions a,
.header-actions button,
.panel-head button,
.row-actions button {
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.header-actions button {
  color: var(--danger);
}

.admin-main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.panel {
  margin-top: 18px;
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head h2 {
  font-size: 20px;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) 160px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-form input,
.inline-form select {
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.inline-form input:focus,
.inline-form select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.inline-form button {
  border: 1px solid var(--brand);
  color: #fff;
  background: var(--brand);
  font-weight: 750;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: #15803d;
  background: #dcfce7;
}

.badge.danger {
  color: #b91c1c;
  background: #fee2e2;
}

.badge.brand {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.feishu {
  color: #047857;
  background: #d1fae5;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button.danger {
  color: var(--danger);
}

.row-actions button.brand {
  color: var(--brand);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .admin-main {
    padding: 18px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }
}
