/* =========================================================
   base.css — 设计令牌 / 重置 / 通用组件（用户端 + 管理端共用）
   ========================================================= */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", Georgia, "Times New Roman", serif;

  --ink: #0b0b0d;
  --text: #141417;
  --text-2: #4a4a52;
  --muted: #7c7c86;
  --line: #e7e7ea;
  --line-strong: #d7d7dc;
  --bg: #f5f5f7;
  --card: #ffffff;

  /* 深色面（取自 LOGO 的墨黑） */
  --graphite: #141417;
  --graphite-700: #0a0a0c;
  --graphite-800: #070708;
  --graphite-50: #f4f4f6;

  /* 品牌色（取自 LOGO 的正红） */
  --brand: #e50012;
  --brand-dark: #c10010;
  --brand-light: #ff4436;
  --brand-50: #fdeceb;
  --brand-soft: #fdeceb;

  --ok: #0e8a5f;
  --ok-bg: #e8f7ef;
  --warn: #b54708;
  --warn-bg: #fef3e2;
  --danger: #b42318;
  --danger-bg: #feecea;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --sh-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sh-2: 0 16px 40px -18px rgba(11, 18, 32, 0.28);
  --sh-3: 0 34px 80px -32px rgba(11, 18, 32, 0.45);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

dl, dd {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  --btn-bg: #fff;
  --btn-fg: var(--text);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease),
    background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s;
  white-space: nowrap;
}

.btn:hover {
  box-shadow: var(--sh-1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  --btn-bg: var(--graphite);
  --btn-fg: #fff;
  --btn-bd: var(--graphite);
  box-shadow: 0 10px 22px -14px rgba(10, 10, 12, 0.9);
}

.btn-primary:hover {
  --btn-bg: var(--graphite-700);
  --btn-bd: var(--graphite-700);
}

.btn-brand {
  --btn-bg: var(--brand);
  --btn-fg: #fff;
  --btn-bd: var(--brand);
  box-shadow: 0 10px 24px -14px rgba(229, 0, 18, 0.95);
}

.btn-brand:hover {
  --btn-bg: var(--brand-dark);
  --btn-bd: var(--brand-dark);
  box-shadow: 0 14px 28px -14px rgba(193, 0, 16, 0.85);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: var(--line-strong);
  --btn-fg: var(--text-2);
}

.btn-quiet {
  --btn-bg: transparent;
  --btn-bd: transparent;
  --btn-fg: var(--text-2);
  padding: 0 10px;
  min-height: 34px;
  font-weight: 500;
}

.btn-quiet:hover {
  --btn-fg: var(--graphite);
  background: var(--graphite-50);
}

.btn-danger-text {
  --btn-bg: transparent;
  --btn-bd: transparent;
  --btn-fg: var(--danger);
  min-height: 34px;
  padding: 0 10px;
  font-weight: 500;
}

.btn-danger-text:hover {
  background: var(--danger-bg);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

.btn-block {
  width: 100%;
}

/* ------------------------------ 表单 ------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field .req {
  color: var(--danger);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.input::placeholder,
.textarea::placeholder {
  color: #a2acbd;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--graphite);
  box-shadow: 0 0 0 3px rgba(20, 20, 23, 0.14);
}

.textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.55;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a8699' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M5 9l7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

/* ------------------------------ 卡片 / 徽标 ------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge-neutral {
  color: var(--text-2);
  background: #eeeef1;
}

.badge-brand {
  color: #b0000c;
  background: var(--brand-50);
}

/* ------------------------------ 表格 ------------------------------ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 760px;
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  background: #fafafb;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

table.data tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}

table.data tbody tr:hover {
  background: #fbfbfc;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data thead th:last-child {
  padding-right: 24px;
}

.cell-strong {
  font-weight: 600;
}

.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.cell-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ------------------------------ 弹窗 / 抽屉 ------------------------------ */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.52);
  backdrop-filter: blur(3px);
  animation: fade 0.2s var(--ease);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: pop 0.24s var(--ease);
}

.modal-lg {
  max-width: 880px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-head p {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

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

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  background: #fcfdff;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.icon-btn:hover {
  background: #f2f2f5;
  color: var(--text);
}

/* ------------------------------ 提示条 ------------------------------ */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--sh-2);
  animation: toastIn 0.26s var(--ease);
}

.toast.is-error {
  background: #7f1d1d;
}

.toast.is-ok {
  background: #0f5132;
}

/* ------------------------------ 空状态 ------------------------------ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.empty svg {
  opacity: 0.45;
}

/* ------------------------------ 动画 ------------------------------ */
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .modal-foot .btn {
    flex: 1;
  }
}
