/* ============================================================
   Cocos AI Tools 授权中控 — 深色毛玻璃设计系统
   全屏壁纸打底，所有面板为可调玻璃；模糊强度/透明度/压暗度/
   磨砂开关/强调色/圆角/密度/字号由「界面设置」实时驱动 CSS 变量。
   ============================================================ */

:root {
  /* 用户可调变量（JS 实时覆写）。 */
  --glass-blur: 18px;
  --glass-alpha: 0.62;
  --bg-dim: 0.55;
  --wallpaper-blur: 16px;
  --wallpaper-url: url("/admin/images/wallpaper.webp");
  --accent: #6366f1;
  --corner: 12px;
  /* 派生令牌。 */
  --ink: #eef1fb;
  --muted: #a7aec6;
  --subtle: #78809c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --canvas: #0b0e1d;
  --surface: rgba(17, 21, 40, var(--glass-alpha));
  --surface-solid: #111528;
  --sidebar-bg: rgba(13, 16, 33, 0.72);
  --green: #35c795;
  --green-dark: #57dfae;
  --amber: #f0b45a;
  --red: #f06d92;
  --red-dark: #ff97b4;
  /* 强调色派生：无 color-mix 支持时回退到固定值。 */
  --accent-strong: var(--accent);
  /* 兜底：不支持 color-mix 的旧浏览器用静态近似值。 */
  --accent-ring: rgba(99, 102, 241, 0.28);
  --accent-tint: rgba(99, 102, 241, 0.18);
  --accent-tint-strong: rgba(99, 102, 241, 0.3);
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --accent-strong: color-mix(in srgb, var(--accent), #000 18%);
    --accent-ring: color-mix(in srgb, var(--accent) 26%, transparent);
    --accent-tint: color-mix(in srgb, var(--accent) 16%, transparent);
    --accent-tint-strong: color-mix(in srgb, var(--accent) 26%, transparent);
  }
}

/* 圆角全部由用户滑杆推导。 */
:root {
  --radius-sm: calc(var(--corner) * 0.5);
  --radius-md: var(--corner);
  --radius-lg: calc(var(--corner) * 1.3);
  --shadow-glass: 0 10px 34px rgba(4, 6, 18, 0.42), 0 2px 8px rgba(4, 6, 18, 0.32);
  --shadow-dialog: 0 30px 80px rgba(4, 6, 18, 0.55);
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); font-size: 14px; }

body {
  margin: 0;
  color: var(--ink);
  /* 打底色由 html 承担；body 若再设不透明背景会盖住 z-index 为负的壁纸层。 */
  font-family: "Segoe UI Variable Text", "Segoe UI", Inter, "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 壁纸层：全屏固定、可磨砂、叠加用户可调的压暗渐变；图片由 --wallpaper-url 驱动（默认或管理员上传）。 */
body::before {
  content: "";
  position: fixed;
  inset: -24px;
  z-index: -2;
  background-image: linear-gradient(rgba(8, 10, 24, var(--bg-dim)), rgba(8, 10, 24, var(--bg-dim))), var(--wallpaper-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  filter: blur(var(--wallpaper-blur)) saturate(1.08);
  transform: translateZ(0);
}

/* 界面设置里的背景图预览与操作按钮。 */
.wallpaper-preview {
  height: 132px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background-color: #0b0e1d;
  background-size: cover;
  background-position: center;
}
.wallpaper-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.wallpaper-state { color: var(--muted); font-size: 0.92em; }

button, input, select, output { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.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; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 16px; top: -64px; z-index: 130; padding: 10px 16px; color: #fff; background: var(--accent); border-radius: var(--radius-sm); transition: top 120ms ease; }
.skip-link:focus { top: 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------
   表单控件（玻璃质感）。
   ------------------------------------------------------------ */
.field-label { display: block; margin: 0 0 7px; color: #cdd3e6; font-size: 0.8125rem; font-weight: 650; }
.field-label output { color: var(--accent); font-weight: 750; font-variant-numeric: tabular-nums; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.75rem; }
.form-error { min-height: 20px; margin: 8px 0 10px; color: var(--red); font-size: 0.75rem; font-weight: 550; }

input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}
select option { color: #10142a; background: #f4f5fa; }
input::placeholder { color: var(--subtle); }
input:hover, select:hover { border-color: rgba(255, 255, 255, 0.24); }
input:focus, select:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
[type="range"] {
  min-height: 28px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
}
[type="range"]::-webkit-slider-runnable-track { height: 6px; background: rgba(255, 255, 255, 0.14); border-radius: 999px; }
[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; background: var(--accent); border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%; box-shadow: 0 2px 8px rgba(4, 6, 18, 0.45); }
[type="range"]::-moz-range-track { height: 6px; background: rgba(255, 255, 255, 0.14); border-radius: 999px; }
[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--accent); border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%; }
[type="checkbox"] { width: 17px; min-height: 17px; accent-color: var(--accent); }

/* ------------------------------------------------------------
   按钮（玻璃）。
   ------------------------------------------------------------ */
.primary-button, .secondary-button, .logout-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  transition: background-color 130ms ease, border-color 130ms ease, box-shadow 130ms ease, color 130ms ease, transform 60ms ease;
}
.primary-button:active:not(:disabled), .secondary-button:active:not(:disabled) { transform: translateY(1px); }

.primary-button { color: #fff; background: var(--accent); border: 1px solid transparent; box-shadow: 0 6px 18px var(--accent-tint-strong); }
.primary-button:hover { background: var(--accent-strong); box-shadow: 0 8px 22px var(--accent-tint-strong); }
.primary-button.danger-button { background: #d6406b; box-shadow: 0 6px 18px rgba(214, 64, 107, 0.32); }
.primary-button.danger-button:hover { background: #bd355c; }

.secondary-button { color: #dfe3f0; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line-strong); backdrop-filter: blur(var(--glass-blur)) saturate(1.1); }
.secondary-button:hover { color: #fff; background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.26); }
.secondary-button.danger-button { color: var(--red); border-color: rgba(240, 109, 146, 0.35); }
.secondary-button.danger-button:hover { color: var(--red-dark); background: rgba(214, 64, 107, 0.14); border-color: rgba(240, 109, 146, 0.5); }

.full-button { width: 100%; }

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #aab1c9;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-button:hover { color: #fff; background: rgba(255, 255, 255, 0.09); }
.icon-button:disabled { color: var(--subtle); background: transparent; }

/* ------------------------------------------------------------
   品牌标识：三根渐变立柱。
   ------------------------------------------------------------ */
.brand-mark { display: grid; grid-template-columns: repeat(3, 11px); gap: 5px; width: max-content; }
.brand-mark span { display: block; width: 11px; height: 32px; background: linear-gradient(180deg, #57d9a9, #2fb98a); border-radius: 3px; }
.brand-mark span:nth-child(2) { height: 23px; margin-top: 9px; background: linear-gradient(180deg, #ffd28a, #f0ab4e); }
.brand-mark span:nth-child(3) { height: 15px; margin-top: 17px; background: rgba(255, 255, 255, 0.85); }
.brand-mark.small { grid-template-columns: repeat(3, 6px); gap: 3px; }
.brand-mark.small span { width: 6px; height: 21px; border-radius: 2px; }
.brand-mark.small span:nth-child(2) { height: 15px; margin-top: 6px; }
.brand-mark.small span:nth-child(3) { height: 10px; margin-top: 11px; }

/* ------------------------------------------------------------
   登录页：壁纸之上，左标语右玻璃卡。
   ------------------------------------------------------------ */
.login-view { min-height: 100vh; min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(430px, 520px); align-items: center; gap: 24px; padding: clamp(20px, 5vw, 72px); }
.login-brand { position: relative; align-self: end; padding-bottom: 18px; }
.login-brand p {
  margin: 0 0 14px;
  color: #fff;
  font-size: clamp(26px, 2.8vw, 36px);
  font-weight: 750;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.65);
}
.login-panel {
  z-index: 1;
  align-self: center;
  width: 100%;
  max-width: 440px;
  padding: clamp(26px, 4vw, 44px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dialog);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.2)) saturate(1.15);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.2)) saturate(1.15);
}
.login-heading { margin-bottom: 30px; }
.login-heading h1 { margin: 8px 0 8px; font-size: 1.6875rem; font-weight: 720; line-height: 1.25; }
.login-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 3px; right: 3px; }
.security-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 22px; color: var(--muted); font-size: 0.75rem; }
.security-note span { color: var(--green); font-size: 8px; }

/* ------------------------------------------------------------
   应用骨架：玻璃侧栏 + 工作区。
   ------------------------------------------------------------ */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  color: #fff;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.4)) saturate(1.2);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.4)) saturate(1.2);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 10px; }
.sidebar-brand strong { display: block; font-size: 0.9375rem; letter-spacing: 0.01em; }
.sidebar-brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 0.6875rem; }

.nav-list { display: grid; gap: 4px; margin-top: 30px; }
.nav-item {
  position: relative;
  width: 100%;
  min-height: 41px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  color: #b6bdd1;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
  font-weight: 600;
  transition: background-color 120ms ease, color 120ms ease;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-item.active { color: #fff; background: var(--accent-tint); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-icon { width: 22px; color: #8b93af; font-size: 1rem; text-align: center; }
.nav-item.active .nav-icon { color: #fff; }

.service-state { margin-top: auto; padding: 15px 11px; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.6875rem; }
.state-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: #e8eaf3; font-size: 0.75rem; font-weight: 650; }
.status-dot { position: relative; flex: 0 0 auto; width: 8px; height: 8px; background: #4ade9d; border-radius: 50%; }
.status-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: rgba(74, 222, 157, 0.25); animation: pulse-dot 2.4s ease-out infinite; }
@keyframes pulse-dot { 0% { transform: scale(0.55); opacity: 1; } 70%, 100% { transform: scale(1.15); opacity: 0; } }
.logout-button { justify-content: flex-start; min-height: 40px; color: #aab1c6; background: transparent; border: 0; }
.logout-button:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.workspace { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 30px;
  background: rgba(11, 14, 29, 0.55);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.3)) saturate(1.15);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.3)) saturate(1.15);
}
.page-heading { min-width: 0; }
.page-heading h1 { margin: 1px 0 0; font-size: 1.25rem; font-weight: 720; line-height: 1.3; }
.topbar-actions { display: flex; gap: 9px; margin-left: auto; }
.menu-button { display: none; }

main { width: min(100%, 1480px); margin: 0 auto; padding: 28px 30px 48px; }

/* ------------------------------------------------------------
   玻璃面板基元。
   ------------------------------------------------------------ */
.data-surface, .settings-surface, .metric, .version-overview div, .dialog, .row-actions, .toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.12);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.12);
}

/* ------------------------------------------------------------
   指标卡。
   ------------------------------------------------------------ */
.metrics-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric { position: relative; overflow: hidden; min-width: 0; padding: 18px 20px 16px; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(180deg, #b9c0d8, #969ebc); }
.metric.positive::before { background: linear-gradient(180deg, #4fe0ae, #1ba87b); }
.metric.warning::before { background: linear-gradient(180deg, #ffd27a, #eaa93b); }
.metric.neutral::before { background: linear-gradient(180deg, #7fb0ea, #4a80c4); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; }
.metric strong { display: block; margin: 7px 0 3px; color: #fff; font-size: 1.6875rem; font-weight: 750; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric small { overflow: hidden; font-size: 0.6875rem; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------
   区块标题与筛选行。
   ------------------------------------------------------------ */
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; color: #fff; font-size: 1.0625rem; font-weight: 720; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 0.75rem; }
.audit-heading, .versions-heading, .announcements-heading, .settings-page-heading { align-items: center; }
.filter-row { display: flex; gap: 8px; }
.search-field { position: relative; width: 320px; }
.search-field > span:not(.sr-only) { position: absolute; left: 12px; top: 7px; color: var(--subtle); font-size: 1.0625rem; }
.search-field input { min-height: 38px; padding-left: 37px; border-radius: 999px; }
.select-field { width: 150px; }
.select-field select { min-height: 38px; border-radius: 999px; }
.audit-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   数据表格（玻璃）。
   ------------------------------------------------------------ */
.data-surface { overflow: hidden; }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 44px; padding: 9px 15px; color: #929bb5; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid var(--line); font-size: 0.6875rem; font-weight: 750; letter-spacing: 0.05em; text-align: left; text-transform: uppercase; }
td { height: 60px; padding: 9px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 110ms ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
th:nth-child(1) { width: 21%; } th:nth-child(2) { width: 10%; } th:nth-child(3) { width: 8%; } th:nth-child(4) { width: 17%; } th:nth-child(5) { width: 16%; } th:nth-child(6) { width: auto; } th:nth-child(7) { width: 68px; }

.license-key-cell { min-width: 0; display: flex; align-items: center; gap: 5px; }
.license-key-cell .license-identity { min-width: 0; }
.license-identity strong, .license-identity small { display: block; }
.license-identity strong { font-variant-numeric: tabular-nums; }
.license-identity small { color: var(--muted); font-size: 0.6875rem; }
.license-key-cell code { display: block; overflow: hidden; color: #dbe1f8; font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.03em; text-overflow: ellipsis; white-space: nowrap; }
.license-key-cell .icon-button { width: 29px; height: 29px; flex: 0 0 29px; font-size: 0.875rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.badge.active { color: #7ce3bd; background: rgba(53, 199, 149, 0.16); }
.badge.active::before { background: var(--green); }
.badge.disabled, .badge.expired { color: #ffa3bd; background: rgba(214, 64, 107, 0.16); }
.badge.disabled::before, .badge.expired::before { background: var(--red); }
.badge.archived { color: #a9b0c7; background: rgba(255, 255, 255, 0.08); }
.badge.archived::before { background: #9097ad; }

.plan-pill { display: inline-flex; min-height: 24px; align-items: center; padding: 3px 9px; color: #e3e8ff; background: var(--accent-tint); border-radius: var(--radius-sm); font-size: 0.6875rem; font-weight: 700; white-space: nowrap; }

.device-cell strong, .device-cell small, .date-cell strong, .date-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-cell strong, .date-cell strong { color: #eceef9; font-size: 0.78125rem; font-weight: 650; }
.device-cell small, .date-cell small { margin-top: 2px; color: var(--muted); font-size: 0.6875rem; }
.unbound { color: var(--subtle); }
.note-cell { overflow: hidden; color: #ccd2e4; text-overflow: ellipsis; white-space: nowrap; }
.action-column, .action-cell { text-align: right; }

.row-actions { position: fixed; z-index: 60; width: 178px; padding: 6px; border-color: var(--line-strong); animation: menu-in 120ms ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.row-actions button { width: 100%; min-height: 33px; display: flex; align-items: center; padding: 6px 10px; color: #d7dcea; background: transparent; border: 0; border-radius: calc(var(--radius-sm) * 0.8); text-align: left; font-weight: 550; }
.row-actions button:hover { color: #fff; background: rgba(255, 255, 255, 0.09); }
.row-actions button.danger { color: var(--red); }
.row-actions button.danger:hover { color: var(--red-dark); background: rgba(214, 64, 107, 0.14); }

.mobile-license-list { display: none; }

.pagination { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 7px 15px; color: var(--muted); background: rgba(255, 255, 255, 0.03); border-top: 1px solid var(--line); font-size: 0.75rem; }
.pagination > div { display: flex; gap: 4px; }
.pagination .icon-button { width: 32px; height: 32px; background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); }

.empty-state { padding: 66px 24px; text-align: center; }
.empty-state h3 { margin: 12px 0 3px; color: #fff; font-size: 0.9375rem; font-weight: 700; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-symbol { width: 44px; height: 44px; display: grid; place-items: center; margin: auto; color: var(--accent); background: var(--accent-tint); border-radius: 50%; font-size: 1.375rem; }

/* ------------------------------------------------------------
   操作审计（人话卡片流）。
   ------------------------------------------------------------ */
.audit-surface { padding: 6px 18px; }
.audit-list { display: grid; }
.audit-item { padding: 13px 0 12px; border-bottom: 1px solid var(--line); }
.audit-item:last-child { border-bottom: 0; }
.audit-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-badge.group-badge { min-height: 22px; }
.audit-item.group-activation .group-badge { color: #7ce3bd; background: rgba(53, 199, 149, 0.14); }
.audit-item.group-validation .group-badge { color: #8fc3ff; background: rgba(74, 144, 226, 0.16); }
.audit-item.group-management .group-badge { color: #cbc3ff; background: rgba(139, 122, 245, 0.16); }
.audit-item.group-risk .group-badge { color: #ffa3bd; background: rgba(214, 64, 107, 0.15); }
.audit-item.group-other .group-badge { color: #a9b0c7; background: rgba(255, 255, 255, 0.08); }
.audit-time { color: var(--muted); font-size: 0.71875rem; font-variant-numeric: tabular-nums; }
.audit-text { margin: 8px 0 0; color: #edeef8; font-size: 0.84375rem; font-weight: 550; }
.audit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.audit-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 2px 9px; color: #b9bfd5; background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 999px; font-size: 0.6875rem; }
.audit-chip.mono { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; letter-spacing: 0.02em; }
.audit-chip.host { color: #d7dcf0; }

/* ------------------------------------------------------------
   版本管理。
   ------------------------------------------------------------ */
.version-overview { display: grid; grid-template-columns: 160px minmax(260px, 1fr) 230px; gap: 14px; margin-bottom: 18px; }
.version-overview div { min-width: 0; padding: 16px 18px; }
.version-overview span { display: block; color: var(--muted); font-size: 0.6875rem; font-weight: 650; }
.version-overview strong { display: block; margin-top: 5px; overflow: hidden; color: #fff; font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }
.version-overview div:first-child strong { font-size: 1.5rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.version-surface { overflow-x: auto; }

.version-batch-toolbar { min-height: 54px; display: flex; align-items: center; gap: 14px; padding: 7px 16px; border-bottom: 1px solid var(--line); }
.build-select-toggle { display: inline-flex; align-items: center; gap: 7px; color: #ccd2e4; font-size: 0.75rem; font-weight: 600; }
#selected-build-count { color: var(--muted); font-size: 0.75rem; }
.version-batch-actions { display: flex; gap: 8px; margin-left: auto; }
.version-batch-actions .secondary-button { min-height: 33px; padding: 6px 12px; }

.version-list-header, .version-row { display: grid; grid-template-columns: 34px 88px 96px minmax(280px, 1fr) 175px minmax(250px, 320px); gap: 14px; align-items: center; padding: 0 16px; }
.version-list-header { min-height: 42px; color: #929bb5; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid var(--line); font-size: 0.6875rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }
.version-row { min-height: 60px; border-bottom: 1px solid var(--line); }
.version-row:last-child { border-bottom: 0; }
.version-row:hover { background: rgba(255, 255, 255, 0.05); }
.version-row code { overflow: hidden; color: #dbe1f8; font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.version-row time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.version-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.version-row-actions .secondary-button { min-width: 0; min-height: 33px; padding: 5px 10px; font-size: 0.75rem; }

.upload-note { margin: 8px 0 16px; color: var(--muted); font-size: 0.75rem; }
.upload-note code { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; }
.build-preview { padding: 12px 14px; background: var(--accent-tint); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.build-preview span { display: block; color: #dcd8ff; font-size: 0.6875rem; font-weight: 700; }
.build-preview strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------
   系统设置 & 界面设置。
   ------------------------------------------------------------ */
.settings-state { display: inline-flex; align-items: center; gap: 9px; color: #ccd2e4; font-size: 0.75rem; font-weight: 650; }
.settings-state .status-dot { flex: 0 0 auto; }
.settings-state .status-dot::after { animation: none; }
.settings-group { padding: 26px 30px 28px; border-bottom: 1px solid var(--line); }
.settings-group:last-of-type { border-bottom: 0; }
.settings-group-heading > div { display: flex; align-items: flex-start; gap: 13px; }
.settings-group-heading h3 { margin: 0; color: #fff; font-size: 1rem; font-weight: 720; }
.settings-group-heading p { margin: 3px 0 0; color: var(--muted); font-size: 0.75rem; }
.settings-index { width: 34px; height: 34px; display: grid; flex: 0 0 34px; place-items: center; color: #fff; background: var(--accent-tint-strong); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-family: "Cascadia Mono", Consolas, monospace; font-size: 0.6875rem; font-weight: 750; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 22px 0 0 47px; }
.settings-grid-trial { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.setting-field { min-width: 0; }
.unit-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.unit-input input { min-width: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.unit-input span { min-width: 60px; display: grid; place-items: center; padding: 0 12px; color: #aab1c9; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.75rem; font-weight: 650; }
.settings-footer { min-height: 74px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, auto) auto; gap: 18px; align-items: center; padding: 14px 30px; background: rgba(255, 255, 255, 0.03); border-top: 1px solid var(--line); }
.settings-footer > div strong, .settings-footer > div span { display: block; }
.settings-footer > div strong { color: #dfe3ef; font-size: 0.75rem; font-weight: 700; }
.settings-footer > div span { margin-top: 2px; color: var(--muted); font-size: 0.6875rem; }
.settings-footer .form-error { min-height: 0; margin: 0; text-align: right; }
.settings-footer .primary-button { min-width: 112px; }
.checkbox-field { min-height: 42px; display: flex; align-items: center; gap: 9px; }
.checkbox-field input { flex: 0 0 auto; width: 17px; min-height: 17px; }
.checkbox-field span { color: #ccd2e4; font-size: 0.78125rem; }
.switch-boxes { min-height: 42px; align-items: flex-start; padding-top: 8px; }
.density-switch { display: inline-flex; gap: 6px; margin: 22px 0 0 47px; padding: 5px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 999px; }
.density-option { min-height: 34px; padding: 0 18px; color: #aab1c9; background: transparent; border: 0; border-radius: 999px; font-weight: 650; }
.density-option:hover { color: #fff; }
.density-option.active { color: #fff; background: var(--accent); box-shadow: 0 4px 14px var(--accent-tint-strong); }
.accent-swatches { display: flex; gap: 10px; margin-top: 4px; }
.accent-swatch { width: 34px; height: 34px; padding: 0; background: var(--swatch); border: 2px solid rgba(255, 255, 255, 0.25); border-radius: 50%; transition: transform 110ms ease, border-color 110ms ease, box-shadow 110ms ease; }
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active { border-color: #fff; box-shadow: 0 0 0 3px var(--accent-ring); }

/* ------------------------------------------------------------
   公告管理。
   ------------------------------------------------------------ */
.announcements-surface { overflow: hidden; }
.announcement-list { display: grid; }
.announcement-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; padding: 19px 24px; border-bottom: 1px solid var(--line); }
.announcement-item:last-child { border-bottom: 0; }
.announcement-main { min-width: 0; }
.announcement-head { display: flex; align-items: center; gap: 10px; }
.app-shell .announcement-title, .announcement-title { margin: 0; color: #fff; font-size: 0.9375rem; font-weight: 700; }
.announcement-status { display: inline-flex; flex: 0 0 auto; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; }
.announcement-status.published { color: #7ce3bd; background: rgba(53, 199, 149, 0.16); }
.announcement-status.archived { color: #a9b0c7; background: rgba(255, 255, 255, 0.08); }
.announcement-content { display: -webkit-box; margin: 8px 0 0; overflow: hidden; color: var(--muted); white-space: pre-wrap; font-size: 0.8125rem; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.announcement-meta { margin: 9px 0 0; color: var(--subtle); font-size: 0.6875rem; }
.announcement-actions { display: flex; align-items: flex-start; }
.announcement-form-body textarea { width: 100%; min-height: 168px; resize: vertical; }
.announcement-form-body .field-label:not(:first-child) { margin-top: 16px; }

/* ------------------------------------------------------------
   对话框（深色玻璃加强版）。
   ------------------------------------------------------------ */
.dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: rgba(15, 18, 38, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dialog);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.6)) saturate(1.2);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.6)) saturate(1.2);
}
.dialog::backdrop { background: rgba(4, 6, 15, 0.55); backdrop-filter: blur(6px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 15px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 2px 0 0; color: #fff; font-size: 1.1875rem; font-weight: 720; }
.dialog-body { padding: 20px 22px; }
.dialog-body > input { margin-bottom: 18px; }
.dialog-body textarea { width: 100%; min-height: 110px; padding: 10px 13px; resize: vertical; color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; line-height: 1.55; }
.dialog-body textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; background: rgba(255, 255, 255, 0.03); border-top: 1px solid var(--line); }

.field-row { display: grid; grid-template-columns: 1fr 150px; gap: 16px; align-items: end; }
.plan-row { margin-bottom: 18px; }

.result-dialog .dialog-body { padding-top: 18px; }
.success-kicker { color: var(--green-dark); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.one-time-warning { margin: 0 0 14px; padding: 10px 13px; color: #ffd9a3; background: rgba(240, 180, 90, 0.12); border-left: 3px solid var(--amber); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.75rem; font-weight: 600; }
.license-key-box { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 13px; background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.license-key-box code { overflow-wrap: anywhere; color: #dcd8ff; font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 0.9375rem; font-weight: 700; letter-spacing: 0.04em; }
.key-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 0; }
.key-meta div { padding: 10px 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.key-meta dt { color: var(--muted); font-size: 0.6875rem; }
.key-meta dd { margin: 3px 0 0; color: #eceef9; font-weight: 650; }

.action-license { margin: 0 0 16px; padding: 12px 14px; background: rgba(255, 255, 255, 0.04); border-radius: var(--radius-sm); }
.action-license strong, .action-license span { display: block; }
.action-license span { margin-top: 2px; color: var(--muted); font-size: 0.75rem; }
.danger-copy { color: var(--red); }

/* ------------------------------------------------------------
   提示浮层。
   ------------------------------------------------------------ */
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { min-width: 250px; max-width: 360px; padding: 12px 15px; color: #eef1fb; font-size: 0.8125rem; animation: toast-in 170ms cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.toast.error { color: #ffe0ea; background: rgba(126, 32, 57, 0.86); border-color: rgba(255, 160, 185, 0.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.sidebar-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(4, 6, 15, 0.55); }

/* ------------------------------------------------------------
   紧凑密度模式。
   ------------------------------------------------------------ */
body[data-density="compact"] main { padding-top: 18px; }
body[data-density="compact"] td { height: 44px; padding-block: 5px; }
body[data-density="compact"] th { height: 38px; }
body[data-density="compact"] .metric { padding: 13px 16px 12px; }
body[data-density="compact"] .metric strong { margin: 4px 0 2px; font-size: 1.4375rem; }
body[data-density="compact"] .metrics-band { margin-bottom: 20px; }
body[data-density="compact"] .topbar { min-height: 60px; }
body[data-density="compact"] .audit-item { padding: 9px 0 8px; }
body[data-density="compact"] .version-row { min-height: 48px; }
body[data-density="compact"] .settings-group { padding: 20px 24px 22px; }

/* ------------------------------------------------------------
   响应式。
   ------------------------------------------------------------ */
@media (max-width: 1023px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-glass); }
  .workspace { width: 100%; }
  .menu-button { display: inline-grid; }
  .topbar { padding-inline: 22px; }
  main { padding-inline: 22px; }
  .metrics-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid-trial, .settings-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; margin-left: 0; }
  .audit-toolbar .search-field { flex: 1 1 220px; width: auto; }
  .version-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .version-list-header, .version-row { grid-template-columns: 34px 76px 88px minmax(250px, 1fr) 150px minmax(230px, 280px); }
}

@media (max-width: 767px) {
  .login-view { grid-template-columns: 1fr; align-items: stretch; gap: 8px; padding: 18px 16px 26px; }
  .login-brand { align-self: start; padding: 6px 6px 0; }
  .login-brand p { font-size: 1.375rem; }
  .login-panel { justify-self: stretch; max-width: none; padding: 22px 18px; }
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-glass); }
  .workspace { width: 100%; }
  .menu-button { display: inline-grid; }
  .topbar { min-height: 64px; padding: 10px 14px; }
  .page-heading .eyebrow, #refresh-button { display: none; }
  .page-heading h1 { font-size: 1.125rem; }
  .topbar-actions .primary-button { min-width: 42px; padding-inline: 12px; }
  main { padding: 18px 14px 34px; }
  .metrics-band { gap: 9px; margin-bottom: 22px; }
  .metric { padding: 15px 16px; }
  .metric strong { font-size: 1.4375rem; }
  .metric small { display: none; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .filter-row { flex-direction: column; }
  .search-field, .select-field { width: 100%; }
  .table-scroll { display: none; }
  .mobile-license-list { display: block; }
  .mobile-license-row { padding: 15px; border-bottom: 1px solid var(--line); }
  .mobile-license-row:last-child { border-bottom: 0; }
  .mobile-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .mobile-row-head .badge { flex: 0 0 auto; }
  .mobile-row-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 13px 0; }
  .mobile-row-meta span { display: block; color: var(--subtle); font-size: 0.625rem; font-weight: 650; text-transform: uppercase; }
  .mobile-row-meta strong { display: block; margin-top: 2px; color: #eceef9; font-size: 0.75rem; overflow-wrap: anywhere; }
  .mobile-row-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.75rem; }
  .mobile-row-foot > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .audit-toolbar { flex-direction: column; }
  .audit-toolbar .search-field, .audit-toolbar .select-field { width: 100%; }
  .versions-heading { align-items: stretch; }
  .version-overview { grid-template-columns: 1fr; }
  .version-list-header, .version-row, .version-batch-toolbar { min-width: 850px; }
  .settings-page-heading { align-items: flex-start; }
  .settings-group { padding: 22px 18px 24px; }
  .settings-grid, .settings-grid-trial, .settings-grid-wide { grid-template-columns: 1fr; gap: 16px; margin: 18px 0 0; }
  .density-switch { margin-left: 0; }
  .setting-field .field-hint { min-height: 0; }
  .settings-footer { grid-template-columns: 1fr; gap: 10px; padding: 16px 18px 18px; }
  .settings-footer .form-error { text-align: left; }
  .settings-footer .primary-button { width: 100%; }
  .announcement-item { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .announcement-actions { justify-content: flex-start; }
  .dialog-header, .dialog-body { padding-left: 18px; padding-right: 18px; }
  .dialog-footer { padding-left: 18px; padding-right: 18px; }
  .field-row, .key-meta { grid-template-columns: 1fr; }
  .toast-region { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; max-width: none; }
}

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