/* ============================================================
   共享设计令牌 + 基础样式
   用户端与管理端共用，保证视觉一致
   ============================================================ */

:root {
  /* 颜色 */
  --bg: #0d1117;
  --bg-soft: #131a23;
  --surface: #171f2a;
  --surface-2: #1e2733;
  --border: #2a3441;
  --border-soft: #222b36;

  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-mute: #6b7885;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);

  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.12);

  /* 尺寸 */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --gap: 16px;

  --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);

  --header-h: 58px;
  --maxw: 1240px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* hidden 属性必须始终生效。
   .login-screen{display:flex} / .admin-app{display:grid} 这类规则
   优先级高于浏览器默认的 [hidden]{display:none}，不加这条会导致
   登录成功后登录框不消失、页面卡住进不去。 */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui,
    -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: #33404f;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #435364;
}

/* ============================================================
   通用组件
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: #27323f;
  border-color: #3a4757;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.btn-ok:hover:not(:disabled) {
  background: #16a34a;
}

.btn-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* 表单 */
.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-mute);
}

.textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.6;
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%239aa7b4' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.field-hint {
  font-size: 11px;
  color: var(--text-mute);
}

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(34, 197, 94, 0.25);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}

.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.25);
}

.badge-purple {
  background: var(--purple-soft);
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.25);
}

.badge-mute {
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--border);
}

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-mute);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.5;
}

/* 加载 */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 提示条 */
#toast-root {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.22s ease;
  max-width: 90vw;
}

.toast-ok {
  background: #14532d;
  color: #86efac;
  border: 1px solid #166534;
}

.toast-err {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1px solid #991b1b;
}

.toast-info {
  background: #1e3a8a;
  color: #bfdbfe;
  border: 1px solid #1e40af;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}

/* 模态框 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

.modal-wide {
  max-width: 720px;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  flex-shrink: 0;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

/* 文本工具 */
.muted {
  color: var(--text-mute);
}

.dim {
  color: var(--text-dim);
}

.mono {
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
}

.strong {
  font-weight: 600;
}

.price {
  color: #fbbf24;
  font-weight: 700;
  font-size: 17px;
}

.price small {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.nowrap {
  white-space: nowrap;
}

.flex {
  display: flex;
}

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

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.flex-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}