/* 内容商店管理后台
   布局：左侧固定导航 + 顶部面包屑栏 + 内容区；未登录时只显示居中登录卡片。
   外观：浅色/深色两套色板并排写在 :root 的 light-dark() 里，可跟随系统或手动切换（见 .theme-picker）。
   所有资源都必须走同源文件，页面禁用内联脚本与内联样式（见 src/routes/admin_ui.rs 的 CSP）。 */

/* 色板：浅色在前、深色在后，全部由 color-scheme 决定用哪一侧。
   这样只维护一份变量，手动切换外观时也只需要改 color-scheme（见下方的 data-theme 规则）。 */
:root {
  color-scheme: light dark;
  /* 底色与面板：浅色为冷白灰，深色沿用原有冷调深灰。 */
  --bg: light-dark(#f3f5f8, #0f1319);
  --shell: light-dark(#eceff5, #141922);
  --panel: light-dark(#ffffff, #171d25);
  --panel-2: light-dark(#f5f7fa, #1f2731);
  --panel-3: light-dark(#e9eef5, #273040);
  --code-bg: light-dark(#f7f9fc, #0c1016);
  --topbar-bg: light-dark(#ffffffe0, #10141bcc);
  /* 描边：line 分区、line-soft 列表内分隔、line-hover 输入与按钮悬停。 */
  --line: light-dark(#dce3ec, #2a333f);
  --line-soft: light-dark(#e8eef5, #222a34);
  --line-hover: light-dark(#b3bdcb, #4b5a71);
  /* 文字：text 正文、muted 次级、faint 提示、placeholder 占位、cell-strong 表格首列。 */
  --text: light-dark(#1b2330, #e9edf4);
  --muted: light-dark(#5c6a7d, #a2afc2);
  --faint: light-dark(#6b7789, #7c8a9f);
  --separator: light-dark(#b6c0ce, #4a566a);
  --placeholder: light-dark(#8b95a5, #6f7d92);
  --cell-strong: light-dark(#2a3644, #c0cee4);
  --scrollbar: light-dark(#c3cbd6, #485872);
  /* 强调色：浅色压深以保证白底上的对比度，深色沿用亮蓝。 */
  --accent: light-dark(#2f5cd8, #79a6ff);
  --accent-hover: light-dark(#2450c4, #97b9ff);
  --accent-ink: light-dark(#ffffff, #0f1c3a);
  --accent-soft: light-dark(#2f5cd81a, #79a6ff1f);
  --accent-ring: light-dark(#2f5cd82e, #79a6ff2e);
  --tab-active-line: light-dark(#bcccee, #35507e);
  --tab-active-ink: light-dark(#1d3f9e, #dbe7ff);
  /* 状态色：danger / ok / warn；浅底与描边由 color-mix 从本色推导，两套主题浓度一致。 */
  --danger: light-dark(#b42318, #ff9299);
  --danger-ink: light-dark(#8f1f2b, #ffd7da);
  --danger-surface: light-dark(#fdf3f4, #2a1d20);
  --ok: light-dark(#0f7a52, #6eddb0);
  --warn: light-dark(#a15a05, #e9c875);
  /* 品牌标识与登录页光晕。 */
  --brand-line: light-dark(#c7d4e8, #3f5d8e);
  --brand-ink: light-dark(#2c5cb8, #b7d0ff);
  --brand-from: light-dark(#eaf1fd, #2c4472);
  --brand-to: light-dark(#d8e5f9, #1b2a48);
  --login-glow: light-dark(#e4ebf7, #1c2841);
  /* 投影与遮罩：浅色用低透明度冷灰，深色用更实的黑。 */
  --shadow-card: light-dark(rgb(15 23 42 / 12%), rgb(0 0 0 / 35%));
  --shadow-dialog: light-dark(rgb(15 23 42 / 22%), rgb(0 0 0 / 65%));
  --shadow-toast: light-dark(rgb(15 23 42 / 16%), rgb(0 0 0 / 45%));
  --backdrop: light-dark(rgb(15 23 42 / 30%), rgb(5 9 18 / 80%));
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --sidebar-w: 244px;
  --topbar-h: 58px;
  --content-w: 1500px;
  --gutter: 30px;
}

/* 手动选择外观时覆盖 color-scheme，让 light-dark() 连同原生控件与滚动条一起切换。 */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, [tabindex] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.error { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 8px 16px; color: var(--accent-ink); background: var(--accent); border-radius: var(--r-sm); }
.skip-link:focus { top: 12px; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }

h1 { font-size: 26px; line-height: 1.3; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 19px; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
h3 .mono { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
h4 { display: flex; align-items: center; gap: 10px; margin: 26px 0 14px; padding-bottom: 9px; border-bottom: 1px solid var(--line-soft); font-size: 13px; font-weight: 650; }
.detail-column > h4:first-child { margin-top: 0; }
p { overflow-wrap: anywhere; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .16em; font-weight: 650; margin-bottom: 8px; }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 0 6px; }
.brand-mark { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border: 1px solid var(--brand-line); border-radius: 11px; background: linear-gradient(160deg, var(--brand-from), var(--brand-to)); color: var(--brand-ink); font-size: 17px; font-weight: 650; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 650; }
.brand-caption { color: var(--faint); font-size: 10.5px; letter-spacing: .08em; }
.brand-lg .brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }
.brand-lg .brand-text strong { font-size: 17px; }

/* ---------- 登录页 ---------- */
.login-view { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background: radial-gradient(120% 90% at 50% -12%, var(--login-glow) 0%, var(--bg) 58%); }
.login-shell { display: flex; flex-direction: column; gap: 22px; width: min(420px, 100%); }
.login-shell .brand { justify-content: center; padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.login-card { padding: 30px 28px; box-shadow: 0 24px 70px var(--shadow-card); }
.login-card h1 { font-size: 22px; }
.login-card > p:first-of-type { margin: 8px 0 0; }
.login-card > label { margin: 22px 0 0; }
.login-card > input { margin: 8px 0 0; }
.login-card > .field-hint { margin: 8px 0 0; }
#login-error { min-height: 20px; margin: 10px 0 0; }
.block { width: 100%; margin-top: 18px; }
.login-help { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.login-help summary { cursor: pointer; }
.login-help p { margin-bottom: 0; }

/* ---------- 控制台框架 ---------- */
.console { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 4px; height: 100dvh; padding: 20px 14px; background: var(--shell); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; }
.side-nav-title { margin: 24px 0 8px; padding: 0 12px; color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .16em; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.tab { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; text-align: left; white-space: normal; }
.tab:hover:not(.active) { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.tab.active { background: var(--accent-soft); border-color: var(--tab-active-line); color: var(--tab-active-ink); font-weight: 600; }
.tab-icon { flex-shrink: 0; width: 17px; height: 17px; opacity: .8; }
.tab.active .tab-icon { color: var(--accent); opacity: 1; }
.tab-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; padding: 1px 7px; border: 1px solid color-mix(in srgb, var(--text) 10%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--muted); font: 11px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }
.tab.active .badge { color: var(--tab-active-ink); background: color-mix(in srgb, var(--text) 10%, transparent); border-color: color-mix(in srgb, var(--text) 14%, transparent); }

.console-body { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--topbar-h); border-bottom: 1px solid var(--line); background: var(--topbar-bg); backdrop-filter: blur(10px); padding-inline: var(--gutter); padding-inline: max(var(--gutter), calc((100% - var(--content-w)) / 2 + var(--gutter))); }
.breadcrumb { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 13px; color: var(--faint); }
.breadcrumb strong { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--separator); }
.topbar-actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
#session-info { overflow-wrap: anywhere; }
.workspace-status { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.workspace-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent); }

main { width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 26px var(--gutter) 72px; min-width: 0; scroll-margin-top: 72px; }

/* ---------- 面板与弹框 ---------- */
.tab-panel, .detail-column, .grid-2 > *, .field-grid > * { min-width: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading > div, .modal-head > div { min-width: 0; }
.panel-heading p, .modal-head p { margin: 6px 0 0; }
.panel-heading > button, .modal-head > button { flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.plugin-grid { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }

/* 审核与资源管理都放在 <dialog> 弹框里：头部固定，正文区域自己滚动。 */
.modal { width: min(1120px, calc(100vw - 40px)); max-width: none; max-height: min(880px, calc(100dvh - 64px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); color: var(--text); box-shadow: 0 24px 100px var(--shadow-dialog); overflow: hidden; }
/* 只在打开时改成 flex 布局，避免覆盖 UA 对关闭状态 dialog 的 display: none。 */
.modal[open] { display: flex; flex-direction: column; }
.app-modal { width: min(640px, calc(100vw - 40px)); }
.app-modal-body { flex: 1 1 auto; min-height: 0; padding: 22px 24px 26px; overflow: auto; overscroll-behavior: contain; }
.app-modal-body > .error:empty { display: none; }
.modal-wide { width: min(1320px, calc(100vw - 40px)); }
.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.modal-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.modal-head h3 { margin: 6px 0 0; }
.modal > .grid-2 { flex: 1 1 auto; min-height: 0; padding: 22px 24px 26px; overflow: auto; overscroll-behavior: contain; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 16px; }
input, select, textarea { width: 100%; min-width: 0; max-width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--text); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
textarea { resize: vertical; min-height: 70px; }
label.checkbox { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-2); color: var(--text); }
label.checkbox input { width: 16px; height: 16px; flex-shrink: 0; margin: 3px 0 0; accent-color: var(--accent); }
.field-hint { display: block; margin-top: 5px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }

/* ---------- 按钮 ---------- */
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; min-height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.4; cursor: pointer; flex-shrink: 0; transition: background .15s, border-color .15s, color .15s; }
button:hover:not(:disabled) { background: var(--panel-3); border-color: var(--line-hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: color-mix(in srgb, var(--danger) 7%, transparent); border-color: color-mix(in srgb, var(--danger) 34%, transparent); color: var(--danger); }
button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); }
button.ghost { background: transparent; }
button.ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 7%, transparent); border-color: var(--line-hover); }
button.mini { min-height: 30px; padding: 6px 12px; border-radius: 7px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button[aria-busy="true"] { cursor: progress; }

/* ---------- 外观主题开关 ---------- */
.theme-picker { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.theme-picker button.theme-option { width: 28px; min-width: 28px; height: 26px; min-height: 26px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--faint); }
.theme-picker button.theme-option:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.theme-picker button.theme-option[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.theme-picker button.theme-option svg { width: 15px; height: 15px; }
.theme-picker--login { align-self: center; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.action-row { margin: 20px 0; }
.reject-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 26px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--r-md); background: color-mix(in srgb, var(--danger) 5%, transparent); }
.danger-zone strong { color: var(--danger); font-size: 13px; font-weight: 600; }
.danger-zone p { margin: 4px 0 0; }

/* ---------- 工具栏与表格 ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar select { width: 158px; margin: 0; flex-shrink: 0; }
.search-field { position: relative; display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 0; max-width: 440px; }
.search-field input { flex: 1; margin: 0; }

.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overscroll-behavior-x: contain; scrollbar-color: var(--scrollbar) transparent; scrollbar-width: thin; }
.table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 800px; }
.table th, .table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; overflow-wrap: anywhere; }
.table th { padding-top: 11px; padding-bottom: 11px; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.table tbody tr.selected { background: var(--accent-soft); }
.table td:first-child { color: var(--cell-strong); }

.pending-table th:nth-child(1) { width: 11%; }
.pending-table th:nth-child(2) { width: 23%; }
.pending-table th:nth-child(3) { width: 11%; }
.pending-table th:nth-child(4) { width: 10%; }
.pending-table th:nth-child(5) { width: 18%; }
.pending-table th:nth-child(6) { width: 17%; }
.pending-table th:nth-child(7) { width: 10%; }
.plugins-table th:nth-child(1) { width: 23%; }
.plugins-table th:nth-child(2) { width: 24%; }
.plugins-table th:nth-child(3) { width: 12%; }
.plugins-table th:nth-child(4) { width: 13%; }
.plugins-table th:nth-child(5), .plugins-table th:nth-child(6) { width: 9%; }
.plugins-table th:nth-child(7) { width: 10%; }
.versions-table { min-width: 560px; }
.versions-table th, .versions-table td { padding: 12px 10px; font-size: 12px; }
.versions-table th:nth-child(1) { width: 20%; }
.versions-table th:nth-child(2) { width: 14%; }
.versions-table th:nth-child(3) { width: 20%; }
.versions-table th:nth-child(4) { width: 12%; }
.versions-table th:nth-child(5) { width: 19%; }
.versions-table th:nth-child(6) { width: 15%; }
.audit-table { min-width: 1000px; }
.audit-table th:nth-child(1) { width: 16%; }
.audit-table th:nth-child(2) { width: 17%; }
.audit-table th:nth-child(3) { width: 16%; }
.audit-table th:nth-child(4) { width: 13%; }
.audit-table th:nth-child(5) { width: 27%; }
.audit-table th:nth-child(6) { width: 11%; }

.pending-table td:nth-child(2) .cell-value, .pending-table td:nth-child(5) .cell-value, .plugins-table td:nth-child(1) .cell-value, .plugins-table td:nth-child(2) .cell-value { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }

.code { width: 100%; min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--code-bg); overflow: auto; max-height: 360px; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; overscroll-behavior: contain; scrollbar-width: thin; }
pre { max-width: 800px; }
.files { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font-size: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--code-bg); scrollbar-width: thin; }
.files li { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.files li:last-child { border-bottom: 0; }
.files li > .mono { min-width: 0; overflow-wrap: anywhere; }
.files li > span:last-child { flex-shrink: 0; color: var(--muted); text-align: right; }
.files li .exec { display: block; color: var(--ok); font-size: 10px; }
.content-preview { margin-bottom: 10px; }
.content-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow: auto; }
.content-preview img { max-width: 100%; max-height: 400px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-sm); }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--text) 4%, transparent); color: var(--muted); font-size: 11px; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
/* 胶囊的底色与描边都从状态本色（currentColor）推导，深浅主题下浓度一致。 */
.status.status-published { color: var(--ok); }
.status.status-pending { color: var(--warn); }
.status.status-rejected, .status.status-expired { color: var(--danger); }
.status.status-published, .status.status-pending, .status.status-rejected, .status.status-expired { border-color: color-mix(in srgb, currentColor 34%, transparent); background: color-mix(in srgb, currentColor 9%, transparent); }

.empty-state { margin: 0; padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--panel); color: var(--muted); text-align: center; }
.list-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--muted); font-size: 12px; }
.list-feedback.error { border-color: color-mix(in srgb, var(--danger) 32%, transparent); background: color-mix(in srgb, var(--danger) 6%, transparent); color: var(--danger); }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 2px 0; }

/* ---------- 弹窗与提示 ---------- */
.confirm-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow: auto; padding: 28px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); color: var(--text); box-shadow: 0 24px 100px var(--shadow-dialog); }
.confirm-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.confirm-dialog p { margin: 14px 0 24px; }
.dialog-actions { justify-content: flex-end; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; overflow-wrap: anywhere; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-2); box-shadow: 0 10px 40px var(--shadow-toast); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 34%, transparent); background: var(--danger-surface); color: var(--danger-ink); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 34%, transparent); }

/* ---------- 响应式：先收窄成单列，再把侧边导航折成横向菜单 ---------- */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .review-grid .detail-column + .detail-column, .plugin-grid .detail-column + .detail-column { padding-top: 24px; border-top: 1px solid var(--line); }
}
@media (max-width: 1024px) { .workspace-status { display: none; } }
@media (max-width: 960px) {
  :root { --gutter: 20px; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; flex-direction: row; align-items: center; gap: 16px; height: auto; padding: 13px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .side-nav-title { display: none; }
  .side-nav { flex-direction: row; gap: 6px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
  .tab { width: auto; min-height: 36px; padding: 7px 12px; }
  .tab-label { flex: 0 1 auto; }
  .topbar { position: static; }
}
@media (max-width: 640px) {
  :root { --gutter: 14px; }
  main { padding-top: 20px; padding-bottom: 56px; }
  .sidebar { flex-wrap: wrap; gap: 10px 12px; }
  .side-nav { width: 100%; margin-left: 0; }
  .topbar { height: auto; min-height: 54px; flex-wrap: wrap; gap: 10px; padding-block: 10px; }
  #session-info { display: none; }
  h1 { font-size: 23px; }
  h2 { font-size: 17px; }
  h3 { font-size: 17px; }
  .panel-heading, .modal-head { gap: 12px; }
  .panel-heading > button, .modal-head > button { padding: 8px 10px; font-size: 12px; }
  .filter-bar { align-items: stretch; }
  .filter-bar select, .search-field { width: 100%; max-width: none; }
  .filter-bar select { flex: 1 1 140px; }
  input, select, textarea { font-size: 16px; }
  .card { padding: 18px; border-radius: 12px; }
  .login-card { padding: 24px 20px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .modal { width: calc(100vw - 20px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .modal-head { padding: 16px 18px; }
  .modal > .grid-2, .app-modal-body { padding: 18px 18px 22px; }
  .code { padding: 12px; font-size: 11px; }
  .danger-zone { flex-wrap: wrap; }
  .table-scroll { border-radius: 10px; }
  .table button.mini { min-height: 38px; }
  .toast { right: 16px; left: 16px; bottom: 16px; }
}

/* 窄屏主列表改成带字段名称的卡片，核心操作始终可见。版本和审计表保留局部滚动。 */
@media (max-width: 640px) {
  .table-scroll:has(.pending-table, .plugins-table) { border: 0; background: transparent; overflow: visible; }
  .pending-table, .plugins-table { display: block; min-width: 0; }
  .pending-table thead, .plugins-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .pending-table tbody, .plugins-table tbody { display: grid; gap: 12px; }
  .pending-table tbody tr, .plugins-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
  .pending-table td, .plugins-table td { display: block; min-width: 0; padding: 0; border: 0; }
  .pending-table td::before, .plugins-table td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
  .pending-table td:nth-child(2), .pending-table td:nth-child(5), .pending-table td:last-child, .plugins-table td:nth-child(1), .plugins-table td:nth-child(2), .plugins-table td:last-child { grid-column: 1 / -1; }
  .pending-table td .mono, .plugins-table td .mono { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .pending-table td:last-child::before, .plugins-table td:last-child::before { display: none; }
  .pending-table td:last-child button, .plugins-table td:last-child button { width: 100%; margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
