/* ===== Global ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;          /* 禁止整体文档滚动，滚动交给 .main-content */
  line-height: 1.6;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Login ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a5f 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

.login-card h1 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text);
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card .logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-card .logo svg {
  width: 56px;
  height: 56px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.btn-block { width: 100%; padding: 14px; font-size: 15px; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}
.error-msg.ok { color: var(--success); text-align: left; }

/* 登录页：方式切换 / 横幅 / 验证码行 */
.login-banner {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}
.login-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.login-tab {
  flex: 1;
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 0;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.login-tab.active {
  background: rgba(37, 99, 235, 0.16);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.login-note {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.code-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.code-row input { flex: 1; }
.code-row .btn { white-space: nowrap; }

/* ===== Layout ===== */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;          /* 整页固定视口，内部各自滚动 */
}

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;          /* 侧栏自身可滚，但默认固定不动 */
  position: sticky;
  top: 0;
}

.sidebar-logo {
  padding: 0 24px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo h2 {
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: all 0.2s;
  font-size: 14px;
}

.sidebar-nav a:hover {
  background: var(--bg-input);
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--primary);
  color: white;
}

.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sidebar-footer .user-info strong {
  color: var(--text);
}

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;          /* 仅内容区独立滚动 */
  height: 100vh;
  max-width: calc(100vw - 240px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 26px;
  color: var(--text);
}

/* ===== Dashboard Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.stat-card .stat-icon svg { width: 24px; height: 24px; }

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Tables ===== */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.15);
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.08);
}

td { font-size: 14px; color: var(--text); }

/* Search table: sortable headers + per-column filter row */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); background: rgba(37, 99, 235, 0.12); }
.sort-ind { display: inline-block; min-width: 10px; margin-left: 2px; color: var(--primary-light, #60a5fa); font-size: 10px; }
tr.filter-row th {
  background: rgba(0, 0, 0, 0.28);
  padding: 6px 8px;
  text-transform: none;
  font-size: 12px;
  letter-spacing: 0;
}
th.filter-cell { vertical-align: middle; }
.col-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  outline: none;
}
.col-filter:focus { border-color: var(--primary, #3b82f6); }
.col-filter::placeholder { color: var(--text-muted); }

.filter-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
  align-self: center;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-blue { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }
.badge-green { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
.badge-amber { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-purple { background: rgba(147, 51, 234, 0.2); color: #c084fc; }
.badge-red { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-orange { background: rgba(234, 88, 12, 0.2); color: #fb923c; }
.badge-gray { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }

/* ===== BOM Tree Validation ===== */
.bom-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.bom-stat {
  flex: 1 1 180px;
  min-width: 160px;
  background: var(--surface-2, rgba(148,163,184,0.06));
  border: 1px solid var(--border, rgba(148,163,184,0.16));
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 16px;
}
.bom-stat.ok { border-left-color: #22c55e; }
.bom-stat.fail { border-left-color: #ef4444; }
.bom-stat.na { border-left-color: #64748b; }
.bom-stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.bom-stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bom-stat.ok .bom-stat-value { color: #4ade80; }
.bom-stat.fail .bom-stat-value { color: #f87171; }
.bom-stat.na .bom-stat-value { color: #94a3b8; }
.bom-stat-overall {
  flex: 1 1 180px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2, rgba(148,163,184,0.06));
  border: 1px solid var(--border, rgba(148,163,184,0.16));
  border-radius: 10px;
  padding: 14px 16px;
}
.bom-flag { font-size: 13px; margin-top: 4px; }
.bom-flag.ok { color: #4ade80; }
.bom-flag.fail { color: #f87171; }
.bom-flag.na { color: #94a3b8; }

.bom-tree {
  border: 1px solid var(--border, rgba(148,163,184,0.16));
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface-1, rgba(15,23,42,0.3));
}
.bom-node { position: relative; }
.bom-node.root { margin-bottom: 6px; }
.bom-node-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-2, rgba(148,163,184,0.06));
  margin: 6px 0;
  flex-wrap: wrap;
}
.bom-node.root > .bom-node-head {
  background: linear-gradient(90deg, rgba(37,99,235,0.18), rgba(37,99,235,0.04));
  border: 1px solid rgba(59,130,246,0.35);
}
.bom-node.preb > .bom-node-head {
  background: rgba(234,88,12,0.10);
  border: 1px solid rgba(251,146,60,0.35);
}
.bom-node-icon { font-size: 16px; }
.bom-node-title { font-weight: 700; font-size: 14px; }
.bom-node-meta { font-size: 12px; color: var(--text-muted); }
.bom-node-item { font-weight: 600; font-variant-numeric: tabular-nums; }
.bom-node-desc { color: var(--text-muted); font-size: 13px; flex: 1 1 auto; min-width: 120px; }
.bom-children { padding-left: 22px; border-left: 2px dashed rgba(148,163,184,0.25); margin-left: 8px; }
.bom-children.grade { border-left-color: rgba(251,146,60,0.35); }
.bom-bullet { width: 8px; height: 8px; border-radius: 50%; background: #60a5fa; flex: 0 0 auto; }
.bom-bullet.small { width: 6px; height: 6px; background: #fb923c; }
.bom-node.grade-item > .bom-node-head { background: rgba(251,146,60,0.06); }
.bom-grade-head > .bom-node-meta { font-weight: 600; color: #fb923c; }
.bom-pct {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(148,163,184,0.16);
  color: var(--text, #e2e8f0);
  white-space: nowrap;
}
.bom-pct.ok { background: rgba(34,197,94,0.18); color: #4ade80; }
.bom-pct.fail { background: rgba(239,68,68,0.18); color: #f87171; }
.bom-qty {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bom-qty.gm { color: #c4b5fd; }            /* 色母用 GM 标注，用紫色区分 */

/* 母料两个分支：基料(Grade) / 色母(Color) */
.bom-branch {
  margin: 8px 0 8px 22px;
  border-left: 2px solid var(--border, rgba(148,163,184,0.2));
  padding-left: 14px;
}
.bom-branch.color { border-left-color: rgba(168,85,247,0.5); }
.bom-branch.grade { border-left-color: rgba(56,189,248,0.5); }
.bom-node-head.branch-head {
  background: rgba(148,163,184,0.08);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
}
.bom-branch.color .branch-head { background: rgba(168,85,247,0.1); }
.bom-branch.grade .branch-head { background: rgba(56,189,248,0.08); }
.bom-node.grade-item, .bom-node.color-item {
  background: rgba(148,163,184,0.04);
  border-radius: 8px;
  margin-bottom: 4px;
}
.bom-node.color-item .bom-node-item { color: #c4b5fd; }
.bom-preb-foot {
  margin: 8px 0 4px 22px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.bom-preb-foot strong { color: var(--text); }

.bom-diag {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border, rgba(148,163,184,0.16));
  font-size: 13px;
  color: var(--text-muted);
}
.bom-diag strong { color: var(--text, #e2e8f0); font-variant-numeric: tabular-nums; }

.bom-color {
  margin-top: 16px;
  border: 1px solid rgba(168,85,247,0.4);
  border-radius: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(168,85,247,0.08), rgba(168,85,247,0.02));
}
.bom-color-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #c4b5fd;
  margin-bottom: 12px;
}
.bom-color-head svg { width: 18px; height: 18px; }
.bom-color-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.bom-color-grid .bom-stat { flex: 1 1 200px; }
.bom-color-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(234,179,8,0.08);
  border-left: 3px solid #eab308;
  border-radius: 6px;
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 300px;
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

/* ===== Filters ===== */
.filters-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

.filters-panel .filter-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.filters-grid .form-group { margin-bottom: 0; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination button {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 12px;
}

/* ===== Detail Page ===== */
.detail-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  margin: -32px -32px 24px;     /* 抵消 main-content 的 32px padding，使顶栏贴边固定 */
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* 组成表（参照 Sabic 配方提炼 六列样式） */
.composition-table th,
.composition-table td { text-align: left; }   /* 表头与所有内容均靠左对齐 */
.composition-table .num { text-align: left; }/* 覆盖默认右对齐，按需求全部靠左 */
.composition-table .comp-total {
  vertical-align: middle; text-align: left;
  background: rgba(148,163,184,0.10);
}
.composition-table .lvl-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.composition-table .lvl-1 { color: #93c5fd; background: rgba(59,130,246,0.15); }
.composition-table .lvl-2 { color: #fdba74; background: rgba(251,146,60,0.15); }
.composition-table .lvl-3 { color: #d8b4fe; background: rgba(168,85,247,0.15); }
.composition-table tr.lv-1 td { border-left: 4px solid rgba(59,130,246,0.55); }
.composition-table tr.lv-2 td { border-left: 4px solid rgba(251,146,60,0.55); }
.composition-table tr.lv-3 td { border-left: 4px solid rgba(168,85,247,0.55); }
.composition-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.composition-table .mat-type {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px;
  background: rgba(148,163,184,0.16); color: #cbd5e1;
}
.comp-note {
  font-size: 12px; color: var(--text-muted); margin-top: 10px; line-height: 1.5;
  padding: 8px 12px; background: rgba(37,99,235,0.07); border-left: 3px solid var(--primary); border-radius: 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
}

.detail-card h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-card h3 svg { width: 20px; height: 20px; color: var(--primary-light); }

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.detail-row:last-child { border-bottom: none; }

.detail-row .label {
  color: var(--text-muted);
  font-size: 14px;
}

.detail-row .value {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: right;
}

.detail-card.full-width { grid-column: 1 / -1; }

/* ===== Zone Temperature Display ===== */
.zone-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.zone-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
  min-width: 80px;
}

.zone-box .zone-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.zone-box .zone-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-light);
  margin-top: 4px;
}

/* ===== Loading Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px;
  color: var(--text-muted);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

/* ===== Full Text View ===== */
.full-text-view {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-muted);
}

/* ===== PDF Preview ===== */
.pdf-page {
  margin: 0 auto 16px;
  max-width: 860px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.pdf-page img.pdf-preview {
  display: block;
  width: 100%;
  height: auto;
  border: none;
  border-radius: 0;
}
.pdf-page-num {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 7px 10px;
  background: rgba(127, 127, 127, 0.08);
  border-top: 1px solid var(--border);
}

/* ===== 设置页：修改密码 + 角色权限配置 并排 ===== */
.settings-top { display: flex; gap: 20px; align-items: flex-start; }
.settings-top > .detail-card { flex: 1 1 0; min-width: 0; }

.rc-wrap { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.rc-row { display: flex; align-items: center; gap: 14px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-muted); }
.rc-role { flex: 0 0 92px; }
.rc-field { flex: 1 1 0; min-width: 0; }
.rc-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.rc-field input { width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-card); color: var(--text); font-size: 14px; }
.rc-sub { font-size: 10px; color: var(--text-muted); }

/* ===== Mobile Top Bar & Drawer Nav (≤768px) ===== */
/* 默认（桌面）隐藏，移动端媒体查询内显示 */
.mobile-topbar { display: none; }
.nav-overlay { display: none; }

@media (max-width: 768px) {
  .settings-top { flex-direction: column; }
  .settings-top > .detail-card { width: 100%; }
  .rc-row { flex-wrap: wrap; }
  .rc-role { flex: 0 0 100%; }
}

@media (max-width: 768px) {
  /* 顶部固定栏：汉堡按钮 + 应用名 */
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 54px;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    z-index: 1100;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
  }
  .hamburger {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
  }
  .mobile-topbar .app-name { font-size: 15px; font-weight: 600; color: var(--text); }

  /* 侧栏改为可滑出抽屉，由汉堡按钮控制开合（默认隐藏，不占布局） */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 80%;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1101;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open { transform: translateX(0); }

  /* 抽屉外遮罩：点击空白处关闭 */
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1090;
  }
  .nav-overlay.open { display: block; }

  /* 内容区：顶部为底部栏(54px)留出空间，避免被遮挡 */
  .main-content {
    max-width: 100%;
    height: 100vh;
    padding: 70px 14px 16px;
  }

  /* 搜索页顶部固定搜索栏：下移到底部栏之下 */
  .search-topbar { top: 54px; background: var(--bg); z-index: 1080; }

  /* 详情页 sticky 顶栏：抵消移动端新的 padding，且吸顶于底部栏之下 */
  .detail-header {
    top: 54px;
    margin: -70px -14px 16px;
    padding: 16px 14px;
  }

  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  box-shadow: var(--shadow);
  z-index: 9999;
  animation: slideIn 0.3s ease;
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 三层架构主视觉 ===== */
.arch-card {
  border: 1px solid rgba(59,130,246,0.4);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.15), var(--shadow);
  margin-bottom: 20px;
}
.arch-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.arch-head h3 { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.arch-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.arch-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; font-size: 12px; color: var(--text-muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lg b { color: var(--text); font-variant-numeric: tabular-nums; }
.lg.feed::before, .lg.preb::before, .lg.base::before, .lg.color::before {
  content: ''; width: 12px; height: 12px; border-radius: 3px; display: inline-block;
}
.lg.feed::before { background: #3b82f6; }
.lg.preb::before { background: #fb923c; }
.lg.base::before { background: #38bdf8; }
.lg.color::before { background: #a855f7; }
.lg.eq.ok { color: #4ade80; }
.lg.eq.fail { color: #f87171; }
.lg.gray { color: #94a3b8; }

.arch-layer { display: flex; gap: 14px; align-items: stretch; margin: 14px 0; }
.arch-layer-tag {
  flex: 0 0 64px; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 12px; font-weight: 700; border-radius: 10px; padding: 8px 4px; color: #fff; line-height: 1.3;
}
.arch-layer-tag.l1 { background: linear-gradient(135deg,#1d4ed8,#3b82f6); }
.arch-layer-tag.l3 { background: linear-gradient(135deg,#7c3aed,#a855f7); }
.arch-layer-body { flex: 1; min-width: 0; background: rgba(148,163,184,0.05); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.arch-layer-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }

.prop-bar {
  display: flex; width: 100%; height: 40px; border-radius: 8px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
}
.seg { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 0; }
.seg-label {
  font-size: 11px; font-weight: 700; color: #0f172a; white-space: nowrap; padding: 0 4px;
  text-shadow: 0 1px 1px rgba(255,255,255,0.3);
}
.seg-preb { background: #fb923c; }
.seg-feed { background: #3b82f6; opacity: 0.92; }
.seg-base { background: #38bdf8; }
.seg-color { background: #a855f7; }
.seg-empty { background: rgba(148,163,184,0.2); color: var(--text-muted); align-items: center; font-size: 12px; }
.prop-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.prop-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--text-muted); }

.arch-connector { display: flex; flex-direction: column; align-items: center; margin: 6px 0; }
.connector-dot { width: 12px; height: 12px; border-radius: 50%; background: #fb923c; box-shadow: 0 0 0 4px rgba(251,146,60,0.2); }
.connector-line { width: 2px; height: 22px; background: linear-gradient(180deg,#fb923c,rgba(168,85,247,0.7)); }
.connector-label { font-size: 13px; color: var(--text-muted); text-align: center; }
.connector-label b { color: var(--text); font-variant-numeric: tabular-nums; }

.arch-note {
  margin-top: 16px; font-size: 12.5px; color: var(--text-muted); line-height: 1.6;
  padding: 12px 14px; background: rgba(37,99,235,0.07); border-left: 3px solid var(--primary); border-radius: 6px;
}
.arch-note b { color: var(--text); }

.bom-tree-title { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; }

tbody tr.row-preb { background: rgba(251,146,60,0.10); }
tbody tr.row-preb:hover { background: rgba(251,146,60,0.16); }

.grade-color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sub-head { font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 8px 8px 0 0; }
.sub-head.sub-base { background: rgba(56,189,248,0.14); color: #7dd3fc; }
.sub-head.sub-color { background: rgba(168,85,247,0.14); color: #c4b5fd; }
.branch-foot { font-size: 12.5px; padding: 10px 12px; border-radius: 0 0 8px 8px; background: rgba(148,163,184,0.06); color: var(--text-muted); }
.branch-foot.sub-base { border-top: 2px solid rgba(56,189,248,0.4); }
.branch-foot.sub-color { border-top: 2px solid rgba(168,85,247,0.4); }
.branch-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.recon-foot {
  grid-column: 1 / -1; margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.3);
  font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.recon-foot b { color: var(--text); }

@media (max-width: 768px) {
  .grade-color-grid { grid-template-columns: 1fr; }
  .arch-layer-tag { flex-basis: 48px; }
}

/* ===== 用户使用历史看板（设置页）===== */
.page-header .subtitle { color: var(--text-muted); font-size: 14px; margin: 6px 0 0; }

/* 配方搜索：筛选框以上部分固定不动 */
.search-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.search-topbar .page-header { margin-bottom: 14px; }

/* 设置页：使用历史筛选与统计 */
.usage-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.usage-filters .form-group { margin-bottom: 0; min-width: 120px; }
.usage-filter-actions { display: flex; gap: 8px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card.stat-view { border-left: 3px solid rgba(74,222,128,0.6); }
.stat-card.stat-dl { border-left: 3px solid rgba(168,85,247,0.6); }
.stat-card.stat-user { border-left: 3px solid rgba(56,189,248,0.6); }

.spec-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.spec-link:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .usage-filters { gap: 12px; }
}

/* ===== 设置页：修改密码 / 账户管理 ===== */
.role-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}
.role-admin { background: #ede9fe; color: #7c3aed; }
.role-advanced { background: #dbeafe; color: #2563eb; }
.role-normal { background: #dcfce7; color: #16a34a; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 { margin: 0; }

.cp-form {
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cp-form .form-group { margin: 0; }
.form-msg { font-size: 13px; min-height: 18px; }
.form-msg.ok { color: #16a34a; }
.form-msg.err { color: #c0392b; }
.form-hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; line-height: 1.5; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 24px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal-box h3 { margin: 0 0 16px; }
.modal-box .form-group { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin: 4px 0 14px;
  color: var(--text, #1f2937);
  cursor: pointer;
}
.checkbox-line input { width: 16px; height: 16px; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-danger { color: #c0392b; }
.btn-danger:hover { background: #fde8e8; }
