/* ============================================================
   Wos UI · 基础层：重置 + 排版 + 通用原子组件
   依赖 tokens.css（所有颜色引用 var(--hue)）
   ============================================================ */

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

html, body { min-height: 100%; }

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

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.011em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }

::selection { background: oklch(0.62 0.15 var(--hue) / 0.18); }

/* 滚动条：细且克制 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: oklch(0.84 0.008 var(--hue));
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: oklch(0.74 0.01 var(--hue)); }

/* 数字统一等宽，避免跳动 */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------- 面板 ---------------- */
/* 用细边框分层，不靠堆叠阴影 —— 阴影只用在悬浮层 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--line-2);
}
.panel-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
}
.panel-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
  font-weight: 400;
}
.panel-body { padding: var(--s-6); }
.panel-body--flush { padding: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--line-hover); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px oklch(0.5 0.16 var(--hue) / 0.28);
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 2px 8px oklch(0.5 0.16 var(--hue) / 0.32);
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: oklch(0.24 0.02 var(--hue) / 0.055); border-color: transparent; }

.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); border-color: oklch(0.82 0.06 27); }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; gap: 5px; }
.btn-lg { height: 42px; padding: 0 22px; font-size: 14.5px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-sm);
}

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.004em;
}
.label .req { color: var(--danger); margin-left: 2px; }

.input,
.select,
.textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.textarea { height: auto; padding: 10px 12px; line-height: 1.65; resize: vertical; min-height: 92px; }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371807f' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-hover); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-glow);
}
.input::placeholder, .textarea::placeholder { color: oklch(0.70 0.008 var(--hue)); }
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-sunken);
  color: var(--text-3);
  cursor: not-allowed;
}
.input--err { border-color: var(--danger); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* 搜索输入框（带图标） */
.search { position: relative; }
.search .input { padding-left: 34px; }
.search::before {
  content: "";
  position: absolute; left: 11px; top: 50%;
  width: 14px; height: 14px; transform: translateY(-50%);
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5L21 21'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5L21 21'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
}

/* ---------------- 徽标 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-sunken);
  color: var(--text-2);
  border: 1px solid var(--line-2);
}
.badge--ok { background: var(--ok-soft); color: oklch(0.42 0.13 155); border-color: oklch(0.88 0.06 155); }
.badge--warn { background: var(--warn-soft); color: oklch(0.48 0.13 75); border-color: oklch(0.88 0.07 75); }
.badge--danger { background: var(--danger-soft); color: oklch(0.48 0.18 27); border-color: var(--danger-line); }
.badge--brand { background: var(--brand-soft); color: oklch(0.47 0.17 var(--hue)); border-color: var(--brand-line); }
.badge--gold { background: oklch(0.96 0.045 85); color: var(--gold-deep); border-color: oklch(0.88 0.07 85); }
.badge--dot::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.03em;
  padding: 10px 16px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th:first-child { padding-left: var(--s-6); border-top-left-radius: var(--r-lg); }
.table th:last-child { padding-right: var(--s-6); border-top-right-radius: var(--r-lg); }
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.table td:first-child { padding-left: var(--s-6); }
.table td:last-child { padding-right: var(--s-6); }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .ta-r { text-align: right; }
.table .ta-c { text-align: center; }

/* ---------------- 空状态 ---------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-16) var(--s-6);
  text-align: center;
}
.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--line-2);
  color: var(--text-3);
  margin-bottom: var(--s-1);
}
.empty-title { font-size: 14.5px; font-weight: 600; }
.empty-desc { font-size: 13px; color: var(--text-3); max-width: 380px; line-height: 1.65; }

/* ---------------- 加载 ---------------- */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid oklch(1 0 0 / 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.62s linear infinite;
  flex-shrink: 0;
}
.spinner--dark { border-color: oklch(0.24 0.02 var(--hue) / 0.16); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--line-2) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------- 工具类 ---------------- */
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-4 { margin-bottom: var(--s-4); }

/* 分隔线用细线，不用卡片堆叠 */
.hr { height: 1px; background: var(--line-2); border: 0; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
