:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f4;
  --text: #182026;
  --muted: #66737d;
  --border: #dce3e7;
  --border-strong: #c4cfd6;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #e4f3f0;
  --warning: #a15c00;
  --warning-soft: #fff2d7;
  --danger: #b42318;
  --danger-soft: #fee9e7;
  --ok: #157347;
  --ok-soft: #e6f4ec;
  --shadow: 0 12px 32px rgba(20, 34, 42, 0.08);
  --radius: 8px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 44%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand-lockup, .sidebar-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}
.brand-lockup h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 18px; margin-top: 28px; }
.login-form label, .settings-form label { display: grid; gap: 7px; }
label > span { color: #34424b; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 108px; }
.form-message { margin: 0; color: var(--danger); font-size: 13px; }
.primary-button, .secondary-button, .danger-button, .ghost-button, .icon-button {
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 9px 14px;
  min-height: 38px;
  font-weight: 700;
}
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { background: #fff; color: #293841; border-color: var(--border-strong); }
.secondary-button:hover { background: var(--surface-soft); }
.danger-button { background: var(--danger); color: #fff; }
.ghost-button { background: transparent; color: var(--accent); border-color: transparent; padding-inline: 8px; }
.ghost-button:hover { background: var(--accent-soft); }
.icon-button { width: 40px; padding: 0; background: #fff; border-color: var(--border-strong); font-size: 20px; }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: 0.55; cursor: not-allowed; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  background: #172329;
  color: #edf3f5;
}
.sidebar-brand { padding: 0 6px 22px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-brand .brand-mark { width: 36px; height: 36px; background: #2c9b90; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { display: block; margin-top: 2px; color: #a9b7bd; font-size: 11px; }
.nav-list { display: grid; gap: 6px; margin-top: 22px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 7px;
  padding: 11px 12px;
  color: #c8d3d8;
  background: transparent;
  text-align: left;
  font-weight: 700;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: #e8f4f2; color: #0b5f59; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.72; }
.sidebar-foot { margin-top: auto; padding: 14px 12px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: #a9b7bd; }
.sidebar-foot strong { color: #f4b266; }
.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.admin-name { color: var(--muted); font-size: 13px; }
.content { padding: 24px 26px 42px; }
.view { display: none; }
.view.active { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { font-size: 28px; line-height: 1; }
.stat-card small { color: var(--muted); font-size: 11px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 20px; }
.panel-head { min-height: 68px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 15px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-row label { display: grid; gap: 6px; min-width: 150px; }
.filter-row .search-field { min-width: 260px; flex: 1; }
.toolbar-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: #4c5a63; background: #f8fafb; font-size: 12px; font-weight: 800; white-space: nowrap; }
.data-table td { font-size: 13px; }
.data-table tbody tr:hover { background: #f9fbfc; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warning); background: var(--warning-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.info { color: #245b8a; background: #e7f1fa; }
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); }
.pagination { min-height: 54px; padding: 10px 14px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
.pagination span { color: var(--muted); font-size: 12px; }

.settings-panel { max-width: 860px; }
.settings-form { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-form .wide, .settings-form .form-actions { grid-column: 1 / -1; }
.settings-form .form-section { display: grid; gap: 4px; padding: 2px 0 0; border-top: 1px solid var(--line); }
.settings-form .form-section:first-child { border-top: 0; }
.settings-form .form-section strong { color: var(--text); font-size: 13px; }
.settings-form .form-section small { color: var(--muted); font-size: 11px; }
.switch-field { grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--border); border-radius: 7px; padding: 12px; }
.switch-field > span { display: grid; gap: 3px; }
.switch-field small { color: var(--muted); font-weight: 400; }
.switch-field input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; }

.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(14, 24, 29, 0.56); }
.modal { width: min(720px, 100%); max-height: min(820px, 92vh); overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 24px 70px rgba(0,0,0,0.34); }
.modal.modal-wide { width: min(920px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 1; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; padding: 14px 20px; display: flex; justify-content: flex-end; gap: 10px; background: #fff; border-top: 1px solid var(--border); }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-grid .wide { grid-column: 1 / -1; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-item { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.detail-item span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.detail-item strong { font-size: 13px; overflow-wrap: anywhere; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 10px; font-size: 14px; }
.compact-table { width: 100%; border-collapse: collapse; }
.compact-table th, .compact-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 12px; }
.compact-table th { color: var(--muted); background: #f8fafb; }
.card-output { width: 100%; min-height: 180px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 120; display: grid; gap: 10px; }
.toast { min-width: 240px; max-width: 420px; padding: 12px 14px; border-radius: 7px; color: #fff; background: #26343b; box-shadow: var(--shadow); font-size: 13px; }
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger); }

.mobile-only { display: none; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: 232px; transform: translateX(-100%); transition: transform 160ms ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { grid-column: 1; }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { padding: 12px 14px; }
  .content { padding: 16px 14px 32px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-row { display: grid; grid-template-columns: 1fr; }
  .filter-row .search-field { min-width: 0; }
  .settings-form, .modal-grid, .detail-grid { grid-template-columns: 1fr; }
  .settings-form .wide, .settings-form .form-actions, .modal-grid .wide { grid-column: auto; }
}

@media (max-width: 520px) {
  .login-view { padding: 16px; }
  .login-panel { padding: 22px; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-actions .admin-name { display: none; }
  .modal-root { padding: 10px; }
  .modal-body, .modal-head, .modal-foot { padding-inline: 15px; }
}
