:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #1a56db;
  --primary-hover: #1648b8;
  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
  --border: #e2e8f0;
  --header: #f1f5f9;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif; }
a { color: var(--primary); text-decoration: none; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #0f172a; color: #fff;
}
.brand { font-weight: 700; font-size: 16px; }
.user { font-size: 13px; opacity: .85; }

.nav {
  display: flex; gap: 4px; overflow-x: auto; background: var(--card);
  border-bottom: 1px solid var(--border); padding: 8px 10px; position: sticky; top: 0; z-index: 20;
}
.nav a {
  flex: 0 0 auto; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px;
}
.nav a.active, .nav a:hover { background: #dbeafe; color: var(--primary); font-weight: 600; }

.container { max-width: 1100px; margin: 0 auto; padding: 14px 12px 80px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center;
}
.stat .num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.flash-ok { background: #ecfdf5; color: #047857; }
.flash-err { background: #fef2f2; color: #b91c1c; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 10px 14px; font-size: 14px;
  cursor: pointer; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-orange { background: var(--orange); }
.btn-gray { background: #64748b; }
.btn-light { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
input, select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px;
  width: 100%; background: #fff;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: center; }
th { background: var(--header); position: sticky; top: 0; }
td.left, th.left { text-align: left; }
tr:nth-child(even) td { background: #fafafa; }
.zero { color: var(--red); font-weight: 700; }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.mode-switch .btn { padding: 14px; font-size: 16px; font-weight: 700; }
.mode-switch .btn.active-in { outline: 3px solid #a7f3d0; }
.mode-switch .btn.active-out { outline: 3px solid #fecaca; }

#reader { width: 100%; max-width: 480px; margin: 0 auto 12px; border-radius: 12px; overflow: hidden; }
.scan-hint { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

.grid-panel { display: none; }
.grid-panel.show { display: block; }
.style-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.size-grid { width: 100%; min-width: 0; }
.size-grid th, .size-grid td { padding: 8px 4px; }
.size-grid .cell-btn {
  width: 100%; min-height: 52px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.size-grid .cell-btn:active { transform: scale(.97); }
.size-grid .cell-btn.empty { color: var(--red); background: #fff5f5; }

.login-wrap { max-width: 380px; margin: 60px auto; }
.login-wrap h1 { text-align: center; font-size: 22px; }
.muted { color: var(--muted); font-size: 13px; }

.fab {
  position: fixed; right: 16px; bottom: 20px; width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; box-shadow: 0 8px 20px rgba(26,86,219,.35); z-index: 30;
}
@media (min-width: 900px) { .fab { display: none; } }

.need { background: #fff7ed !important; }
.summary-box {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 12px; margin: 10px 0;
  font-size: 14px; line-height: 1.6;
}
