:root {
  /* UI/UX Pro Max 建议：Dark Mode (OLED) + Trust Blue */
  --bg: #0a0e27;
  --panel: rgba(18, 26, 51, 0.72);
  --panel2: rgba(18, 26, 51, 0.55);
  --text: rgba(232, 236, 255, 0.98);
  --muted: rgba(232, 236, 255, 0.68);
  --accent: #3b82f6; /* trust blue */
  --accent2: #60a5fa;
  --cta: #f97316;
  --danger: #ff6a6a;
  --ok: #43d19e;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.36);
  --radius: 14px;
  --ring: rgba(59, 130, 246, 0.42);

  --font-body: "Open Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  --font-heading: "Poppins", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% 10%, rgba(59, 130, 246, 0.28), transparent 60%),
    radial-gradient(900px 700px at 90% 20%, rgba(249, 115, 22, 0.14), transparent 58%),
    radial-gradient(1000px 760px at 55% 92%, rgba(67, 209, 158, 0.1), transparent 60%), var(--bg);
  min-height: 100vh;
  font-family: var(--font-body);
  line-height: 1.55;
  color-scheme: dark;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11, 16, 32, 0.75);
  border-bottom: 1px solid var(--border);
}

.title {
  padding: 16px 18px 10px 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  font-family: var(--font-heading);
}

.nav {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px 16px;
}

.tab {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.tab.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
}

.tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.container {
  /* 管理后台以信息密度为主：默认拉满宽度，避免按钮/表格过早换行 */
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 18px 18px 48px 18px;
}

.view {
  display: block;
}

.hidden {
  display: none !important;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 14px 0;
  backdrop-filter: blur(12px) saturate(140%);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  align-items: start;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-header > :first-child {
  min-width: 0;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.panel-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 90ch;
}

.panel-actions {
  display: flex;
  gap: 8px;
  /* 不换行：按钮过多时横向滚动（比换行更可控） */
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.panel-actions::-webkit-scrollbar {
  height: 6px;
}

.panel-actions::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.panel-actions::-webkit-scrollbar-track {
  background: transparent;
}

.panel-actions .btn {
  flex: 0 0 auto;
}

.muted {
  color: var(--muted);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.row > * {
  flex: 1;
  min-width: 180px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 39, 0.55);
  color: var(--text);
  outline: none;
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button {
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: rgba(232, 236, 255, 0.45);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 3px var(--ring);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}

textarea {
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.help {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 90ch;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 2px 10px 2px;
}

.page-header > :first-child {
  min-width: 0;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 90ch;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 0.2px;
  font-weight: 700;
  color: rgba(232, 236, 255, 0.9);
  margin: 12px 0 8px 2px;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 0;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease,
    opacity 160ms ease;
}

.btn.primary {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn.danger {
  background: rgba(255, 106, 106, 0.12);
  border-color: rgba(255, 106, 106, 0.35);
}

.btn.ok {
  background: rgba(67, 209, 158, 0.14);
  border-color: rgba(67, 209, 158, 0.35);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn.primary:hover {
  background: rgba(59, 130, 246, 0.25);
}

.btn.ok:hover {
  background: rgba(67, 209, 158, 0.18);
}

.btn.danger:hover {
  background: rgba(255, 106, 106, 0.16);
}

.btn:focus-visible,
.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.table thead th {
  font-size: 12px;
  color: rgba(232, 236, 255, 0.7);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.stat-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(67, 209, 158, 0.35);
}

.badge.bad {
  color: var(--danger);
  border-color: rgba(255, 106, 106, 0.35);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: rgba(18, 26, 51, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 10px 12px;
  max-width: 420px;
  animation: toast-in 160ms ease-out;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0.2;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.modal-card {
  width: min(960px, 100%);
  max-height: min(86vh, 860px);
  overflow: hidden;
  padding: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 0.2px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#modalActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#modalActions::-webkit-scrollbar {
  height: 6px;
}

#modalActions::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

#modalActions::-webkit-scrollbar-track {
  background: transparent;
}

#modalActions .btn {
  flex: 0 0 auto;
}

.btn-group {
  display: flex;
  gap: 8px;
  /* 不换行：按钮过多时横向滚动，避免挤压换行 */
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.btn-group::-webkit-scrollbar {
  height: 6px;
}

.btn-group::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.btn-group::-webkit-scrollbar-track {
  background: transparent;
}

.btn-group .btn {
  flex: 0 0 auto;
}

/* Flex gap 兼容：少数旧浏览器不支持 gap，会导致按钮贴在一起 */
@supports not (gap: 8px) {
  .panel-actions > * + * {
    margin-left: 8px;
  }
  #modalActions > * + * {
    margin-left: 8px;
  }
  .btn-group > * + * {
    margin-left: 8px;
  }
}

.modal-body {
  padding: 14px;
  overflow: auto;
  max-height: calc(min(86vh, 860px) - 58px);
}

.modal-body textarea {
  min-height: 460px;
}

/* 登录页 */
.login-shell {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 0 40px 0;
}

.login-card {
  width: 100%;
  max-width: 520px;
  padding: 22px;
  border-color: rgba(59, 130, 246, 0.22);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(255, 255, 255, 0.03));
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-logo {
  font-family: var(--font-heading);
  font-weight: 900;
  letter-spacing: 0.2px;
}

.login-tag {
  font-size: 12px;
  color: rgba(232, 236, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 2px 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-family: var(--font-heading);
}

.login-subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.login-form {
  margin-top: 16px;
}

.field {
  margin-top: 12px;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 74px;
}

.btn.sm {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
}

.input-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.login-btn {
  width: 100%;
  margin-top: 16px;
}

.login-foot {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
