/* ============================================================
   软件仓库 · 公共基础样式（网站与管理器共用）
   ============================================================ */

:root {
  --bg:            #f4f5f9;
  --bg-soft:       #eceef5;
  --header-bg:     rgba(255, 255, 255, .86);
  --panel:         #ffffff;
  --panel-2:       #fafbfd;
  --panel-3:       #f2f4f9;

  --text:          #191c2b;
  --text-2:        #5a6178;
  --text-3:        #8b92a8;
  --text-inv:      #ffffff;

  --border:        #e4e7f0;
  --border-2:      #eef0f7;
  --border-strong: #d3d8e6;

  --accent:        #4f46e5;
  --accent-2:      #6366f1;
  --accent-3:      #818cf8;
  --accent-soft:   #eef0ff;
  --accent-ink:    #3730a3;

  --ok:            #0d9488;
  --ok-soft:       #e6f7f5;
  --warn:          #d97706;
  --warn-soft:     #fef3e2;
  --danger:        #dc2626;
  --danger-soft:   #fdeceb;
  --info:          #2563eb;
  --info-soft:     #e8f0fe;

  --radius-lg: 16px;
  --radius:    12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(20, 26, 48, .05);
  --shadow-sm: 0 2px 8px rgba(20, 26, 48, .06);
  --shadow:    0 6px 20px rgba(20, 26, 48, .08);
  --shadow-lg: 0 20px 56px rgba(20, 26, 48, .16);

  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Hiragino Sans GB",
          system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;

  --header-h: 62px;
}

[data-theme="dark"] {
  --bg:            #10131d;
  --bg-soft:       #161a27;
  --header-bg:     rgba(25, 29, 43, .86);
  --panel:         #191d2b;
  --panel-2:       #1e2231;
  --panel-3:       #232838;

  --text:          #eef0f7;
  --text-2:        #a8b0c6;
  --text-3:        #737c96;
  --text-inv:      #14172a;

  --border:        #2a3043;
  --border-2:      #232838;
  --border-strong: #3a4257;

  --accent:        #7c83ff;
  --accent-2:      #8b91ff;
  --accent-3:      #a5aaff;
  --accent-soft:   #23264a;
  --accent-ink:    #c7caff;

  --ok:            #2dd4bf;
  --ok-soft:       #12312f;
  --warn:          #fbbf24;
  --warn-soft:     #362a13;
  --danger:        #f87171;
  --danger-soft:   #3a1e1e;
  --info:          #60a5fa;
  --info-soft:     #1a2740;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow:    0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

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

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

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

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

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
  user-select: none;
}
.btn:hover { background: var(--panel-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-3); color: var(--text); }

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14px; }
.btn-icon { padding: 0; width: 36px; }
.btn-icon.btn-sm { width: 30px; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}
.field-label .req { color: var(--danger); margin-left: 3px; }
.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 78px; }
.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b92a8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > .input { flex: 1; min-width: 0; }

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

/* ---------------- 标签 / 徽章 ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--panel-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag-ok     { background: var(--ok-soft); color: var(--ok); }
.tag-warn   { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info   { background: var(--info-soft); color: var(--info); }

/* ---------------- 开关 ---------------- */
.switch {
  position: relative;
  width: 42px; height: 24px;
  flex: none;
  border-radius: 999px;
  background: var(--border-strong);
  border: 0;
  cursor: pointer;
  padding: 0;
  transition: background .18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
  transition: transform .18s cubic-bezier(.2, .8, .3, 1);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------------- 弹层 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 38, .45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  z-index: 200;
  animation: fadeIn .16s ease-out;
  overflow-y: auto;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn .18s cubic-bezier(.2, .8, .3, 1);
}
.modal-lg { max-width: 820px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  flex: none;
}
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-2);
  background: var(--panel-2);
  flex: none;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------- 提示条 ---------------- */
.toast-wrap {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  animation: toastIn .22s cubic-bezier(.2, .8, .3, 1);
  max-width: 82vw;
}
.toast::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--accent);
}
.toast.ok::before     { background: var(--ok); }
.toast.warn::before   { background: var(--warn); }
.toast.error::before  { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- 空状态 / 加载 ---------------- */
.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-3);
}
.empty svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 12px; }
.empty h4 { font-size: 15px; color: var(--text-2); margin-bottom: 5px; }
.empty p { margin: 0; font-size: 13px; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex: none;
}
.spinner-lg { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.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;
}

/* ---------------- 提示卡片 ---------------- */
.notice {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: var(--radius);
  background: var(--info-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.65;
}
.notice.warn { background: var(--warn-soft); }
.notice.ok   { background: var(--ok-soft); }
.notice b { color: var(--text); }
.notice svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--info); }
.notice.warn svg { color: var(--warn); }

/* ---------------- 通用工具类 ---------------- */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.hidden { display: none !important; }
