/* ============================================================
   大聚 X9 环控系统 · 通用组件（HMI / 远程端共用，各端可覆写）
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
table { border-collapse: collapse; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9ccd2; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #adb2ba; }

/* ---------- 文本 ---------- */
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0.2px; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-num); }

/* ---------- 布局工具 ---------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.hide { display: none !important; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px 10px;
}
.card-title {
  font-size: 16px; font-weight: 700; letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 8px;
}
.card-title .dot { width: 4px; height: 16px; border-radius: 2px; background: var(--dark); }
.card-body { padding: 8px 20px 20px; }
.card-dark {
  background: var(--dark); color: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card-dark .card-title { color: #fff; }
.card-dark .card-title .dot { background: #fff; }

/* ---------- 表格（黑色表头，设计稿风格） ---------- */
.tbl { width: 100%; font-size: 14px; background: var(--panel); }
.tbl thead th {
  background: var(--dark); color: #fff; font-weight: 600;
  text-align: center; padding: 12px 10px; white-space: nowrap;
  font-size: 14px; letter-spacing: 0.4px;
}
.tbl thead th:first-child { border-top-left-radius: var(--radius-md); }
.tbl thead th:last-child { border-top-right-radius: var(--radius-md); }
.tbl tbody td {
  padding: 11px 10px; text-align: center; border-bottom: 1px solid var(--line);
  color: var(--ink-2); white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #f7f8f9; }
.tbl tbody tr.selected td { background: var(--blue-soft); }
.tbl .t-left { text-align: left; }
.tbl .t-right { text-align: right; }
.tbl .t-blue { color: var(--blue-deep); font-weight: 600; }
.tbl .t-red { color: var(--red); font-weight: 600; }
.tbl .t-muted { color: var(--muted); }
.tbl--compact tbody td { padding: 8px 8px; }
.tbl-scroll { overflow: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s;
  user-select: none;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-dark { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-dark:hover { background: var(--dark-3); }
.btn-blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-blue:hover { background: #3a6eff; }
.btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.btn-red:hover { background: #ef5b60; }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0, 0, 0, .05); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.icon-btn.dark { color: #cfd2d8; }
.icon-btn.dark:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- 开关 ---------- */
.switch { position: relative; display: inline-flex; width: 46px; height: 26px; flex: 0 0 auto; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  width: 46px; height: 26px; border-radius: 13px; background: #d6d8dd;
  transition: background .18s; pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:disabled + .track { opacity: .45; }
.switch.sm { width: 38px; height: 22px; }
.switch.sm .track { width: 38px; height: 22px; }
.switch.sm .track::after { width: 16px; height: 16px; }
.switch.sm input:checked + .track::after { transform: translateX(16px); }

/* ---------- 分段选择 ---------- */
.seg { display: inline-flex; background: var(--panel-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-3); font-size: 14px; font-weight: 600;
  height: 32px; padding: 0 16px; border-radius: 7px; cursor: pointer;
}
.seg button.on { background: var(--dark); color: #fff; }
.seg.light button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- 状态灯 / 圆点 ---------- */
.led { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: #c9ccd2; }
.led.green { background: var(--green); box-shadow: 0 0 0 3px rgba(31, 158, 88, .14); }
.led.red { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 72, 77, .14); }
.led.blue { background: var(--blue); box-shadow: 0 0 0 3px rgba(31, 94, 255, .14); }
.led.amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(239, 159, 31, .16); }
.led.gray { background: #c9ccd2; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 5px; font-size: 12px; font-weight: 600; background: var(--panel-3); color: var(--ink-3);
  white-space: nowrap;
}
.tag.blue { background: var(--blue-soft); color: var(--blue-deep); }
.tag.red { background: var(--red-soft); color: var(--red-deep); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: #a86a00; }
.tag.dark { background: var(--dark); color: #fff; }
.tag.gray { background: #eef0f2; color: var(--ink-3); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.input, .select {
  height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; padding: 0 12px; font-size: 14px; color: var(--ink); outline: none;
  font-family: inherit; width: 100%;
}
.input:focus, .select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 94, 255, .12); }
.input.num { font-family: var(--font-num); font-size: 16px; letter-spacing: .5px; }
.input[readonly] { background: var(--panel-3); color: var(--ink-3); cursor: pointer; }
.unit { color: var(--muted); font-size: 13px; margin-left: 4px; }
.input-sm { height: 32px; font-size: 13px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }

/* ---------- 统计块 ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.stat .v { font-family: var(--font-num); font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--ink); }
.stat .v u { text-decoration: none; font-size: 15px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.stat .v.blue { color: var(--blue-deep); }
.stat .v.red { color: var(--red); }
.stat .v.green { color: var(--green); }
.stat .sub { font-size: 12px; color: var(--muted); }

/* ---------- 空状态 / 加载 ---------- */
.empty { padding: 46px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.skeleton {
  background: linear-gradient(90deg, #eef0f2 25%, #f7f8f9 37%, #eef0f2 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .15); border-top-color: var(--blue);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(14, 15, 18, .5);
  display: flex; align-items: center; justify-content: center; z-index: 900;
  padding: 30px; backdrop-filter: blur(2px);
  animation: fadein .16s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-2);
  max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column;
  overflow: hidden; animation: popin .18s ease;
}
@keyframes popin { from { transform: translateY(10px) scale(.98); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; background: var(--dark); color: #fff; font-size: 17px; font-weight: 700;
  letter-spacing: .5px;
}
.modal-head .close { color: #c9ccd2; }
.modal-body { padding: 22px 24px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 0 24px 22px; }
.modal.red .modal-head { background: var(--red); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; top: 34px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 950; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 10px;
  background: rgba(26, 26, 28, .94); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-2); animation: toastin .2s ease; max-width: 70vw;
}
.toast.ok { background: rgba(24, 110, 62, .96); }
.toast.err { background: rgba(178, 38, 43, .96); }
.toast.warn { background: rgba(150, 98, 10, .96); }
@keyframes toastin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 数字键盘 ---------- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 330px; }
.keypad button {
  height: 58px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  font-family: var(--font-num); font-size: 24px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.keypad button:hover { background: var(--panel-3); }
.keypad button:active { background: #eceef1; }
.keypad button.ok { background: var(--dark); color: #fff; border-color: var(--dark); }
.keypad button.cancel { background: var(--panel-3); font-size: 16px; font-family: var(--font-sans); }
.keypad button.del { font-size: 20px; }
.keypad-display {
  height: 64px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; padding: 0 16px;
  font-family: var(--font-num); font-size: 32px; font-weight: 700; color: var(--ink); margin-bottom: 12px;
}

/* ---------- 提示 ---------- */
.hint {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: 9px;
  background: var(--amber-soft); color: #8a5a00; font-size: 13px; line-height: 1.5;
}
.hint.blue { background: var(--blue-soft); color: var(--blue-deep); }
.hint.red { background: var(--red-soft); color: var(--red-deep); }
.hint.gray { background: var(--panel-3); color: var(--ink-3); }

/* ---------- 分割 / 脚手架 ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.vdivider { width: 1px; align-self: stretch; background: var(--line); }
.scroll { overflow: auto; }
