/* HOMIE 开本中心 · UI v2 设计系统
   参考：shadcn/ui 分组侧边栏 + floating sidebar、Ant Design Pro 信息层级、
   Tremor/Recharts 数据可视化排版（纯 CSS + 内联 SVG，无外部依赖/离线可用） */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --brand: #6d28d9;
  --brand-2: #8b5cf6;
  --brand-soft: #f1ebff;
  --amber: #f59e0b;
  --amber-soft: #fef4e2;
  --green: #12b76a;
  --green-soft: #e7f8ef;
  --red: #e5484d;
  --red-soft: #fdecec;
  --blue: #2e90fa;
  --blue-soft: #e8f2ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 46px rgba(16, 24, 40, .16);
  --sidebar-w: 248px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
input, select, textarea, button { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 15% -10%, #ede9fe 0%, transparent 60%),
    radial-gradient(900px 420px at 95% 0%, #fef3c7 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-weight: 800; font-size: 16px; letter-spacing: .5px;
}
.login-card h1 { font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.help { color: var(--muted); font-size: 12px; margin-top: 10px; }
.error { color: var(--red); font-size: 12.5px; min-height: 18px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #5b21b6; border-color: #5b21b6; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--red); border-color: #f5c2c3; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 应用框架 ---------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 12px auto 12px 12px; width: var(--sidebar-w);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; z-index: 30;
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px;
}
.sidebar-brand .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-brand .tag { color: var(--muted); font-size: 11px; font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: #98a2b3; padding: 16px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 550; font-size: 13px; cursor: pointer;
  transition: .12s; user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav-item .ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.nav-item .pill {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: var(--red-soft); color: var(--red);
}
.nav-item .pill.zero { display: none; }
.nav-collapse > .nav-item .chev { margin-left: auto; font-size: 10px; transition: .15s; }
.nav-collapse.open > .nav-item .chev { transform: rotate(90deg); }
.nav-sub { display: none; margin: 2px 0 4px 14px; border-left: 1px solid var(--line); padding-left: 8px; }
.nav-collapse.open .nav-sub { display: block; }
.nav-sub .nav-item { padding: 6px 10px; font-size: 12.5px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px;
  background: var(--surface-2);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber), #f97316); color: #fff;
  font-weight: 700; font-size: 13px;
}
.user-chip .who { font-weight: 650; font-size: 12.5px; }
.user-chip .role { color: var(--muted); font-size: 11px; }

.main { margin-left: calc(var(--sidebar-w) + 24px); padding: 12px 16px 40px 8px; min-height: 100vh; }
.topbar {
  position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.crumb b { color: var(--text); font-size: 14px; font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
  font-size: 14px; position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.badge-dot {
  position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 1.5px solid #fff;
}
.searchbox { position: relative; width: 230px; }
.searchbox input {
  width: 100%; padding: 8px 12px 8px 32px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); outline: none;
}
.searchbox .lens { position: absolute; left: 10px; top: 7px; color: var(--muted); font-size: 13px; }

/* ---------------- 页面与卡片 ---------------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin: 4px 4px 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.page-head .desc { color: var(--muted); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g2 { grid-template-columns: 1.6fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g11 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1200px) { .g2, .g3, .g11 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px 18px; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.kpi .value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .foot { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.kpi .ico-badge {
  position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
}
.trend-up { color: var(--green); font-weight: 700; }
.trend-down { color: var(--red); font-weight: 700; }
.trend-flat { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: var(--surface-3); color: var(--text-2); }
.badge.green { background: var(--green-soft); color: #067647; }
.badge.amber { background: var(--amber-soft); color: #b54708; }
.badge.red { background: var(--red-soft); color: #b42318; }
.badge.blue { background: var(--blue-soft); color: #175cd3; }
.badge.violet { background: var(--brand-soft); color: var(--brand); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--muted);
  font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); z-index: 1;
}
.table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fcfcfd; }
.table .empty-row td { color: var(--muted); text-align: center; padding: 26px; }
.table .num { font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 650; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis-label { fill: #98a2b3; font-size: 10px; }
.chart .area { fill: url(#areaGradient); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: #fff; stroke: var(--brand); stroke-width: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.bar-row { display: grid; grid-template-columns: 88px 1fr 52px; gap: 10px; align-items: center; padding: 6px 0; font-size: 12.5px; }
.bar-track { display: block; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-fill.amber { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.green { background: linear-gradient(90deg, #12b76a, #32d583); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }

.list-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.list-row:last-child { border-bottom: none; }
.list-row .t { font-weight: 650; }
.list-row .meta { color: var(--muted); font-size: 11.5px; }
.list-row .right { margin-left: auto; text-align: right; }

/* ---------------- 弹层 / 抽屉 / 提示 ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 20px;
}
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; }
.modal-head .x { margin-left: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: 520px; max-width: 94vw;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 60;
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 16px 18px; overflow: auto; }

#toast { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast-item {
  background: #101828; color: #fff; padding: 10px 14px; border-radius: 10px;
  box-shadow: var(--shadow-md); font-size: 13px; animation: toastIn .18s ease-out; max-width: 360px;
}
.toast-item.ok { background: #05603a; }
.toast-item.err { background: #912018; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Tabs / 工具条 ---------------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; }
.seg button {
  border: none; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 650; color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.split { display: flex; gap: 14px; align-items: flex-start; }
.split > * { min-width: 0; }
.timeline { position: relative; padding-left: 16px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 14px 10px; font-size: 12.5px; }
.timeline-item::before {
  content: ""; position: absolute; left: -17px; top: 4px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand);
}
.timeline-item .when { color: var(--muted); font-size: 11px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------------- AI 助手 ---------------- */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 40; height: 46px; padding: 0 18px;
  border-radius: 999px; border: none; cursor: pointer; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px rgba(109, 40, 217, .35); display: flex; align-items: center; gap: 8px;
}
.ai-panel {
  position: fixed; right: 22px; bottom: 80px; z-index: 41; width: 380px; max-width: 94vw;
  height: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.ai-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.ai-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.ai-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 12.8px; white-space: pre-wrap; }
.ai-user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.ai-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-err { align-self: flex-start; background: var(--red-soft); color: #912018; }
.ai-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }

/* 状态色 */
.st-pending { color: #b54708; }
.st-accepted { color: #175cd3; }
.st-done, .st-settled, .st-closed { color: #067647; }
.st-cancelled { color: var(--red); }
.st-archived { color: var(--red); }

@media (max-width: 980px) {
  .sidebar { transform: translateX(-105%); transition: .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .searchbox { display: none; }
}

/* ===== 剧本详情页 v1.4 ===== */
.detail-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; flex-wrap:wrap; }
.detail-head h2 { letter-spacing:-.02em; }
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:14px; overflow-x:auto; }
.tab { padding:9px 14px; font-size:13px; font-weight:600; color:var(--muted); text-decoration:none; border-bottom:2px solid transparent; white-space:nowrap; }
.tab:hover { color:var(--text); }
.tab.active { color:var(--brand); border-bottom-color:var(--brand); }
.tab-count { margin-left:6px; font-size:11px; padding:0 6px; border-radius:99px; background:var(--surface-3); color:var(--text-2); }
.detail-hero { display:flex; gap:16px; align-items:flex-start; flex-wrap:wrap; }
.detail-cover { width:150px; height:200px; object-fit:cover; border-radius:12px; border:1px solid var(--line); background:var(--surface-3); }
.detail-cover.placeholder { display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:12px; }
.detail-info { flex:1; min-width:240px; }
.alert-inline { margin-top:10px; padding:8px 10px; border-radius:9px; background:var(--amber-soft); color:#b54708; font-size:12px; }
.alert-inline.ok { background:var(--green-soft); color:#067647; }
.cat-chips { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.cat-chip { padding:5px 10px; border-radius:99px; border:1px solid var(--line); font-size:12px; color:var(--text-2); text-decoration:none; background:var(--surface); }
.cat-chip.active { background:var(--brand-soft); border-color:transparent; color:var(--brand); font-weight:600; }
.role-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:10px; }
.role-card { border:1px solid var(--line); border-radius:12px; padding:12px; background:var(--surface); }
.meta-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:10px; }
.meta-card { border:1px solid var(--line); border-radius:12px; padding:12px; background:var(--surface); display:flex; flex-direction:column; gap:6px; }
.meta-key { font-size:11px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.meta-value { font-size:13px; color:var(--text); white-space:pre-wrap; word-break:break-word; }
.note-raw { margin:0; padding:12px; border-radius:10px; background:var(--surface-3); font-size:12px; line-height:1.7; white-space:pre-wrap; word-break:break-word; max-height:420px; overflow:auto; }
.media-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(180px, 1fr)); gap:12px; }
.media-card { border:1px solid var(--line); border-radius:12px; overflow:hidden; background:var(--surface); }
.media-card img, .media-card video { width:100%; height:130px; object-fit:cover; display:block; background:#111; }
.media-meta { padding:8px 10px; }
.media-meta .t { font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ===== 文件预览（剧本详情 打开按钮） ===== */
.preview-img { display:block; max-width:100%; max-height:72vh; margin:0 auto; border-radius:10px; }
.preview-frame { width:100%; height:72vh; border:1px solid var(--line); border-radius:10px; background:#fff; }
.preview-media { display:block; max-width:100%; max-height:72vh; margin:0 auto; border-radius:10px; }
.media-card { cursor:pointer; }


/* ===== 手机端（v1.5.2） ===== */
.mobile-menu { display: none; }
.nav-backdrop { display: none; position: fixed; inset: 0; z-index: 29; background: rgba(16,24,40,.45); }
.nav-backdrop.show { display: block; }
@media (max-width: 980px) {
  .mobile-menu { display: inline-flex; }
  .sidebar { width: min(84vw, 300px); inset: 0 auto 0 0; border-radius: 0 18px 18px 0; z-index: 30; }
  .sidebar.open { transform: none; box-shadow: 0 20px 60px rgba(16,24,40,.35); }
  .main { margin-left: 0; padding: 8px 10px 96px; }
  .topbar { top: 6px; padding: 8px 10px; margin-bottom: 12px; border-radius: 12px; gap: 8px; }
  .crumb { font-size: 11.5px; gap: 6px; }
  .crumb b { font-size: 13px; }
  .page-head { margin: 2px 2px 10px; gap: 8px; }
  .page-head h2 { font-size: 18px; }
  .page-head .desc { font-size: 11.5px; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .card { padding: 12px; border-radius: 14px; }
  .card-head { gap: 8px; flex-wrap: wrap; }
  .card-head h3 { font-size: 14px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 22px; }
  .g2, .g3, .g4, .g11, .kpis { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .tabs { gap: 0; }
  .tab { padding: 8px 10px; font-size: 12px; }
  .table { font-size: 12px; }
  .table thead th { padding: 8px 8px; font-size: 10.5px; }
  .table tbody td { padding: 9px 8px; }
  .actions-cell, td.actions { white-space: nowrap; }
  .modal { max-width: none; width: auto; margin: 0 10px; padding: 16px; max-height: 90vh; border-radius: 14px; }
  .modal.wide { max-width: none; }
  .drawer { width: 100%; max-width: none; top: 0; right: 0; bottom: 0; border-radius: 0; }
  .detail-head { gap: 8px; }
  .detail-head h2 { font-size: 18px; }
  .detail-cover { width: 104px; height: 140px; }
  .meta-grid, .role-grid, .media-grid { grid-template-columns: 1fr; }
  .ai-fab { right: 12px; bottom: 14px; height: 40px; padding: 0 14px; font-size: 12px; }
  .ai-panel { right: 12px; left: 12px; width: auto; bottom: 64px; }
  #toast { right: 12px; left: 12px; bottom: 12px; }
  .toast-item { max-width: none; }
  .login-wrap { padding: 16px; }
  .login-card { padding: 22px; }
}

@media (max-width: 980px) {
  .table { min-width: 660px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

.m-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface); }
.m-card:last-child { margin-bottom: 0; }
.m-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.m-title { font-weight: 700; font-size: 14px; line-height: 1.4; }
.m-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 长列表渲染优化：屏幕外卡片跳过布局/绘制 */
.script-card{content-visibility:auto;contain-intrinsic-size:260px;}
