/* ============================================================================
   幻写次元管理后台 - 砚池 Ink Console（v4 · 新中式水墨）
   宣纸浅底 + 浓墨侧栏 + 朱砂印章 + 玉绿/黛蓝/鎏金语义色
   设计原则：纸上作业的书卷气；细线（毫）、留白（余）、印章（点睛）
   ============================================================================ */

:root {
  /* 纸 */
  --paper: #f5f1e6;
  --paper-2: #fbf8ef;
  --paper-3: #efe9d9;
  --paper-inset: #f1ebdc;
  /* 墨 */
  --ink: #26231c;
  --ink-2: #3b372d;
  --ink-dim: #6e6757;
  --ink-faint: #98907c;
  --ink-solid: #2a261e;
  --ink-sidebar: #211e17;
  /* 朱砂 */
  --vermilion: #b03a2e;
  --vermilion-2: #c94f35;
  --vermilion-deep: #93291f;
  --vermilion-soft: rgba(176, 58, 46, 0.08);
  /* 五彩：玉 / 黛 / 鎏金 / 赭石 / 紫檀 */
  --jade: #35755a;
  --indigo-ink: #3e5878;
  --gold: #96762a;
  --ochre: #a5622d;
  --plum: #7c5276;
  /* 线与影 */
  --border: rgba(64, 54, 36, 0.14);
  --border-strong: rgba(64, 54, 36, 0.26);
  --border-focus: rgba(176, 58, 46, 0.55);
  --shadow-sm: 0 6px 22px rgba(84, 66, 38, 0.08);
  --shadow-lg: 0 26px 70px rgba(56, 42, 20, 0.22);
  /* 字 */
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "STZhongsong", "SimSun", serif;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  /* 形 */
  --radius: 10px;
  --radius-sm: 7px;
  /* 兼容旧变量名（防其他处引用） */
  --bg: var(--paper);
  --bg-2: var(--paper-2);
  --text: var(--ink);
  --text-dim: var(--ink-dim);
  --text-faint: var(--ink-faint);
  --primary: var(--vermilion);
  --danger: #a63325;
  --success: var(--jade);
  --warning: var(--gold);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  min-width: 320px;
  color-scheme: light;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  /* 宣纸：暖白底 + 角落淡墨晕 */
  background:
    radial-gradient(1100px 520px at 108% -8%, rgba(94, 76, 44, 0.055), transparent 64%),
    radial-gradient(900px 560px at -6% 112%, rgba(94, 76, 44, 0.045), transparent 62%),
    var(--paper);
}

body.modal-open,
body.nav-open { overflow: hidden; }

::selection { background: rgba(176, 58, 46, 0.2); color: var(--ink); }

/* 全局滚动条：淡墨 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(64, 54, 36, 0.24);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(64, 54, 36, 0.38); }

.hidden { display: none !important; }

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(176, 58, 46, 0.65);
  outline-offset: 2px;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 顶部加载线：朱砂拖出一笔 */
.network-progress {
  position: fixed;
  z-index: 500;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  pointer-events: none;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--vermilion), #d08c46, var(--vermilion));
  box-shadow: 0 0 10px rgba(176, 58, 46, 0.4);
}

.app.is-fetching .network-progress {
  opacity: 1;
  animation: networkProgress 1.25s ease-in-out infinite;
}

@keyframes networkProgress {
  0% { transform: translateX(-42%) scaleX(0.32); }
  50% { transform: translateX(22%) scaleX(0.58); }
  100% { transform: translateX(100%) scaleX(0.18); }
}

/* ============================================================================
   登录页：纸上山水（远山 · 朱阳 · 飞鸟 · 纸纹）
   ============================================================================ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 28px;
  background:
    radial-gradient(1000px 480px at 82% -10%, rgba(148, 118, 66, 0.07), transparent 62%),
    radial-gradient(760px 420px at 10% 108%, rgba(94, 76, 44, 0.08), transparent 60%),
    linear-gradient(180deg, #f8f4ea 0%, var(--paper) 58%, #efe9d8 100%);
}

/* 宣纸纤维纹理 */
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 100, 66, 0.03) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 100, 66, 0.022) 0 1px, transparent 1px 4px);
}

/* ---------------- 山水装饰层 ---------------- */

.sky { position: absolute; inset: 0; z-index: 0; pointer-events: none; }

/* 墨点尘埃：极淡，若有似无 */
.sky-stars {
  position: absolute;
  inset: -60px;
  opacity: 0.4;
  background-image:
    radial-gradient(1.4px 1.4px at 18px 34px, rgba(64, 54, 36, 0.5), transparent 60%),
    radial-gradient(1px 1px at 76px 8px,  rgba(64, 54, 36, 0.35), transparent 60%),
    radial-gradient(1.2px 1.2px at 132px 62px, rgba(64, 54, 36, 0.4), transparent 60%),
    radial-gradient(1px 1px at 55px 118px, rgba(64, 54, 36, 0.3), transparent 60%),
    radial-gradient(1.3px 1.3px at 165px 146px, rgba(64, 54, 36, 0.35), transparent 60%),
    radial-gradient(1px 1px at 105px 92px, rgba(64, 54, 36, 0.25), transparent 60%);
  background-repeat: repeat;
  background-size: 230px 230px;
  animation: inkBreathe 9s ease-in-out infinite;
}

.sky-stars-2, .sky-stars-3 { display: none; }

@keyframes inkBreathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.18; }
}

/* ---------------- 朱阳：一轮丹日 ---------------- */

.sky-moon {
  position: absolute;
  top: 88px;
  right: 15%;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 38%, rgba(201, 79, 53, 0.95), rgba(176, 58, 46, 0.88) 58%, rgba(176, 58, 46, 0.72) 74%, rgba(176, 58, 46, 0) 76%);
  filter: drop-shadow(0 0 26px rgba(176, 58, 46, 0.28));
  animation: sunFloat 10s ease-in-out infinite alternate;
}

/* 日晕：一圈朱砂淡晕 */
.sky-moon::after {
  content: "";
  position: absolute;
  inset: -34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(176, 58, 46, 0.12), rgba(176, 58, 46, 0.04) 52%, transparent 70%);
}

@keyframes sunFloat {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); }
}

/* ---------------- 飞鸟：水墨海鸥笔 ---------------- */

.sky-meteor {
  position: absolute;
  width: 38px;
  height: 16px;
  opacity: 0.6;
  animation: birdDrift 14s ease-in-out infinite alternate;
}

.sky-meteor::before,
.sky-meteor::after {
  content: "";
  position: absolute;
  top: 5px;
  width: 19px;
  height: 12px;
  border-top: 2.5px solid rgba(38, 35, 28, 0.62);
  border-radius: 100% 100% 0 0;
  background: transparent;
}

.sky-meteor::before { left: 0; transform: rotate(-16deg); transform-origin: right top; }
.sky-meteor::after { right: 0; transform: rotate(16deg); transform-origin: left top; }

.sky-meteor-1 { top: 19%; left: 13%; }
.sky-meteor-2 { top: 14%; left: 19%; transform: scale(0.7); animation-delay: -4s; }
.sky-meteor-3 { top: 25%; left: 9%; transform: scale(0.5); animation-delay: -8s; }
.sky-meteor-4, .sky-meteor-5, .sky-meteor-6 { display: none; }

@keyframes birdDrift {
  from { translate: 0 0; }
  to   { translate: 46px -12px; }
}

/* ---------------- 远山：层叠墨晕 ---------------- */

.sky-horizon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 260px;
  background:
    radial-gradient(52% 200px at 12% 100%, rgba(58, 48, 32, 0.30), transparent 70%),
    radial-gradient(64% 240px at 46% 102%, rgba(58, 48, 32, 0.20), transparent 72%),
    radial-gradient(48% 180px at 78% 100%, rgba(58, 48, 32, 0.27), transparent 70%),
    radial-gradient(70% 310px at 96% 104%, rgba(58, 48, 32, 0.15), transparent 74%),
    linear-gradient(180deg, transparent, rgba(58, 48, 32, 0.07));
}

/* ---------------- 登录卡：装裱立轴 ---------------- */

.login-card {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  padding: 40px 38px 34px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.6), rgba(255, 253, 246, 0) 30%),
    var(--paper-2);
  box-shadow:
    0 30px 80px rgba(56, 42, 20, 0.18),
    0 4px 18px rgba(56, 42, 20, 0.08);
  animation: cardIn 0.5s cubic-bezier(0.22, 0.8, 0.32, 1) both;
}

/* 内框：书画装裱的衬线 */
.login-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  border: 1px solid rgba(64, 54, 36, 0.12);
  border-radius: 8px;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
}

/* 品牌印章：朱砂方印 */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  color: #f8f2e4;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  background: linear-gradient(150deg, var(--vermilion-2), var(--vermilion) 55%, var(--vermilion-deep));
  box-shadow:
    inset 0 0 0 2px rgba(248, 242, 228, 0.4),
    inset 0 0 0 3.5px rgba(147, 41, 31, 0.5),
    0 6px 16px rgba(147, 41, 31, 0.3);
  transform: rotate(-2deg);
}

.login-brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 11px;
  font-size: 27px;
}

.login-eyebrow {
  margin-bottom: 3px;
  color: var(--vermilion);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
}

.login-logo {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 4px;
  text-align: left;
}

.login-sub {
  margin: 22px 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-faint);
  font-size: 12.5px;
  letter-spacing: 4px;
  text-align: left;
}

.login-error {
  min-height: 22px;
  margin: -2px 0 10px;
  color: var(--danger);
  font-size: 13px;
  text-align: left;
}

.login-card .form-group { margin-bottom: 17px; }

.login-card .form-group label { color: var(--ink-dim); font-weight: 600; }

.login-card .form-group input {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 9px;
  background: #f6f1e3;
}

.login-card .btn-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 11px 16px;
  border-radius: 9px;
  font-size: 14.5px;
  letter-spacing: 5px;
  text-indent: 5px;
}

.login-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 17px;
  color: var(--ink-faint);
  font-size: 11.5px;
}

.login-footnote .icon { width: 13px; height: 13px; }

/* ============================================================================
   应用框架：浓墨侧栏 + 宣纸主区
   ============================================================================ */

.app {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  position: relative;
}

/* 主界面纸纹与角落淡墨山影 */
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(520px 190px at 104% 102%, rgba(64, 54, 36, 0.075), transparent 70%),
    radial-gradient(720px 240px at 88% 104%, rgba(64, 54, 36, 0.05), transparent 72%),
    repeating-linear-gradient(0deg, rgba(120, 100, 66, 0.02) 0 1px, transparent 1px 3px);
}

.mobile-topbar,
.sidebar-backdrop { display: none; }

/* ---------------- 侧边栏：一锭浓墨 ---------------- */

.sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 2;
  padding: 0 12px 12px;
  border-right: 1px solid rgba(30, 26, 18, 0.5);
  color: #cfc7b2;
  background:
    radial-gradient(420px 210px at 88% -4%, rgba(201, 79, 53, 0.07), transparent 62%),
    linear-gradient(180deg, #262218, var(--ink-sidebar) 42%, #1b1812);
  box-shadow: inset -14px 0 30px -22px rgba(0, 0, 0, 0.6);
}

/* 右缘一道淡淡的墨痕 */
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35) 30%, rgba(0, 0, 0, 0.35) 70%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  margin: 0;
  padding: 16px 10px;
  border-bottom: 1px solid rgba(248, 242, 228, 0.09);
}

.brand-copy { display: flex; min-width: 0; flex-direction: column; }

.brand-copy strong {
  color: #f4efe1;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 3px;
}

.brand-copy small {
  margin-top: 3px;
  color: #8a8168;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2.2px;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 0;
  overflow-y: auto;
}

.nav::before {
  content: "工作台";
  padding: 0 12px 8px;
  color: #776f58;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #a89f88;
  background: transparent;
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: 1px;
  text-align: left;
  cursor: pointer;
  user-select: none;
  appearance: none;
  transition: all 0.16s ease;
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  color: #7d7460;
  transition: color 0.18s ease, transform 0.18s ease;
}

.nav-item:hover {
  border-color: rgba(248, 242, 228, 0.07);
  color: #efe9d8;
  background: rgba(248, 242, 228, 0.05);
}

.nav-item:hover .icon { color: #cfc4a6; transform: translateX(1px); }

.nav-item.active {
  border-color: rgba(201, 79, 53, 0.26);
  color: #f8f3e5;
  font-weight: 650;
  background: linear-gradient(90deg, rgba(176, 58, 46, 0.26), rgba(176, 58, 46, 0.05) 78%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}

.nav-item.active .icon { color: #e08d70; }

/* 活动项左侧朱砂批注条 */
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--vermilion-2), var(--vermilion-deep));
  box-shadow: 0 0 12px rgba(201, 79, 53, 0.55);
}

/* 未读徽章：朱砂小印 */
.badge {
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0 6px;
  border: 1px solid rgba(248, 242, 228, 0.25);
  border-radius: 999px;
  color: #fdf6e8;
  background: linear-gradient(150deg, var(--vermilion-2), var(--vermilion-deep));
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(147, 41, 31, 0.4);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 13px 7px 0;
  border-top: 1px solid rgba(248, 242, 228, 0.09);
  color: #a89f88;
  font-size: 13px;
}

.admin-profile { display: flex; min-width: 0; align-items: center; gap: 9px; }

/* 管理员小印：玉章 */
.admin-avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(112, 168, 137, 0.3);
  border-radius: 8px;
  color: #a9cdb4;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
  background: rgba(53, 117, 90, 0.2);
  box-shadow: inset 0 0 0 2px rgba(169, 205, 180, 0.12);
}

.admin-copy { display: flex; min-width: 0; flex-direction: column; }

.admin-copy strong {
  max-width: 128px;
  overflow: hidden;
  color: #efe9d8;
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-copy small {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #7fae8f;
  font-size: 10px;
}

.admin-copy small::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6fae85;
  box-shadow: 0 0 7px rgba(111, 174, 133, 0.8);
}

#admin-name { display: block; }
#admin-name::before { display: none; content: none; }

.icon-btn {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink-dim);
  background: rgba(64, 54, 36, 0.04);
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
  background: rgba(64, 54, 36, 0.08);
}

.icon-btn:active { transform: translateY(1px); }

/* 侧栏内的图标按钮走暗色 */
.sidebar .icon-btn {
  border-color: rgba(248, 242, 228, 0.14);
  color: #a89f88;
  background: rgba(248, 242, 228, 0.05);
}

.sidebar .icon-btn:hover {
  border-color: rgba(201, 79, 53, 0.45);
  color: #f0a58c;
  background: rgba(176, 58, 46, 0.14);
}

.logout-btn { width: 34px; height: 34px; }

/* ---------------- 主区 ---------------- */

.main {
  flex: 1;
  width: 100%;
  max-width: 1640px;
  min-width: 0;
  min-height: 100vh;
  margin-right: auto;
  padding: 34px 42px 56px;
  position: relative;
  z-index: 1;
}

.main:focus { outline: none; }

.page { position: relative; animation: pageEnter 0.24s ease both; }

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.page.is-loading::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(64, 54, 36, 0.18);
  border-top-color: var(--vermilion);
  border-radius: 50%;
  animation: spin 0.72s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(23px, 2vw, 28px);
  font-weight: 900;
  letter-spacing: 2px;
}

/* 标题前：一竖浓墨 */
.page h1::before {
  content: "";
  width: 5px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--ink-2), var(--ink) 55%, rgba(38, 35, 28, 0.55));
}

/* 标题后：一方朱印 */
.page h1::after {
  content: "";
  width: 13px;
  height: 13px;
  margin-top: 2px;
  border-radius: 3px;
  background: linear-gradient(150deg, var(--vermilion-2), var(--vermilion-deep));
  box-shadow: inset 0 0 0 1.5px rgba(248, 242, 228, 0.5);
  transform: rotate(-3deg);
  opacity: 0.92;
}

.page-desc {
  max-width: 920px;
  margin: 0 0 24px 17px;
  color: var(--ink-faint);
  font-size: 13px;
  letter-spacing: 0.3px;
}

/* ---------------- 统一空态 ---------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  text-align: center;
  padding: 40px 20px;
  gap: 4px;
}

.empty-state .es-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--ink-faint);
  background:
    linear-gradient(160deg, rgba(176, 58, 46, 0.05), transparent 55%),
    var(--paper-inset);
}

.empty-state .es-icon .icon { width: 25px; height: 25px; }

.empty-state .es-title { font-size: 14px; font-weight: 650; color: var(--ink-2); }

.empty-state .es-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.7;
  max-width: 320px;
}

.table tr.empty-row td { white-space: normal; padding: 0; }
.table tbody tr.empty-row:hover { background: transparent; }

/* ============================================================================
   卡片与统计
   ============================================================================ */

.card {
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.55), rgba(255, 253, 246, 0) 34%),
    var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card h3 { font-size: 15px; letter-spacing: 0.4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.order-stats {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
}

.stat-card {
  --accent: var(--vermilion);
  position: relative;
  overflow: hidden;
  min-height: 126px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.5), rgba(255, 253, 246, 0) 40%),
    var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 34px rgba(84, 66, 38, 0.14);
}

.stat-card:nth-child(6n + 1) { --accent: var(--vermilion); }
.stat-card:nth-child(6n + 2) { --accent: var(--indigo-ink); }
.stat-card:nth-child(6n + 3) { --accent: var(--jade); }
.stat-card:nth-child(6n + 4) { --accent: var(--gold); }
.stat-card:nth-child(6n + 5) { --accent: var(--plum); }
.stat-card:nth-child(6n + 6) { --accent: var(--ochre); }

/* 顶部一笔淡彩 */
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 30%;
  height: 2px;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}

.stat-card .stat-ico {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  background: var(--paper-inset);
}

.stat-card .stat-ico .icon { width: 19px; height: 19px; }

.stat-card .num {
  max-width: calc(100% - 48px);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(25px, 2.5vw, 31px);
  font-weight: 900;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-card .label {
  margin-top: 9px;
  color: var(--ink-dim);
  font-size: 12.5px;
  letter-spacing: 0.4px;
}

/* ---------------- 用量归属分布 ---------------- */

.usage-kind-title {
  margin-top: 30px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.usage-kind-grid {
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.5), rgba(255, 253, 246, 0) 40%),
    var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.usage-kind-row {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr minmax(150px, 190px);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.15s ease;
}

.usage-kind-row:hover { background: rgba(64, 54, 36, 0.04); }

.usage-kind-label {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-kind-bar {
  height: 7px;
  background: rgba(64, 54, 36, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.usage-kind-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--vermilion), #cf8a4c);
}

.usage-kind-nums {
  text-align: right;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============================================================================
   工具栏 / 表单
   ============================================================================ */

.toolbar {
  display: flex;
  gap: 9px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-search { width: min(280px, 100%); }
.toolbar-push { margin-left: auto; }

.input, textarea.input, select.input,
.form-group input, .form-group textarea, .form-group select {
  min-height: 40px;
  width: auto;
  background: #f6f1e3;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 9px 13px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  box-shadow: inset 0 1px 3px rgba(84, 66, 38, 0.07);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-group input, .form-group textarea, .form-group select { width: 100%; }

textarea.input, .form-group textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.65;
}

.input::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder { color: #ab9f85; }

.input:hover,
.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover { border-color: rgba(64, 54, 36, 0.4); }

.input:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  background: #fbf7ec;
  box-shadow: 0 0 0 3px rgba(176, 58, 46, 0.12);
}

.form-group { margin-bottom: 17px; }

.form-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-dim);
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: 0.3px;
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.hint { color: var(--ink-faint); font-size: 12px; margin-top: 4px; line-height: 1.7; }

.field-error {
  min-height: 18px;
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
}

.switch-group { display: flex; flex-wrap: wrap; gap: 12px 26px; }

.switch-label {
  display: inline-flex !important;
  align-items: center;
  gap: 9px;
  margin-bottom: 0 !important;
  color: var(--ink-2) !important;
  cursor: pointer;
  user-select: none;
  line-height: 1.45;
}

input[type="checkbox"] { accent-color: var(--vermilion); width: 15px; height: 15px; cursor: pointer; }

/* 开关：玉色为启 */
.switch-label input[type="checkbox"] {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  appearance: none;
  background: #e3dcc8;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.switch-label input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #9a9078;
  box-shadow: 0 2px 5px rgba(84, 66, 38, 0.3);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch-label input[type="checkbox"]:checked {
  border-color: rgba(53, 117, 90, 0.6);
  background: linear-gradient(135deg, #3d8465, #2c6a4e);
}

.switch-label input[type="checkbox"]:checked::after {
  background: #f7f3e6;
  transform: translateX(16px);
}

.switch-offset { margin-top: 26px !important; }

/* ============================================================================
   按钮
   ============================================================================ */

.btn {
  position: relative;
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--ink-2);
  background: #f7f3e7;
  cursor: pointer;
  font-size: 14px;
  font-weight: 570;
  font-family: inherit;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(84, 66, 38, 0.08), inset 0 1px rgba(255, 255, 255, 0.5);
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.btn:hover {
  border-color: rgba(64, 54, 36, 0.42);
  color: var(--ink);
  background: #efe9d8;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* 主按钮：一锭研好的浓墨 */
.btn-primary {
  border-color: rgba(20, 17, 12, 0.85);
  color: #f6f1e2;
  background: linear-gradient(180deg, #423c2e, var(--ink-solid) 55%, #1d1a13);
  font-weight: 620;
  box-shadow: 0 8px 20px rgba(38, 32, 20, 0.28), inset 0 1px rgba(255, 255, 255, 0.14);
}

.btn-primary:hover {
  border-color: #000;
  color: #fffdf4;
  background: linear-gradient(180deg, #4c4536, #322d22 55%, #232016);
  box-shadow: 0 10px 26px rgba(38, 32, 20, 0.36), inset 0 1px rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

/* 危险按钮：朱批 */
.btn-danger {
  border-color: rgba(176, 58, 46, 0.4);
  color: var(--danger);
  background: rgba(176, 58, 46, 0.07);
}

.btn-danger:hover {
  border-color: rgba(176, 58, 46, 0.62);
  color: var(--vermilion-deep);
  background: rgba(176, 58, 46, 0.13);
}

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--ink-dim); box-shadow: none; }
.btn-ghost:hover { color: var(--ink); border-color: rgba(64, 54, 36, 0.45); background: rgba(64, 54, 36, 0.05); }

.btn-sm { min-height: 34px; padding: 7px 12px; font-size: 12.5px; }
.btn-xs { min-height: 29px; padding: 5px 9px; border-radius: 7px; font-size: 11.5px; }
.btn-block { width: 100%; }

.btn.is-loading {
  min-width: var(--loading-width, auto);
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading > * { opacity: 0; }

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(246, 241, 226, 0.35);
  border-top-color: #f6f1e2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn:not(.btn-primary).is-loading::after {
  border-color: rgba(64, 54, 36, 0.25);
  border-top-color: var(--vermilion);
}

/* ============================================================================
   数据表格 / 标签 / 分页
   ============================================================================ */

.card.table-scroll { padding: 0; overflow: auto; }
.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
}

.table th, .table td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: #857b63;
  background: #f0eadb;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 1.6px;
  box-shadow: inset 0 -1px rgba(64, 54, 36, 0.16);
}

.table td { color: #454033; font-size: 12.5px; }
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: rgba(64, 54, 36, 0.035); }
.table tr:last-child td { border-bottom: none; }
.table .cell-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.mono {
  font-family: "Cascadia Code", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.reject-hint { max-width: 240px; margin: 4px 0 0; white-space: normal; }
.actions-column { min-width: 220px; }

/* 语义印色标签：描边小印 */
.tag {
  display: inline-flex;
  min-height: 21px;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

.tag-green  { background: rgba(53, 117, 90, 0.08);  color: #2c6a4e; border-color: rgba(53, 117, 90, 0.36); }
.tag-red    { background: rgba(176, 58, 46, 0.07);  color: #a63325; border-color: rgba(176, 58, 46, 0.38); }
.tag-gray   { background: rgba(110, 103, 87, 0.07); color: #6e6757; border-color: rgba(110, 103, 87, 0.3); }
.tag-blue   { background: rgba(62, 88, 120, 0.07);  color: #3e5878; border-color: rgba(62, 88, 120, 0.34); }
.tag-orange { background: rgba(165, 98, 45, 0.08);  color: #97572a; border-color: rgba(165, 98, 45, 0.36); }
.tag-purple { background: rgba(124, 82, 118, 0.07); color: #7c5276; border-color: rgba(124, 82, 118, 0.34); }
.tag-yellow { background: rgba(150, 118, 42, 0.09); color: #85681f; border-color: rgba(150, 118, 42, 0.38); }

.pager {
  position: sticky;
  left: 0;
  min-width: min(100%, 720px);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  padding: 13px 14px;
  border-top: 1px solid var(--border);
  color: var(--ink-dim);
  background: rgba(247, 243, 231, 0.85);
  font-size: 13px;
}

/* ============================================================================
   页签
   ============================================================================ */

.tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 3px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper-inset);
  flex-wrap: wrap;
}

.tab {
  min-height: 34px;
  padding: 7px 15px;
  border: 0;
  border-radius: 7px;
  color: var(--ink-dim);
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  letter-spacing: 1px;
  transition: all 0.16s ease;
}

.tab:hover { color: var(--ink); background: rgba(64, 54, 36, 0.06); }

.tab.active {
  color: #f6f1e2;
  font-weight: 620;
  background: linear-gradient(180deg, #423c2e, var(--ink-solid) 60%);
  box-shadow: 0 4px 12px rgba(38, 32, 20, 0.26);
}

/* ============================================================================
   模型配置双栏
   ============================================================================ */

.model-layout {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.conn-panel {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.5), rgba(255, 253, 246, 0) 40%),
    var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 520px;
  box-shadow: var(--shadow-sm);
}

.conn-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 1px;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--border);
  background: rgba(64, 54, 36, 0.03);
}

.conn-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.conn-list .empty-state { padding: 30px 12px; min-height: 0; }
.conn-list .empty-state .es-icon { width: 52px; height: 52px; font-size: 23px; border-radius: 13px; }

.conn-editor { min-height: 520px; display: flex; flex-direction: column; }
.conn-editor > .empty-state { flex: 1; }

.conn-editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.conn-editor-title {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 1px;
}

.conn-item {
  display: block;
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8f4e9;
  color: var(--ink-dim);
  cursor: pointer;
  font: inherit;
  text-align: left;
  appearance: none;
  transition: all 0.15s ease;
}

.conn-item:hover {
  border-color: rgba(176, 58, 46, 0.4);
  background: #fbf7ec;
}

.conn-item.selected {
  border-color: rgba(176, 58, 46, 0.5);
  background: linear-gradient(120deg, rgba(176, 58, 46, 0.07), rgba(176, 58, 46, 0.015));
  box-shadow: inset 3px 0 var(--vermilion), 0 6px 16px rgba(84, 66, 38, 0.1);
}

.conn-item .conn-name { font-weight: 650; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.conn-item .conn-meta { display: block; color: var(--ink-faint); font-size: 12px; margin-top: 4px; word-break: break-all; white-space: normal; }

.inline-actions { margin-top: 6px; margin-bottom: 0; }
.inline-hint { margin-top: 10px; }
.compact-card { max-width: 680px; }
.compact-card .section-title { margin-bottom: 15px; }

/* ============================================================================
   设置
   ============================================================================ */

.settings-stack {
  display: flex;
  max-width: 900px;
  flex-direction: column;
  gap: 16px;
}

.settings-card { max-width: none; }

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 9px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
}

/* 节标题前一枚小朱点 */
.section-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--vermilion-2), var(--vermilion-deep));
}

.section-title-divided {
  margin-top: 25px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.section-hint {
  margin: 0 0 19px;
  padding: 10px 12px;
  border-left: 2px solid rgba(176, 58, 46, 0.55);
  border-radius: 0 7px 7px 0;
  background: rgba(176, 58, 46, 0.045);
}

.prompt-official-card {
  max-width: 900px;
  margin-top: 16px;
  animation: pageEnter 0.2s ease both;
}

/* ============================================================================
   客服聊天
   ============================================================================ */

.chat-layout {
  display: grid;
  grid-template-columns: minmax(230px, 286px) minmax(0, 1fr);
  height: min(660px, calc(100vh - 180px));
  min-height: 500px;
  padding: 0;
  overflow: hidden;
}

.chat-threads {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: rgba(64, 54, 36, 0.025);
}

.chat-thread {
  display: block;
  width: 100%;
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  appearance: none;
  transition: background 0.13s ease;
}

.chat-thread:hover { background: rgba(64, 54, 36, 0.045); }

.chat-thread.selected {
  box-shadow: inset 2px 0 var(--vermilion);
  background: linear-gradient(90deg, rgba(176, 58, 46, 0.08), rgba(176, 58, 46, 0.015));
}

.chat-thread .t-name { font-weight: 650; display: flex; justify-content: space-between; align-items: center; }
.chat-thread .t-last { display: block; color: var(--ink-faint); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { display: flex; flex-direction: column; min-width: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(420px 260px at 92% 0, rgba(176, 58, 46, 0.03), transparent 70%),
    #f6f2e5;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
}

.chat-threads .empty-state { padding: 34px 14px; min-height: 0; }
.chat-threads .empty-state .es-icon { width: 50px; height: 50px; font-size: 22px; border-radius: 12px; }

.msg {
  max-width: min(76%, 720px);
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  animation: msgIn 0.2s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* 用户气泡：素笺 */
.msg-user {
  align-self: flex-start;
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--ink-2);
}

/* 管理员气泡：墨书 */
.msg-admin {
  align-self: flex-end;
  color: #f4efe0;
  background: linear-gradient(160deg, #453f30, var(--ink-solid) 62%);
  border-bottom-right-radius: 4px;
  box-shadow: 0 6px 16px rgba(38, 32, 20, 0.22);
}

.msg .msg-time { display: block; font-size: 11px; opacity: 0.6; margin-top: 4px; }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 13px;
  border-top: 1px solid var(--border);
  background: rgba(247, 243, 231, 0.9);
}

.chat-input-row .input { flex: 1; }

/* ============================================================================
   弹窗 / Toast / 阅读器
   ============================================================================ */

.modal-mask {
  position: fixed;
  inset: 0;
  padding: 24px;
  background: rgba(38, 30, 16, 0.45);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  width: min(560px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.65), rgba(255, 253, 246, 0) 26%),
    var(--paper-2);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.28s cubic-bezier(0.22, 0.8, 0.32, 1) both;
}

.modal.modal-wide { width: min(760px, 100%); }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-heading { display: flex; min-width: 0; align-items: center; gap: 12px; }

.modal-heading h2 {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
}

/* 弹窗图标：一方小印 */
.modal-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(62, 88, 120, 0.28);
  border-radius: 9px;
  color: var(--indigo-ink);
  background: rgba(62, 88, 120, 0.08);
}

.modal-icon .icon { width: 19px; height: 19px; }

.modal.tone-danger .modal-icon {
  border-color: rgba(176, 58, 46, 0.35);
  color: var(--vermilion);
  background: rgba(176, 58, 46, 0.08);
}

.modal.tone-success .modal-icon {
  border-color: rgba(53, 117, 90, 0.35);
  color: var(--jade);
  background: rgba(53, 117, 90, 0.09);
}

.modal-description {
  max-width: 430px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.modal-close .icon { width: 18px; height: 18px; }

.modal-close:hover {
  border-color: var(--border);
  color: var(--ink);
  background: rgba(64, 54, 36, 0.06);
}

.modal-body { padding: 21px; overflow-y: auto; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: rgba(64, 54, 36, 0.025);
}

.dialog-message {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.dialog-detail {
  margin-top: 11px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.65;
}

.viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
  color: var(--ink-faint);
  font-size: 12px;
}

.viewer-content {
  max-height: min(52vh, 460px);
  padding: 15px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink-2);
  background: #f6f1e3;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* 砚台：深色代码块 */
.code-list {
  background: #23201a;
  border: 1px solid rgba(248, 242, 228, 0.12);
  border-radius: 9px;
  padding: 13px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre;
  user-select: all;
  color: #cfe4d3;
}

/* Toast：墨牌 */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  min-width: 220px;
  max-width: min(440px, calc(100vw - 32px));
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 16px;
  border: 1px solid rgba(248, 242, 228, 0.16);
  border-radius: 10px;
  color: #f2edde;
  background: rgba(38, 34, 26, 0.96);
  z-index: 200;
  box-shadow: 0 18px 46px rgba(38, 30, 16, 0.4);
  backdrop-filter: blur(12px);
  animation: toastIn 0.25s cubic-bezier(0.22, 0.8, 0.32, 1) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a89f88;
  box-shadow: 0 0 9px rgba(168, 159, 136, 0.55);
}

.toast.err { border-color: rgba(230, 126, 108, 0.4); color: #f4c1b5; }
.toast.err::before { background: #e07a63; box-shadow: 0 0 9px rgba(224, 122, 99, 0.66); }

.toast.ok { border-color: rgba(126, 190, 154, 0.4); color: #c4e2cd; }
.toast.ok::before { background: #7ebe9a; box-shadow: 0 0 9px rgba(126, 190, 154, 0.66); }

/* ============================================================================
   折叠侧栏：平板与小型桌面
   ============================================================================ */

@media (max-width: 1200px) and (min-width: 769px) {
  .sidebar {
    width: 82px;
    padding-inline: 10px;
  }

  .sidebar .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar .brand-copy,
  .sidebar .nav-label,
  .sidebar .admin-copy,
  .sidebar .nav::before {
    display: none;
  }

  .sidebar .nav { padding-top: 16px; }

  .sidebar .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar .nav-item .icon { width: 19px; height: 19px; }

  .sidebar .nav-item.active::before { left: -11px; }

  .sidebar .nav-item .badge {
    position: absolute;
    top: 3px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }

  .sidebar-footer {
    flex-direction: column;
    justify-content: center;
  }

  .main { padding-inline: 30px; }
}

@media (max-width: 1024px) {
  .main { padding: 30px 26px 46px; }
  .model-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .usage-kind-row { grid-template-columns: 115px minmax(150px, 1fr) 150px; }
}

/* ============================================================================
   移动导航与单列布局
   ============================================================================ */

@media (max-width: 768px) {
  .app { display: block; }

  .mobile-topbar {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    height: 62px;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(245, 241, 230, 0.92);
    backdrop-filter: blur(16px);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 1.5px;
  }

  .mobile-brand .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 7px;
    font-size: 14px;
  }

  .mobile-status {
    width: 9px;
    height: 9px;
    border: 2px solid rgba(53, 117, 90, 0.22);
    border-radius: 50%;
    background: var(--jade);
    box-shadow: 0 0 9px rgba(53, 117, 90, 0.5);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 55;
    inset: 0;
    display: block;
    border: 0;
    opacity: 0;
    background: rgba(38, 30, 16, 0.5);
    pointer-events: none;
    backdrop-filter: blur(3px);
    transition: opacity 0.2s ease;
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(292px, calc(100vw - 48px));
    height: 100dvh;
    padding-inline: 12px;
    transform: translateX(-104%);
    transition: transform 0.24s cubic-bezier(0.22, 0.8, 0.32, 1);
    box-shadow: 20px 0 60px rgba(38, 30, 16, 0.4);
  }

  .app.sidebar-open .sidebar { transform: translateX(0); }

  .app.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar .brand-copy,
  .sidebar .nav-label,
  .sidebar .admin-copy {
    display: flex;
  }

  .sidebar .nav::before { display: block; }

  .sidebar .nav-item {
    justify-content: flex-start;
    gap: 10px;
    padding-inline: 12px;
  }

  .sidebar-footer {
    flex-direction: row;
    justify-content: space-between;
  }

  .main {
    width: 100%;
    min-height: 100dvh;
    padding: 86px 18px 36px;
  }

  .page h1 { font-size: 23px; }
  .page-desc { margin-bottom: 20px; }

  .form-grid-2 {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .switch-offset { margin-top: 0 !important; }

  .model-layout { grid-template-columns: minmax(0, 1fr); }

  .conn-panel,
  .conn-editor { min-height: 0; }

  .conn-list { max-height: 300px; }

  .chat-layout {
    height: calc(100dvh - 190px);
    min-height: 580px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 190px minmax(0, 1fr);
  }

  .chat-threads {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .msg { max-width: 86%; }

  .settings-stack { max-width: none; }
}

/* 手机数据表转为可读卡片 */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .card.table-scroll {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .table {
    display: block;
    min-width: 0;
  }

  .table thead { display: none; }

  .table tbody {
    display: grid;
    gap: 11px;
  }

  .table tbody tr:not(.empty-row) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--paper-2);
    box-shadow: var(--shadow-sm);
  }

  .table tbody tr:not(.empty-row):hover { background: var(--paper-2); }

  .table tbody tr:not(.empty-row) td {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 5px;
    padding: 11px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: normal;
    word-break: break-word;
  }

  .table tbody tr:not(.empty-row) td:nth-child(2n) { border-right: 0; }

  .table tbody tr:not(.empty-row) td:nth-last-child(2):nth-child(odd) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .table tbody tr:not(.empty-row) td::before {
    content: attr(data-label);
    color: #8a8168;
    font-size: 9.5px;
    font-weight: 750;
    letter-spacing: 1.2px;
  }

  .table tbody tr:not(.empty-row) td[data-label="操作"] {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }

  .table tbody tr:not(.empty-row) td[data-label="操作"] .cell-actions,
  .table tbody tr:not(.empty-row) td[data-label="操作"] {
    width: 100%;
  }

  .table tbody tr:not(.empty-row) td[data-label="操作"] .btn { flex: 1 1 auto; }

  .table tbody tr.empty-row {
    display: block;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--paper-2);
  }

  .table tbody tr.empty-row td { display: block; }

  .table .empty-state { min-height: 230px; }

  .pager {
    position: static;
    min-width: 0;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--paper-2);
  }

  .toolbar { align-items: stretch; }

  .toolbar > .input,
  .toolbar > input,
  .toolbar > select {
    min-width: min(210px, 100%);
    flex: 1 1 210px;
  }

  .toolbar-push { margin-left: 0; }

  .usage-kind-row {
    grid-template-columns: minmax(92px, 120px) 1fr;
    gap: 8px;
  }

  .usage-kind-nums {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .login-wrap {
    align-items: flex-start;
    padding: 18px 14px;
    overflow-y: auto;
  }

  .login-card {
    margin: auto 0;
    padding: 28px 22px;
    border-radius: 12px;
  }

  .login-brand-mark {
    width: 46px;
    height: 46px;
  }

  .login-logo { font-size: 23px; }

  .main { padding: 82px 13px 28px; }

  .page h1::before { height: 21px; }

  .page-desc { margin-left: 0; }

  .stats-grid { grid-template-columns: minmax(0, 1fr); }

  .stat-card { min-height: 112px; }

  .card,
  .settings-card {
    padding: 17px;
    border-radius: 10px;
  }

  .tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tab { flex: 0 0 auto; }

  .chat-layout {
    height: calc(100dvh - 176px);
    min-height: 530px;
    grid-template-rows: 164px minmax(0, 1fr);
  }

  .chat-messages { padding: 14px; }

  .chat-input-row {
    gap: 7px;
    padding: 10px;
  }

  .chat-input-row .btn { padding-inline: 12px; }

  .modal-mask {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: min(88dvh, 780px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    animation: modalSheetIn 0.24s cubic-bezier(0.22, 0.8, 0.32, 1) both;
  }

  @keyframes modalSheetIn {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: none; }
  }

  .modal-head {
    min-height: 66px;
    padding: 13px 15px;
  }

  .modal-icon {
    width: 34px;
    height: 34px;
  }

  .modal-body { padding: 17px 15px; }

  .modal-footer { padding: 12px 15px max(14px, env(safe-area-inset-bottom)); }

  .modal-footer .btn { flex: 1; }

  .toast {
    top: auto;
    bottom: 18px;
    min-width: 0;
    width: calc(100vw - 26px);
    animation-name: toastInMobile;
  }

  @keyframes toastInMobile {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
}

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

  .sky-stars, .sky-moon, .sky-meteor { animation: none !important; }
}
