/* ============ Personal Hub 样式 ============ */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1c2433;
  --text-sub: #6b7688;
  --primary: #3b6ef5;
  --primary-dark: #2d57c8;
  --danger: #e5484d;
  --ok: #18a058;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.08), 0 4px 16px rgba(20, 30, 60, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- 登录 / 初始化 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8eefc 0%, #f4f6fa 55%, #e9f4ee 100%);
  padding: 20px;
}
.auth-card {
  width: 380px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.auth-logo { font-size: 44px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-sub { font-size: 13px; color: var(--text-sub); text-align: center; margin-bottom: 22px; }

form label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 14px; }
form input, form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
  transition: border 0.15s;
}
form input:focus, form select:focus { border-color: var(--primary); background: #fff; }

.form-error {
  background: #fdecec;
  border: 1px solid #f5c2c4;
  color: #b42318;
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-sub); }
.btn-ghost:hover { border-color: #c6cedd; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c5353a; }
.btn-block { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 12.5px; }

/* ---------- 主布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand {
  font-size: 17px;
  font-weight: 700;
  padding: 4px 10px 18px;
  letter-spacing: 0.5px;
}
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-sub);
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: #f0f4fb; color: var(--text); }
.nav-item.active { background: #e8effd; color: var(--primary); font-weight: 600; }
.nav-item .badge-reserved {
  margin-left: auto;
  font-size: 10.5px;
  background: #eef1f6;
  color: #9aa5b5;
  border-radius: 6px;
  padding: 2px 6px;
}
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.user-chip { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.user-name { font-size: 13.5px; font-weight: 600; }

.main { flex: 1; padding: 28px 34px; max-width: 1200px; }

.module-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.module-header h2 { font-size: 21px; }
.module-desc { color: var(--text-sub); font-size: 13.5px; margin-bottom: 24px; }

/* ---------- 房间分组与设备卡片 ---------- */
.room-title {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 600;
  letter-spacing: 1px;
  margin: 22px 0 12px;
}
.room-title:first-of-type { margin-top: 0; }
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.device-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}
.device-card:hover { transform: translateY(-2px); }
.device-top { display: flex; align-items: flex-start; justify-content: space-between; }
.device-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: #f0f4fb;
  border-radius: 10px;
}
.device-icon.on { background: #fff3e0; }
.device-name { font-size: 15px; font-weight: 600; }
.device-meta { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.device-bottom { display: flex; align-items: center; justify-content: space-between; }
.device-state { font-size: 13px; color: var(--text-sub); }
.device-state.on { color: var(--ok); font-weight: 600; }

.device-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  width: 30px; height: 30px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-sub);
  transition: border 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: #c6cedd; color: var(--text); }
.icon-btn.del:hover { border-color: #f0b4b6; color: var(--danger); }

/* 开关 */
.switch {
  position: relative;
  width: 44px; height: 24px;
  background: #d4dae4;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(20px); }
.switch.busy { opacity: 0.6; pointer-events: none; }

/* 空状态 & 预留模块 */
.empty-box {
  background: var(--panel);
  border: 1px dashed #cdd6e4;
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
}
.empty-box .big { font-size: 34px; margin-bottom: 10px; }

.reserved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.reserved-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  opacity: 0.75;
}
.reserved-card .r-icon { font-size: 26px; margin-bottom: 8px; }
.reserved-card .r-name { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.reserved-card .r-desc { font-size: 12.5px; color: var(--text-sub); line-height: 1.5; }
.reserved-tag {
  display: inline-block;
  font-size: 11px;
  background: #eef3fe;
  color: var(--primary);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 10px;
}

/* 顶部统计 */
.stats-row { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 130px;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--text-sub); margin-top: 2px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 460px;
  max-width: 100%;
  padding: 26px 26px 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-small { width: 360px; }
.modal h2 { font-size: 17px; margin-bottom: 18px; }
.modal p { font-size: 14px; color: var(--text-sub); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.params-box {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 0;
  margin-bottom: 14px;
}

/* ---------- 发货清单模块 ---------- */
.header-actions { display: flex; align-items: center; gap: 10px; }
.engine-badge {
  font-size: 12px; color: var(--text-sub); background: #f1f5f9;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}
.engine-badge.online { color: #0b6b47; background: #e7f6ef; border-color: #b7e2cd; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 16px 0 20px; }
.tab-btn {
  background: none; border: none; padding: 10px 16px; cursor: pointer;
  font-size: 14px; color: var(--text-sub); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.ship-editor textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  font-size: 14px; line-height: 1.7; resize: vertical; font-family: inherit; outline: none;
}
.ship-editor textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.ship-toolbar, .ship-save-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-sub); }
.inline-field select { width: auto; min-width: 220px; }
.hint { font-size: 12.5px; color: var(--text-sub); }
.muted { color: var(--text-sub); }

.ship-save-row input { flex: 1; min-width: 200px; }
.kw-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.kw-toolbar input { max-width: 320px; margin: 0; }

/* 分类条形图 */
.cat-list { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 18px; }
.cat-row { display: flex; flex-direction: column; gap: 6px; }
.cat-head { display: flex; justify-content: space-between; font-size: 13.5px; }
.cat-val { color: var(--text-sub); }
.bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #38bdf8); border-radius: 999px; transition: width 0.3s ease; }

/* 数据表 */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.data-table th {
  background: #f7f9fc; text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-sub); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfd; }
.cell-word { font-weight: 600; }
.cell-src { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-sub); }
.cell-actions { white-space: nowrap; }
.tag-new { margin-left: 6px; font-size: 11px; color: #b45309; background: #fef3c7; border-radius: 4px; padding: 1px 6px; font-weight: 500; }
.qty-input { width: 76px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.kw-chip {
  display: inline-block; font-size: 12px; background: #eef4ff; color: #1d4ed8;
  border-radius: 999px; padding: 2px 10px; margin: 2px 4px 2px 0;
}
.kw-chip.empty { background: #f1f5f9; color: var(--text-sub); }

/* 未匹配区 */
.unmatched-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 18px; }
.unmatched-item {
  display: flex; align-items: center; gap: 12px; background: #fbfcfd;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.u-text { flex: 1; font-size: 13.5px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 清单卡片 */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.list-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.list-card.done { opacity: 0.72; }
.lc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lc-title { font-size: 15px; font-weight: 600; word-break: break-all; }
.status-tag { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: #fff4e5; color: #b45309; white-space: nowrap; }
.status-tag.done { background: #e7f6ef; color: #0b6b47; }
.lc-meta { font-size: 12.5px; color: var(--text-sub); margin: 6px 0 10px; }
.lc-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 26px; }
.lc-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* 迷你开关 */
.switch-mini { position: relative; display: inline-block; width: 34px; height: 18px; cursor: pointer; }
.switch-mini input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-mini span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: 0.2s; }
.switch-mini span::before {
  content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch-mini input:checked + span { background: var(--primary); }
.switch-mini input:checked + span::before { transform: translateX(16px); }

.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-sub); }
.checkbox-line input { width: auto; margin: 0; }
.form-ok { font-size: 13px; color: #0b6b47; background: #e7f6ef; border-radius: 8px; padding: 8px 12px; margin-top: 12px; }
.modal-wide { width: 720px; }
form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.7;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  outline: none;
}
form textarea:focus { border-color: var(--primary); background: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #26324b;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 20px;
  border-radius: 10px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.3);
  animation: toast-in 0.25s ease;
}
.toast.err { background: #b42318; }
.toast.ok { background: #147247; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar-footer { border-top: none; padding-top: 0; }
  .main { padding: 20px 16px; }
}
