@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #e8edf2;
  --bg-grid: rgba(15, 40, 70, 0.045);
  --panel: #ffffff;
  --ink: #142033;
  --muted: #5b6b7c;
  --line: #c9d4e0;
  --line-strong: #9aadc0;
  --accent: #0f5ea8;
  --accent-soft: #e6f0fa;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #0f7a4c;
  --ok-soft: #e6f6ee;
  --sidebar: #10233a;
  --sidebar-ink: #d7e3f0;
  --sidebar-muted: #8fa3b8;
  --rail: 4px;
  --radius: 2px;
  --font: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

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

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: var(--radius);
  border: 1px solid #c9daf0;
}

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

.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0a1828;
}

.brand {
  padding: 22px 20px 18px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff;
}

.brand span {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--sidebar-muted);
  text-transform: none;
  font-family: var(--font);
  font-weight: 400;
}

.sidebar nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-ink);
  padding: 10px 12px;
  text-decoration: none;
  border-radius: var(--radius);
  border-left: var(--rail) solid transparent;
  opacity: 0.78;
  font-weight: 500;
  font-size: 13px;
}

.sidebar nav a:hover {
  opacity: 1;
  background: rgba(255,255,255,0.05);
  text-decoration: none;
}

.sidebar nav a.active {
  opacity: 1;
  background: rgba(15, 94, 168, 0.28);
  border-left-color: #4da3ff;
  color: #fff;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-user {
  position: relative;
  color: var(--muted);
  font-size: 13px;
}

.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.topbar-user-trigger:hover,
.topbar-user.is-open .topbar-user-trigger,
.topbar-user:hover .topbar-user-trigger {
  color: var(--ink);
  background: #f3f6f9;
  border-color: var(--line);
}

.topbar-user-chevron {
  transition: transform 0.15s ease;
}

.topbar-user.is-open .topbar-user-chevron,
.topbar-user:hover .topbar-user-chevron {
  transform: rotate(180deg);
}

.topbar-user-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 168px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(10, 24, 40, 0.14);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.topbar-user-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}

.topbar-user:hover .topbar-user-menu,
.topbar-user:focus-within .topbar-user-menu,
.topbar-user.is-open .topbar-user-menu {
  display: flex;
}

.topbar-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.topbar-user-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.topbar-user-item-danger {
  color: var(--danger);
}

.topbar-user-item-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

#modal-admin-password .modal-panel {
  width: min(420px, 100%);
}

.content { padding: 24px 28px 40px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: #0d1b2a;
  background-image:
    linear-gradient(rgba(77, 163, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 163, 255, 0.06) 1px, transparent 1px),
    radial-gradient(ellipse at 20% 0%, rgba(15, 94, 168, 0.35), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(15, 122, 76, 0.18), transparent 45%);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.login-card {
  width: min(400px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.login-card .muted {
  margin: -4px 0 4px;
}

.captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.captcha-row input {
  flex: 1;
  min-width: 0;
}

.captcha-img {
  width: 120px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  background: #f5f7fa;
  object-fit: cover;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input[type=text],
input[type=password],
input[type=file],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7fafc;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.12);
}

textarea { resize: vertical; min-height: 84px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}

.btn:hover {
  text-decoration: none;
  background: var(--accent-soft);
  border-color: #8eb4db;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: #0c4f8f;
  border-color: #0c4f8f;
  color: var(--accent-ink);
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-size: 13px;
}

.alert-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b7e0cb;
}

.alert-err {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f3c0bb;
}

/* ─── Toast（右侧轻提示）──────────────────────────────── */
.toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 220px;
  max-width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(16, 35, 58, 0.14);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-in {
  opacity: 1;
  transform: translateX(0);
}

.toast.is-out {
  opacity: 0;
  transform: translateX(16px);
}

.toast-ok { border-left-color: var(--ok); }
.toast-err { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }

.toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.toast-icon .icon {
  width: 14px;
  height: 14px;
}

.toast-ok .toast-icon {
  background: var(--ok-soft);
  color: var(--ok);
}

.toast-err .toast-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast-info .toast-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.toast-body {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  margin: -4px -4px -4px 0;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  padding: 0;
}

.toast-close:hover {
  color: var(--ink);
  background: var(--bg);
}

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

.btn .icon,
.actions .icon,
.filters .btn .icon {
  margin-right: 2px;
}

.btn-with-icon,
.actions .link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filters input,
.filters select,
.filters .c-select {
  width: auto;
  min-width: 168px;
  background: var(--panel);
}

/* ─── Custom Select ───────────────────────────────────── */
.c-select {
  position: relative;
  display: block;
  width: 100%;
  font: inherit;
}

.c-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.c-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #fcfeff 0%, #f4f8fb 100%);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.c-select-trigger:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.c-select.is-open .c-select-trigger,
.c-select-trigger:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.12);
}

.c-select.is-disabled .c-select-trigger {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
  background: #f3f6f9;
}

.c-select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.c-select-value.is-placeholder {
  color: var(--muted);
  font-weight: 400;
}

.c-select-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform .18s ease, color .15s;
}

.c-select.is-open .c-select-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.c-select-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow:
    0 10px 28px rgba(16, 35, 58, 0.12),
    0 2px 6px rgba(16, 35, 58, 0.06);
  max-height: 240px;
  overflow-y: auto;
  transform-origin: top center;
  animation: c-select-in .14s ease-out;
}

@keyframes c-select-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scaleY(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .c-select-menu { animation: none; }
  .c-select-chevron { transition: none; }
}

.c-select-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.35;
  transition: background .12s, color .12s;
}

.c-select-option::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background .12s;
}

.c-select-option:hover,
.c-select-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.c-select-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent);
}

.c-select-option.is-selected::before {
  background: var(--accent);
}

.c-select-option.is-selected::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.16);
}

.list-page.is-loading [data-list-body] {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity .15s;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

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

.table th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f3f7fb;
  border-bottom: 1px solid var(--line);
}

.table tbody tr:hover td {
  background: #f8fbfe;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions .inline { display: inline; margin: 0; }

.actions a,
.actions button.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  background: #eef2f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b7e0cb;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: var(--rail) solid var(--accent);
  padding: 16px 18px;
}

.stat-n {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.stat-l {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  letter-spacing: 0.02em;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.form {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 860px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.form-actions { display: flex; gap: 10px; }

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 13px;
  color: var(--ink);
}

label.checkbox-block {
  align-items: flex-start;
  margin-top: 0;
}

label.checkbox-block span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label.checkbox-block .muted {
  font-weight: 400;
}

/* ─── Switch ──────────────────────────────────────────── */
.c-switch {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fcfeff 0%, #f5f8fb 100%);
  cursor: pointer;
  color: var(--ink);
  letter-spacing: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.c-switch:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.c-switch:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.12);
  background: #fff;
}

.c-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.c-switch-control {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  margin-top: 1px;
  border-radius: 999px;
  background: #c5d0dc;
  border: 1px solid #a8b7c8;
  transition: background .18s ease, border-color .18s ease;
}

.c-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 35, 58, 0.28);
  transition: transform .18s ease;
}

.c-switch-input:checked + .c-switch-control {
  background: var(--accent);
  border-color: #0c4f8f;
}

.c-switch-input:checked + .c-switch-control .c-switch-thumb {
  transform: translateX(18px);
}

.c-switch-input:focus-visible + .c-switch-control {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.c-switch-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-top: 1px;
}

.c-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.c-switch-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  .c-switch-control,
  .c-switch-thumb {
    transition: none;
  }
}

.pager { margin-top: 16px; }
.pager ul {
  display: flex;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.pager a,
.pager span {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
}

.pager .active span {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 24, 40, 0.55);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  box-shadow: 0 24px 60px rgba(10, 24, 40, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}

.modal-close:hover {
  color: var(--ink);
  background: var(--bg);
}

.modal-body { padding: 18px; }

.modal .form {
  border: 0;
  padding: 0;
  max-width: none;
  background: transparent;
}

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }
  .sidebar nav a {
    white-space: nowrap;
    border-left: 0;
    border-bottom: var(--rail) solid transparent;
  }
  .sidebar nav a.active {
    border-left-color: transparent;
    border-bottom-color: #4da3ff;
  }
  .content { padding: 18px 16px 32px; }
  .topbar { padding: 14px 16px; }
}
