/* ============================================================
   猫猫宝客服助手 · 管理后台样式
   统一设计体系 v2026.08.29-ui2
   品牌色沿用「猫小二」企业红，全站一套色彩语言
   ============================================================ */

:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);

  --brand: #b51f35;
  --brand-dark: #8f1628;
  --brand-deep: #6f0f1f;
  --brand-soft: #fbeef0;
  --brand-tint: #fdf6f7;

  --ink: #262c36;
  --ink-strong: #1b2129;
  --muted: #6b7480;
  --faint: #99a1ab;

  --line: #e5e9ee;
  --line-strong: #cfd6dd;

  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --bg: #f2f4f7;

  --navy: #2f5d8a;
  --amber: #b87a17;
  --ok: #1a8a5c;
  --danger: #e5484d;
  --danger-dark: #c53438;

  --r: 10px;
  --r-lg: 14px;
  --r-sm: 6px;

  --shadow-sm: 0 1px 2px rgba(23, 30, 40, .05), 0 1px 6px rgba(23, 30, 40, .04);
  --shadow-md: 0 4px 14px rgba(23, 30, 40, .08), 0 1px 4px rgba(23, 30, 40, .05);
  --shadow-lg: 0 18px 48px rgba(30, 38, 50, .16);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

::selection { background: rgba(181, 31, 53, .16); }

/* ---------- 通用控件 ---------- */
label { display: grid; gap: 7px; margin-bottom: 15px; color: #4a545f; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 9px 11px; color: var(--ink); background: var(--surface); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #a9b3bd; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181, 31, 53, .11);
}
textarea { resize: vertical; min-height: 130px; }
input::placeholder, textarea::placeholder { color: var(--faint); }

.primary, .secondary, .danger, .toolbar-button {
  min-height: 36px; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 7px 15px; font-weight: 600;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.primary {
  background: linear-gradient(180deg, #c42440 0%, var(--brand) 100%);
  color: #fff; box-shadow: 0 2px 6px rgba(181, 31, 53, .26), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.primary:hover { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%); }
.primary:active { transform: translateY(1px); }
.secondary, .toolbar-button { background: var(--surface); border-color: var(--line-strong); color: #42505c; box-shadow: var(--shadow-sm); }
.secondary:hover, .toolbar-button:hover { background: #f4f7f9; border-color: #a7b2bc; }
.danger { color: var(--danger-dark); background: var(--surface); border-color: #efc3c5; }
.danger:hover { background: #fdf3f3; border-color: #e5a3a6; }
.wide { width: 100%; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid rgba(181, 31, 53, .45); outline-offset: 1px;
}

.form-error { color: var(--danger-dark); min-height: 20px; margin: 5px 0 10px; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 品牌标识 ---------- */
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden;
  padding: 3px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
}
.brand-mark img { width: 100%; height: 100%; display: block; border-radius: 3px; object-fit: cover; }
.brand-mark.small { width: 32px; height: 32px; font-size: 15px; }

/* ============================================================
   登录页
   ============================================================ */
.login-view {
  display: grid; min-height: 100vh; place-items: center; padding: 48px 6vw;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(181, 31, 53, .055), transparent 60%),
    radial-gradient(900px 480px at 105% 108%, rgba(47, 93, 138, .05), transparent 55%),
    linear-gradient(180deg, #f6f8fb 0%, #eef2f6 100%);
}
.login-layout {
  width: min(1460px, 100%); display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(400px, 480px);
  align-items: center; gap: clamp(72px, 9vw, 150px);
}
.login-intro { position: relative; min-width: 0; padding: 34px 0 35px 46px; }
.login-intro::before {
  content: ""; position: absolute; left: 0; top: 42px; bottom: 42px; width: 3px;
  border-radius: 2px; background: linear-gradient(180deg, var(--brand), #d9636f);
}
.company-logo { width: 300px; height: 151px; margin-bottom: 34px; overflow: hidden; }
.company-logo img { width: 300px; height: 300px; display: block; transform: translateY(-66px); mix-blend-mode: multiply; }
.login-kicker {
  display: block; margin-bottom: 13px; color: var(--brand); font-size: 11px;
  font-weight: 700; letter-spacing: 1.6px;
}
.login-intro-copy h1 { margin: 0; color: #1e2a3a; font-size: 42px; font-weight: 600; line-height: 1.28; letter-spacing: .5px; }
.login-intro-copy > p { margin: 22px 0 0; color: #66707e; font-size: 16px; line-height: 1.8; }
.operation-map {
  width: min(660px, 100%); display: grid; grid-template-columns: repeat(3, 1fr);
  margin-top: 45px; border-top: 1px solid #d7dfe8; border-bottom: 1px solid #d7dfe8;
}
.operation-map > div { position: relative; display: grid; min-height: 106px; align-content: center; gap: 4px; padding: 15px 24px; }
.operation-map > div + div { border-left: 1px solid #d7dfe8; }
.operation-map small { color: var(--brand); font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.operation-map strong { color: #242f42; font-size: 17px; font-weight: 600; }
.operation-map span { color: #7b8593; font-size: 12px; }

.login-panel {
  width: 100%; padding: 44px 42px 34px; background: var(--surface);
  border: 1px solid #dde4ec; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255, 255, 255, .8) inset;
  position: relative; overflow: hidden;
}
.login-panel::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand) 45%, #dd5568 100%);
}
.login-heading { padding: 0 0 29px; }
.login-heading h2 { margin: 0; color: #1c2836; font-size: 32px; font-weight: 600; line-height: 1.35; }
.login-heading p { margin: 10px 0 0; color: #737e8c; font-size: 14px; }
.login-panel label { gap: 8px; margin-bottom: 18px; color: #2d3846; font-size: 14px; font-weight: 600; }
.login-panel input:not([type="checkbox"]) {
  height: 44px; padding: 9px 12px; border-color: #d4dde7; border-radius: var(--r-sm);
  color: #1f2e43; font-weight: 400; background: #fdfdfe;
}
.login-panel input:not([type="checkbox"]):focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181, 31, 53, .11); background: #fff;
}
.login-panel input::placeholder { color: #a2adbb; }
.remember-login {
  display: flex; width: fit-content; grid-template-columns: none; align-items: center;
  gap: 9px !important; margin: 2px 0 17px !important; color: #506077 !important;
  font-weight: 400 !important; cursor: pointer;
}
.remember-login input { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); }
.login-panel .form-error { min-height: 20px; margin: 0 0 7px; font-size: 13px; }
.login-panel .primary {
  height: 44px; margin: 0; border-radius: var(--r-sm); font-weight: 600; letter-spacing: 4px;
}
.login-note { margin: 28px 0 0; color: #8b95a3; text-align: center; font-size: 12px; }

/* ============================================================
   应用框架
   ============================================================ */
.app-shell { display: grid; grid-template-columns: 222px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-right: 1px solid var(--line);
}
.product {
  height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 17px;
  border-bottom: 1px solid var(--line); color: #1c2836;
}
.product strong { font-size: 15px; letter-spacing: .3px; }
.sidebar nav { padding: 14px 10px; display: grid; gap: 2px; }
.sidebar nav button, .sidebar-footer button {
  position: relative; min-height: 40px; padding: 9px 12px 9px 16px; border: 0;
  background: transparent; color: #56616c; font-weight: 500; text-align: left;
  border-radius: var(--r-sm); transition: background .13s ease, color .13s ease;
}
.sidebar nav button::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px;
  border-radius: 2px; background: transparent; transition: background .13s ease;
}
.sidebar nav button:hover { color: var(--brand-dark); background: #f4f6f8; }
.sidebar nav button.active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 700; }
.sidebar nav button.active::before { background: var(--brand); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 8px; }
.sidebar-footer button { width: 100%; color: #6b7480; border-radius: var(--r-sm); }
.sidebar-footer button:hover { color: var(--danger-dark); background: #fdf3f3; }

.workspace { min-width: 0; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 64px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 10px 26px;
}
.topbar-main { display: flex; align-items: center; gap: 20px; min-width: 0; }
.topbar-title { flex: 0 0 auto; }
.topbar h2 { font-size: 18px; margin: 0 0 2px; color: #212b35; }
.server-state { color: var(--muted); font-size: 12px; }
.server-state::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px;
  border-radius: 50%; background: #c3cad2; vertical-align: 1px;
  transition: background .2s ease;
}
.server-state.ok { color: var(--ok); }
.server-state.ok::before { background: #2faa72; box-shadow: 0 0 0 3px rgba(47, 170, 114, .15); }
.desktop-download {
  min-height: 36px; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border: 1px solid #cfd7de; border-radius: var(--r-sm);
  background: var(--surface); color: #34434f; font-size: 13px; font-weight: 600;
  line-height: 1; white-space: nowrap; text-decoration: none;
  box-shadow: 0 1px 2px rgba(26, 39, 52, .05); transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.desktop-download:hover { border-color: #b8c3cc; background: var(--brand-tint); color: var(--brand-dark); }
.desktop-download:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.desktop-download-icon { font-size: 18px; line-height: 1; transform: translateY(-1px); }
.account-badge { color: #43505a; text-align: right; line-height: 1.5; }
.account-badge strong { font-size: 13px; }
.page-content { max-width: 1680px; padding: 24px 26px 42px; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; }
.stat {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 17px 18px; min-height: 94px; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.stat:nth-child(2n)::before { background: var(--navy); }
.stat:nth-child(3n)::before { background: var(--amber); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 26px; font-weight: 700; color: #222c35; font-variant-numeric: tabular-nums; }

/* ---------- 区块与表格 ---------- */
.section {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm);
}
.section-header {
  min-height: 54px; padding: 9px 14px 9px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, #fbfcfd, #f6f8fa);
}
.section-header h3 { margin: 0; font-size: 15px; color: #29343d; }
.toolbar { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; min-height: 36px; padding: 7px 9px; border-radius: var(--r-sm); }

.table-wrap { overflow: auto; background: var(--surface); }
.management-groups { min-width: 0; }
.management-group > summary { flex-wrap: wrap; gap: 10px; padding: 13px 16px; }
.management-group > summary strong { overflow-wrap: anywhere; }
.management-group > summary:focus-visible, .page-button:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: -3px; }
.management-group .tree-chevron { flex: 0 0 auto; }
.management-group .group-code { font-size: 12px; }
.group-count { margin-left: auto; flex-shrink: 0; color: #65717b; font-size: 12px; }
.management-group table { table-layout: fixed; }
.management-groups-accounts table { min-width: 1040px; }
.management-groups-accounts .tag { white-space: nowrap; }
.management-group td { overflow-wrap: anywhere; }
.management-group .row-actions { display: table-cell; }
.management-group .row-actions button { margin-right: 4px; }
.pagination { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.pagination nav { display: flex; gap: 6px; align-items: center; }
.page-button { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; border-radius: 4px; }
.page-button:disabled { opacity: .4; cursor: default; }
.page-position { min-width: 100px; text-align: center; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid #eaeef1; vertical-align: top; }
th {
  background: var(--surface-soft); color: #59636d; font-weight: 600; white-space: nowrap;
  font-size: 12px; letter-spacing: .4px; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line-strong);
}
tbody tr { transition: background .1s ease; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: var(--brand-tint); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions button { border: 0; background: transparent; color: var(--brand-dark); padding: 2px 4px; border-radius: 4px; }
.row-actions button:hover { background: var(--brand-soft); }
.row-actions button.danger-link { color: var(--danger-dark); }
.row-actions button.danger-link:hover { background: #fdf1f1; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--brand-dark); text-align: left; }
.link-button:hover { color: var(--brand-deep); text-decoration: underline; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 9px;
  border-radius: 999px; background: var(--brand-tint); color: var(--brand-dark);
  font-size: 12px; font-weight: 500; border: 1px solid rgba(181, 31, 53, .14);
}
.tag.green { background: #e9f6ef; color: #1e7d4e; border-color: rgba(30, 125, 78, .16); }
.tag.red { background: #fdeeee; color: #b03a40; border-color: rgba(176, 58, 64, .18); }
.tag.muted-tag { background: #eef1f4; color: #6e7883; border-color: #e0e5ea; }

.account-session { display: grid; min-width: 150px; gap: 3px; align-items: start; }
.account-session .tag { width: fit-content; margin-bottom: 2px; }
.account-session strong { color: #31403a; font-size: 12px; font-weight: 600; }
.account-session small { color: #74807c; font-size: 11px; white-space: nowrap; }

.empty { padding: 42px 18px; text-align: center; color: #85909a; }

/* ============================================================
   弹窗 / 提示
   ============================================================ */
dialog {
  width: min(560px, calc(100vw - 28px)); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 0; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(24, 32, 42, .44); backdrop-filter: blur(2px); }
dialog header, dialog footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
dialog header { min-height: 54px; background: var(--surface-soft); }
dialog footer { border: 0; border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; min-height: 58px; background: #fbfcfd; }
dialog h3 { margin: 0; font-size: 16px; color: #27313a; }
.dialog-fields { padding: 19px 18px 8px; max-height: 65vh; overflow: auto; }
.icon-button { width: 30px; height: 30px; border: 0; border-radius: var(--r-sm); background: transparent; font-size: 20px; color: #6b7480; }
.icon-button:hover { background: #eef1f4; color: #3c4750; }
#dialog-error { padding: 0 16px; }

.dialog-multiselect {
  margin: 0 0 14px; padding: 11px 12px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: #fbfcfd;
}
.dialog-multiselect legend { padding: 0 5px; color: #34414b; font-size: 13px; font-weight: 600; }
.dialog-check-list {
  max-height: 170px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px; overflow-y: auto; padding: 2px;
}
.dialog-check-list label {
  min-width: 0; min-height: 34px; display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: 4px;
  color: #4b5963; background: #fff; cursor: pointer;
}
.dialog-check-list label:hover { border-color: #cbd7df; background: var(--brand-tint); }
.dialog-check-list label:has(input:checked) { border-color: rgba(181, 31, 53, .28); background: var(--brand-soft); color: var(--brand-dark); }
.dialog-check-list input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.dialog-check-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-check-list p { grid-column: 1 / -1; margin: 4px 0; color: #87929b; font-size: 12px; text-align: center; }
.dialog-multiselect > small { display: block; margin-top: 8px; color: #72808b; font-size: 11px; font-weight: 400; }

/* 图片字段 */
.dialog-image-field { display: grid; gap: 8px; }
.dialog-image-toolbar { display: flex; align-items: center; gap: 10px; }
.dialog-image-toolbar small { color: #71808b; font-weight: 400; }
.dialog-image-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dialog-image-card {
  position: relative; min-width: 0; height: 92px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); overflow: hidden; background: #f3f6f8;
  box-shadow: var(--shadow-sm);
}
.dialog-image-card img { width: 100%; height: 66px; display: block; object-fit: cover; background: #e8eef2; }
.dialog-image-card span { display: block; overflow: hidden; padding: 4px 6px; color: #526069; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.dialog-image-card button {
  position: absolute; top: 3px; right: 3px; width: 23px; height: 23px; border: 0;
  border-radius: 4px; padding: 0; background: rgba(24, 32, 40, .78); color: #fff;
  font-size: 17px; line-height: 1; transition: background .13s ease;
}
.dialog-image-card button:hover { background: rgba(181, 31, 53, .92); }
.dialog-image-card.image-missing img { opacity: .18; }
.dialog-image-empty {
  grid-column: 1 / -1; padding: 18px; border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm); color: #81909a; text-align: center;
}

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 1200; max-width: 340px;
  background: #232b33; color: #fff; padding: 12px 15px; border-radius: var(--r-sm);
  border-left: 4px solid var(--brand); box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   基地/项目/店铺 层级树
   ============================================================ */
.tenant-tree { background: var(--surface); }
.tree-base, .tree-project { border: 0; }
.tree-base + .tree-base { border-top: 1px solid var(--line); }
.tree-base > summary, .tree-project > summary {
  list-style: none; display: flex; align-items: center; gap: 9px;
  min-height: 46px; padding: 8px 14px; cursor: pointer; user-select: none;
  transition: background .12s ease;
}
.tree-base > summary { background: var(--brand-tint); border-bottom: 1px solid #eee2e4; }
.tree-base > summary:hover { background: var(--brand-soft); }
.tree-project > summary { background: #fafbfc; border-bottom: 1px solid #edf0f3; }
.tree-project > summary:hover { background: #f2f5f7; }
.tree-base > summary::-webkit-details-marker, .tree-project > summary::-webkit-details-marker { display: none; }
.tree-chevron {
  width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  border-left: 7px solid #8b97a1; transition: transform .15s ease;
}
details[open] > summary .tree-chevron { transform: rotate(90deg); }
.tree-projects { margin-left: 22px; border-left: 1px solid #ccd7de; }
.tree-project { position: relative; }
.tree-project > summary::before { content: ""; width: 18px; border-top: 1px solid #ccd7de; margin-left: -14px; }
.tree-shops { margin-left: 36px; border-left: 1px solid #dde4e9; }
.tree-shop {
  min-height: 42px; display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 0; border-bottom: 1px solid #eef1f4;
  transition: background .12s ease;
}
.tree-shop:hover { background: #f7f9fa; }
.tree-line { width: 18px; border-top: 1px solid #dde4e9; }
.tree-shop-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.tree-actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.tree-actions button { border: 0; background: transparent; color: var(--brand-dark); padding: 4px 5px; border-radius: 4px; }
.tree-actions button:hover { background: var(--brand-soft); }
.tree-actions .danger-link { color: var(--danger-dark); }
.tree-actions .danger-link:hover { background: #fdf1f1; }
.tree-empty { color: #7b8791; padding: 12px 18px 12px 36px; border-bottom: 1px solid #eef1f4; }

.tenant-path { min-width: 170px; max-width: 260px; color: #52606b; line-height: 1.55; }

/* ============================================================
   话术资源管理
   ============================================================ */
.script-manager {
  height: calc(100vh - 124px); min-height: 520px; margin-top: 18px;
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.script-manager-toolbar { flex: 0 0 auto; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.script-scope-tabs {
  min-height: 48px; display: flex; align-items: end; gap: 3px; padding: 8px 14px 0;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.script-scope-tabs button {
  min-width: 78px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 0 13px; border: 0; border-bottom: 2px solid transparent; background: transparent;
  color: #56616c; font-weight: 600; border-radius: 6px 6px 0 0;
  transition: background .12s ease, color .12s ease;
}
.script-scope-tabs button:hover { background: #f2f5f7; color: var(--brand-dark); }
.script-scope-tabs button.active { border-bottom-color: var(--brand); color: var(--brand-dark); background: var(--brand-tint); }
.script-scope-tabs small {
  min-width: 22px; padding: 1px 6px; border-radius: 999px; background: #e8edf1;
  color: #6b7480; font-size: 11px; font-weight: 500;
}
.script-scope-tabs button.active small { background: #f6d9dd; color: var(--brand-dark); }

.script-filter-row {
  min-height: 58px; display: grid;
  grid-template-columns: repeat(4, minmax(120px, 160px)) minmax(220px, 1fr);
  gap: 9px; align-items: center; padding: 10px 14px;
}
.script-filter-row select, .script-filter-row input { min-width: 0; min-height: 36px; margin: 0; }
.script-filter-row .primary { min-height: 36px; white-space: nowrap; }
.script-search { position: relative; min-width: 0; }
.script-search input { padding-right: 34px; }
.script-search button {
  position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; border: 0;
  border-radius: var(--r-sm); background: transparent; color: #7b8791; font-size: 18px; line-height: 1;
}
.script-search button:hover { color: var(--brand); background: var(--brand-tint); }

.script-workspace { min-height: 0; flex: 1 1 auto; display: grid; grid-template-columns: minmax(250px, 292px) minmax(0, 1fr); }
.script-sidebar {
  min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line); background: var(--surface-soft);
}
.script-sidebar-header, .script-main-header {
  min-height: 56px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.script-sidebar-header > div { min-width: 0; display: grid; gap: 2px; }
.script-main-header { flex-wrap: wrap; }
.script-main-header > div:first-child { flex: 1 1 140px; min-width: 0; }
.script-sidebar-header strong { font-size: 15px; color: #2a343d; }
.script-sidebar-header span { color: #7a8690; font-size: 11px; }
.script-main-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; }
.script-main-actions button { min-height: 34px; white-space: nowrap; }
.icon-add {
  width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); color: var(--brand-dark);
  font-size: 17px; line-height: 1; transition: background .13s ease, border-color .13s ease;
}
.icon-add:hover { background: var(--brand-soft); border-color: #e3aab2; }

.script-tree {
  min-height: 0; padding: 7px 0 28px; overflow-x: hidden; overflow-y: hidden;
  scrollbar-color: #9aa5ae #eef1f3; scrollbar-width: auto;
}
.script-tree.is-scrollable { overflow-y: auto; }
.script-tree::-webkit-scrollbar { width: 11px; }
.script-tree::-webkit-scrollbar-track { background: #eef1f3; }
.script-tree::-webkit-scrollbar-thumb { min-height: 42px; border: 2px solid #eef1f3; border-radius: 6px; background: #9aa5ae; }
.script-tree::-webkit-scrollbar-thumb:hover { background: #7f8b95; }

.script-tree-base, .script-tree-category { border: 0; }
.script-tree-base + .script-tree-base { border-top: 1px solid var(--line); }
.script-tree-base > summary, .script-tree-category > summary {
  position: relative; display: flex; align-items: center; gap: 4px; list-style: none;
  cursor: pointer; user-select: none;
}
.script-tree-base > summary { min-height: 43px; padding: 4px 8px; background: var(--brand-tint); }
.script-tree-category > summary { min-height: 42px; padding: 3px 7px 3px 5px; }
.script-tree-base > summary::-webkit-details-marker, .script-tree-category > summary::-webkit-details-marker { display: none; }
.script-tree-base > summary:hover { background: var(--brand-soft); }
.script-tree-category > summary:hover, .script-tree-group:hover { background: #eef2f5; }
.script-tree-base > summary .script-tree-select { color: var(--brand-dark); font-weight: 600; }
.script-tree-base .tree-chevron { flex: 0 0 auto; border-left-color: #8b97a1; transform: scale(.85); }
.script-tree-category .tree-chevron { flex: 0 0 auto; border-left-color: #99a3ab; transform: scale(.75); }
.script-tree-categories { margin-left: 17px; border-left: 1px solid #ccd7de; background: #f9fbfc; }
.script-tree-select {
  min-width: 0; flex: 1; min-height: 32px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; border: 0; border-radius: var(--r-sm);
  padding: 5px 7px; background: transparent; color: #37424b; text-align: left;
  transition: background .12s ease, color .12s ease;
}
.script-tree-select > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-tree-select > .script-tree-label { min-width: 0; display: grid; gap: 1px; overflow: hidden; }
.script-tree-label > span, .script-tree-label em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-tree-label em { color: #84909a; font-size: 11px; font-style: normal; font-weight: 400; }
.script-tree-select small {
  flex: 0 0 auto; min-width: 22px; padding: 1px 6px; border-radius: 999px;
  background: #e6ebef; color: #6d7781; text-align: center; font-size: 11px;
}
.script-tree-select.active, .script-tree-group.active .script-tree-select {
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 600;
}
.script-tree-select.active small, .script-tree-group.active small { background: #fff; color: var(--brand-dark); }
.script-tree-groups { padding-left: 23px; }
.script-tree-type > summary { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 3px 7px; list-style: none; cursor: pointer; background: #eaf1f5; color: #364b59; }
.script-tree-type > summary::-webkit-details-marker { display: none; }
.script-tree-type > summary strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.script-tree-type > summary small { color: #74818b; }
.script-tree-type > summary:hover .script-tree-more { opacity: 1; }
.script-type-groups { padding-left: 10px; }
.script-tree-type + .script-tree-type { margin-top: 3px; }
.script-tree-group {
  position: relative; min-height: 38px; display: flex; align-items: center;
  padding: 2px 7px 2px 6px; border-left: 1px solid #ccd7de; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.script-tree-group::before { content: ""; width: 10px; flex: 0 0 10px; border-top: 1px solid #ccd7de; }
.script-tree-empty { padding: 9px 14px 9px 30px; color: #81909a; font-size: 12px; }
.script-tree-empty.large { padding: 34px 14px; text-align: center; }

.script-tree-actions { position: relative; flex: 0 0 auto; }
.script-tree-more {
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: var(--r-sm);
  background: transparent; color: #71808b; font-size: 18px; line-height: 1; opacity: .7;
  transition: opacity .12s ease, background .12s ease;
}
.script-tree-category > summary:hover .script-tree-more, .script-tree-group:hover .script-tree-more,
.script-tree-actions.open .script-tree-more, .script-tree-more:focus { opacity: 1; }
.script-tree-more:hover, .script-tree-actions.open .script-tree-more { background: var(--brand-soft); color: var(--brand-dark); }
.script-tree-menu {
  position: fixed; z-index: 1000; inset: auto; top: 0; left: 0; width: 138px; display: none;
  margin: 0; padding: 5px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-sm); box-shadow: 0 8px 22px rgba(32, 42, 52, .16);
}
.script-tree-menu.portal-open { display: grid; max-height: calc(100vh - 16px); overflow-y: auto; }
.script-tree-menu button { min-height: 31px; border: 0; border-radius: 4px; background: transparent; color: #3a454f; text-align: left; }
.script-tree-menu button:hover { background: var(--brand-tint); color: var(--brand-dark); }
.script-tree-menu span { height: 1px; margin: 4px 3px; background: var(--line); }
.script-tree-menu button.danger { color: var(--danger-dark); }
.script-tree-menu button.danger:hover { background: #fdf1f1; color: #a82830; }

.script-main { min-width: 0; background: var(--surface); }
.script-main-header h3 { margin: 0 0 3px; font-size: 15px; color: #2a343d; }
.script-main-header h3 span { padding: 0 4px; color: #9aa4ad; font-weight: 400; }
.script-list { max-height: calc(100vh - 287px); overflow-x: hidden; overflow-y: auto; }
.script-list-head, .script-item-row {
  display: grid; grid-template-columns: 28px minmax(210px, 1.45fr) minmax(175px, .9fr) 128px 142px;
  column-gap: 12px; align-items: center; padding: 0 15px;
}
.script-list-head {
  position: sticky; top: 0; z-index: 2; min-height: 38px; border-bottom: 1px solid var(--line);
  background: var(--surface-soft); color: #5c6670; font-size: 12px; font-weight: 600; letter-spacing: .3px;
}
.script-item-row { min-height: 76px; border-bottom: 1px solid #edf0f3; transition: background-color .12s ease; }
.script-item-row:hover { background: var(--brand-tint); }
.script-select-cell { display: flex; align-items: center; justify-content: center; }
.script-select-cell input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.script-item-copy { min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; }
.script-item-heading { grid-column: 1 / -1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.script-image-preview {
  flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden;
  padding: 0; border: 1px solid #d5e0e6; border-radius: 4px; background: #f4f8fa;
  color: #71808a; font-size: 10px; cursor: zoom-in;
}
.script-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.script-image-preview.loaded:hover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.script-image-preview.missing { cursor: default; border-style: dashed; color: #9b6e3b; background: #fdf6eb; }
.script-item-title {
  width: fit-content; max-width: 100%; overflow: hidden; padding: 2px 8px;
  border-radius: 4px; color: #fff; font-size: 12px; font-weight: 500;
  text-overflow: ellipsis; white-space: nowrap;
}
.script-image-count {
  flex: 0 0 auto; padding: 2px 7px; border-radius: 999px; background: var(--brand-tint);
  color: var(--brand-dark); border: 1px solid rgba(181, 31, 53, .12); font-size: 11px;
}
.script-item-copy p {
  min-width: 0; grid-column: 2; display: -webkit-box; margin: 0; overflow: hidden;
  color: #42505a; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.scope-badge {
  grid-column: 1; align-self: start; min-width: 38px; display: inline-flex; justify-content: center;
  padding: 2px 7px; border-radius: 4px; background: var(--brand-tint); color: var(--brand-dark); font-size: 11px;
}
.scope-group { background: #e9f2ec; color: #2f7050; }
.scope-shop { background: #fdf2e2; color: #9a641f; }
.scope-private { background: #f5eaf2; color: #955078; }
.script-item-location { min-width: 0; display: grid; gap: 3px; }
.script-item-location strong, .script-item-location span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-item-location strong { color: #334049; font-size: 13px; }
.script-item-location span { color: #74808a; font-size: 12px; }
.script-item-row time { color: #6f7b85; font-size: 12px; white-space: nowrap; }
.script-item-actions { display: flex; justify-content: flex-end; gap: 1px; white-space: nowrap; }
.script-item-actions button { border: 0; background: transparent; color: var(--brand-dark); padding: 4px 7px; border-radius: 4px; }
.script-item-actions button:hover { background: var(--brand-soft); }
.script-item-actions .danger-link { color: var(--danger-dark); }
.script-item-actions .danger-link:hover { background: #fdf1f1; }
.script-empty {
  min-height: 280px; display: grid; place-content: center; gap: 7px; padding: 24px;
  text-align: center; color: #84909a;
}
.script-empty strong { color: #516069; font-size: 15px; }

.image-preview-dialog {
  width: min(860px, calc(100vw - 48px)); max-height: calc(100vh - 48px); padding: 42px 20px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff;
  box-shadow: 0 18px 48px rgba(25, 36, 44, .24);
}
.image-preview-dialog::backdrop { background: rgba(19, 29, 36, .62); }
.image-preview-dialog > button {
  position: absolute; top: 8px; right: 10px; width: 30px; height: 30px; padding: 0;
  border: 0; background: transparent; color: #59666f; font-size: 24px; line-height: 1;
}
.image-preview-dialog img { display: block; width: 100%; max-height: calc(100vh - 150px); object-fit: contain; }
.image-preview-dialog p { margin: 10px 0 0; color: #66737c; text-align: center; font-size: 12px; }

/* ============================================================
   日志 / 其他
   ============================================================ */
.audit-action { display: inline-flex; min-width: 64px; color: var(--brand-dark); font-weight: 600; }
.resource-id { color: #64707a; font-family: Consolas, "Segoe UI", monospace; font-size: 12px; }
.content-preview { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1400px) {
  .script-list-head, .script-item-row { grid-template-columns: 28px minmax(240px, 1.35fr) minmax(180px, .8fr) 118px; }
  .script-list-head span:nth-child(4), .script-item-row time { display: none; }
}
@media (max-width: 1180px) {
  .script-filter-row { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .script-search { grid-column: 1 / 3; }
}
@media (max-width: 1050px) {
  .login-view { padding: 38px; }
  .login-layout { grid-template-columns: minmax(400px, 1fr) minmax(370px, 440px); gap: 54px; }
  .login-intro { padding-left: 32px; }
  .company-logo { width: 270px; height: 136px; margin-bottom: 26px; }
  .company-logo img { width: 270px; height: 270px; transform: translateY(-59px); }
  .login-intro-copy h1 { font-size: 34px; }
  .operation-map > div { padding: 14px; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 176px minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .page-content { max-width: none; padding: 18px; }
  .topbar { padding: 10px 16px; }
}
@media (max-width: 820px) {
  .script-scope-tabs { overflow-x: auto; }
  .script-scope-tabs button { min-width: 68px; }
  .script-filter-row { grid-template-columns: 1fr 1fr; }
  .script-search { grid-column: 1 / -1; }
  .script-manager { height: auto; min-height: 0; }
  .script-workspace { grid-template-columns: 1fr; }
  .script-sidebar { grid-template-rows: auto minmax(0, 300px); border-right: 0; border-bottom: 1px solid var(--line); }
  .script-tree { max-height: 300px; }
  .script-list { max-height: none; }
  .script-list-head, .script-item-row { grid-template-columns: 28px minmax(0, 1fr) 118px; }
  .script-list-head span:nth-child(3), .script-list-head span:nth-child(4), .script-item-location { display: none; }
}
@media (max-width: 780px) {
  .login-view { align-items: start; padding: 22px 18px 32px; }
  .login-layout { width: min(450px, 100%); grid-template-columns: 1fr; gap: 18px; }
  .login-intro { display: grid; justify-items: center; padding: 0; text-align: center; }
  .login-intro::before { display: none; }
  .company-logo { width: 245px; height: 122px; margin: 0 0 7px; }
  .company-logo img { width: 245px; height: 245px; transform: translateY(-54px); }
  .login-kicker { margin-bottom: 6px; }
  .login-intro-copy h1 { font-size: 27px; }
  .login-intro-copy > p, .operation-map { display: none; }
  .login-panel { padding: 30px 26px 26px; }
  .login-heading h2 { font-size: 27px; }
}
@media (max-width: 720px) {
  .tree-base > summary, .tree-project > summary { flex-wrap: wrap; }
  .tree-actions { width: 100%; margin-left: 24px; }
  .tree-shop { align-items: flex-start; flex-wrap: wrap; }
  .tree-shop .tree-actions { width: auto; margin-left: 28px; }
}
@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .product { height: 52px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .sidebar nav button { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .stat-grid, .split { grid-template-columns: 1fr; }
  .account-badge { display: none; }
  .topbar-main { width: 100%; justify-content: space-between; gap: 12px; }
  .desktop-download { padding-inline: 10px; }
  .dialog-image-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-image-toolbar { align-items: flex-start; flex-direction: column; }
  .topbar { position: static; }
}

/* 打印时去除装饰 */
@media print {
  .sidebar, .topbar, .toast { display: none; }
  .app-shell { display: block; }
  .section, .stat { box-shadow: none; }
}
