/* 一拖二升降柱集中管理平台 - 工业深色主题 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #0e1726;
  color: #d7e3f4;
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, #12233d, #0e1b2e);
  border-bottom: 1px solid #1e3552;
  padding: 10px 18px;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; color: #eef5ff; }
.brand .logo { color: #3d9bff; font-size: 20px; }
.hd-right { display: flex; align-items: center; gap: 10px; }
.badge {
  background: #1b2f4d; color: #9db9d9; border: 1px solid #2a4266;
  padding: 5px 12px; border-radius: 12px; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.user-box { color: #9db9d9; font-size: 13px; }

/* ---------------- 按钮 ---------------- */
.btn {
  background: #1c3252; color: #d7e3f4; border: 1px solid #2c4a73;
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: #27466e; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: #1f6feb; border-color: #2f80ed; color: #fff; }
.btn.primary:hover { background: #2a7ff0; }
.btn.danger { background: #7a2e2e; border-color: #c94f4f; color: #fff; }
.btn.danger:hover { background: #963c3c; }

/* ---------------- 公司名称条 ---------------- */
.brand-bar {
  background: linear-gradient(90deg, #0f2744, #163a63);
  border-bottom: 1px solid #2c4a73;
  padding: 10px 18px; text-align: center;
  color: #eef5ff; font-size: 16px; font-weight: 700; letter-spacing: 1px;
}

/* ---------------- 卡片区 ---------------- */
main { padding: 16px 18px 30px; max-width: 1700px; margin: 0 auto; }
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(620px, 1fr));
  gap: 16px; margin-bottom: 18px;
}
.card {
  background: #14243c;
  border: 1px solid #223c5e; border-radius: 10px; padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.card.offline { opacity: .8; border-color: #33455e; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.card-head .dot { width: 11px; height: 11px; border-radius: 50%; background: #ff5b5b; }
.card-head .dot.on { background: #2ecc71; box-shadow: 0 0 7px #2ecc71; }
.node-name { font-size: 16px; font-weight: 700; color: #eef5ff; }
.node-ip { color: #7d98ba; font-size: 12px; }
.card-head .ops { margin-left: auto; display: flex; gap: 6px; }
.card-head .ops .btn { padding: 4px 10px; font-size: 12px; }

/* ---------------- 两通道 ---------------- */
.channels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.channel {
  background: #0f1d31; border: 1px solid #223c5e; border-radius: 9px; padding: 12px;
}
.ch-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: #eef5ff; margin-bottom: 8px;
}
.ch-label .tag {
  background: #1f6feb; color: #fff; border-radius: 5px; padding: 2px 8px; font-size: 12px;
}
.ch-mid { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.anim { flex: 0 0 64px; display: flex; justify-content: center; }
.bollard { position: relative; width: 54px; height: 92px; overflow: hidden; }
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 11px; z-index: 2;
  background: linear-gradient(180deg, #2c3e57, #16243a);
  border-top: 1px solid #46607f; border-radius: 2px;
}
.pillar {
  position: absolute; left: 50%; margin-left: -12px; bottom: 11px; z-index: 1;
  width: 24px; height: 72px; transform: translateY(72px);
  transition: transform 4s linear;   /* 与 PLC 4 秒行程一致 */
  will-change: transform;
  background: linear-gradient(90deg, #8fa6c0, #e8f0fa 45%, #9fb4cc);
  border: 1px solid #c3d2e4; border-radius: 3px 3px 0 0;
  box-shadow: inset 0 0 6px rgba(0,0,0,.25);
}
.pillar::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: #f59e0b; border-radius: 3px 3px 0 0;
}
.ch-state { flex: 1; font-size: 16px; font-weight: 700; }
.st-idle { color: #8fb4dd; }
.st-up_running, .st-down_running { color: #3d9bff; }
.st-up_limit, .st-down_limit { color: #2ecc71; }
.st-up_held { color: #2ecc71; }
.st-anti { color: #fbbf24; }

/* 通道小指标 */
.ch-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px;
  font-size: 12px; color: #9db9d9; margin-bottom: 10px;
}
.ch-meta b { color: #eef5ff; font-weight: 600; }
.ch-meta .warn { color: #fbbf24; }

/* 通道按钮 */
.ch-btns { display: flex; gap: 6px; }
.ch-btns .cmd {
  flex: 1; padding: 8px 0; font-size: 13px; font-weight: 600;
  border-radius: 6px; border: 1px solid; cursor: pointer;
}
.cmd.up { background: #0f4c81; border-color: #2f80ed; color: #fff; }
.cmd.up:hover { background: #1660a5; }
.cmd.down { background: #27406b; border-color: #3d6bb5; color: #fff; }
.cmd.down:hover { background: #33538c; }
.cmd.stop { background: #7a2e2e; border-color: #c94f4f; color: #fff; }
.cmd.stop:hover { background: #963c3c; }
.cmd:disabled { opacity: .35; cursor: not-allowed; }

/* ---------------- 共享区 ---------------- */
.shared {
  margin-top: 12px; background: #0f1d31; border: 1px solid #223c5e;
  border-radius: 9px; padding: 11px 14px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.indicators { display: flex; gap: 16px; flex-wrap: wrap; flex: 1; }
.ind { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #9db9d9; }
.ind .lamp { width: 10px; height: 10px; border-radius: 50%; background: #3a4c66; }
.ind .lamp.on-green { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.ind .lamp.on-red { background: #ff5b5b; box-shadow: 0 0 6px #ff5b5b; }
.ind .lamp.on-amber { background: #fbbf24; box-shadow: 0 0 6px #fbbf24; }
.ind .lamp.on-blue { background: #3d9bff; box-shadow: 0 0 6px #3d9bff; }
.shared .btn { padding: 8px 18px; font-weight: 700; }

/* ---------------- 日志面板 ---------------- */
.panel { background: #101d31; border: 1px solid #1e3552; border-radius: 10px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #1e3552; }
.panel-head h3 { font-size: 14px; color: #cfe0f2; }
.filters { display: flex; gap: 8px; }
.filters select {
  background: #16283f; color: #d7e3f4; border: 1px solid #2c4a73;
  border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
.table-wrap { max-height: 340px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #14253d; color: #8fb4dd;
  text-align: left; padding: 8px 12px; font-weight: 600; border-bottom: 1px solid #2a4266;
}
tbody td { padding: 7px 12px; border-bottom: 1px solid #16283f; color: #c3d3e8; }
tbody tr:hover { background: #132540; }
td.fail { color: #ff7b7b; }
td.ok { color: #4ade80; }
td.warn { color: #fbbf24; }
td.info { color: #8fb4dd; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(4,10,20,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: #14243c; border: 1px solid #2c4a73; border-radius: 12px;
  padding: 22px; width: 640px; max-width: 94vw; max-height: 88vh; overflow: auto;
}
.modal-box.small { width: 400px; }
.modal-box h2 { font-size: 16px; color: #eef5ff; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: #8fb4dd; }
.field input, .field select {
  width: 100%; min-width: 0;
  background: #0f1d31; color: #d7e3f4; border: 1px solid #2c4a73;
  border-radius: 6px; padding: 8px 9px; font-size: 13px;
}
.switch { display:inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: #9db9d9; }
.switch input { accent-color: #2f80ed; width: 16px; height: 16px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.err { color: #ff7b7b; font-size: 13px; margin-top: 10px; min-height: 16px; }

#loginModal label { display: block; margin: 12px 0 5px; font-size: 12.5px; color: #8fb4dd; }
#loginModal input { width: 100%; background: #0f1d31; color: #d7e3f4; border: 1px solid #2c4a73; border-radius: 6px; padding: 9px 10px; font-size: 14px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%);
  background: #16283f; border: 1px solid #2c4a73; color: #d7e3f4;
  padding: 10px 22px; border-radius: 8px; z-index: 200; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.toast.ok { border-color: #1f6b4c; color: #4ade80; }
.toast.err { border-color: #8a3036; color: #ff7b7b; }

/* ---------------- 扫描设备 ---------------- */
.scan-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed #1d3550;
}
.scan-tip { font-size: 12px; color: #7c93aa; }
.scan-result { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.scan-hint { font-size: 12px; color: #7c93aa; }
.scan-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer;
  background: #0d1b2a; border: 1px solid #1d3550; border-radius: 6px;
  font-size: 13px;
}
.scan-item:hover { border-color: #2f5b86; background: #10243a; }
.scan-item.sel { border-color: #2ecc71; background: #0f2a20; }
.scan-item b { color: #e8f2ff; font-weight: 600; }
.scan-item span { color: #9db4c9; flex: 1; }
.scan-item em { font-style: normal; font-size: 11px; color: #2ecc71; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .channels { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .hd-right { flex-wrap: wrap; }
}
