:root {
  --navy: #13305a;
  --blue: #1d5bab;
  --blue-soft: #e8f0fa;
  --line: #dbe4ef;
  --ink: #1b2a41;
  --muted: #5b6b80;
  --bg: #f3f6fa;
  --ok-bg: #e7f6ec; --ok: #1d7a3d;
  --err-bg: #fdecec; --err: #b42318;
  --warn-bg: #fff6e5; --warn: #8a5a00;
  --mono: Consolas, "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
h1, h2, h3, h4 { font-size: 16px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* 外壳：左侧菜单 + 顶栏 + 标签栏 + 标签页 iframe */
body.shell-body { height: 100vh; overflow: hidden; background: #fff; }
.shell { display: flex; height: 100vh; }
.side { width: 216px; flex: none; background: var(--navy); color: #fff; display: flex; flex-direction: column; overflow-y: auto; }
.brand { padding: 20px 18px; display: flex; align-items: center; color: #fff; }
.brand .logo { display: block; height: 24px; width: auto; }
.login-logo { color: var(--navy); margin-bottom: 18px; }
.login-logo .logo { display: block; height: 28px; width: auto; }
.side nav { flex: 1; }
.side nav .group { font-size: 18px; color: #9fb3cf; padding: 14px 18px 6px; }
.side nav a { display: block; color: #dce6f4; padding: 8px 18px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #6ea3ea; font-weight: 700; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { flex: none; height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: linear-gradient(90deg, var(--navy) 0%, var(--blue) 100%); color: #fff; }
.sys-name { min-width: 0; font-size: 18px; font-weight: 700; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-name span { margin-left: 10px; font-size: 12px; font-weight: 400; letter-spacing: 1px; color: rgba(255,255,255,.65); }
.topbar .user-menu summary { color: #fff; }
.topbar .user-menu summary:hover, .topbar .user-menu[open] summary { background: rgba(255,255,255,.14); box-shadow: none; }
.topbar .user-menu .avatar { background: #fff; color: var(--navy); }
.topbar .user-menu .caret { border-top-color: rgba(255,255,255,.8); }
.tabbar { flex: none; height: 42px; display: flex; align-items: stretch; background: #fff; box-shadow: 0 1px 3px rgba(19,48,90,.08); position: relative; z-index: 2; }
.tabs { flex: 1; min-width: 0; display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: flex; align-items: center; gap: 6px; max-width: 220px; padding: 0 16px; color: #4a5566; cursor: pointer; user-select: none; position: relative; white-space: nowrap; }
.tab.fixed { background: #f6f8fb; }
.tab:hover { color: var(--blue); }
.tab.active { color: var(--ink); font-weight: 700; }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; border-radius: 1px; background: var(--blue); }
.tab:focus-visible { outline: 2px solid #a9c6ec; outline-offset: -2px; }
.tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab-close { width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: none; color: #8a94a3; font: 14px/16px sans-serif; cursor: pointer; }
.tab-close:hover { background: #e5484d; color: #fff; }
.tab-ctrl { flex: none; display: flex; align-items: center; padding: 0 6px; border-left: 1px solid #eef1f5; }
.tab-ctrl button { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: #4a5566; cursor: pointer; border-radius: 4px; }
.tab-ctrl button:hover:not(:disabled) { color: var(--blue); background: var(--blue-soft); }
.tab-ctrl button:disabled { color: #c8ced8; cursor: default; }
.tab-ctrl svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-menu { position: fixed; z-index: 60; min-width: 120px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(19,48,90,.16); padding: 4px 0; }
.tab-menu[hidden] { display: none; }
.tab-menu button { display: block; width: 100%; text-align: left; padding: 6px 16px; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.tab-menu button:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.tab-menu button:disabled { color: #c0c4cc; cursor: default; }
.tab-menu hr { margin: 4px 0; border: 0; border-top: 1px solid #eef1f5; }
.frames { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.frames iframe[hidden] { display: none; }
/* 标签页内的页面 */
.main { padding: 16px 20px 24px; }
.user-menu { position: relative; flex: none; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 20px; color: var(--ink); user-select: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: #fff; box-shadow: 0 0 0 1px var(--line); }
.user-menu .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.user-menu .caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: var(--muted); margin-top: 4px; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 140px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(19,48,90,.14); padding: 6px 0; z-index: 50; }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left; padding: 7px 16px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--blue-soft); text-decoration: none; }
.user-menu .menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }


.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; border: 1px solid #c5d1df; border-radius: 6px; padding: 6px 9px; background: #fff; min-width: 140px;
}
textarea { width: 100%; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a9c6ec; border-color: var(--blue); }
.btn { font: inherit; border: 1px solid var(--blue); background: var(--blue); color: #fff; border-radius: 6px; padding: 6px 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--blue); }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.small { padding: 3px 10px; font-size: 14px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
form.inline { display: inline; }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { background: #f6f9fc; font-weight: 700; color: var(--muted); font-size: 14px; white-space: nowrap; }
.grid tr:last-child td { border-bottom: 0; }
.grid th.num, .grid td.num { text-align: right; }
.grid td.mono, .grid td .mono { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 0 !important; }

.tag { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; line-height: 20px; background: #eef2f7; color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--blue-soft); color: var(--blue); }

/* 列表页筛选栏 */
.filter-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-bar input[type=text], .filter-bar input[type=date], .filter-bar select { height: 32px; padding: 4px 8px; border-color: #dcdfe6; border-radius: 4px; min-width: 0; }
.filter-bar > select { width: 120px; }
.filter-bar .filter-kw { width: 200px; }
.filter-bar .btn { height: 32px; padding: 0 12px; border-radius: 4px; }
.date-range { display: inline-flex; align-items: center; height: 32px; border: 1px solid #dcdfe6; border-radius: 4px; background: #fff; padding: 0 4px; }
.date-range:focus-within { border-color: var(--blue); }
.date-range input[type=date] { border: 0; height: 30px; width: 130px; padding: 0 4px; }
.date-range input[type=date]:focus { outline: none; }
/* 日期选择（datepicker.js） */
.date-box { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.date-box input { cursor: pointer; padding-right: 26px !important; }
.date-box input::placeholder { color: #a8abb2; }
.date-range .date-box input { width: 118px; min-width: 0; height: 30px; border: 0; padding-left: 4px; }
.date-range .date-box input:focus { outline: none; }
.date-icon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #a0a8b5; pointer-events: none; }
.date-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.date-box:hover .date-icon, .date-box.open .date-icon { color: var(--blue); }
.dp-pop { position: absolute; top: calc(100% + 6px); left: -5px; z-index: 60; width: 252px; padding: 10px 10px 8px; background: #fff; border: 1px solid #e4ebf3; border-radius: 8px; box-shadow: 0 6px 20px rgba(19,48,90,.10); cursor: default; user-select: none; }
.dp-pop.flip { left: auto; right: -5px; }
.dp-pop button { font: inherit; border: 0; background: none; cursor: pointer; color: var(--ink); }
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.dp-head button { width: 26px; height: 26px; border-radius: 4px; color: #8a96a8; font-size: 15px; line-height: 1; }
.dp-head button:hover { background: #f2f6fb; color: var(--blue); }
.dp-title { flex: 1; text-align: center; font-weight: 600; font-size: 13px; color: var(--ink); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-week { text-align: center; font-size: 12px; color: #9aa5b4; height: 26px; line-height: 26px; }
.dp-day { height: 30px; border-radius: 4px; font-size: 13px; }
.dp-day:hover { background: #f2f6fb; color: var(--blue); }
.dp-day.other { color: #c3cad4; }
.dp-day.today { color: var(--blue); font-weight: 600; box-shadow: inset 0 0 0 1px #c9daf0; }
.dp-day.sel, .dp-day.sel:hover { background: var(--blue-soft); color: var(--blue); font-weight: 600; box-shadow: inset 0 0 0 1px #a9c6ec; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid #eef2f7; }
.dp-foot button { font-size: 12px; color: var(--blue); padding: 3px 6px; border-radius: 4px; }
.dp-foot button[data-clear] { color: #8a96a8; }
.dp-foot button:hover { background: #f2f6fb; }
.date-range .sep { color: var(--muted); padding: 0 4px; }
.filter-more-btn { background: #fff; color: var(--ink); border-color: #dcdfe6; }
.filter-more-btn:hover, .filter-more-btn[aria-expanded=true] { color: var(--blue); border-color: var(--blue); filter: none; }
.filter-more-btn.on { color: var(--blue); border-color: #a9c6ec; background: var(--blue-soft); }
.filter-more-btn .count:not(:empty) { display: inline-block; margin-left: 4px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: var(--blue); color: #fff; font-size: 11px; text-align: center; padding: 0 4px; }
.filter-refresh { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: #a0a8b5; cursor: pointer; border-radius: 4px; }
.filter-refresh:hover { color: var(--blue); background: var(--blue-soft); }
.filter-refresh svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.filter-more { position: relative; }
.filter-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 360px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(19,48,90,.16); padding: 18px 20px 14px; }
.filter-panel[hidden] { display: none; }
.filter-panel.flip { left: auto; right: 0; }
.filter-panel .row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 12px; margin-bottom: 12px; }
.filter-panel .row > span { text-align: right; color: var(--ink); }
.filter-panel .row select, .filter-panel .row input { width: 100%; height: 32px; padding: 4px 8px; border-color: #dcdfe6; border-radius: 4px; min-width: 0; }
.filter-panel .row > .combo, .combo { position: relative; display: block; min-width: 0; text-align: left; }
.combo input::placeholder { color: var(--ink); opacity: 1; }
.combo input { padding-right: 24px !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23606266' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 9px center; }
.combo-list { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 50; max-height: 220px; overflow-y: auto; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid #dcdfe6; border-radius: 4px; box-shadow: 0 6px 16px rgba(19,48,90,.14); }
.combo-list[hidden] { display: none; }
.combo-list li { padding: 6px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li.sel { color: var(--blue); font-weight: 600; }
.combo-list li.cur, .combo-list li:hover { background: var(--blue-soft); }
.combo-list li.none { color: #999; cursor: default; background: none; }
.filter-panel .foot { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.filter-panel .foot .save-range { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; cursor: pointer; }
.filter-panel .foot .link { text-decoration: underline; margin-right: 4px; }
.filter-panel .foot .btn { height: 28px; padding: 0 12px; font-size: 14px; }
.filter-panel .foot .btn.ghost { color: var(--ink); border-color: #dcdfe6; }
.filter-panel .foot .spacer { margin-right: auto; }

/* 分页 */
.pager { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: flex-end; margin-top: 10px; color: #4a5566; font-size: 14px; }
.pager-btns { display: flex; gap: 6px; }
.pager .pg { min-width: 28px; height: 28px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #dcdfe6; border-radius: 4px; background: #fff; color: #4a5566; }
.pager a.pg:hover { color: var(--blue); border-color: var(--blue); text-decoration: none; }
.pager .pg.current { color: var(--blue); border-color: var(--blue); }
.pager .pg.disabled { background: #f4f5f7; border-color: #ebeef3; color: #c0c4cc; cursor: not-allowed; }
.pager .pg svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pager-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.pager-form select, .pager-form input[type=number] { min-width: 0; height: 28px; padding: 2px 6px; font-size: 14px; border-color: #dcdfe6; border-radius: 4px; }
.pager-form select { width: 64px; }
.pager-form input[type=number] { width: 48px; text-align: center; -moz-appearance: textfield; }
.pager-form input[type=number]::-webkit-inner-spin-button, .pager-form input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pager-form span:nth-of-type(2) { margin-left: 8px; }

/* 列表页：表头、分页固定，只滚动表体 */
.table-scroll { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.table-scroll > table.grid { border: 0; border-radius: 0; overflow: visible; }
.table-scroll .grid th { position: sticky; top: 0; z-index: 1; }
.main.fit { height: 100vh; display: flex; flex-direction: column; overflow: auto; }
.main.fit > * { flex: none; }
.main.fit > .table-scroll { flex: 1 1 0; min-height: 240px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
/* 固定行高的分页表格：单行不换行，超宽时横向滚动 */
.paged-wrap { overflow-x: auto; }
.grid.fixed-rows td { height: 40px; padding-top: 0; padding-bottom: 0; vertical-align: middle; white-space: nowrap; }
.paged-wrap + .pager { margin-top: 10px; }
.qr { word-break: break-all; font-family: var(--mono); font-size: 14px; background: #f6f9fc; border-radius: 4px; padding: 4px 6px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #13305a, #1d5bab); }
.login { width: 360px; background: #fff; border-radius: 10px; padding: 30px 30px 26px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login h1 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.login p { margin: 0 0 20px; color: var(--muted); }
.login label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.login input { width: 100%; margin-top: 4px; }
.login .btn { width: 100%; padding: 9px; font-size: 15px; }

.main { overflow-x: auto; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .side { width: auto; flex: none; overflow: visible; }
  .topbar { height: 44px; padding: 0 12px; }
  .sys-name { font-size: 16px; letter-spacing: 1px; }
  .sys-name span { display: none; }
  .workspace { flex: 1; min-height: 0; }
  .brand { padding: 12px 16px 6px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 8px; }
  .side nav .group { display: none; }
  .side nav a { border-left: 0; border-radius: 6px; padding: 5px 10px; }
  .side nav a.active { background: rgba(255,255,255,.18); }
  .main { padding: 12px; }
  .grid th, .grid td { white-space: nowrap; }
  .main.fit { height: auto; display: block; overflow: visible; }
  .main.fit > .table-scroll { height: 70vh; min-height: 0; }
  .filter-more { position: static; }
  .filter-panel { left: 0; right: auto; width: 100%; }
  .filter-bar .filter-kw { flex: 1 1 160px; }
}

/* 主页：概况卡片与统计图表 */
.dash-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.dash-head h1 { font-size: 16px; margin: 0; color: var(--navy); }
.dash-head .seg { margin: 0 0 0 auto; }
.seg { display: inline-flex; border: 1px solid #dcdfe6; border-radius: 4px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: 14px; height: 30px; padding: 0 12px; border: 0; border-left: 1px solid #dcdfe6; background: none; color: #4a5566; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--blue); }
.seg button.on { background: var(--blue); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; color: var(--ink); }
a.stat:hover { border-color: #a9c6ec; text-decoration: none; box-shadow: 0 2px 8px rgba(19,48,90,.08); }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat.alert { border-color: #f3c1bd; background: #fffafa; }
.stat.alert .stat-sub { color: var(--err); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.dash-grid .card { margin: 0; min-width: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.chart-head .muted { font-size: 12px; }
.chart { height: 240px; position: relative; }
.chart svg { display: block; }
.chart .grid { stroke: #eef1f5; }
.chart .axis { stroke: #c5d1df; }
.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .tick.strong { fill: var(--ink); font-weight: 700; }
.chart .bar.s1 { fill: #2a78d6; }
.chart .bar.s2 { fill: #eb6834; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hover-band { fill: #1d5bab; fill-opacity: .06; }
.chart-empty { color: var(--muted); text-align: center; padding: 60px 0; margin: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: -2px 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: #c5d1df; flex: none; }
.sw.s1 { background: #2a78d6; }
.sw.s2 { background: #eb6834; }
.chart-tip { position: fixed; z-index: 70; pointer-events: none; min-width: 140px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(19,48,90,.16); padding: 8px 10px; font-size: 12px; }
.chart-tip[hidden] { display: none; }
.tip-title { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 20px; }
.tip-row span { color: var(--muted); }
.tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tip-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars a { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); padding: 2px 4px; margin: 0 -4px; border-radius: 4px; }
.hbars a:hover { background: #f3f6fa; text-decoration: none; }
.hbars a:hover .hb-name { color: var(--blue); }
.hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 12px; background: #f3f6fa; border-radius: 0 4px 4px 0; }
.hb-bar { display: block; height: 100%; min-width: 2px; background: #2a78d6; border-radius: 0 4px 4px 0; }
.hb-val { min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.hb-val small { color: var(--muted); margin-left: 6px; }
@media (max-width: 760px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-head .seg { margin-left: 0; }
}

/* 系统设置：占满右侧，保存按钮固定右下角 */
.main.fit > .settings-form { flex: 1 1 auto; display: flex; flex-direction: column; margin-bottom: 0; }
.settings-form .settings-actions { margin-top: auto; padding-top: 16px; display: flex; justify-content: flex-end; }
.settings-form .settings-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid #eef1f5; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 16px; max-width: 960px; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.settings-grid input, .settings-grid select { width: 100%; min-width: 0; }
.settings-grid label[hidden] { display: none; }

/* 弹出窗 */
dialog.modal { width: 440px; max-width: calc(100vw - 32px); padding: 0; border: 0; border-radius: 8px; background: #fff; color: var(--ink); box-shadow: 0 16px 48px rgba(19,48,90,.28); }
dialog.modal::backdrop { background: rgba(15,30,55,.45); }
.modal form { margin: 0; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid #eef1f5; }
.modal-head h2 { flex: 1; margin: 0; font-size: 16px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-x { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 4px; background: none; color: #8a94a3; font: 20px/28px sans-serif; cursor: pointer; }
.modal-x:hover { background: #e5484d; color: #fff; }
.modal-body { padding: 18px 20px 6px; }
.modal-body .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.modal-body .field input[type=text], .modal-body .field input[type=password], .modal-body .field select { width: 100%; min-width: 0; height: 34px; }
.modal-body .check { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.modal-foot .btn.ghost { color: var(--ink); border-color: #dcdfe6; }
.modal-foot .btn:disabled { opacity: .6; cursor: default; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; margin-bottom: 12px; }
.page-actions p { margin: 0; flex: 1; }
.filter-bar .bar-end { margin-left: auto; }
.grid td.ops { white-space: nowrap; }
.grid td.ops .link + .link { margin-left: 12px; }
.grid td.ops .link.danger { color: var(--err); }
dialog.modal.wide { width: 760px; }
.modal-body > p { margin: 0 0 12px; }
.modal-table { max-height: 50vh; overflow: auto; border: 1px solid #eef1f5; border-radius: 6px; margin-bottom: 10px; }
.modal-table .grid { margin: 0; }
.modal-table thead th { position: sticky; top: 0; }

/* 设备日志：固定弹窗和表格区域，翻页及长文本不撑开窗口。 */
dialog.device-logs { height: 520px; max-height: calc(100dvh - 32px); overflow: hidden; }
dialog.device-logs[open] { display: flex; flex-direction: column; }
.device-logs .modal-head { flex: none; }
.device-logs .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 16px; }
.device-logs .modal-table { flex: 1; min-height: 0; max-height: none; margin-bottom: 0; }
.device-logs .grid { width: 100%; min-width: 600px; table-layout: fixed; }
.device-logs .log-time { width: 158px; }
.device-logs .log-actor { width: 110px; }
.device-logs .log-action { width: 90px; }
.device-logs .grid td { white-space: normal; overflow-wrap: anywhere; }
.device-logs .grid td.mono { white-space: nowrap; }
.device-logs .pager { flex: none; justify-content: space-between; }
.device-logs .pg { font: inherit; cursor: pointer; }
.device-logs .pg:disabled { background: #f4f5f7; border-color: #ebeef3; color: #c0c4cc; cursor: not-allowed; }
.device-logs .pg:enabled:hover { color: var(--blue); border-color: var(--blue); }
/* 全局提示（toast.js）：顶部居中，成功绿色、失败红色 */
.toast { position: fixed; z-index: 1000; inset: auto; left: 50%; top: 16px; margin: 0; max-width: min(560px, calc(100vw - 32px)); overflow: visible; transform: translate(-50%, -12px); background: #1f9d55; color: #fff; border: 0; border-radius: 6px; padding: 10px 20px; font-size: 14px; line-height: 1.5; box-shadow: 0 8px 24px rgba(19,48,90,.18); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #d93025; }
.sync-body { padding-bottom: 14px; }
.sync-bar { position: relative; height: 6px; border-radius: 3px; background: #eef1f5; overflow: hidden; }
.sync-bar i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: 3px; background: var(--blue); animation: sync-run 1.2s ease-in-out infinite; }
@keyframes sync-run { from { left: -40%; } to { left: 100%; } }
.sync-msg { margin: 14px 0 4px; }
.sync-bar[hidden] + .sync-msg { margin-top: 0; }
#dlg-sync .modal-foot[hidden] { display: none; }
.sync-msg.sync-ok { color: var(--ok); }
.sync-msg.sync-err { color: var(--err); }
.sync-time { margin: 0; font-size: 12px; }

/* 打印模板编辑器 */
.seg a { font-size: 14px; line-height: 30px; padding: 0 12px; border-left: 1px solid #dcdfe6; color: #4a5566; }
.seg a:first-child { border-left: 0; }
.seg a:hover { color: var(--blue); text-decoration: none; }
.seg a.on { background: var(--blue); color: #fff; }
.pt-tip { font-size: 12px; }
.pt-editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.pt-editor .card { margin: 0; min-width: 0; }
.pt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.pt-toolbar input[type=number] { width: 76px; min-width: 0; padding: 3px 6px; }
.pt-toolbar select { min-width: 0; padding: 3px 6px; }
.pt-size { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.pt-style { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.pt-style select { max-width: 180px; }
.pt-style-menu { min-width: 160px; }
.pt-submenu { position: relative; }
.pt-submenu-btn { position: relative; padding-right: 32px !important; }
.pt-submenu-btn::after { content: ""; position: absolute; right: 14px; top: 50%; width: 6px; height: 6px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: translateY(-50%) rotate(45deg); }
.pt-submenu-list { display: none; position: absolute; left: 100%; top: -5px; margin-left: 2px; min-width: 150px; max-height: 320px; overflow-y: auto; }
.pt-style-menu.sub-left .pt-submenu-list { left: auto; right: 100%; margin: 0 2px 0 0; }
.pt-submenu:hover .pt-submenu-list, .pt-submenu:focus-within .pt-submenu-list { display: block; }
.pt-submenu:hover .pt-submenu-btn { background: var(--blue-soft); color: var(--blue); }
.tab-menu .pt-check { position: relative; padding-left: 30px; }
.tab-menu .pt-check.on { color: var(--blue); }
.tab-menu .pt-check.on::before { content: ""; position: absolute; left: 12px; top: 50%; width: 9px; height: 5px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-70%) rotate(-45deg); }
.pt-zoom { margin-left: auto; font-size: 13px; }
.pt-style + .pt-zoom { margin-left: 8px; }
.pt-stage-wrap { overflow: auto; padding: 16px; background: repeating-conic-gradient(#eef2f7 0 25%, #f6f8fb 0 50%) 0 0 / 16px 16px; border-radius: 6px; height: calc(100vh - 230px); min-height: 360px; box-sizing: border-box; }
.pt-stage { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 1px 6px rgba(19,48,90,.25); outline: none; user-select: none; touch-action: none; }
.pt-el { position: absolute; box-sizing: border-box; cursor: move; outline: 1px dashed rgba(29,91,171,.35); }
.pt-el:hover { outline-color: rgba(29,91,171,.7); }
.pt-el.sel { outline: 2px solid var(--blue); z-index: 2; }
.pt-el svg { display: block; width: 100%; height: 100%; fill: #000; pointer-events: none; }
.pt-line { background: #000; }
.pt-text-body { width: 100%; height: 100%; overflow: hidden; color: #000; line-height: 1.22; word-break: break-all; display: -webkit-box; -webkit-box-orient: vertical; pointer-events: none; font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
.pt-handle { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: #fff; border: 2px solid var(--blue); border-radius: 2px; cursor: nwse-resize; display: none; }
.pt-el.sel .pt-handle { display: block; }
.pt-hint { font-size: 12px; margin: 10px 0 0; }
.pt-panel { position: sticky; top: 0; }
.pt-panel h2.pt-sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid #eef1f5; }
.pt-type { font-weight: 700; margin-bottom: 8px; }
.pt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.pt-f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.pt-f.wide { grid-column: 1 / -1; }
.pt-f input, .pt-f select, .pt-f textarea { min-width: 0; width: 100%; }
.pt-f textarea { min-height: 52px; resize: vertical; }
.pt-checks { grid-column: 1 / -1; display: flex; gap: 18px; }
.pt-checks .pt-f { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.pt-el-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pt-list { margin: 0; padding: 0; list-style: none; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.pt-list:empty::before { content: "暂无元素"; display: block; padding: 8px 10px; color: var(--muted); }
.pt-list li { display: flex; gap: 8px; padding: 5px 10px; cursor: pointer; border-top: 1px solid #eef1f5; font-size: 13px; }
.pt-list li:first-child { border-top: 0; }
.pt-list li:hover { background: #f6f9fc; }
.pt-list li.sel { background: var(--blue-soft); color: var(--blue); }
.pt-list li b { flex: none; width: 48px; }
.pt-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.pt-vars-tip { font-size: 12px; margin: -4px 0 8px; }
.pt-vars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pt-var { display: flex; flex-direction: column; align-items: flex-start; text-align: left; font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); cursor: pointer; min-width: 0; }
.pt-var:hover { border-color: #a9c6ec; background: #f6f9fc; }
.pt-var code { color: var(--blue); font-size: 12px; }
.pt-var span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pt-break { flex-basis: 100%; height: 0; }
.pt-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: 12px; }
.pt-actions form { margin: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
@media (max-width: 1100px) {
  .pt-editor { grid-template-columns: 1fr; }
  .pt-panel { position: static; }
}

/* 右侧抽屉（箱码详情等） */
dialog.drawer { position: fixed; inset: 0 0 0 auto; width: min(1000px, 92vw); max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); box-shadow: -12px 0 40px rgba(19,48,90,.25); flex-direction: column; }
dialog.drawer[open] { display: flex; animation: drawer-in .22s ease-out; }
dialog.drawer::backdrop { background: rgba(15,30,55,.35); }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; margin: 0; font-size: 16px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
