/* ===================================================================
   基础样式：设计变量 / 重置 / 通用组件
   配色取自「仙缘民俗绣品」国风调性：靛蓝 + 朱砂 + 米白
   =================================================================== */

:root {
  --brand: #234e70;
  --brand-strong: #1a3a56;
  --brand-soft: #eaf1f7;
  --accent: #c0503c;
  --accent-soft: #fbeeeb;

  --bg: #f6f2ec;
  --bg-elev: #ffffff;
  --bg-sunken: #efeae2;
  --border: #e2dcd2;
  --border-strong: #cec5b7;

  --text: #26221e;
  --text-soft: #6b6358;
  --text-faint: #9a9186;

  --ok: #2f7d63;
  --warn: #b7791f;
  --danger: #c0503c;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(38, 34, 30, .06), 0 2px 8px rgba(38, 34, 30, .04);
  --shadow: 0 4px 16px rgba(38, 34, 30, .08);
  --shadow-lg: 0 12px 40px rgba(38, 34, 30, .16);

  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7fb2d8;
    --brand-strong: #a3cbe6;
    --brand-soft: #1d2b38;
    --accent: #e08a76;
    --accent-soft: #33221f;

    --bg: #15161a;
    --bg-elev: #1d1f24;
    --bg-sunken: #111216;
    --border: #2c2f37;
    --border-strong: #3b3f4a;

    --text: #e7e4de;
    --text-soft: #a49d92;
    --text-faint: #6f6a62;

    --ok: #5fbf9b;
    --warn: #d9a441;
    --danger: #e08a76;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 4px 16px rgba(0, 0, 0, .38);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body.is-busy { cursor: progress; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
p { margin: 0 0 .6em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--brand); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); background-clip: content-box; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-sunken); border-color: var(--text-faint); }

.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #a8412f; }
@media (prefers-color-scheme: dark) { .btn-accent:hover { background: #c97663; } }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.field-error { margin-top: 6px; font-size: 12.5px; color: var(--danger); min-height: 1em; }

/* ---------------- 卡片 / 徽章 ---------------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}
.badge-soft { background: var(--bg-sunken); color: var(--text-soft); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------- 空状态 / 加载 ---------------- */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}
.empty .empty-title {
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 弹窗 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 18, 15, .48);
  backdrop-filter: blur(2px);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 1000;
  max-width: min(90vw, 460px);
  padding: 10px 18px;
  border-radius: 22px;
  background: #2b2723;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }
.toast-ok { background: var(--ok); }

/* ---------------- 通用布局工具 ---------------- */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--bg-sunken); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.active { background: var(--brand-soft); }

/* ---------------- 分段控件 / 标签页 ---------------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}
.seg button {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button.active {
  background: var(--bg-elev);
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
