/* 红外感应器开发平台 · 网页版
   配色与桌面版 QSS 保持一致：米白底 + 橙色点缀 */

:root {
  --bg: #FAF5EE;
  --panel: #FFFDFA;
  --line: #EBDFCE;
  --line-strong: #E3D5C0;
  --text: #2B2118;
  --muted: #A08D75;
  --muted2: #6B5D4F;
  --accent: #E67E22;
  --accent-hi: #F08C33;
  --accent-soft: #FBEEDC;
  --danger: #C24A3F;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", "PingFang SC", sans-serif;
  font-size: 13px;
}

body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------------------------------------------------------------- 顶栏 */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.app-name { font-size: 16px; font-weight: 700; color: #1F1C18; }
.ver { font-size: 11px; color: var(--muted); }
.proj-name { font-size: 12px; color: var(--accent); margin-left: 6px; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- 主体 */
main { flex: 1; display: flex; min-height: 0; }

#nav {
  width: 168px; flex: 0 0 auto; padding: 10px 8px;
  background: var(--bg); overflow-y: auto;
}
#nav .nav-item {
  height: 36px; display: flex; align-items: center;
  padding: 0 12px; margin-bottom: 2px;
  border-radius: 6px; color: var(--muted2); cursor: pointer;
  user-select: none;
}
#nav .nav-item:hover { background: #F3E9DB; color: var(--text); }
#nav .nav-item.active { background: var(--accent-soft); color: #D2691E; font-weight: 600; }

#content { flex: 1; min-width: 0; overflow-y: auto; padding: 12px 14px 20px; }

.page { display: none; max-width: 1100px; }
.page.active { display: block; }

/* ---------------------------------------------------------------- 卡片 */
.group {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px 12px; margin-bottom: 12px;
}
.group > .group-title {
  color: var(--muted); font-weight: 600; margin-bottom: 10px;
  border-left: 3px solid var(--accent); padding-left: 8px;
}
.hint { color: var(--muted); line-height: 1.7; margin-top: 8px; }
.calc {
  background: var(--accent-soft); color: #D2691E; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; white-space: nowrap;
}

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.row + .row { margin-top: 8px; }
.field { display: flex; align-items: center; gap: 6px; }
.field > label { color: var(--text); }
.field.wide > label { width: 156px; display: inline-block; }
.field .unit { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- 控件 */
input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 4px 8px; color: var(--text);
  min-height: 26px; font-size: 13px; outline: none;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="number"]:hover, select:hover { border-color: #D4C2A6; }
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus { border-color: var(--accent); }
input[type="number"] { width: 76px; }
input[type="text"].hex { width: 96px; }
input:disabled { background: #F1EFEB; color: #ABA69D; border-color: var(--line); }

button {
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 5px 16px; color: var(--text);
  font-size: 13px; cursor: pointer; font-family: inherit;
}
button:hover { background: #F8F0E4; border-color: #D4C2A6; }
button:active { background: #F1E5D3; }
button:disabled { color: #C0B2A0; border-color: var(--line); background: var(--bg); cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
button.danger { color: var(--danger); }
button.danger:hover { background: #FBEAE7; border-color: #E8B7B0; }

label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; cursor: pointer;
}
.mode-chip:hover { background: var(--bg); border-color: #D4C2A6; }
.mode-chip.on { background: var(--accent-soft); border-color: var(--accent); color: #D2691E; }

/* ---------------------------------------------------------------- 表格 */
table.led { border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.led th, table.led td { border: 1px solid #F3EBDD; padding: 5px 8px; text-align: center; }
table.led th { background: #F8F1E6; color: var(--muted); font-weight: 600; }
table.led td.scene { text-align: left; color: var(--text); white-space: nowrap; }
table.led input[type="number"] { width: 72px; }

/* ---------------------------------------------------------------- 预览 / 日志 */
pre.mono {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin: 0; color: #3E3A34;
  font-family: Consolas, "Courier New", monospace; font-size: 12px;
  line-height: 1.55; overflow: auto; white-space: pre;
}
#preview { height: 380px; }
#buildLog { height: 260px; }

.path-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.path-line label { width: 84px; flex: 0 0 auto; color: var(--text); }
.path-line input[type="text"], .path-line input[type="password"] { flex: 1; min-width: 0; font-family: Consolas, monospace; font-size: 12px; }

.result-label { margin: 10px 0 8px; color: var(--muted); }
.result-label.ok { color: #2E7D32; }
.result-label.err { color: var(--danger); }

.progress-wrap { margin-top: 10px; height: 22px; background: #F3E9DB; border-radius: 6px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .25s ease; }
.progress-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text); font-weight: 600;
}

/* ---------------------------------------------------------------- 底栏 */
#bottombar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel);
}
#statusMsg { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- 弹窗 / 提示 */
#modal, #alertModal, #confirmModal {
  position: fixed; inset: 0; background: rgba(43, 33, 24, .35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
#alertModal, #confirmModal { z-index: 60; }
#alertText, .confirm-text { color: var(--text); line-height: 1.8; }
.confirm-text { white-space: pre-wrap; }
.modal-box {
  width: 460px; max-width: 92vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  box-shadow: 0 12px 40px rgba(43, 33, 24, .25);
}
.modal-title { font-weight: 700; color: #1F1C18; margin-bottom: 12px; }
.modal-row { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-row input { flex: 1; }
.proj-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.proj-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #F3EBDD; }
.proj-item:last-child { border-bottom: none; }
.proj-item .nm { flex: 1; }
.proj-item .meta { color: var(--muted); font-size: 12px; }
.proj-empty { padding: 16px; text-align: center; color: var(--muted); }
.modal-foot { margin-top: 12px; text-align: right; }

#toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
  background: #2B2118; color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; max-width: 70vw; white-space: pre-wrap; z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
#toast.err { background: var(--danger); }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 登录 / 注册 */
body.auth-body { align-items: center; justify-content: center; }
.auth-card {
  width: 360px; max-width: 92vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 24px;
  box-shadow: 0 14px 44px rgba(43, 33, 24, .12);
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .app-name { font-size: 18px; }
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg);
  border-radius: 8px; padding: 4px; margin-bottom: 16px;
}
.auth-tab {
  flex: 1; text-align: center; padding: 7px 0; border-radius: 6px;
  color: var(--muted2); cursor: pointer; user-select: none;
}
.auth-tab.active { background: var(--panel); color: #D2691E; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted2); font-size: 12px; }
.auth-form input { width: 100%; min-height: 34px; }
.auth-form button { margin-top: 4px; min-height: 36px; }
.auth-msg { margin-top: 12px; min-height: 16px; text-align: center; font-size: 12px; color: var(--danger); }
.auth-msg.ok { color: #2E7D32; }

/* 图形验证码 / 短信验证码那一行：输入框 + 图片 / 获取按钮 并排 */
.cap-row, .code-row { display: flex; gap: 8px; align-items: stretch; }
.cap-row input, .code-row input { flex: 1 1 auto; min-width: 0; }
.cap-img {
  flex: none; display: block; width: 132px; height: 34px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); cursor: pointer;
}
.code-row .send-code {
  flex: none; margin-top: 0; min-height: 34px; padding: 0 12px; white-space: nowrap;
}

/* 调试模式：登录页的测试账号快捷按钮 */
.debug-note { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.debug-chips { display: flex; gap: 6px; margin-bottom: 14px; }
.debug-chip {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 7px 10px; font-size: 12px; line-height: 1.35; text-align: left;
}
.debug-chip span { color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.debug-chip.active { border-color: var(--accent); background: var(--accent-soft); color: #D2691E; }
.debug-chip.active span { color: #D2691E; }

#userName { color: var(--muted2); font-size: 12px; margin-left: 4px; }
#userName::before { content: "当前用户："; color: var(--muted); }

/* ---------------------------------------------------------------- 后台管理 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; color: #1F1C18; margin-top: 4px; }

table.grid {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
table.grid th, table.grid td {
  border-bottom: 1px solid #F3EBDD; padding: 7px 10px;
  text-align: left; vertical-align: middle;
}
table.grid th { background: #F8F1E6; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: none; }
table.grid td.actions { white-space: nowrap; }
table.grid td.actions button { padding: 3px 10px; font-size: 12px; margin: 2px 4px 2px 0; }
table.grid td.num, table.grid th.num { text-align: center; }
table.grid tfoot td { background: #FBF6EE; font-weight: 600; }

/* 客户页：三个品种的卡片 */
.type-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin: 12px 0;
}
.type-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 13px 15px;
  background: var(--bg); cursor: pointer; user-select: none;
}
.type-card:hover { border-color: var(--accent); background: #FFFBF5; }
.type-card.active { border-color: var(--accent); background: var(--accent-soft); }
.type-card .k { font-size: 12px; color: var(--muted); }
.type-card .v { font-size: 24px; font-weight: 700; color: #1F1C18; margin-top: 5px; }
.crumb { color: var(--muted); font-size: 13px; }
.crumb b { color: var(--text); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag.on { background: #E4F3E5; color: #2E7D32; }
.tag.off { background: #F1EFEB; color: #A39E95; }
.tag.admin { background: var(--accent-soft); color: #D2691E; }
.tag.user { background: #EEF1F6; color: #5A6B85; }
.tag.type { background: #EEF4EC; color: #4A7C59; }
.tag.warn { background: #FBF0DC; color: #B8791B; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 12px; align-items: baseline; }
.kv .k { color: var(--muted); font-size: 12px; }
.kv .v { color: var(--text); font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }

.form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 10px 12px; align-items: center; }
.form-grid label { color: var(--muted2); }
.form-grid input, .form-grid select { width: 100%; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.empty { padding: 20px; text-align: center; color: var(--muted); }

/* 后台：每种工程类型一块设置 */
.type-block {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg);
}
.type-block .path-line { margin-bottom: 6px; }
.type-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.type-head b { color: var(--text); }
.mono-cell { font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }

/* ---------------------------------------------------------------- 客户工作台（左侧栏目布局） */
.wb { flex: 1; display: flex; min-height: 0; }

.side {
  width: 214px; flex: 0 0 auto; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-brand { padding: 16px 18px 13px; border-bottom: 1px solid var(--line); }
.side-brand .t { font-size: 15px; font-weight: 700; color: #1F1C18; }
.side-brand .s { font-size: 11px; color: var(--muted); margin-top: 3px; }
.side-nav { flex: 1; padding: 10px; overflow-y: auto; }
.side-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px;
  margin-bottom: 3px; border-radius: 7px; color: var(--muted2);
  cursor: pointer; user-select: none; font-size: 13px;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: #D2691E; font-weight: 600; }
.side-item .ic { width: 16px; flex: 0 0 auto; }
.side-item .ic svg { width: 15px; height: 15px; display: block; }
.side-item .ic svg * { stroke: currentColor; fill: none; stroke-width: 1.5;
                       stroke-linecap: round; stroke-linejoin: round; }
.side-item .badge { margin-left: auto; font-size: 11px; color: var(--muted); }

.ws { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.ws-head .tt { font-size: 15px; font-weight: 700; color: #1F1C18; }
.ws-head .st { font-size: 12px; color: var(--muted); }
.ws-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-user { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.head-user b { color: var(--text); font-weight: 600; }
.ws-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 40px; }
.wb-page { display: none; }
.wb-page.active { display: block; }

/* 图表 */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.chart-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px 10px;
}
.chart-box h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px;
          font-size: 12px; color: var(--muted2); }
.legend span { display: inline-flex; align-items: center; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.pname { font-weight: 600; }
.pname .tag { margin-left: 7px; }
.muted { color: var(--muted); font-size: 12px; }
.search { min-width: 180px; }
