:root {
  --ink: #172a3a;
  --muted: #6b7c8d;
  --line: #e5ebef;
  --surface: #fff;
  --wash: #f4f7f8;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --blue: #2878bd;
  --amber: #d88a20;
  --red: #d85d55;
  --shadow: 0 10px 32px rgba(21, 49, 68, .07);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--wash); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eaf3f1; }
.login-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 38px; box-shadow: var(--shadow); }
.brand-mark { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 21px; letter-spacing: .2px; }
.brand-dot { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--teal); font-size: 19px; }
.login-card h1 { margin: 42px 0 8px; font-size: 27px; }
.login-card .hint { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }
.field { display: grid; gap: 7px; margin: 15px 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 11px 12px; outline: 0; color: var(--ink); background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
.btn { border: 1px solid transparent; border-radius: 7px; padding: 10px 15px; color: var(--ink); background: #f0f4f5; font-weight: 650; }
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-danger { color: #a94039; background: #fff1ef; }
.btn-plain { padding: 6px 9px; background: transparent; color: var(--blue); }
.login-card .btn { width: 100%; margin-top: 12px; padding: 12px; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 242px 1fr; }
.sidebar { background: #142b37; color: #d8e4e7; padding: 24px 14px; display: flex; flex-direction: column; }
.sidebar .brand-mark { color: #fff; padding: 0 12px 30px; }
.sidebar .brand-dot { background: #0d9488; }
.nav { display: grid; gap: 4px; }
.nav button { text-align: left; border: 0; border-radius: 7px; padding: 11px 12px; color: #afc1c8; background: transparent; font-weight: 600; }
.nav button:hover, .nav button.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-kicker { padding: 18px 12px 7px; font-size: 11px; color: #6e8a94; letter-spacing: 1.4px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 16px 12px 0; font-size: 13px; color: #a9bbc2; }
.sidebar-footer button { margin-top: 12px; border: 0; padding: 0; color: #fff; background: transparent; }
.main { min-width: 0; }
.topbar { min-height: 70px; padding: 15px 30px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 20px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.farm-select { border: 1px solid var(--line); padding: 8px 10px; border-radius: 7px; min-width: 145px; color: var(--ink); background: #fff; }
.content { max-width: 1500px; margin: 0 auto; padding: 28px 30px 45px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 21px; }
.page-head h1 { margin: 0 0 5px; font-size: 25px; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-bottom: 19px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 18px; box-shadow: 0 2px 6px rgba(21,49,68,.02); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 9px; font-size: 28px; font-weight: 750; }
.stat-note { margin-top: 7px; color: var(--muted); font-size: 12px; }
.stat-note.good { color: var(--teal-dark); }
.grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.irrigation-layout { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(560px, 1.3fr); gap: 18px; align-items: start; }
.irrigation-task-list { display: grid; gap: 0; }
.irrigation-task-card { padding: 18px; border-bottom: 1px solid var(--line); }
.irrigation-task-card:last-child { border-bottom: 0; }
.irrigation-task-head, .irrigation-tree-group, .irrigation-task-actions, .irrigation-builder-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.irrigation-tree { display: grid; gap: 7px; margin: 15px 0; }
.irrigation-running { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 15px 0; padding: 12px; border: 1px solid #b8ded8; background: #effaf7; }
.irrigation-running > div { display: grid; gap: 4px; }
.irrigation-running span, .irrigation-config { color: var(--muted); font-size: 12px; }
.irrigation-running b { font-size: 13px; word-break: break-word; }
.irrigation-running-devices { grid-column: 1 / -1; }
.irrigation-config { display: flex; gap: 18px; margin: 14px 0; }
.irrigation-tree-group { padding: 9px 11px; border-left: 3px solid #6abbb2; background: #f5faf9; font-size: 13px; }
.irrigation-tree-group.active { border-left-color: var(--teal-dark); background: #e8f7f3; }
.irrigation-tree-group b { margin-right: 9px; }
.irrigation-tree-group span, .irrigation-tree-group small { color: var(--muted); font-size: 12px; }
.irrigation-group-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.irrigation-task-actions { justify-content: flex-start; flex-wrap: wrap; }
.modal-wide { width: min(880px, 100%); }
.irrigation-builder { display: grid; gap: 12px; }
.irrigation-builder-group { padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: #fbfdfd; }
.irrigation-builder-head { margin-bottom: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px 6px rgba(21,49,68,.02); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f7f9fa; color: var(--muted); font-weight: 650; text-align: left; white-space: nowrap; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfdfd; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #a5b2b8; }
.status.online::before, .status.success::before { background: var(--teal); }
.status.warn::before { background: var(--amber); }
.status.error::before { background: var(--red); }
/* OTA 状态列保持进度条宽度固定，错误原因可换行以免撑开表格。 */
.ota-state { display: grid; gap: 4px; min-width: 120px; }
.ota-state small { color: var(--muted); max-width: 220px; overflow-wrap: anywhere; }
.ota-state progress { width: 120px; height: 6px; accent-color: var(--teal); }
.ota-select, #ota-select-all { width: 16px; height: 16px; accent-color: var(--teal); }
.ota-release-section { margin-bottom: 18px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 35px 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.toolbar input, .toolbar select { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; color: var(--ink); background: #fff; }
.toolbar #ota-release-select { min-width: 0; max-width: 100%; flex: 1 1 280px; }
/* 小屏将固件选择器和发送按钮放在同一行，避免操作区横向溢出。 */
@media (max-width: 700px) {
  .panel-head:has(.ota-toolbar) { flex-wrap: wrap; }
  .ota-toolbar { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .ota-toolbar > * { min-width: 0; flex: none; }
  .ota-toolbar label { grid-column: 1 / -1; }
  .ota-toolbar select { width: 100%; }
  .ota-toolbar button { white-space: nowrap; }
}
.toolbar input { min-width: 210px; }
.chart-bars { min-height: 186px; display: flex; align-items: flex-end; gap: 15px; padding: 15px 8px 6px; border-bottom: 1px solid var(--line); }
.bar-wrap { flex: 1; display: grid; gap: 6px; justify-items: center; min-width: 35px; }
.bar { width: 100%; max-width: 42px; min-height: 4px; border-radius: 5px 5px 0 0; background: #72c7be; }
.bar-label, .bar-value { color: var(--muted); font-size: 11px; }
.bar-value { color: var(--ink); font-weight: 650; }
.device-list { display: grid; gap: 12px; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.device-row:last-child { padding-bottom: 0; border-bottom: 0; }
.device-name { font-weight: 650; }
.device-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(13, 33, 43, .42); }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; border-radius: 10px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 22px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 20px; border-top: 1px solid var(--line); }
.modal-note { margin-bottom: 14px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.irrigation-choices { display: grid; gap: 7px; max-height: 310px; overflow: auto; padding: 2px; }
.irrigation-choice { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 60px; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.irrigation-choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.irrigation-choice small { color: var(--muted); white-space: nowrap; }
.irrigation-order { width: 60px; padding: 6px; border: 1px solid var(--line); border-radius: 5px; text-align: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.toast { position: fixed; right: 25px; bottom: 24px; z-index: 20; transform: translateY(18px); opacity: 0; pointer-events: none; border-radius: 7px; padding: 12px 16px; color: #fff; background: #173943; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { transform: translateY(0); opacity: 1; }
@media (max-width: 1120px) { .irrigation-layout { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .irrigation-running { grid-template-columns: 1fr; } .irrigation-config { display: grid; gap: 5px; } }
@media (max-width: 980px) { .shell { grid-template-columns: 70px 1fr; } .sidebar { padding: 18px 8px; } .sidebar .brand-mark { padding: 0 8px 25px; } .brand-mark span:last-child, .nav-kicker, .sidebar-footer span, .sidebar-footer button { display: none; } .nav button { text-align: center; font-size: 0; } .nav button::first-letter { font-size: 17px; } .sidebar-footer { padding: 15px 8px 0; } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .topbar { padding: 12px 16px; } .topbar h2 { font-size: 17px; } .content { padding: 20px 16px 35px; } .stats { grid-template-columns: 1fr 1fr; } .page-head { display: block; } .page-actions { margin-top: 14px; } .form-grid { grid-template-columns: 1fr; } .form-grid .full { grid-column: auto; } .toolbar input { min-width: 0; width: 100%; } .toolbar { align-items: stretch; } .toolbar > * { flex: 1; } .farm-select { min-width: 110px; } }
@media (max-width: 700px) {
  .topbar h2, #refresh { white-space: nowrap; }
  .top-actions { min-width: 0; flex: 1; justify-content: flex-end; }
  .top-actions .farm-select { min-width: 0; width: 100%; max-width: 150px; }
  #refresh { flex: none; }
}

/* ★ 新增：登录方式切换Tab样式 */
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.login-tab {
  flex: 1;
  padding: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.login-tab.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

/* ★ 新增：扫码登录面板样式 */
.qr-wrap {
  text-align: center;
  padding: 10px 0;
}
.qr-img {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}
.qr-loading {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}
.qr-tip {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
