/* 打印农场 · Hub 版总控台
   参考：拓竹群控系统的信息布局（左导航 + 可点统计条 + 高密度卡片 + 打印中高亮）
   目标设备：iPad mini 6（8.3吋，最窄目标）→ 挂墙 iPad 9（10.2吋）→ 桌面浏览器
   触摸优先：点击目标 ≥44px、不依赖 hover。 */
:root {
  color-scheme: dark;
  --bg: #0b0e12; --panel: #12161d; --card: #161b23; --card2: #0d1116;
  --line: #232a34; --line2: #2d3644;
  --tx: #e9ecf1; --tx2: #98a2b3; --dim: #5b6673;
  --acc: #22c55e;            /* 主色：绿（拓竹风） */
  --acc-d: #16a34a;
  --blue: #3b82f6; --amber: #f59e0b; --red: #ef4444;
  --tap: 44px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--tx);
  font: 14px/1.45 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
.spacer { margin-left: auto; }

.app { display: flex; height: 100%; }

/* ---------------- 左侧导航 ---------------- */
.nav {
  width: 208px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .logo { font-size: 22px; }
.brand .bt { display: flex; flex-direction: column; font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.brand small { font-weight: 500; font-size: 10px; color: var(--dim); letter-spacing: .6px; }
.ni {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: var(--tap);
  padding: 0 12px; border-radius: 10px; color: var(--tx2); font-size: 14px; text-align: left;
}
.ni i { font-style: normal; width: 20px; text-align: center; font-size: 15px; flex: none; }
.ni:active { background: #1b212b; }
.ni.act { background: #17301f; color: #86efac; font-weight: 700; }
.ni.act i { color: var(--acc); }
.navfoot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  font-size: 12px; color: var(--tx2); border-top: 1px solid var(--line); }
.hubdot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.hubdot.on { background: var(--acc); box-shadow: 0 0 8px var(--acc); }

/* ---------------- 主区 ---------------- */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel); flex: none;
}
/* 可点统计条（点一下即筛选） */
.stats { display: flex; gap: 6px; flex-wrap: wrap; align-content: flex-start; }
.st {
  display: flex; align-items: baseline; gap: 5px; min-height: 34px; padding: 0 11px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--card2); color: var(--tx2);
  font-size: 12px; white-space: nowrap;
}
.st b { font-size: 15px; font-weight: 800; color: var(--tx); }
.st.on { border-color: var(--acc); background: #14251a; color: #86efac; }
.st.on b { color: #86efac; }
.st:active { background: #1b212b; }

.search { display: flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card2); flex: 0 1 230px; }
.search i { font-style: normal; font-size: 13px; color: var(--dim); }
.search input { border: none; background: none; outline: none; width: 100%; min-width: 0; font-size: 14px; }
button.go { min-height: 38px; padding: 0 18px; border-radius: 10px; background: var(--acc-d);
  color: #fff; font-weight: 700; white-space: nowrap; }
button.go:active { background: #15803d; }

.banner { display: none; margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px;
  background: #3a2a10; color: #fcd34d; font-size: 13px; flex: none; }
.banner.show { display: block; }

/* ---------------- 卡片网格 ---------------- */
.grid {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  display: grid; gap: 12px; padding: 14px 18px calc(30px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  align-content: start;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 13px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.card.printing { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), 0 6px 22px -12px var(--acc); }
.card.awaiting { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.card.alarm { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.card.off { opacity: .55; }

/* 卡头：名字 + 机型标签 */
.chead { display: flex; align-items: center; gap: 8px; }
.chead .nm { font-size: 17px; font-weight: 800; letter-spacing: .3px; }
.chead .mdl { margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--tx2); white-space: nowrap; }
.chead .mdl .d { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }

/* 卡身：左机器图 + 右信息 */
.cbody { display: flex; gap: 12px; }
.pic { flex: 0 0 84px; }
.pic svg { width: 84px; height: 96px; display: block; }
.info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.line1 { display: flex; align-items: baseline; gap: 8px; }
.line1 .sname { font-size: 14px; font-weight: 800; }
.line1 .pct { margin-left: auto; font-size: 14px; font-weight: 800; color: var(--tx2); }
.bar { height: 5px; border-radius: 4px; background: #202836; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .6s; }
.rem { font-size: 15px; font-weight: 800; }
.rows { font-size: 11.5px; color: var(--tx2); display: flex; flex-direction: column; gap: 2px; }
.rows .f { color: #b8c2d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* AMS 槽位色块（照参考图：小方块一排） */
.amsrow { display: flex; align-items: center; gap: 8px; }
.amsrow .lb { font-size: 10px; font-weight: 800; color: var(--dim); letter-spacing: .6px; flex: none; }
.sq { display: flex; gap: 5px; align-items: center; }
/* 装了料 = 实心块 + 亮边（深色料如黑 PLA 才看得出来，不然跟空槽混） */
.sq span { width: 17px; height: 17px; border-radius: 4px; border: 1px solid #7c8798;
  box-shadow: inset 0 0 0 1px #00000055; flex: none; }
/* 空槽：虚线空框，跟"装了黑料"明确区分开（黑料是实心块） */
.sq span.e { background: none; border: 1px dashed #3d4757; box-shadow: none; }
.sq .sep { width: 1px; height: 15px; background: var(--line2); border: none; box-shadow: none;
  border-radius: 0; margin: 0 2px; }

.alarmline { font-size: 11.5px; color: #fca5a5; }

/* 卡片底部操作（照参考图：一排文字按钮） */
.cfoot { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.cfoot button { min-height: 34px; padding: 0 10px; border-radius: 8px; font-size: 13px; color: var(--tx2); }
.cfoot button:active { background: #1b212b; }
.cfoot .prim { color: #86efac; font-weight: 700; }
.cfoot .warn { color: #fca5a5; }
.cfoot .rt { margin-left: auto; display: flex; gap: 4px; }

/* ---------------- 右侧抽屉 ---------------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(94vw, 440px); z-index: 40;
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(101%); transition: transform .26s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.dh { display: flex; align-items: center; gap: 10px; padding: 15px 18px;
  padding-top: calc(15px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); font-size: 17px; }
.dh b { font-weight: 800; }
.dh .x { width: var(--tap); height: var(--tap); display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--tx2); margin: -10px -8px -10px 0; }
.dbody { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 18px calc(26px + env(safe-area-inset-bottom)); }
.tag { font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 20px; }

.sec { margin-bottom: 18px; }
.sec > h4 { margin: 0 0 9px; font-size: 12px; color: var(--dim); font-weight: 800; letter-spacing: .5px; }
.row { display: flex; align-items: center; gap: 9px; margin: 8px 0; }
.row > .lbl { font-size: 13px; color: var(--tx2); flex: 0 0 72px; }
.row input[type=number], .row select {
  flex: 1; min-width: 0; min-height: var(--tap); padding: 0 11px;
  background: var(--card2); border: 1px solid var(--line2); border-radius: 10px; font-size: 15px;
}
.row input[type=color] { width: 52px; height: var(--tap); padding: 0; border: 1px solid var(--line2);
  border-radius: 10px; background: var(--card2); flex: none; }
.btn { min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--card2); font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:active { background: #1b212b; }
.btn.pri { background: var(--acc-d); border-color: var(--acc-d); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.warn { border-color: #7f2d2d; color: #fca5a5; }
.btn:disabled { opacity: .42; }
.btn.wide { width: 100%; justify-content: center; }

.slotcard { border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 10px; }
.slotcard .sh2 { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; }
.slotcard .sh2 b { font-size: 14px; }
.slotcard .sw { width: 18px; height: 18px; border-radius: 5px; border: 1px solid #0008; flex: none; }
.slotcard .cur { font-size: 11.5px; color: var(--tx2); }
.locked { color: var(--amber); font-size: 11.5px; margin-top: 6px; line-height: 1.5; }
.hint { color: var(--dim); font-size: 11.5px; margin-top: 8px; line-height: 1.55; }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 7px 0;
  border-bottom: 1px solid var(--line); }
.kv:last-child { border: none; }
.kv span:first-child { color: var(--tx2); }

/* ---------------- 弹窗 / 提示 ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.78); padding: 16px; }
.modal.open { display: flex; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  width: min(96vw, 470px); max-height: 92vh; overflow: auto; }
.box h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.box label { display: block; font-size: 12.5px; color: var(--tx2); margin: 15px 0 6px; }
.box input[type=file], .box input[type=number], .box select {
  width: 100%; min-height: var(--tap); padding: 0 11px; background: var(--card2);
  border: 1px solid var(--line2); border-radius: 10px; font-size: 15px; }
.box input[type=file] { padding: 10px 11px; height: auto; }
.machpick { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.machpick button { min-height: var(--tap); padding: 0 13px; border-radius: 10px;
  border: 1px solid var(--line2); background: var(--card2); font-size: 14px; }
.machpick button.on { background: var(--acc-d); border-color: var(--acc-d); color: #fff; font-weight: 700; }
.machpick button:disabled { opacity: .36; }
.msg { margin-top: 14px; font-size: 13.5px; min-height: 20px; line-height: 1.55; white-space: pre-line; }
.btns { display: flex; gap: 11px; margin-top: 18px; }
.btns button { flex: 1; min-height: 48px; border-radius: 12px; background: #232a34; font-size: 16px; font-weight: 700; }
.btns button.pri { background: var(--acc-d); color: #fff; }
.btns button:disabled { opacity: .5; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 22px); z-index: 60;
  max-width: 88vw; padding: 12px 20px; border-radius: 12px; background: #1c232e;
  border: 1px solid var(--line2); font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: #276e42; }
.toast.err { border-color: #7f2d2d; }
.empty { grid-column: 1/-1; color: var(--dim); text-align: center; padding: 70px 20px; font-size: 14px; line-height: 1.8; }

/* ---------------- 横屏优化（iPad 主用姿势：宽而矮）----------------
   iPad mini 6 横屏 1133×744 / iPad 9 横屏 1080×810。
   宽度够 → 多列；高度矮 → 卡片压扁、顶栏收紧，尽量一屏看到更多机器。 */
@media (min-width: 1000px) and (max-height: 840px) {
  header { padding: 8px 16px; }
  .st { min-height: 30px; padding: 0 9px; font-size: 11.5px; }
  .st b { font-size: 14px; }
  .search, button.go { min-height: 34px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; padding: 10px 16px 16px; }
  .card { padding: 10px 11px; gap: 7px; }
  .pic { flex: 0 0 66px; }
  .pic svg { width: 66px; height: 76px; }
  .chead .nm { font-size: 16px; }
  .rem { font-size: 14px; }
  .rows { font-size: 11px; }
  .sq span { width: 15px; height: 15px; }
  .cfoot { padding-top: 6px; }
  .cfoot button { min-height: 31px; font-size: 12.5px; }
}
/* 更宽的桌面/大 iPad 横屏：铺到 4-5 列 */
@media (min-width: 1400px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

/* ---------------- 窄屏（iPad mini 竖屏 744 / 手机）---------------- */
@media (max-width: 1000px) {
  .nav { width: 62px; padding: 12px 8px; align-items: center; }
  .nav .bt, .ni span { display: none; }
  .brand { padding: 4px 0 14px; }
  .ni { justify-content: center; padding: 0; }
  .navfoot { justify-content: center; padding: 10px 0; }
  header { flex-wrap: wrap; padding: 10px 12px; }
  .search { flex: 1 1 100%; order: 3; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); padding: 12px; gap: 10px; }
}
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; top: auto; height: 90vh; border-radius: 18px 18px 0 0;
    border-left: none; border-top: 1px solid var(--line); transform: translateY(101%); }
  .drawer.open { transform: none; }
}
