/* ── 基础 ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
h4,
p,
figure,
dl,
dd {
  margin: 0;
}
img {
  display: block;
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
svg {
  display: block;
  flex: none;
}
:focus-visible {
  outline: 2px solid var(--accent-3);
  outline-offset: 2px;
  border-radius: 4px;
}
.num {
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── 按钮 ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--r-s);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    transform 0.14s var(--ease), color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--sh-1);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
}
.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-2);
  color: var(--ink);
  background: var(--surface-2);
}
.btn-quiet {
  color: var(--ink-3);
}
.btn-quiet:hover:not(:disabled) {
  color: var(--ink);
}
.btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: #f3dbd8;
}
.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: 15.5px;
  border-radius: var(--r-m);
}
.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: var(--r-xs);
}
.btn-block {
  width: 100%;
}

/* ── 表单 ───────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field > label,
.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.label .opt {
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 5px;
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
  appearance: none;
}
.input::placeholder,
.textarea::placeholder {
  color: #b0aa9e;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-3);
  box-shadow: 0 0 0 3px rgba(63, 117, 102, 0.13);
}
.textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.65;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b857a' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
}
.hint {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.err {
  font-size: 12.5px;
  color: var(--danger);
}

/* ── 选择标签 ────────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  transition: all 0.16s var(--ease);
}
.chip:hover {
  border-color: var(--line-2);
}
.chip[aria-pressed="true"] {
  background: var(--accent-tint);
  border-color: var(--accent-3);
  color: var(--accent-2);
  font-weight: 500;
}
.chip:active {
  transform: scale(0.96);
}

/* ── 徽章 ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge-ok {
  background: var(--accent-tint);
  color: var(--accent-2);
}
.badge-clay {
  background: var(--clay-tint);
  color: var(--clay);
}
.badge-warn {
  background: var(--warn-tint);
  color: var(--warn);
}
.badge-danger {
  background: var(--danger-tint);
  color: var(--danger);
}
.badge-line {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
}

/* ── 卡片 / 分割 ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--sh-1);
}
.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

/* ── 完整度环 ────────────────────────────────────────── */
.ring {
  --p: 0;
  --size: 46px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent-3) calc(var(--p) * 1%), var(--paper-2) 0);
  position: relative;
  flex: none;
}
.ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--surface);
  border-radius: 50%;
}
.ring > span {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
}
.ring[data-low="1"] {
  background: conic-gradient(var(--warn) calc(var(--p) * 1%), var(--paper-2) 0);
}
.ring[data-low="1"] > span {
  color: var(--warn);
}

/* ── 进度条 ──────────────────────────────────────────── */
.bar {
  height: 5px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-3);
  transition: width 0.4s var(--ease);
}
.bar[data-low="1"] > i {
  background: var(--warn);
}

/* ── 提示 / 空态 / 骨架 ──────────────────────────────── */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  background: #211f1b;
  color: #fbfaf6;
  padding: 10px 15px;
  border-radius: var(--r-s);
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: var(--sh-3);
  animation: toastIn 0.26s var(--ease);
  max-width: 100%;
}
.toast[data-kind="err"] {
  background: #7d2b24;
}
.toast[data-kind="ok"] {
  background: var(--accent-2);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-l);
  padding: 40px 22px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface-2);
}
.empty h3 {
  font-size: 15px;
  color: var(--ink-2);
  margin-bottom: 6px;
  font-weight: 600;
}
.empty p {
  font-size: 13px;
  line-height: 1.7;
  max-width: 34ch;
  margin: 0 auto;
}

.skel {
  background: linear-gradient(90deg, var(--paper-2) 25%, #f7f5ef 37%, var(--paper-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-s);
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

.spin {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rot 0.7s linear infinite;
}
.spin-dark {
  border-color: rgba(27, 26, 23, 0.18);
  border-top-color: var(--ink-2);
}
@keyframes rot {
  to {
    transform: rotate(360deg);
  }
}

/* ── 弹层 ───────────────────────────────────────────── */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.42);
  backdrop-filter: blur(2px);
  z-index: 100;
  animation: fadeIn 0.2s var(--ease);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.modal {
  position: fixed;
  z-index: 101;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: var(--sh-3);
  padding: 22px;
  animation: modalIn 0.24s var(--ease);
  max-height: calc(100dvh - 48px);
  overflow: auto;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.97);
  }
}
.modal h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.modal .sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 18px;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

/* ── 表格 ───────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover {
  background: var(--surface-2);
}

/* ── 动效收敛 ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
