* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2328; background: #f6f7f9; }
a { color: #0b5cad; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 480px; margin: 0 auto; padding: 16px; }

nav.top { display: flex; align-items: center; gap: 4px 20px; padding: 0 16px; background: #1f2d3d; }
nav.top .nav-head { display: contents; }
nav.top a, nav.top .who, nav.top button.link { color: #dbe4ee; font-size: 14px; white-space: nowrap; }
nav.top a.brand { color: #fff; font-weight: 600; order: 0; }
nav.top .nav-links { order: 1; flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.top .nav-links::-webkit-scrollbar { display: none; }
nav.top .nav-links a { padding: 12px 8px; border-bottom: 3px solid transparent; }
nav.top .nav-links a.on { color: #fff; border-bottom-color: #4c9aff; }
nav.top .nav-links a:hover { text-decoration: none; color: #fff; }
nav.top .who { order: 2; }
nav.top form.inline { order: 3; }
form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; color: #0b5cad; font: inherit; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.ok { background: #e6f4ea; color: #1e6b34; }
.flash.err { background: #fdecea; color: #a1261b; }

.card { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 auto; }
.muted { color: #6a737d; font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 7px 8px; border-bottom: 1px solid #eceef1; text-align: left; vertical-align: top; }
th { background: #f2f4f7; font-weight: 600; font-size: 13px; color: #444; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

label { display: block; font-size: 13px; color: #555; margin-bottom: 3px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 5px; background: #fff; max-width: 100%; }
input[type=number] { width: 110px; }
textarea { width: 100%; min-height: 90px; }
button, .btn { display: inline-block; font: inherit; padding: 7px 14px; border-radius: 5px; border: 1px solid #0b5cad;
  background: #0b5cad; color: #fff; cursor: pointer; }
button.secondary, .btn.secondary { background: #fff; color: #0b5cad; }
button.danger { background: #fff; color: #b3261e; border-color: #b3261e; }
button.small { padding: 3px 9px; font-size: 13px; }

.demo-login { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #eceef1; }
.demo-login .muted { margin: 0 0 8px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-chips .demo-chip { min-width: 4.5em; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: #eceef1; color: #444; }
.badge.red { background: #fdecea; color: #a1261b; }
.badge.yellow { background: #fff4d6; color: #7a5a00; }
.badge.green { background: #e6f4ea; color: #1e6b34; }
.badge.blue { background: #e3effc; color: #0b5cad; }
tr.risk-red td:first-child { border-left: 4px solid #d93025; }
tr.risk-yellow td:first-child { border-left: 4px solid #f2b400; }
tr.risk-green td:first-child { border-left: 4px solid #34a853; }

.bar { height: 8px; background: #eceef1; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: #34a853; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 12px 16px; min-width: 130px; }
.stat b { display: block; font-size: 24px; }

.flag { font-size: 12px; color: #a1261b; }
.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-mobile { display: inline; }
  .hide-mobile { display: none !important; }
}
td.edited, input.warn, select.warn { background: #fff8e1; }

/* 工人报工：大按钮、大数字 */
.worker { font-size: 17px; }
.worker .big { font-size: 34px; font-weight: 700; }
.ops { display: grid; gap: 8px; margin: 12px 0; }
.ops a { display: block; padding: 12px; border: 2px solid #c9cfd6; border-radius: 8px; color: #1f2328; background: #fff; }
.ops a.on { border-color: #0b5cad; background: #e3effc; }
.ops a.off { opacity: .5; }
.field-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.field-toggle button { padding: 10px 0; background: #fff; color: #1f2328; border: 2px solid #c9cfd6; }
.field-toggle button.on { border-color: #0b5cad; background: #e3effc; }
.display { font-size: 40px; font-weight: 700; text-align: right; padding: 8px 12px; background: #fff; border: 2px solid #0b5cad;
  border-radius: 8px; min-height: 64px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.keypad button { font-size: 28px; padding: 16px 0; background: #fff; color: #1f2328; border: 1px solid #c9cfd6; }
.submit-big { width: 100%; font-size: 22px; padding: 16px; }
.queue { background: #fff4d6; color: #7a5a00; padding: 10px; border-radius: 6px; margin: 10px 0; }

/* 手机 */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .wrap, .narrow { padding: 12px; }
  h1 { font-size: 19px; margin: 4px 0 12px; }
  h2 { font-size: 16px; margin: 18px 0 8px; }

  nav.top { display: block; padding: 0; position: sticky; top: 0; z-index: 10; }
  nav.top .nav-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 2px; }
  nav.top .nav-head .brand { flex: 1; overflow: hidden; text-overflow: ellipsis; }
  nav.top .who { font-size: 13px; color: #9fb0c3; }
  nav.top .nav-links { padding: 0 4px; }
  nav.top .nav-links a { padding: 10px 10px 9px; font-size: 15px; }

  .card { padding: 12px; }
  .row { gap: 10px; }
  /* 表单：两列栅格，输入框撑满 */
  form.row > div, .card.row > div { flex: 1 1 calc(50% - 5px); min-width: 0; }
  form.row > div.grow, .card.row > div.grow { flex-basis: 100%; }
  form.row input:not([type=checkbox]):not([type=radio]), form.row select,
  .card.row input:not([type=checkbox]), .card.row select { width: 100%; }
  form.row > div:last-child:has(> button:only-child) { flex: 0 0 auto; align-self: flex-end; }
  form.row > input, form.row > select { flex: 1 1 140px; min-width: 0; }
  input, select, textarea { font-size: 16px; }   /* iOS 小于 16px 会自动放大页面 */
  button, .btn { padding: 9px 16px; }
  button.small { padding: 6px 10px; font-size: 14px; }

  /* 表格：不挤压成一字一行，改为横向滑动 */
  .table-scroll { margin: 0 -12px; padding: 0 12px; }
  .table-scroll table { min-width: 100%; width: max-content; }
  th, td { white-space: nowrap; padding: 8px 10px; }
  td .muted { white-space: normal; }
  td form.row { flex-wrap: nowrap; }
  td form.row > * { flex: 0 0 auto; }
  td form.row input { width: auto !important; }

  /* 常用列表在手机上改为卡片：每行一张卡，td 用 data-label 显示字段名 */
  .table-scroll:has(> table.cards) { margin: 0; padding: 0; }
  table.cards { width: 100% !important; min-width: 0 !important; background: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards tr:has(> th) { display: none; }
  table.cards tr { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; margin-bottom: 10px; padding: 8px 12px; }
  table.cards td { border: 0; padding: 3px 0; white-space: normal; display: flex; gap: 10px; text-align: left !important; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); flex: 0 0 5.5em; color: #6a737d; font-size: 13px; padding-top: 1px; }
  table.cards td.card-title { font-weight: 600; font-size: 16px; }
  table.cards td.card-title .muted { font-weight: normal; }
  table.cards td.card-actions { padding-top: 8px; }
  table.cards td.card-actions form.row { flex-wrap: wrap; width: 100%; }
  table.cards td.card-actions form.row input { flex: 1 1 120px; width: auto !important; }
  table.cards tr.risk-red { border-left: 5px solid #d93025; }
  table.cards tr.risk-yellow { border-left: 5px solid #f2b400; }
  table.cards tr.risk-green { border-left: 5px solid #34a853; }
  table.cards tr[class^=risk] td:first-child { border-left: 0; }
  table.cards td > .bar { flex: 1; align-self: center; }

  .stats { gap: 8px; }
  .stat { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 10px 12px; }
  .stat b { font-size: 22px; }
}

/* 打印：流转卡 / 送货单 */
.sheet { background: #fff; max-width: 800px; margin: 0 auto; padding: 24px; }
.sheet table th, .sheet table td { border: 1px solid #333; }
.card-head { display: flex; justify-content: space-between; gap: 16px; }
.qr svg { width: 150px; height: 150px; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .sheet { padding: 0; }
}
