/* ==========================================================
   机车监控打温系统 · 大屏样式
   小清新浅色风 / CSS Grid 四区 / 三级响应式
   ========================================================== */
:root {
  --bg: #f3f9f6;
  --bg-grad:
    radial-gradient(1100px 620px at 10% -12%, #dff3ea 0%, transparent 62%),
    radial-gradient(900px 560px at 92% 6%, #e5f2fb 0%, transparent 60%),
    #f4f9f7;
  --panel: #ffffff;
  --panel-head: #f1faf5;
  --panel-alt: #f7fbfa;
  --line: #dbe9e3;
  --line-soft: #e9f2ee;
  --text: #233e39;
  --text-2: #4f6e68;
  --muted: #78938d;
  --cyan: #2fa48f;
  --green: #2fa36f;
  --amber: #c9901f;
  --orange: #d9753a;
  --red: #d95d61;
  --blue: #5b9dd9;
  --purple: #8a72c4;
  --shadow: 0 6px 22px rgba(45, 100, 86, .07);
  --radius: 14px;
  --num: 'Bahnschrift', 'DIN Alternate', 'Roboto Condensed', Consolas, 'SF Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg-grad);
  color: var(--text);
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 16px clamp(14px, 1.6vw, 30px) 10px; max-width: 2400px; margin: 0 auto; }

/* ───────── 顶栏 ───────── */
.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { width: 50px; height: 50px; flex: none; color: var(--cyan); filter: drop-shadow(0 3px 8px rgba(47,164,143,.22)); }
.brand-mark svg { width: 100%; height: 100%; }

.band-switch { text-align: center; }
.band-title { font-size: 11px; color: var(--text-2); letter-spacing: 2px; margin-bottom: 7px; }
.band-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.band-btn {
  position: relative; min-width: 146px; padding: 9px 12px; cursor: pointer;
  background: #ffffff; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: clamp(13px, 1vw, 16px); font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(45,100,86,.04);
  transition: .18s ease;
}
.band-btn small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.band-btn:hover { border-color: var(--cyan); color: var(--text); transform: translateY(-1px); }
.band-btn.active {
  background: linear-gradient(135deg, #e3f6ef, #e9f4fb);
  border-color: var(--cyan); color: var(--text);
  box-shadow: 0 0 0 1px rgba(47,164,143,.18), 0 6px 18px rgba(47,164,143,.12);
}
.band-btn.active small { color: #4a9987; }
.band-btn.active::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); transform: translateX(-50%); box-shadow: 0 0 8px rgba(47,164,143,.6); }
/* 停止倒计时档位（0℃以上 / -20℃以下）用蓝色区分于正常计时档 */
.band-btn[data-paused].active { background: linear-gradient(135deg, #e6f0fb, #eaf6f4); border-color: var(--blue); box-shadow: 0 0 0 1px rgba(91,157,217,.18), 0 6px 18px rgba(91,157,217,.12); }
.band-btn[data-paused].active small { color: #4a7fb5; }
.band-btn[data-paused].active::after { background: var(--blue); box-shadow: 0 0 8px rgba(91,157,217,.6); }

.topright { display: flex; align-items: center; justify-content: flex-end; gap: clamp(10px, 1.2vw, 20px); }
.clock { text-align: center; line-height: 1.1; }
.clock-time { font-family: var(--num); font-size: clamp(22px, 2vw, 34px); font-weight: 700; letter-spacing: 2px; color: var(--text); font-variant-numeric: tabular-nums; }
.clock-date { font-size: 11px; color: var(--text-2); margin-top: 4px; }

/* ───────── 概览条 ───────── */
.overview { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.kpi {
  flex: 1 1 120px; min-width: 108px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f5fbf8);
  box-shadow: 0 2px 10px rgba(45,100,86,.04);
}
.kpi-label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.kpi strong { font-family: var(--num); font-size: clamp(22px, 1.9vw, 30px); line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 11px; color: var(--muted); }
.c-cyan { color: var(--cyan); } .c-amber { color: var(--amber); } .c-red { color: var(--red); } .c-muted { color: var(--muted); }
.overview-meta { flex: 1 1 280px; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 3px; padding: 4px 6px; }
.meta-line { font-size: 11px; color: var(--muted); }
.switch-line { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); cursor: pointer; user-select: none; }
.switch-line input { accent-color: var(--cyan); cursor: pointer; }
.weather-line { display: flex; align-items: center; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.weather-temp { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; cursor: help; }
.weather-temp.is-fallback { color: var(--orange); }
.mini-btn {
  font: inherit; font-size: 10px; line-height: 1; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--text-2); cursor: pointer; white-space: nowrap; transition: .2s;
}
.mini-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.mini-btn:active { transform: translateY(1px); }

/* ───────── 四区 ───────── */
.zones { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-content: start; }
.zone {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.zone-head {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 16px;
  background: linear-gradient(90deg, #eef8f3, #ffffff);
  border-bottom: 1px solid var(--line-soft); border-left: 3px solid var(--zone-color, var(--cyan));
}
.zone-index {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border-radius: 8px; background: var(--zone-color, var(--cyan)); color: #ffffff;
  font-family: var(--num); font-weight: 800; font-size: 15px;
}
.zone-name { font-size: clamp(14px, 1.15vw, 18px); font-weight: 700; letter-spacing: 1px; color: var(--text); }
.zone-count { font-size: 12px; color: var(--text-2); margin-left: 4px; }
.zone-tags { margin-left: 12px; display: flex; gap: 6px; }
.ztag { font-size: 11px; padding: 3px 8px; border-radius: 11px; border: 1px solid var(--line); color: var(--text-2); background: #ffffff; }
.ztag.warn { color: var(--amber); border-color: rgba(201,144,31,.35); background: rgba(201,144,31,.09); }
.ztag.over { color: var(--red); border-color: rgba(217,93,97,.35); background: rgba(217,93,97,.08); }

.thead, .row { display: grid; grid-template-columns: 1.12fr 1fr .82fr .82fr 1.18fr; align-items: center; gap: 8px; }
.thead { padding: 8px 16px; background: #f6fbf9; border-bottom: 1px solid var(--line-soft); }
.thead span { font-size: 11px; color: var(--text-2); font-weight: 600; letter-spacing: 1px; text-align: center; }
.thead span:last-child { text-align: center; }
.zone-body { padding: 4px 0; }
.row {
  position: relative; padding: 7px 16px; min-height: 66px;
  border-bottom: 1px solid var(--line-soft); transition: background .15s;
}
.zone-body .row:last-child { border-bottom: none; }
.row:hover { background: rgba(47,164,143,.06); }
.row.is-over { background: linear-gradient(90deg, rgba(217,93,97,.10), transparent 70%); }
.row.is-over::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); }
.row.is-warn { background: linear-gradient(90deg, rgba(201,144,31,.08), transparent 70%); }
.empty-row { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* 列：机车号 */
.loco-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: center; text-align: center; }
.loco-no { font-family: var(--num); font-size: clamp(17px, 1.45vw, 23px); font-weight: 700; letter-spacing: 1px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.loco-sub { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font-size: 10px; line-height: 1.5; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--text-2); background: #f7fbfa; white-space: nowrap; }
.chip.track { color: var(--cyan); border-color: rgba(47,164,143,.35); background: rgba(47,164,143,.09); font-family: var(--num); font-weight: 700; }
.chip.status { color: var(--amber); border-color: rgba(201,144,31,.3); background: rgba(201,144,31,.07); }
/* 每台机车「备用」后的「库内」按钮：点选停止该车倒计时，再点取消 */
.chip-btn { cursor: pointer; font-family: inherit; transition: .15s ease; }
.chip-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.chip-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.chip-btn.is-on { color: #fff; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
/* 自动入库标识：机车中心落在 7G/8G/9G「大库」框内，随位置自动进出库，不可点 */
.chip-auto { color: var(--cyan); border-color: var(--cyan); border-style: dashed; background: rgba(47,164,143,.07); font-weight: 700; cursor: default; }

/* 列：打温时间 */
.time-cell { display: flex; flex-direction: column; gap: 3px; align-items: center; text-align: center; }
.time-main { font-family: var(--num); font-size: clamp(14px, 1.15vw, 18px); font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.time-sub { font-size: 10px; color: var(--muted); }
.time-cell.none .time-main { color: var(--muted); }

/* 列：图片 */
.thumb {
  position: relative; width: 100%; max-width: 118px; height: clamp(38px, 3.4vw, 50px);
  border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #f2f8f5;
  display: grid; place-items: center; cursor: zoom-in; transition: .15s;
}
.thumb:hover { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(47,164,143,.22); }
.thumb img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--muted); background: repeating-linear-gradient(45deg, #f0f7f3, #f0f7f3 6px, #e9f3ee 6px, #e9f3ee 12px); }
.thumb.ok .thumb-ph { display: none; }
.thumb-label { font-size: 9px; color: var(--muted); margin-top: 3px; }

/* 列：图片（居中缩略图） */
.img-cell { display: flex; justify-content: center; align-items: center; }

/* 列：倒计时 */
.count-cell { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.count-num { font-family: var(--num); font-size: clamp(19px, 1.65vw, 27px); font-weight: 700; line-height: 1; letter-spacing: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.count-tag { font-size: 10px; padding: 1px 7px; border-radius: 9px; border: 1px solid transparent; }
.s-normal .count-num { color: var(--green); } .s-normal .count-tag { color: var(--green); border-color: rgba(47,163,111,.35); background: rgba(47,163,111,.07); }
.s-warn .count-num { color: var(--amber); } .s-warn .count-tag { color: var(--amber); border-color: rgba(201,144,31,.35); background: rgba(201,144,31,.09); }
.s-danger .count-num { color: var(--orange); } .s-danger .count-tag { color: var(--orange); border-color: rgba(217,117,58,.4); background: rgba(217,117,58,.1); }
.s-over .count-num { color: var(--red); animation: blink 1.1s infinite; } .s-over .count-tag { color: #fff; background: rgba(217,93,97,.88); }
.s-none .count-num { color: var(--muted); } .s-none .count-tag { color: var(--muted); border-color: var(--line); }
.s-paused .count-num { color: var(--blue); font-size: clamp(15px, 1.25vw, 21px); }
.s-paused .count-tag { color: var(--blue); border-color: rgba(91,157,217,.4); background: rgba(91,157,217,.09); }
/* 两步提交：只交了打温前照片 → 机车打温中（文字状态，不是数字倒计时） */
.s-warming .count-num { color: var(--purple); font-family: inherit; font-size: clamp(15px, 1.25vw, 21px); letter-spacing: 1px; }
.s-warming .count-tag { color: var(--purple); border-color: rgba(138,114,196,.4); background: rgba(138,114,196,.09); }

/* ───────── 底栏 ───────── */
.footer { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-normal { background: var(--green); } .lg-warn { background: var(--amber); } .lg-danger { background: var(--orange); } .lg-over { background: var(--red); } .lg-none { background: var(--muted); } .lg-warming { background: var(--purple); } .lg-paused { background: var(--blue); }

/* ───────── 图片查看器 / 提示 ───────── */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(26,58,52,.58); display: none; place-items: center; padding: 30px; backdrop-filter: blur(6px); }
.lightbox.open { display: grid; }
.lb-body { max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lb-body img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 10px; border: 1px solid rgba(255,255,255,.7); box-shadow: 0 18px 50px rgba(20,50,44,.3); }
.lb-caption { color: #ffffff; font-size: 13px; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.lb-close { position: absolute; top: 20px; right: 26px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.8); background: #ffffff; color: var(--text); font-size: 26px; line-height: 1; cursor: pointer; }
.lb-close:hover { border-color: var(--red); color: var(--red); }
.toast { position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 14px); padding: 10px 20px; border-radius: 10px; background: #ffffff; border: 1px solid var(--line); color: var(--text); font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 120; box-shadow: 0 8px 28px rgba(45,100,86,.16); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(217,93,97,.5); color: #b84448; }

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .38; } }

/* ───────── 响应式 ───────── */
/* 标准大屏：让四区填满视口高度，行在各自区内均分，行数少也不留空 */
@media (min-width: 1181px) and (min-height: 700px) {
  .app { height: 100vh; overflow: hidden; }
  .zones { min-height: 0; grid-auto-rows: minmax(0, 1fr); }
  .zone { min-height: 0; }
  .zone-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
  .zone-body .row { flex: 1 0 auto; }
  .zone-body::-webkit-scrollbar { width: 6px; }
  .zone-body::-webkit-scrollbar-thumb { background: #c8dfd7; border-radius: 3px; }
}
@media (min-width: 1500px) {
  .loco-no { font-size: clamp(20px, 1.6vw, 28px); }
  .count-num { font-size: clamp(22px, 1.9vw, 32px); }
  .time-main { font-size: clamp(16px, 1.25vw, 20px); }
  .thumb { height: clamp(46px, 5.2vh, 68px); max-width: 132px; }
  .chip { font-size: 11px; }
}
/* 超宽屏：四区仍保持 2×2（每区更宽、五列更从容），只放大字号，不切四列 */
@media (min-width: 2100px) {
  .topbar { padding-bottom: 18px; }
  .loco-no { font-size: 30px; }
  .count-num { font-size: 34px; }
  .time-main { font-size: 21px; }
  .thumb { height: 68px; max-width: 150px; }
  .chip { font-size: 12px; }
}
@media (max-width: 1500px) {
  .band-btn { min-width: 126px; padding: 8px 8px; }
  .brand-text p { letter-spacing: 0; }
  .row, .thead { gap: 6px; padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 1180px) {
  .zones { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr auto; }
  .band-switch { grid-column: 1 / -1; grid-row: 2; }
  .overview-meta { align-items: flex-start; flex: 1 1 100%; flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .app { padding: 12px 10px 8px; gap: 10px; max-width: 100%; overflow-x: hidden; }
  .topbar { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .topbar > * { min-width: 0; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 18px; letter-spacing: 1px; }
  .brand-text p { font-size: 10px; white-space: normal; }
  .band-switch { grid-column: 1; grid-row: auto; }
  .band-buttons { gap: 6px; min-width: 0; }
  .band-btn { flex: 1 1 44%; min-width: 0; font-size: 12px; padding: 8px 4px; }
  .band-btn small { font-size: 10px; letter-spacing: -.2px; }
  .topright { justify-content: space-between; gap: 8px; min-width: 0; flex-wrap: wrap; }
  .clock-time { font-size: 22px; }
  .kpi { flex: 1 1 30%; min-width: 92px; padding: 8px 10px; gap: 4px; }
  .kpi-label { font-size: 10px; }
  .kpi strong { font-size: 21px; }
  .thead { display: none; }
  .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px; padding: 12px; min-height: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .cell { position: relative; min-width: 0; }
  .cell::before { content: attr(data-label); display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; letter-spacing: 1px; }
  .loco-cell { grid-column: 1 / -1; padding-bottom: 6px; border-bottom: 1px dashed var(--line-soft); }
  .loco-cell::before { display: none; }
  .time-cell { grid-column: 1 / -1; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
  .time-cell::before { margin: 0; }
  .img-cell { display: flex; flex-direction: column; }
  .thumb { max-width: 100%; height: 74px; }
  .count-cell { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; border-top: 1px dashed var(--line-soft); padding-top: 8px; }
  .count-cell::before { margin: 0; }
  .weather-line { justify-content: flex-start; }
  .legend { gap: 8px; font-size: 10px; }
}
