/* =========================================================
   力王AI自动分析供应商不良率 · 钉钉 H5 微应用样式
   ========================================================= */

:root {
  --brand: #1677ff;
  --brand-d: #0b5cd5;
  --brand-l: #e8f1ff;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c1f23;
  --text-2: #5a6472;
  --text-3: #8a94a6;
  --line: #e6e9ef;
  --good: #00b578;
  --good-l: #e6f8f1;
  --warn: #ff8f1f;
  --warn-l: #fff4e6;
  --bad: #f5222d;
  --bad-l: #ffecec;
  --radius: 12px;
  --topbar-h: 58px;   /* 顶栏实际高度由 JS 动态测量写入（标题会折行，高度不固定） */
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(24px + var(--safe-b)); }

#app { max-width: 1180px; margin: 0 auto; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--brand) 0%, #3d94ff 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(22, 119, 255, .25);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar .logo {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px;
  background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: 0;
}
/* 应用名较长（力王AI自动分析供应商不良率），允许折成两行，避免被截断 */
.topbar h1 {
  margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.topbar .sub { margin: 2px 0 0; font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, .18); color: #fff;
  border: 0; border-radius: 8px; padding: 7px 11px; font-size: 12.5px;
  font-family: inherit; cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, .32); }

/* ---------------- Tab ---------------- */
.tabs {
  position: sticky; top: var(--topbar-h, 58px); z-index: 39;
  display: flex; background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; min-width: 84px;
  border: 0; background: none; font-family: inherit; font-size: 13.5px;
  color: var(--text-2); padding: 11px 6px 9px; cursor: pointer;
  position: relative; white-space: nowrap;
}
.tabs button.active { color: var(--brand); font-weight: 600; }
.tabs button.active::after {
  content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand);
}
.tabs .badge {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px;
  background: var(--bad); color: #fff; border-radius: 8px; font-size: 10px; line-height: 16px;
  vertical-align: 1px;
}

main { padding: 12px; }
@media (min-width: 700px) { main { padding: 16px; } }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card > h2 {
  margin: 0 0 10px; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.card > h2 .dot { width: 4px; height: 15px; border-radius: 2px; background: var(--brand); }
.card > h2 .hint { margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.card-sub { font-size: 12px; color: var(--text-3); margin: -6px 0 10px; }

/* ---------------- 上传 ---------------- */
.dropzone {
  border: 2px dashed #c3d4ee; border-radius: var(--radius);
  background: #fafcff; padding: 26px 16px; text-align: center;
  transition: .18s; cursor: pointer;
}
.dropzone.dragover { border-color: var(--brand); background: var(--brand-l); }
.dropzone .ic { font-size: 34px; line-height: 1; }
.dropzone .t1 { font-size: 15px; font-weight: 600; margin-top: 8px; }
.dropzone .t2 { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.dropzone .btn { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 9px; padding: 10px 18px;
  font-size: 14px; font-family: inherit; font-weight: 500;
  background: var(--brand); color: #fff; cursor: pointer; transition: .15s;
}
.btn:active { background: var(--brand-d); transform: scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.ghost { background: var(--brand-l); color: var(--brand); }
.btn.gray { background: #eef1f5; color: var(--text-2); }
.btn.good { background: var(--good); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }

.progress { height: 6px; border-radius: 3px; background: #e9edf3; overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.file-chip {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--brand-l); border-radius: 9px; font-size: 13px; margin-bottom: 10px;
}
.file-chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field > label .req { color: var(--bad); }
select, input[type=text], input[type=password], input[type=number], textarea {
  width: 100%; padding: 10px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text);
  appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' stroke='%238a94a6' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
select:focus, input:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 119, 255, .12); }
textarea { min-height: 68px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 13.5px; }
.switch input { width: 42px; height: 24px; appearance: none; -webkit-appearance: none; background: #d8dee8; border-radius: 12px; position: relative; transition: .18s; cursor: pointer; flex: 0 0 42px; }
.switch input:checked { background: var(--brand); }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked::after { left: 20px; }

/* 字段映射表 */
.maplist { display: flex; flex-direction: column; gap: 8px; }
.maprow { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fafbfd; border: 1px solid var(--line); border-radius: 9px; }
.maprow .role { flex: 0 0 96px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.maprow .role em { display: block; font-style: normal; font-weight: 400; font-size: 10.5px; color: var(--text-3); }
.maprow select { flex: 1; padding: 7px 26px 7px 9px; font-size: 13px; }
.maprow.ok { border-color: #bfe6d5; background: #f6fdfa; }
.maprow.miss { border-color: #f7d0d0; background: #fff8f8; }

.wide-cols { display: flex; flex-wrap: wrap; gap: 6px; }
.wide-cols label { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; background: #f1f4f9; border-radius: 15px; font-size: 12.5px; cursor: pointer; }
.wide-cols input { width: 14px; height: 14px; accent-color: var(--brand); }

.alert { padding: 10px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 10px; line-height: 1.6; }
.alert.warn { background: var(--warn-l); color: #a35b00; }
.alert.err { background: var(--bad-l); color: #a8071a; }
.alert.info { background: var(--brand-l); color: var(--brand-d); }
.alert.ok { background: var(--good-l); color: #00734f; }
.alert b { font-weight: 600; }

/* ---------------- 决策摘要（行动清单） ---------------- */
.actionlist { display: flex; flex-direction: column; gap: 9px; }
.action {
  border-radius: 10px; padding: 11px 12px; border-left: 4px solid var(--text-3);
  background: #f8fafd; position: relative;
}
.action.blocker { border-left-color: #722ed1; background: #f6f0ff; }
.action.high { border-left-color: var(--bad); background: #fff5f5; }
.action.mid { border-left-color: var(--warn); background: #fffaf2; }
.action.low { border-left-color: var(--brand); background: #f4f9ff; }
.action .ah { display: flex; align-items: baseline; gap: 7px; margin-bottom: 3px; }
.action .no {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; background: var(--text-3);
  color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.action.blocker .no { background: #722ed1; }
.action.high .no { background: var(--bad); }
.action.mid .no { background: var(--warn); }
.action.low .no { background: var(--brand); }
.action .at { font-size: 13.5px; font-weight: 700; line-height: 1.4; }
.action .ad { font-size: 12.5px; color: var(--text-2); line-height: 1.65; margin: 4px 0 0 25px; }
.action .ad b { color: var(--text); }
.action .act {
  font-size: 12px; margin: 6px 0 0 25px; padding-top: 6px; border-top: 1px dashed rgba(0,0,0,.09);
  color: var(--brand-d);
}
.action .act b { font-weight: 700; }
.action .gain {
  display: inline-block; background: rgba(0,0,0,.05); border-radius: 5px;
  padding: 0 6px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* 责任归属标签 */
.tag { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; margin-left: 5px; vertical-align: 1px; font-weight: 600; }
.tag.supplier { background: var(--bad-l); color: #a8071a; }
.tag.part { background: #f0e6ff; color: #531dab; }
.tag.stable { background: #eef1f5; color: var(--text-2); }

/* 损失条（改善机会） */
.lossbar { display: inline-block; height: 6px; border-radius: 3px; background: var(--bad); vertical-align: middle; }

/* ---------------- 分析区间条 ---------------- */
.rangebar {
  border: 1px solid #cfe0f7; background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
  border-left: 4px solid var(--brand);
}
.rangebar.filtered { border-color: #ffe0b8; background: linear-gradient(180deg, #fffcf6 0%, #fff7e8 100%); border-left-color: var(--warn); }
.rangebar .rb-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 9px; }
.rangebar .rb-label {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--brand);
  padding: 2px 7px; border-radius: 5px; flex: 0 0 auto;
}
.rangebar.filtered .rb-label { background: var(--warn); }
.rangebar .rb-cur { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.rangebar .rb-meta { font-size: 11.5px; color: var(--text-2); }
.rangebar .rb-note { font-size: 11.5px; color: #96540a; margin-top: 8px; }
.rangebar .rb-custom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.rangebar .rb-custom input[type=date] {
  padding: 6px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-family: inherit; flex: 0 0 auto; width: auto;
}
.rangebar .rb-custom .sep { color: var(--text-3); }

/* ---------------- 登录页 ---------------- */
.login-screen {
  position: fixed; inset: 0; z-index: 500; overflow: auto;
  background: linear-gradient(160deg, #1677ff 0%, #3d94ff 45%, #eaf3ff 100%);
  display: flex; align-items: center; justify-content: center; padding: 22px 16px;
  padding-bottom: calc(22px + var(--safe-b));
}
.login-box {
  width: min(94vw, 400px); background: #fff; border-radius: 16px;
  padding: 26px 22px 20px; box-shadow: 0 12px 40px rgba(9, 30, 66, .22);
}
.login-logo {
  width: 48px; height: 48px; border-radius: 13px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #4aa3ff 100%);
  color: #fff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-box h1 { margin: 0; font-size: 17px; font-weight: 700; text-align: center; line-height: 1.4; }
.login-sub { margin: 5px 0 18px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.login-hint {
  margin-top: 12px; padding: 9px 11px; border-radius: 9px; font-size: 12px; line-height: 1.7;
  background: var(--warn-l); color: #96540a;
}
.login-hint b { font-weight: 700; }
.login-hint code {
  background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.login-roles { margin-top: 16px; padding-top: 13px; border-top: 1px dashed var(--line); }
.login-roles .lr-title { font-size: 11.5px; color: var(--text-3); margin-bottom: 7px; }
.login-roles .lr { display: flex; gap: 7px; font-size: 11.5px; color: var(--text-2); line-height: 1.65; margin-bottom: 5px; }
.login-roles .lr b { flex: 0 0 58px; color: var(--text); font-weight: 600; }

/* 顶栏用户名按钮 */
.user-chip {
  position: fixed; z-index: 400; left: 50%; transform: translateX(-50%);
  top: 62px; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(9,30,66,.2);
  padding: 6px; min-width: 210px; display: none;
}
.user-chip.on { display: block; }
.user-chip .uc-head { padding: 9px 11px 10px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.user-chip .uc-name { font-size: 14px; font-weight: 600; }
.user-chip .uc-role { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.user-chip button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  font-family: inherit; font-size: 13.5px; color: var(--text); padding: 10px 11px;
  border-radius: 8px; cursor: pointer;
}
.user-chip button:hover, .user-chip button:active { background: var(--brand-l); color: var(--brand-d); }
.user-chip button.danger { color: var(--bad); }

/* 权限不足提示 */
.no-perm {
  text-align: center; padding: 40px 20px; color: var(--text-3);
}
.no-perm .ic { font-size: 42px; opacity: .4; }
.no-perm .t { margin-top: 10px; font-size: 15px; color: var(--text-2); font-weight: 600; }
.no-perm .s { margin-top: 6px; font-size: 12.5px; line-height: 1.7; }

/* 用户管理表 */
table.tbl.users td, table.tbl.users th { text-align: left; }
table.tbl.users select { padding: 5px 24px 5px 8px; font-size: 12.5px; }

/* 数据体检 */
.chklist { display: flex; flex-direction: column; gap: 7px; }
.chk {
  font-size: 12.5px; line-height: 1.65; padding: 8px 11px; border-radius: 8px;
  background: #f8fafd; border-left: 3px solid #ccd6e4; color: var(--text-2);
}
.chk b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chk.ok { background: var(--good-l); border-left-color: var(--good); color: #026e4e; }
.chk.ok b { color: #026e4e; }
.chk.warn { background: var(--warn-l); border-left-color: var(--warn); color: #96540a; }
.chk.warn b { color: #96540a; }
.chk.diff { background: var(--bad-l); border-left-color: var(--bad); color: #a8071a; }
.chk.diff b { color: #a8071a; }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--card); border-radius: var(--radius); padding: 13px 14px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.kpi .v { font-size: 23px; font-weight: 700; line-height: 1.15; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 12.5px; font-weight: 500; margin-left: 2px; color: var(--text-3); }
.kpi .d { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.kpi.hero { grid-column: span 2; background: linear-gradient(135deg, #1677ff 0%, #4aa3ff 100%); color: #fff; }
.kpi.hero .k, .kpi.hero .d { color: rgba(255, 255, 255, .82); }
.kpi.hero .v { font-size: 32px; }
.kpi .badge2 { position: absolute; top: 10px; right: 10px; font-size: 10.5px; padding: 2px 7px; border-radius: 8px; background: rgba(255,255,255,.22); }

/* ---------------- 良率配色 ---------------- */
.y-good { color: var(--good); }
.y-ok { color: #4aa3ff; }
.y-warn { color: var(--warn); }
.y-bad { color: var(--bad); }
.bg-good { background: var(--good-l); }
.bg-ok { background: var(--brand-l); }
.bg-warn { background: var(--warn-l); }
.bg-bad { background: var(--bad-l); }

/* ---------------- 料号对比卡 ---------------- */
.partcard { border: 1px solid var(--line); border-radius: 11px; margin-bottom: 10px; overflow: hidden; }
.partcard > .head {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  background: #f8fafd; border-bottom: 1px solid var(--line); cursor: pointer;
}
.partcard > .head .pn { font-weight: 700; font-size: 14px; }
.partcard > .head .meta { font-size: 11.5px; color: var(--text-3); }
.partcard > .head .spread { margin-left: auto; text-align: right; font-size: 11.5px; color: var(--text-3); }
.partcard > .head .spread b { display: block; font-size: 15px; color: var(--bad); }
.partcard > .body { padding: 4px 12px 10px; }
.partcard.collapsed > .body { display: none; }

.srow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed #eef1f5; }
.srow:last-child { border-bottom: 0; }
.srow .rk {
  flex: 0 0 20px; height: 20px; border-radius: 6px; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; background: #eef1f5; color: var(--text-2);
}
.srow .rk.r1 { background: var(--good); color: #fff; }
.srow .rk.rn { background: var(--bad); color: #fff; }
.srow .nm { flex: 1; min-width: 0; }
.srow .nm .n { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .nm .d { font-size: 11px; color: var(--text-3); }
.srow .yv { flex: 0 0 auto; text-align: right; font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.srow .gap { flex: 0 0 52px; text-align: right; font-size: 11px; color: var(--text-3); }
.bar { height: 5px; border-radius: 3px; background: #eef1f5; margin-top: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; }

/* ---------------- 表格 ---------------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 520px; }
table.tbl th, table.tbl td { padding: 8px 9px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { background: #f8fafd; color: var(--text-2); font-weight: 600; font-size: 11.5px; position: sticky; top: 0; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
table.tbl tr:active { background: #f8fafd; }
table.tbl td.bad-cell { color: var(--bad); font-weight: 600; }

/* 热力图 */
.hm { border-collapse: separate; border-spacing: 2px; font-size: 11px; }
.hm th { font-weight: 500; color: var(--text-2); padding: 4px 6px; font-size: 10.5px; white-space: nowrap; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.hm th.rowh { text-align: right; position: sticky; left: 0; background: var(--card); z-index: 1; }
.hm td { width: 62px; height: 34px; border-radius: 6px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; color: #fff; }
.hm td.empty { background: #f4f6f9; color: #ccd3de; font-weight: 400; }
.hm td.best { outline: 2px solid var(--good); outline-offset: -2px; }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0 2px; font-size: 11.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tip {
  position: absolute; pointer-events: none; background: rgba(28,31,35,.92); color: #fff;
  font-size: 11.5px; padding: 6px 9px; border-radius: 7px; white-space: nowrap;
  transform: translate(-50%, -120%); opacity: 0; transition: opacity .12s; z-index: 5; line-height: 1.5;
}
.tip.on { opacity: 1; }
.tip b { color: #7cc0ff; }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 16px; padding: 5px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }

/* ---------------- 预警列表 ---------------- */
.alist { display: flex; flex-direction: column; gap: 8px; }
.aitem { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bad-l); }
.aitem.mid { background: var(--warn-l); }
.aitem .lv { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--bad); color: #fff; }
.aitem.mid .lv { background: var(--warn); }
.aitem .in { flex: 1; min-width: 0; }
.aitem .in .l1 { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aitem .in .l2 { font-size: 11.5px; color: var(--text-2); }
.aitem .rt { text-align: right; font-variant-numeric: tabular-nums; }
.aitem .rt .v { font-size: 15px; font-weight: 700; color: var(--bad); }
.aitem.mid .rt .v { color: var(--warn); }
.aitem .rt .s { font-size: 11px; color: var(--text-3); }

/* ---------------- 空态 ---------------- */
.empty { text-align: center; padding: 44px 18px; color: var(--text-3); }
.empty .ic { font-size: 46px; opacity: .35; }
.empty .t { margin-top: 10px; font-size: 14px; color: var(--text-2); }
.empty .s { margin-top: 5px; font-size: 12.5px; }

/* ---------------- Toast / Modal ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 42px; transform: translate(-50%, 16px);
  background: rgba(28,31,35,.93); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; max-width: 84vw; text-align: center; opacity: 0; pointer-events: none;
  transition: .22s; z-index: 200; line-height: 1.5;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: rgba(190, 18, 30, .95); }
#toast.ok { background: rgba(0, 137, 90, .95); }

/* ---------------- 页脚（ICP 备案号）---------------- */
#site-footer {
  padding: 18px 16px calc(14px + var(--safe-b));
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}
#site-footer a { color: inherit; text-decoration: none; }
#site-footer a:hover { text-decoration: underline; }

#modal { position: fixed; inset: 0; z-index: 300; display: none; }
#modal.on { display: block; }
#modal .mask { position: absolute; inset: 0; background: rgba(0,0,0,.42); }
#modal .box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 560px); max-height: 84vh; overflow: auto;
  background: #fff; border-radius: 14px; padding: 16px;
}
#modal .box h3 { margin: 0 0 10px; font-size: 15.5px; }
#modal .box .acts { display: flex; gap: 8px; margin-top: 14px; }
#modal .box .acts .btn { flex: 1; }
pre.msg {
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  font-size: 11.5px; line-height: 1.62; overflow: auto; max-height: 46vh; white-space: pre-wrap;
  word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; margin: 0;
}
.busy { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hist { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; }
.hist .in { flex: 1; min-width: 0; }
.hist .in .l1 { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .in .l2 { font-size: 11.5px; color: var(--text-3); }
.hist .yv { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: var(--brand-l); color: var(--brand); margin-left: 5px; vertical-align: 1px; }
.collapse-head { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.collapse-head .arw { transition: .18s; color: var(--text-3); font-size: 11px; }
.collapse.closed .collapse-body { display: none; }
.collapse.closed .collapse-head .arw { transform: rotate(-90deg); }
