/* ============================================================
   Sms888 CMS · 石墨暖金 设计系统
   单一来源：全站 token 与通用组件
   特性：亮/暗双色板（data-theme 切换）、侧边栏布局、移动端抽屉、全站响应式
   ============================================================ */

/* ---------------- 主题色板 ---------------- */
:root,
:root[data-theme="light"] {
  --paper: #F7F6F3;
  --surface: #FFFFFF;
  --surface-2: #F1EFEA;
  --ink: #1A1A1A;
  --soft: #6E6B64;
  --faint: #9C988E;
  --line: #E4E2DC;
  --hairline: #EEEDE8;
  --accent: #9A7B4F;
  --accent-deep: #7E6240;
  --accent-wash: #F0EAE0;
  --live: #3F7A5E;
  --live-wash: #E7EFE9;
  --live-line: #C7DACE;
  --alert: #A23A36;
  --alert-wash: #F4E7E6;

  --sidebar: #211F1B;        /* 侧边栏深底（亮色模式下也用深色，仪表盘气质） */
  --sidebar-ink: #EDEAE3;
  --sidebar-soft: #9A958A;
  --sidebar-line: #34302A;
  --sidebar-active: #2E2A24;

  --shadow: 0 18px 44px -22px rgba(40, 34, 24, 0.32);
}

:root[data-theme="dark"] {
  --paper: #14130F;
  --surface: #1C1A16;
  --surface-2: #242019;
  --ink: #ECE8DF;
  --soft: #A39E92;
  --faint: #726D62;
  --line: #2E2A22;
  --hairline: #262219;
  --accent: #C49A63;
  --accent-deep: #D8AE76;
  --accent-wash: #2A2318;
  --live: #5FA982;
  --live-wash: #1B2A22;
  --live-line: #2D4438;
  --alert: #D67670;
  --alert-wash: #2E1C1A;

  --sidebar: #0F0E0B;
  --sidebar-ink: #ECE8DF;
  --sidebar-soft: #8C8779;
  --sidebar-line: #221F18;
  --sidebar-active: #1C1A14;

  --shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.6);
}

:root {
  --display: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --rad: 4px;
  --sb-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.25s, color 0.25s;
}

::selection { background: var(--accent); color: #fff; }
a { color: inherit; }
.mono { font-family: var(--mono); }

/* ============================================================
   应用布局：侧边栏 + 主区
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: var(--sb-w); flex-shrink: 0;
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  border-right: 1px solid var(--sidebar-line);
}
.sidebar .sb-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 22px; border-bottom: 1px solid var(--sidebar-line);
  font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em;
  text-decoration: none; color: var(--sidebar-ink);
}
.sidebar .sb-brand .mark {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
.sidebar .sb-brand i { font-style: normal; color: var(--accent); }

.sb-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sb-group { margin-bottom: 18px; }
.sb-group .gt {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  color: var(--sidebar-soft); padding: 6px 12px 8px; text-transform: none;
}
.sb-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--rad);
  color: var(--sidebar-soft); text-decoration: none; font-size: 14px;
  transition: background 0.15s, color 0.15s; margin-bottom: 2px;
}
.sb-link:hover { background: var(--sidebar-active); color: var(--sidebar-ink); }
.sb-link.on { background: var(--sidebar-active); color: var(--sidebar-ink); }
.sb-link.on .ic { color: var(--accent); }
.sb-link .ic { width: 18px; height: 18px; flex-shrink: 0; color: var(--sidebar-soft); }
.sb-link .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px;
}

.sb-foot { border-top: 1px solid var(--sidebar-line); padding: 14px 16px; display: flex; align-items: center; gap: 11px; text-decoration: none; transition: background 0.15s; }
.sb-foot:hover { background: var(--sidebar-active); }
.sb-foot .avatar {
  width: 34px; height: 34px; border-radius: var(--rad); flex-shrink: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 13px;
}
.sb-foot .who { line-height: 1.3; min-width: 0; }
.sb-foot .who .nm { font-size: 13px; font-weight: 500; color: var(--sidebar-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot .who .id { font-family: var(--mono); font-size: 11px; color: var(--sidebar-soft); }

/* ---------------- 主区 ---------------- */
.main { flex: 1; min-width: 0; margin-left: var(--sb-w); display: flex; flex-direction: column; }

.appbar {
  height: 62px; flex-shrink: 0;
  border-bottom: 1px solid var(--line); background: var(--paper);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 40;
}
.appbar .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.appbar .page-name { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.appbar .right { display: flex; align-items: center; gap: 12px; }

.menu-btn {
  display: none; width: 38px; height: 38px; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--rad); cursor: pointer;
  align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0;
}

.balchip {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--mono); font-size: 13px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); padding: 6px 12px; white-space: nowrap;
}
.balchip span { color: var(--faint); font-size: 10px; }
.balchip b { font-weight: 600; color: var(--ink); }
.balchip em { font-style: normal; color: var(--accent); font-size: 11px; }

/* 主题切换三态 */
.theme-toggle {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); padding: 3px;
}
.theme-toggle button {
  width: 30px; height: 28px; border: none; background: transparent; cursor: pointer;
  border-radius: 3px; display: grid; place-items: center; color: var(--soft);
  transition: background 0.15s, color 0.15s;
}
.theme-toggle button svg { width: 16px; height: 16px; }
.theme-toggle button.on { background: var(--accent-wash); color: var(--accent-deep); }

.icon-btn { width: 38px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--rad); cursor: pointer; display: grid; place-items: center; color: var(--soft); transition: color 0.15s, border-color 0.15s; }
.icon-btn:hover { color: var(--alert); border-color: var(--alert); }

.content { padding: 0 24px; flex: 1; }

/* ---------------- 标题区 ---------------- */
.head { padding: 32px 0 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  color: var(--soft); display: flex; align-items: center; gap: 11px; margin-bottom: 14px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--accent); }
.head h1 { font-family: var(--display); font-weight: 600; font-size: clamp(26px, 3.4vw, 40px); letter-spacing: -0.03em; line-height: 1.06; }
.head h1 em { font-style: normal; color: var(--accent); }
.head p { margin-top: 12px; color: var(--soft); max-width: 480px; font-size: 14px; }

.live-pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: var(--live-wash); border: 1px solid var(--live-line);
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); position: relative; }
.dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--live); animation: ping 1.8s ease-out infinite; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.9); opacity: 0; } }
.head .meta { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 8px; }

/* ---------------- 面板 ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--hairline); }
.panel-h .lead { display: flex; align-items: center; gap: 11px; min-width: 0; }
.panel-h .ttl { font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.panel-h .code { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--faint); }

/* ---------------- 表单 ---------------- */
.field { padding: 15px 18px; border-bottom: 1px solid var(--hairline); }
.field:last-of-type { border-bottom: none; }
.field > label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--faint); display: block; margin-bottom: 9px; }
.input { width: 100%; font-family: var(--body); font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); padding: 11px 13px; transition: border-color 0.15s, box-shadow 0.15s; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
textarea.input { resize: vertical; min-height: 96px; }

.underline-input { width: 100%; font-family: var(--body); font-size: 15px; color: var(--ink); background: transparent; border: none; border-bottom: 1px solid var(--line); padding: 11px 2px; transition: border-color 0.15s; }
.underline-input::placeholder { color: var(--faint); }
.underline-input:focus { outline: none; border-bottom-color: var(--accent); }

.seg { display: flex; gap: 7px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 56px; font-family: var(--body); font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--soft); border-radius: var(--rad); padding: 9px 0; cursor: pointer; transition: all 0.15s; }
.seg button:hover { border-color: var(--soft); }
.seg button.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }

.selectish { width: 100%; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); background: var(--surface); border-radius: var(--rad); padding: 11px 13px; font-size: 14px; cursor: pointer; transition: border-color 0.15s; position: relative; }
.selectish:hover { border-color: var(--soft); }
.selectish.open { border-color: var(--accent); }
.selectish .v { display: flex; align-items: center; gap: 9px; }
.selectish .cc { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.selectish svg { color: var(--faint); flex-shrink: 0; transition: transform 0.15s; }
.selectish.open svg { transform: rotate(180deg); }

/* 下拉菜单 */
.select-menu {
  list-style: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad);
  box-shadow: var(--shadow); padding: 5px; max-height: 280px; overflow-y: auto;
}
.select-menu li {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 3px;
  font-size: 14px; cursor: pointer; transition: background 0.12s;
}
.select-menu li:hover { background: var(--surface-2); }
.select-menu li.on { background: var(--accent-wash); color: var(--accent-deep); }

/* Toast */
.toast-box {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); font-size: 14px;
  padding: 12px 22px; border-radius: 999px; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 9px;
}
.toast-box::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.toast-box.error::before { background: var(--alert); }
.toast-box.show { opacity: 1 !important; transform: translateX(-50%) translateY(0); }

/* ---------------- 按钮 ---------------- */
.btn { font-family: var(--display); font-weight: 600; font-size: 15px; background: var(--ink); color: var(--paper); border: none; border-radius: var(--rad); padding: 13px 22px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: background 0.15s, transform 0.12s; }
.btn:hover { background: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn kbd { font-family: var(--mono); font-size: 11px; font-weight: 400; opacity: 0.65; }
.btn.gold { background: var(--accent); }
.btn.gold:hover { background: var(--accent-deep); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface); border-color: var(--ink); transform: none; }

.copybtn { font-family: var(--mono); font-size: 12px; border: 1px solid var(--accent); color: var(--accent-deep); background: var(--surface); border-radius: var(--rad); padding: 8px 15px; cursor: pointer; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.copybtn:hover { background: var(--accent); color: #fff; }

/* ---------------- 表格 ---------------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.tbl thead th { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--faint); text-align: left; font-weight: 500; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl thead th.r, .tbl tbody td.r { text-align: right; }
.tbl tbody td { padding: 14px 16px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-family: var(--mono); font-weight: 500; }

/* ---------------- 状态徽标 ---------------- */
.st { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 2px; display: inline-block; white-space: nowrap; }
.st.active { background: var(--live-wash); color: var(--live); }
.st.wait { background: var(--accent-wash); color: var(--accent-deep); }
.st.lock { background: var(--surface-2); color: var(--faint); }
.st.done { background: var(--surface-2); color: var(--soft); }
.st.fail { background: var(--alert-wash); color: var(--alert); }

/* ---------------- 页脚 ---------------- */
.foot-rule { border-top: 1px solid var(--line); padding: 22px 0 40px; display: flex; align-items: center; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); flex-wrap: wrap; gap: 12px; }
.foot-rule .tick { display: flex; gap: 22px; flex-wrap: wrap; }
.foot-rule .tick span b { color: var(--live); }

/* ---------------- 移动端遮罩 ---------------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 55; }
.scrim.show { display: block; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sb-w: 224px; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; width: 264px; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .appbar { padding: 0 16px; }
  .content { padding: 0 16px; }
  .appbar .balchip .lbl-hide { display: none; }
}

@media (max-width: 560px) {
  .head { padding: 22px 0 18px; }
  .appbar .page-name { font-size: 15px; }
  .balchip { padding: 5px 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; scroll-behavior: auto; transition: none !important; }
}
