/* ==========================================================================
   ovO 元器件库存助手 · V2 工程工作台基础层
   职责：浅色设计令牌 + 工作台布局骨架 + 全部组件样式 + 响应式规则。
   深色主题令牌、品牌点缀与主题细节见 assets/portal-style-u1.css。
   不引入任何外部字体、CDN 或网络请求。
   ========================================================================== */

:root {
  color-scheme: light;
  /* 主色：成熟紫；青色仅作辅助信息色 */
  --primary: #5a4fd6;
  --primary-strong: #4739c2;
  --primary-soft: #ebe9fc;
  --primary-softer: #f6f5fe;
  --cyan: #0d8390;
  --cyan-soft: #def2f4;
  /* 语义色 */
  --green: #177a4c;
  --green-soft: #e0f6ea;
  --amber: #8f5f0b;
  --amber-soft: #fdf2d5;
  --red: #bf392c;
  --red-soft: #fce9e6;
  /* 中性 */
  --ink: #1c2333;
  --muted: #5c6780;
  --faint: #8a93a7;
  --line: #e1e5ef;
  --line-strong: #c9d0e1;
  --bg: #f1f3f9;
  --bg-soft: #e8ebf3;
  --panel: #ffffff;
  --panel-soft: #f7f8fc;
  --hover: #f4f3fd;
  /* 侧栏与其余工作台共用同一组主题令牌 */
  --side-bg: var(--panel);
  --side-bg-2: var(--panel);
  --side-text: var(--muted);
  /* 形态 */
  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(23, 30, 52, .05), 0 6px 18px rgba(23, 30, 52, .05);
  --shadow-lg: 0 24px 60px rgba(10, 8, 26, .28);
  --focus: 0 0 0 3px rgba(90, 79, 214, .2);
  /* 兼容旧变量别名 */
  --blue: var(--primary);
  --blue-soft: var(--primary-soft);
  --teal: var(--cyan);
  --text-muted: var(--muted);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { touch-action: manipulation; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* LCSC 审核弹窗打开时锁定背景滚动 */
body.lcsc-preview-open { overflow: hidden; }
body.lcsc-preview-open::before { content: ""; position: fixed; inset: 0; z-index: 110; background: rgba(14, 11, 30, .5); }

/* ---------- ovO 文字品牌 ---------- */
.brand-wordmark { font-weight: 800; letter-spacing: .01em; }
.brand-wordmark i { color: #46c2cd; font-style: normal; }

/* ---------- 启动同步覆盖层 ---------- */
.startup-sync-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; background: rgba(14, 11, 30, .5); }
.startup-sync-card { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-lg); text-align: center; }
.startup-sync-card strong { display: block; margin-top: 16px; color: var(--ink); font-size: 20px; }
.startup-sync-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.65; overflow-wrap: anywhere; }
.startup-sync-spinner { display: inline-block; width: 38px; height: 38px; border: 4px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: startup-sync-spin .8s linear infinite; }
@keyframes startup-sync-spin { to { transform: rotate(360deg); } }

/* ---------- 应用骨架与工程侧栏 ---------- */
#app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar {
  --sb-bg: #fff;
  --sb-surface: #f6f6fa;
  --sb-inset: #eaeaf2;
  --sb-text: #1d1b28;
  --sb-muted: #5f6375;
  --sb-faint: #85899a;
  --sb-line: #e1e1e9;
  --sb-line-strong: #c9cad6;
  --sb-primary: #6557dd;
  --sb-primary-soft: #efedff;
  --sb-success: #23865c;
  position: sticky; top: 0; z-index: 20;
  height: 100vh;
  height: 100dvh;
  padding: calc(18px + env(safe-area-inset-top)) 14px 0;
  display: flex; flex-direction: column;
  color: var(--sb-text);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-line);
}
.brand { display: flex; align-items: center; min-width: 0; margin: 0 2px; padding: 2px 6px 14px; border-bottom: 1px solid var(--sb-line); color: var(--sb-text); text-decoration: none; }
.brand-copy { min-width: 0; display: grid; gap: 1px; }
.brand-line { min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.brand-wordmark { flex: none; color: var(--sb-text); font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; line-height: 1.2; }
.brand-wordmark i { color: #4fb9c9; font-style: normal; }
.brand-line strong { min-width: 0; color: var(--sb-text); font-size: .95rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-copy small { color: var(--sb-muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

nav#main-nav { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding: 12px 0 8px; }
nav#main-nav { scrollbar-width: thin; scrollbar-color: var(--sb-line-strong) transparent; }
.nav-group-label { margin: 14px 10px 6px; color: var(--sb-faint); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.nav-group-label:first-child { margin-top: 2px; }
.nav-item { width: 100%; min-height: 44px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 10px; color: var(--sb-muted); background: transparent; text-align: left; font-size: .94rem; font-weight: 600; transition: background .15s ease, color .15s ease; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .92; }
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { color: var(--sb-text); background: var(--sb-surface); }
.nav-item.active { color: var(--sb-primary); background: var(--sb-primary-soft); box-shadow: none; }
.nav-item.active .nav-icon { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 12px 0 calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; border-top: 1px solid var(--sb-line); }
.sidebar-status-card { min-width: 0; display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--sb-line); border-radius: 12px; background: var(--sb-surface); }
.sidebar-status-card > div { min-width: 0; }
.sidebar-status-card strong, .sidebar-status-card small { display: block; }
.sidebar-foot strong { color: var(--sb-text); font-size: .8rem; }
.sidebar-foot small { margin-top: 2px; color: var(--sb-faint); font-size: .72rem; overflow-wrap: anywhere; }
.sidebar-utilities { display: grid; gap: 10px; }
.sidebar-utility { width: 100%; min-height: 44px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--sb-line); border-radius: 10px; color: var(--sb-muted); background: transparent; font: inherit; font-size: .8rem; font-weight: 650; text-align: left; text-decoration: none; }
.sidebar-utility:hover, .sidebar-utility:focus-visible { color: var(--sb-primary); border-color: var(--sb-primary); background: var(--sb-surface); }
.sidebar-utility .theme-icon { color: currentColor; }
html[data-theme="dark"] .sidebar-utility .theme-icon { box-shadow: -5px -2px 0 -2px var(--sb-bg); }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--sb-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sb-success) 16%, transparent); }

/* 移动端抽屉遮罩（桌面不显示） */
.drawer-scrim { display: none; }

.main { min-width: 0; padding: 0 26px calc(40px + env(safe-area-inset-bottom)); }
.site-footer {
  grid-column: 2;
  margin: -18px 26px calc(22px + env(safe-area-inset-bottom));
  padding: 14px 18px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-size: 12px; text-align: center;
}
.site-footer a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--primary); text-decoration: underline; }
.site-footer-separator { color: var(--faint); }

/* ---------- 顶栏：模块标题 + 全局操作 ---------- */
.topbar { padding: 16px 0 15px; margin-bottom: 18px; display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px 14px; border-bottom: 1px solid var(--line); }
.topbar-title { min-width: 0; }
.topbar-crumb { display: block; margin-bottom: 3px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.topbar h2 { margin: 0 0 3px; font-size: 21px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.topbar p { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.top-actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ---------- 视图切换 ---------- */
.view { display: none; }
.view.active { display: block; animation: enter .18s ease; }
@keyframes enter { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- 按钮体系 ---------- */
.button { min-height: 38px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 700; line-height: 1.3; text-decoration: none; transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover { background: var(--primary-strong); }
.button.ai { color: #fff; background: #6b4de0; }
.button.ai:hover { background: #593fd2; }
.button.ghost { color: var(--ink); background: var(--panel); border-color: var(--line-strong); }
.button.ghost:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-softer); }
.button.danger { color: #fff; background: var(--red); }
.button.danger:hover { background: #a92f24; }
.button.danger-outline { color: var(--red); background: var(--panel); border-color: var(--red); }
.button.danger-outline:hover { background: var(--red-soft); }
.button.warning { color: #6b4303; background: #ffd166; }
.button.warning:hover { background: #f5c34f; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.button:disabled { cursor: default; opacity: .6; }
.button-row { display: flex; gap: 8px; align-items: center; }
.button-row.wrap { flex-wrap: wrap; }
.link-button { padding: 5px 0; border: 0; color: var(--primary); background: transparent; font-weight: 700; }
.link-button:hover { text-decoration: underline; }
.icon-button { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--muted); font-size: 20px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover { color: var(--primary); border-color: var(--primary); }
.mobile-only { display: none; }

/* 主题切换按钮图标 */
.theme-toggle { gap: 8px; white-space: nowrap; }
.theme-icon { width: 16px; height: 16px; position: relative; flex: 0 0 auto; border: 2px solid currentColor; border-radius: 50%; }
.theme-icon::before { content: ""; position: absolute; inset: -5px; border: 1px dotted currentColor; border-radius: 50%; opacity: .55; }
html[data-theme="dark"] .theme-icon { border: 0; background: currentColor; box-shadow: -5px -2px 0 -2px var(--panel); transform: rotate(-18deg); }
html[data-theme="dark"] .theme-icon::before { display: none; }
.theme-label { font-size: 12px; }

/* ---------- 面板 ---------- */
.panel { margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-head { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.panel-head.align-end { align-items: flex-end; }
.panel-head > div { min-width: 0; }
.panel h3 { margin: 0 0 4px; font-size: 15px; letter-spacing: -.01em; }
.panel p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 12px; overflow-wrap: anywhere; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 18px; }

/* ---------- 统计卡片（指标条，不再全紫卡片） ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-grid.five { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
.stat-card { min-height: 96px; padding: 14px 16px; display: flex; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.stat-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); font-weight: 900; font-size: 15px; }
.stat-card > div { min-width: 0; display: grid; gap: 2px; }
.stat-card > div small { color: var(--muted); font-size: 11px; }
.stat-card > div strong { font-size: 24px; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-card > div em { color: var(--faint); font-size: 10px; font-style: normal; overflow-wrap: anywhere; }

.category-summary { display: grid; gap: 9px; }
.category-summary button { padding: 6px 0; display: grid; grid-template-columns: minmax(80px, 150px) 1fr 34px; gap: 10px; align-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.category-summary button:hover span { color: var(--primary); }
.category-summary span { overflow-wrap: anywhere; }
.category-summary i { height: 7px; overflow: hidden; border-radius: 99px; background: var(--bg-soft); }
.category-summary i b { height: 100%; display: block; border-radius: inherit; background: var(--primary); }
.category-summary strong { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 快速操作 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick-action { padding: 14px; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: left; transition: border-color .15s ease, box-shadow .15s ease; }
.quick-action:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.quick-action strong { align-self: end; font-size: 13px; }
.quick-action small { color: var(--muted); font-size: 10px; }
.quick-icon { grid-row: 1 / 3; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; font-size: 20px; font-weight: 800; }
.quick-icon.positive { color: var(--green); background: var(--green-soft); }
.quick-icon.negative { color: var(--red); background: var(--red-soft); }
.quick-icon.info { color: var(--primary); background: var(--primary-soft); }
.quick-icon.neutral { color: var(--muted); background: var(--bg-soft); }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.table-panel { padding: 0; overflow: hidden; }
.table-panel .table-wrap { border: 0; border-radius: 0; }
.table-panel-head { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.table-panel-head h3 { margin: 0 0 2px; font-size: 13px; }
.table-panel-head p { margin: 0; color: var(--muted); font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 2; padding: 10px 12px; color: var(--muted); background: var(--bg-soft); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
.compact td, .compact th { padding: 8px 10px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.subtext { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.empty-state { padding: 36px 20px; color: var(--muted); text-align: center; display: grid; gap: 6px; justify-items: center; }
.empty-state.small { padding: 18px 12px; }
.empty-state strong { display: block; color: var(--ink); }
.empty-state span { overflow-wrap: anywhere; }
td small { margin-top: 4px; display: block; color: var(--muted); font-size: 9px; line-height: 1.45; overflow-wrap: anywhere; }

.import-preview-grid { min-width: 1380px; }
.import-preview-grid .import-name { min-width: 260px; max-width: 420px; white-space: normal; line-height: 1.5; }
.import-preview-grid th:nth-child(5), .import-preview-grid td:nth-child(5) { min-width: 130px; }
.import-preview-grid th:nth-child(6), .import-preview-grid td:nth-child(6) { min-width: 150px; }

.inventory-grid { width: 100%; min-width: 0; table-layout: fixed; }
.inventory-grid th { position: sticky; padding-right: 17px; white-space: normal; overflow-wrap: anywhere; }
.inventory-grid th .column-resizer { width: 9px; height: 100%; padding: 0; position: absolute; top: 0; right: -4px; z-index: 4; border: 0; background: transparent; cursor: col-resize; touch-action: none; }
.inventory-grid th .column-resizer::after { content: ""; width: 2px; height: 52%; position: absolute; top: 24%; left: 3px; border-radius: 2px; background: var(--line-strong); opacity: .6; }
.inventory-grid th .column-resizer:hover::after, body.resizing-columns .inventory-grid th .column-resizer::after { background: var(--primary); opacity: 1; }
.inventory-grid tbody tr { height: 96px; }
.inventory-grid td { height: 96px; padding-top: 10px; padding-bottom: 10px; white-space: normal; overflow-wrap: anywhere; }
.inventory-cell { height: 74px; max-height: 74px; min-width: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; line-height: 1.45; }
.inventory-cell > strong, .inventory-cell > span, .inventory-cell > small { max-width: 100%; overflow-wrap: anywhere; }
.inventory-actions-cell { align-items: stretch; overflow-y: auto; }
body.resizing-columns { cursor: col-resize; user-select: none; }

.row-actions { display: flex; flex-wrap: wrap; gap: 5px; white-space: normal; }
.row-actions button, .backup-list button { min-height: 28px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); color: var(--ink); font-size: 10px; }
.row-actions button:hover, .backup-list button:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-softer); }
.row-actions .danger-link { color: var(--red); }
.code { display: block; color: var(--primary-strong); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.key-parameters { display: inline-block; color: var(--primary-strong); font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.candidate { margin: 2px 4px 2px 0; padding: 3px 6px; display: inline-block; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: 9px; white-space: nowrap; }
.review-row { background: var(--amber-soft); }
.ai-note { color: var(--primary-strong); }
.score { color: var(--muted); font-size: 10px; font-weight: 700; }

/* ---------- 徽章与库存数字 ---------- */
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; font-size: 10px; font-weight: 800; }
.badge.blue { color: var(--primary-strong); background: var(--primary-soft); }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }
.badge.gray { color: var(--muted); background: var(--bg-soft); }
.stock-number { font-weight: 800; font-variant-numeric: tabular-nums; }
.stock-number.low { color: var(--amber); }
.stock-number.zero { color: var(--red); }

/* ---------- 活动流 ---------- */
.activity-list { display: grid; gap: 2px; }
.activity-item { padding: 10px 0; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-weight: 800; font-size: 11px; }
.activity-dot.stock { color: var(--green); background: var(--green-soft); }
.activity-dot.component { color: var(--cyan); background: var(--cyan-soft); }
.activity-dot.import, .activity-dot.bom { color: var(--amber); background: var(--amber-soft); }
.activity-dot.backup, .activity-dot.system { color: var(--muted); background: var(--bg-soft); }
.activity-item strong { display: block; margin: 1px 0 3px; font-size: 12px; }
.activity-item p { font-size: 10px; }
.activity-item time { color: var(--faint); font-size: 9px; white-space: nowrap; }

/* ---------- 搜索与筛选 ---------- */
.search-panel { padding: 14px 16px; }
.search-row, .filter-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.filter-row { margin-top: 10px; padding-top: 11px; border-top: 1px dashed var(--line-strong); }
.search-box { min-width: 220px; flex: 1; min-height: 42px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); }
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.search-box span { color: var(--faint); font-size: 19px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; min-height: 40px; padding: 0; box-shadow: none !important; }
select, input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="url"], textarea { min-height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); background: var(--panel); outline: 0; }
select { padding: 7px 30px 7px 10px; }
input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="url"], textarea { padding: 8px 10px; }
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"] { accent-color: var(--primary); }
.filter-row select { min-height: 34px; font-size: 12px; }
.column-resize-hint { color: var(--faint); font-size: 10px; }
.result-count { margin-left: auto; color: var(--muted); font-size: 11px; }
#search-summary:empty { display: none; }
.search-hint { margin-bottom: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--primary-softer); color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.search-hint.success { border-color: var(--green); background: var(--green-soft); }
.search-hint.warning { border-color: var(--amber); background: var(--amber-soft); }
.search-hint b { color: var(--ink); }

/* ---------- 表单 ---------- */
.form-stack { display: grid; gap: 14px; }
.form-stack > label:not(.file-drop), .field-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field-grid .span-2 { grid-column: 1 / -1; }
.field-grid textarea { min-height: 72px; resize: vertical; }
.field-grid input, .field-grid select, .field-grid textarea { width: 100%; min-width: 0; }
.file-drop { min-height: 185px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--panel-soft); color: var(--muted); text-align: center; transition: border-color .15s ease, background .15s ease; cursor: pointer; }
.file-drop:hover, .file-drop.dragging { border-color: var(--primary); background: var(--primary-softer); }
.file-drop input { display: none; }
.file-drop .drop-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 24px; font-weight: 800; }
.file-drop strong { color: var(--ink); }
.file-drop small { color: var(--muted); font-size: 10px; }
.file-drop em { margin-top: 6px; color: var(--primary); font-size: 10px; font-style: normal; max-width: 100%; overflow-wrap: anywhere; }
.callout { padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); }
.callout.info { border-left: 3px solid var(--primary); background: var(--primary-softer); }
.callout.warning { border-left: 3px solid var(--amber); background: var(--amber-soft); }
.callout.neutral { margin-top: 16px; border-left: 3px solid var(--faint); background: var(--panel-soft); }
.callout strong { display: block; margin-bottom: 3px; font-size: 11px; }
.callout p { font-size: 10px; }
.download-list { display: grid; gap: 9px; }
.download-list button { padding: 12px; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left; transition: border-color .15s ease, background .15s ease; }
.download-list button:hover { border-color: var(--primary); background: var(--primary-softer); }
.download-list button > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.download-list strong, .download-list small { display: block; }
.download-list strong { margin-bottom: 3px; font-size: 12px; }
.download-list small { color: var(--muted); font-size: 10px; }
.download-list em { color: var(--primary); font-size: 11px; font-style: normal; font-weight: 700; }
hr { margin: 16px 0; border: 0; border-top: 1px solid var(--line); }

/* ---------- BOM 分析 ---------- */
.bom-upload-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr); gap: 16px; align-items: stretch; margin-bottom: 14px; }
.bom-upload-grid .file-drop { min-height: 230px; }
.bom-rules { display: grid; gap: 9px; align-content: start; }
.bom-rules article { padding: 13px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 11px; align-items: start; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.bom-rules article > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--primary); font-weight: 900; }
.bom-rules strong { display: block; margin: 1px 0 4px; font-size: 12px; }
.bom-rules p { color: var(--muted); font-size: 10px; line-height: 1.55; }
.bom-review-grid { min-width: 1280px; table-layout: fixed; }
.bom-review-grid th:nth-child(1) { width: 11%; }
.bom-review-grid th:nth-child(2) { width: 20%; }
.bom-review-grid th:nth-child(3) { width: 12%; }
.bom-review-grid th:nth-child(4) { width: 36%; }
.bom-review-grid th:nth-child(5) { width: 21%; }
.bom-review-grid td { vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.bom-review-grid td > strong { display: block; margin-bottom: 4px; }
.bom-candidates { display: grid; gap: 7px; }
.bom-candidate { padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.bom-candidate.selected { border-color: var(--primary); background: var(--primary-softer); box-shadow: inset 3px 0 0 var(--primary); }
.bom-candidate.exact { border-color: var(--green); background: var(--green-soft); }
.bom-candidate strong, .bom-candidate small { display: block; }
.bom-candidate strong { font-size: 10px; }
.bom-candidate small { margin-top: 3px; }
.bom-candidate ul { margin: 6px 0 0; padding-left: 17px; color: var(--amber); font-size: 9px; line-height: 1.5; }
.bom-candidate em { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; font-style: normal; }
.bom-decision { display: grid; gap: 7px; }
.bom-decision select { width: 100%; min-width: 0; }
.bom-decision small { margin: 0; }
.bom-sets-toolbar { align-items: flex-end; }
.bom-sets-toolbar label { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.bom-sets-toolbar input { width: 88px; min-width: 88px; min-height: 34px; padding: 6px 9px; }
.bom-final-grid { min-width: 1100px; }
.bom-final-grid td { white-space: normal; overflow-wrap: anywhere; }

/* ---------- 设置 ---------- */
.settings-actions { margin-top: 14px; margin-bottom: 0; }
.panel-head + .settings-actions, .field-grid + .settings-actions { margin-top: 14px; }
.info-list { margin: 0; display: grid; }
.info-list > div { min-width: 0; padding: 9px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { flex: 0 0 112px; color: var(--muted); font-size: 12px; }
.info-list dd { margin: 0; min-width: 0; text-align: right; font-weight: 700; font-size: 12px; overflow-wrap: anywhere; }
.danger-zone { border-color: var(--red); }
.danger-zone h3 { color: var(--red); }
.danger-item { padding: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.danger-item strong { display: block; margin-bottom: 5px; font-size: 12px; }
.danger-item p { max-width: 650px; }
.file-button { display: inline-flex; align-items: center; }
.file-button input { display: none; }
.backup-list { display: grid; gap: 8px; margin-top: 14px; }
.backup-list > div { padding: 11px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 9px; }
.backup-list > div > span { min-width: 0; }
.backup-list > div > span strong, .backup-list > div > span small { display: block; }
.backup-list > div > span small { margin-top: 3px; color: var(--muted); font-size: 9px; }

/* ---------- 立创补全 ---------- */
.source-cards { margin-bottom: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.source-cards article { min-width: 0; padding: 13px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-soft); }
.source-cards article > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 800; }
.source-cards strong { display: block; margin: 1px 0 5px; font-size: 11px; }
.source-cards p { color: var(--muted); font-size: 9px; line-height: 1.55; }
.external-link { color: var(--primary); text-decoration: none; font-weight: 700; }
.external-link:hover { text-decoration: underline; }
.lcsc-search-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 14px; }
.lcsc-search-row > input { min-width: 240px; flex: 1; }
.lcsc-overwrite { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.lcsc-overwrite input { width: 16px; height: 16px; margin: 0; }
.sync-session { align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 14px; flex-wrap: wrap; }
.sync-session:not(.hidden) { display: flex; }
.sync-session p { margin: 4px 0 0; }
.lcsc-preview-grid { min-width: 1500px; }
.lcsc-preview-grid th:nth-child(2), .lcsc-preview-grid td:nth-child(2) { min-width: 230px; }
.lcsc-preview-grid th:nth-child(3), .lcsc-preview-grid td:nth-child(3) { min-width: 280px; max-width: 400px; }
.lcsc-preview-grid th:nth-child(4), .lcsc-preview-grid td:nth-child(4) { min-width: 620px; }
.lcsc-preview-grid .lcsc-no-change { background: var(--panel-soft); color: var(--muted); }
.lcsc-preview-dialog { width: auto; height: auto; max-width: 1600px; margin: auto; padding: 0; position: fixed; inset: 24px; z-index: 120; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-lg); }
.lcsc-preview-dialog .lcsc-preview-head { flex: 0 0 auto; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.lcsc-preview-dialog #lcsc-preview-table { min-height: 0; flex: 1 1 auto; overflow: auto; border: 0; border-radius: 0; }
.lcsc-preview-dialog #lcsc-preview-table th { top: 0; }
.lcsc-preview-dialog #lcsc-preview-table td { white-space: normal; overflow-wrap: anywhere; }
.lcsc-links { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 12px; }
.source-line { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.manual-source-grid { display: grid; grid-template-columns: minmax(190px, 240px) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.manual-source-grid label { display: grid; align-content: start; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; min-width: 0; }
.manual-source-grid textarea { min-height: 170px; resize: vertical; }
.page-link { text-decoration: none; }
.lcsc-comparisons { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 6px; }
.lcsc-field { padding: 7px 9px; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.lcsc-field > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.lcsc-field > small { margin: 0; color: var(--faint); font-size: 9px; overflow-wrap: anywhere; }
.lcsc-field > strong { font-size: 10px; overflow-wrap: anywhere; }
.lcsc-field-choice { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 10px; font-weight: 800; }
.lcsc-field-choice input { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; }
.lcsc-edit-value { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.lcsc-edit-value input, .lcsc-edit-value textarea { width: 100%; min-height: 32px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--panel); font-size: 10px; font-weight: 600; resize: vertical; }
.lcsc-edit-value textarea { min-height: 58px; line-height: 1.45; }
.lcsc-field.will-write .lcsc-edit-value input, .lcsc-field.will-write .lcsc-edit-value textarea { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(90, 79, 214, .1); }
.lcsc-field.will-write { border-color: var(--primary); background: var(--primary-softer); }
.lcsc-field.different:not(.will-write) { border-color: var(--amber); background: var(--amber-soft); }

/* ---------- 弹窗 ---------- */
.modal-backdrop { position: fixed; inset: 0; padding: 24px; padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); display: grid; place-items: center; background: rgba(14, 11, 30, .5); z-index: 100; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(920px, 100%); }
.modal-head { padding: 16px 20px; display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.modal-head > div { min-width: 0; }
.modal-head h3 { margin: 0 0 4px; font-size: 16px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.modal-body { padding: 20px; overflow: auto; }
.modal-actions { padding: 13px 20px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); background: var(--panel-soft); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.confirm-field { display: grid; gap: 10px; color: var(--muted); }
.confirm-field input { width: 100%; }

/* ---------- 立创选型 ---------- */
.selector-composer { display: grid; gap: 12px; }
.selector-composer > textarea { width: 100%; min-height: 125px; padding: 14px; resize: vertical; font-size: 13px; line-height: 1.65; }
.selector-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.selector-actions > label:first-child { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.selector-ai-toggle { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; color: var(--primary-strong); font-size: 10px; font-weight: 700; }
.selector-ai-toggle input { width: 16px; height: 16px; margin: 0; }
.selector-actions .button:first-of-type { margin-left: auto; }
.selector-requirements { display: grid; gap: 12px; }
.selector-context { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--primary-softer); }
.selector-context strong { display: block; margin-bottom: 4px; color: var(--primary-strong); font-size: 13px; }
.selector-context p { font-size: 11px; }
.selector-requirement-list { display: flex; flex-wrap: wrap; gap: 8px; }
.selector-requirement { min-height: 32px; padding: 7px 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--panel-soft); font-size: 10px; }
.selector-requirement b { font-size: 9px; }
.selector-requirement.hard { color: var(--primary-strong); border-color: var(--primary); background: var(--primary-soft); }
.selector-requirement.soft { color: #6d4fc4; border-color: #c6b9ee; background: var(--primary-softer); }
.selector-requirement.question, .selector-requirement.unknown { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.selector-results { display: grid; gap: 12px; }
.selector-result-card { min-width: 0; display: grid; grid-template-columns: 74px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); box-shadow: var(--shadow); }
.selector-result-card.rejected { opacity: .82; border-color: var(--red); background: var(--panel); }
.selector-rank { padding: 16px 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--primary-strong); background: var(--primary-softer); font-size: 11px; font-weight: 800; text-align: center; }
.selector-result-card.rejected .selector-rank { color: var(--red); background: var(--red-soft); }
.selector-rank strong { margin-top: 6px; font-size: 22px; }
.selector-rank small { color: var(--muted); font-size: 8px; }
.selector-result-main { min-width: 0; padding: 15px 16px; }
.selector-result-title { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.selector-result-title h4 { margin: 3px 0 4px; font-size: 15px; overflow-wrap: anywhere; }
.selector-result-title p { font-size: 10px; }
.selector-parameters { margin-top: 10px; padding: 9px 11px; border-radius: 8px; color: var(--primary-strong); background: var(--primary-softer); font-size: 10px; font-weight: 700; line-height: 1.6; overflow-wrap: anywhere; }
.selector-checks { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.selector-check { padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 700; }
.selector-check.pass { color: var(--green); background: var(--green-soft); }
.selector-check.fail { color: var(--red); background: var(--red-soft); }
.selector-check.unknown { color: var(--amber); background: var(--amber-soft); }
.selector-explanation { margin-top: 10px; display: grid; gap: 4px; }
.selector-explanation p { color: var(--muted); font-size: 10px; }
.selector-explanation strong { color: var(--ink); }
.selector-explanation .selector-risk { color: var(--amber); }
.selector-links { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.selector-links a { text-decoration: none; }
.selector-links > span { margin-left: auto; color: var(--muted); font-size: 9px; }

/* ---------- AI 操作助手 ---------- */
.assistant-layout { max-width: 1050px; margin: 0 auto; }
.assistant-chat-panel { padding-bottom: 16px; }
.assistant-messages { min-height: 230px; max-height: 430px; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.assistant-message { max-width: 82%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 2px 8px rgba(23, 30, 52, .04); }
.assistant-message strong { display: block; margin-bottom: 5px; font-size: 11px; }
.assistant-message p { margin: 2px 0; color: inherit; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.assistant-message.bot { align-self: flex-start; border-bottom-left-radius: 4px; }
.assistant-message.user { align-self: flex-end; color: #fff; border-color: transparent; border-bottom-right-radius: 4px; background: var(--primary); }
.assistant-examples { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 7px; }
.assistant-examples button { min-height: 30px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); background: var(--panel); font-size: 10px; }
.assistant-examples button:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-softer); }
.assistant-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.assistant-composer textarea { min-height: 76px; padding: 11px 12px; resize: vertical; }
.assistant-composer .button { min-height: 44px; }
.assistant-plan-list { display: grid; gap: 10px; }
.assistant-plan-card { padding: 14px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.assistant-plan-card.has-error { border-color: var(--red); background: var(--red-soft); }
.assistant-plan-index { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--primary-strong); background: var(--primary-soft); font-weight: 800; }
.assistant-plan-main { min-width: 0; }
.assistant-plan-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.assistant-plan-title strong { font-size: 13px; overflow-wrap: anywhere; }
.assistant-plan-title em { margin-left: auto; color: var(--ink); font-size: 13px; font-style: normal; font-weight: 800; }
.assistant-plan-main > label { margin-top: 10px; display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.assistant-plan-main select { width: 100%; }
.assistant-plan-meta { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 10px; }
.assistant-plan-meta strong { color: var(--ink); }
.identity-ok { color: var(--green); font-weight: 700; }
.identity-warn { color: var(--amber); font-weight: 700; }
.assistant-candidates { margin-top: 10px; }
.plan-error { margin-top: 8px !important; color: var(--red) !important; font-weight: 700; }

/* ---------- 通知 ---------- */
#notice-area { position: fixed; top: calc(16px + env(safe-area-inset-top)); right: calc(18px + env(safe-area-inset-right)); width: min(360px, calc(100vw - 32px)); display: grid; gap: 8px; z-index: 200; pointer-events: none; }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-lg); animation: toast-in .2s ease; pointer-events: auto; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--amber); }
.toast strong { display: block; margin-bottom: 3px; font-size: 11px; }
.toast span { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ---------- 登录与权限 ---------- */
.auth-login-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; background: rgba(14, 11, 30, .58); }
.auth-login-overlay.hidden { display: none; }
.auth-login-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-lg); }
.auth-login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.auth-login-wordmark { font-size: 22px; font-weight: 800; letter-spacing: .01em; }
.auth-login-wordmark i { color: var(--cyan); font-style: normal; }
.auth-login-card h2 { margin: 0 0 8px; }
.auth-login-card > p { margin: 0 0 20px; color: var(--muted); }
.auth-login-form { display: grid; gap: 15px; }
.auth-login-form label { display: grid; gap: 7px; font-weight: 650; }
.auth-login-form input { width: 100%; }
.auth-login-form button { margin-top: 4px; min-height: 44px; }
.auth-login-note { margin-top: 16px !important; font-size: 12px; color: var(--muted); }
.auth-login-divider { position: relative; margin: 18px 0 14px; text-align: center; color: var(--muted); font-size: 11px; }
.auth-login-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.auth-login-divider span { position: relative; padding: 0 10px; background: var(--panel); }
.auth-offline-entry { width: 100%; }
.auth-user-controls { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auth-user-management { margin-bottom: 18px; }
.auth-create-user { align-items: end; }
.auth-create-user > button { min-height: 42px; }
.auth-public .server-settings { display: none !important; }
.auth-public .auth-offline-entry, .auth-public .auth-login-divider { display: none !important; }
.auth-offline .server-settings, .auth-offline .auth-user-management { display: none !important; }
.auth-offline #heartbeat-status { background: var(--amber-soft); color: var(--amber); }
.auth-reader [data-auth-admin], .auth-reader [data-auth-write] { display: none !important; }
.auth-reader [data-row-action="in"], .auth-reader [data-row-action="out"], .auth-reader [data-row-action="lcsc"], .auth-reader [data-row-action="edit"], .auth-reader [data-row-action="delete"] { display: none !important; }
.auth-reader .inventory-actions-cell::before { content: "只读"; color: var(--muted); font-size: .85rem; }

/* ---------- 移动端元器件卡片与详情 ---------- */
.inventory-mobile-cards { display: none; }
.component-mobile-card { width: 100%; padding: 16px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--panel); box-shadow: var(--shadow); text-align: left; font: inherit; }
.component-mobile-card:active { transform: translateY(1px); }
.component-card-head { display: flex; align-items: flex-start; gap: 12px; }
.component-card-title { min-width: 0; display: grid; gap: 4px; }
.component-card-title strong { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.component-card-title small { color: var(--muted); font-size: 11px; font-weight: 700; overflow-wrap: anywhere; }
.component-card-chevron { margin-left: auto; color: var(--faint); font-size: 30px; font-weight: 300; line-height: .8; }
.component-card-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.component-card-tags > span { padding: 5px 9px; border-radius: 999px; color: var(--muted); background: var(--bg-soft); font-size: 10px; font-weight: 700; overflow-wrap: anywhere; }
.component-card-tags .component-card-match { color: var(--primary-strong); background: var(--primary-soft); }
.component-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.component-card-grid > span { min-width: 0; display: grid; gap: 4px; }
.component-card-grid small { color: var(--muted); font-size: 10px; }
.component-card-grid strong { font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.component-detail-summary { padding: 16px; display: flex; align-items: flex-start; gap: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--primary-softer); }
.component-detail-summary > div { min-width: 0; flex: 1; }
.component-detail-summary .code { color: var(--primary-strong); font-size: 12px; font-weight: 800; }
.component-detail-summary h3 { margin: 5px 0; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.component-detail-summary p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.component-detail-stock { min-width: 92px; padding: 11px 12px; display: grid; justify-items: center; border-radius: 12px; color: var(--green); background: var(--green-soft); }
.component-detail-stock small { font-size: 10px; }
.component-detail-stock strong { margin-top: 2px; font-size: 25px; line-height: 1; }
.component-detail-stock em { margin-top: 4px; font-size: 10px; font-style: normal; }
.component-detail-list { margin: 14px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.component-detail-item { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.component-detail-item.wide { grid-column: 1 / -1; }
.component-detail-item dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.component-detail-item dd { margin: 0; color: var(--ink); line-height: 1.55; overflow-wrap: anywhere; }

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid.five { grid-template-columns: repeat(3, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .bom-upload-grid { grid-template-columns: 1fr; }
}

/* 抽屉断点：侧栏转为可关闭抽屉 */
@media (max-width: 820px) {
  #app-shell { display: block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
    width: min(320px, 85vw); height: auto;
    padding-top: calc(18px + env(safe-area-inset-top));
    transform: translateX(-106%);
    transition: transform .22s ease;
    border-right: 0;
    box-shadow: none;
  }
  body.menu-open .sidebar { transform: translateX(0); box-shadow: 24px 0 64px rgba(5, 3, 14, .4); }
  body.menu-open { overflow: hidden; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(12, 8, 26, .5); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; }
  body.menu-open .drawer-scrim { opacity: 1; visibility: visible; }
  .main { padding: 0 16px calc(30px + env(safe-area-inset-bottom)); }
  .site-footer { margin: -10px 16px calc(20px + env(safe-area-inset-bottom)); }
  .mobile-only { display: grid; }
  .topbar { padding: calc(12px + env(safe-area-inset-top)) 0 12px; align-items: center; gap: 10px; }
  .topbar-title { flex: 1 1 auto; }
  .top-actions { order: 3; flex-basis: 100%; margin-left: 0; justify-content: flex-start; gap: 8px; }
  .button { min-height: 44px; }
  .button.small { min-height: 40px; }
  .icon-button { width: 44px; height: 44px; }
  .nav-item { min-height: 44px; }
  /* 防止 iOS 输入聚焦自动放大 */
  input, select, textarea { font-size: 16px; }
  .filter-row select { min-height: 44px; }
  .search-box input { font-size: 16px; }
  .lcsc-edit-value input, .lcsc-edit-value textarea { font-size: 16px; }
  .stat-grid, .stat-grid.five { grid-template-columns: repeat(2, 1fr); }
  .search-row, .filter-row { align-items: stretch; }
  .search-box { flex-basis: 100%; min-width: 0; }
  .search-row > select, .search-row > .button { flex: 1 1 auto; }
  .result-count { width: 100%; margin: 4px 0 0; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span-2 { grid-column: auto; }
  .assistant-message { max-width: 94%; }
  .assistant-composer { grid-template-columns: 1fr; }
  .assistant-composer .button { width: 100%; }
  .source-cards { grid-template-columns: 1fr; }
  .manual-source-grid { grid-template-columns: 1fr; }
  .lcsc-search-row { align-items: stretch; }
  .lcsc-search-row > input { flex-basis: 100%; min-width: 0; }
  .lcsc-search-row > .button { flex: 1 1 auto; }
  .lcsc-preview-dialog { inset: 10px; border-radius: 14px; }
  .selector-actions { align-items: stretch; }
  .selector-actions > label:first-child { flex: 1 1 100%; }
  .selector-actions > label:first-child select { width: 100%; }
  .selector-actions .button:first-of-type { margin-left: 0; }
  .selector-actions .button { flex: 1 1 auto; }
  .bom-sets-toolbar .button { flex: 1 1 auto; }
  .auth-login-card { padding: 24px 20px; }
  .info-list > div { display: grid; grid-template-columns: minmax(92px, 34%) minmax(0, 1fr); align-items: start; gap: 12px; }
  .info-list dt { flex: none; }
  .info-list dd { text-align: left; line-height: 1.55; }
}

/* 库存表 → 卡片视图 */
@media (max-width: 760px) {
  #view-inventory .table-panel { border: 0; box-shadow: none; background: transparent; }
  #view-inventory .table-panel-head { padding: 0 2px 10px; border-bottom: 0; background: transparent; }
  #view-inventory .table-wrap { border: 0; overflow: visible; background: transparent; }
  #inventory-table .inventory-grid { display: none; }
  .inventory-mobile-cards { display: grid; gap: 12px; }
  #view-inventory .filter-row > select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  #view-inventory .filter-row .column-resize-hint, #view-inventory [data-action="reset-inventory-columns"] { display: none; }
  #view-inventory .filter-row > .button { flex: 1 1 calc(50% - 6px); }
  #view-inventory #inventory-global-sync { flex: 1 1 100%; }
  .component-detail-summary { flex-direction: column; }
  .component-detail-stock { width: 100%; grid-template-columns: auto auto auto; justify-content: center; align-items: baseline; gap: 8px; }
  .component-detail-stock strong { font-size: 22px; }
  .component-detail-list { grid-template-columns: 1fr; }
  .component-detail-item.wide { grid-column: auto; }
  #modal-actions .button { flex: 1 1 calc(50% - 8px); }
}

@media (max-width: 520px) {
  .topbar h2 { font-size: 18px; }
  .topbar p { display: none; }
  .topbar-crumb { font-size: 9px; }
  .top-actions > .button, .top-actions > a.button { flex: 1 1 calc(50% - 8px); }
  .top-actions .auth-user-controls { flex: 1 1 100%; justify-content: space-between; }
  .site-footer { padding: 12px 10px; gap: 5px; }
  .site-footer-separator { display: none; }
  .site-footer span:first-child, .site-footer a { width: 100%; }
  .panel { padding: 15px; }
  .panel-head, .danger-item { align-items: flex-start; flex-direction: column; }
  .panel-head .button-row, .panel-head > .button { width: 100%; }
  .panel-head .button-row .button { flex: 1 1 auto; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); border-radius: 16px; }
  .lcsc-preview-dialog { inset: 6px; }
  .lcsc-preview-dialog .lcsc-preview-head { padding: 12px; }
  .lcsc-preview-dialog .button-row .button { flex: 1 1 calc(50% - 8px); }
  .selector-result-card { grid-template-columns: 1fr; }
  .selector-rank { padding: 8px 12px; flex-direction: row; justify-content: flex-start; gap: 8px; }
  .selector-rank strong { margin: 0; font-size: 16px; }
  .selector-links > span { width: 100%; margin-left: 0; }
  #notice-area { top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); left: calc(12px + env(safe-area-inset-left)); width: auto; }
}

@media (max-width: 420px) {
  .main { padding-left: 10px; padding-right: 10px; }
  .stat-grid, .stat-grid.five, .quick-grid { grid-template-columns: 1fr; }
  .panel { border-radius: 12px; }
  .info-list > div { grid-template-columns: 1fr; gap: 5px; }
  .info-list dt { font-weight: 700; }
  .component-mobile-card { padding: 14px; }
  .component-card-grid { grid-template-columns: 1fr; gap: 9px; }
  .component-card-grid > span { padding-top: 8px; border-top: 1px solid var(--line); }
  .component-card-grid > span:first-child { padding-top: 0; border-top: 0; }
  .component-detail-summary { padding: 14px; }
  #modal-actions .button { flex-basis: 100%; }
}

/* 尊重减少动态偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
