* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f5f7; color: #222; font-size: 14px; }
header { display: flex; align-items: center; gap: 16px; background: #1f3a5f; color: #fff; padding: 8px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav button { background: transparent; border: 0; color: #cfd8e3; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; }
nav button.active { background: #fff; color: #1f3a5f; font-weight: 600; }
.userbox { display: flex; gap: 8px; align-items: center; }
.userbox button { background: #2c4f7c; color: #fff; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.badge { background: #d92d20; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border-radius: 10px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card .num { font-size: 22px; font-weight: 700; margin-top: 4px; }
.card .lbl { color: #667; }
table { border-collapse: collapse; width: 100%; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
th, td { border-bottom: 1px solid #eee; padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: #f0f2f5; font-weight: 600; }
tr.low td { background: #fff4f2; }
.short { color: #d92d20; font-weight: 700; }
.ok { color: #12805c; }
button.btn { background: #1f6fd6; color: #fff; border: 0; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
button.btn.secondary { background: #e8ecf1; color: #234; }
button.btn.danger { background: #d92d20; }
button.btn.small { padding: 3px 8px; font-size: 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
input, select, textarea { padding: 6px 8px; border: 1px solid #c9d1d9; border-radius: 6px; font-size: 14px; }
textarea { width: 100%; min-height: 110px; }
.error { color: #d92d20; }
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card { background: #fff; padding: 28px; border-radius: 12px; width: 320px; box-shadow: 0 4px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }
.login-card button { background: #1f6fd6; color: #fff; border: 0; padding: 9px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; justify-content: center; align-items: flex-start; padding: 30px 12px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 12px; padding: 18px; width: 760px; max-width: 96vw; }
.modal h3 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.subtabs button { background: #e8ecf1; border: 0; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.subtabs button.active { background: #1f3a5f; color: #fff; }
.group-head td { background: #eef3f9; font-weight: 700; }
.muted { color: #889; font-size: 12px; }
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; inset: 0; }
}
.label-sheet { display: flex; flex-wrap: wrap; gap: 2mm; }
.label { border: 1px solid #999; padding: 1.5mm 2mm; overflow: hidden; page-break-inside: avoid; display: flex; flex-direction: column; justify-content: space-between; }
.label .code { font-weight: 700; font-size: 11pt; }
.label .name { font-size: 8pt; }
.label .spec { font-size: 7pt; color: #333; }
.label svg { width: 100%; height: 12mm; }
.label .bc-text { font-size: 7pt; text-align: center; letter-spacing: 1px; }
/* Phones: compress the header (brand + nav + user box) so the wrapped
   navigation rows take much less vertical space. Desktop is untouched. */
@media (max-width: 640px) {
  header { gap: 6px 10px; padding: 6px 10px; }
  .brand { font-size: 13px; }
  nav { gap: 2px; }
  nav button { padding: 3px 8px; font-size: 12.5px; border-radius: 5px; }
  .userbox { gap: 6px; font-size: 12px; }
  .userbox button { padding: 3px 8px; font-size: 12px; }
  main { padding: 10px; }
  th, td { padding: 5px 6px; }
}
