:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e3e5e8;
  --brand: #1d4ed8;
  --brand-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #b91c1c;
  --bad-soft: #fde8e8;
  --side: #1e293b;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: 200px; background: var(--side); color: #cbd5e1; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 18px 20px; font-weight: 700; font-size: 16px; color: #fff; border-bottom: 1px solid #334155; }
.side .logo small { display: block; font-weight: 400; font-size: 12px; color: #94a3b8; }
.side nav { padding: 8px 0 24px; }
.side .grp { padding: 14px 20px 4px; font-size: 12px; color: #64748b; }
.side a { display: block; padding: 7px 20px; color: #cbd5e1; }
.side a:hover { background: #273449; text-decoration: none; color: #fff; }
.side a.on { background: #2563eb; color: #fff; }
.main { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); gap: 12px; }
.top .who { color: var(--muted); font-size: 13px; }
.menu-btn { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; padding: 0 4px; }
.content { padding: 20px 24px 60px; }

@media (max-width: 860px) {
  .side { position: fixed; left: -220px; z-index: 50; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; }
  .content { padding: 14px 12px 60px; }
  .top { padding: 10px 12px; }
}

/* 组件 */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel.flush { padding: 0; }
.grid { display: grid; gap: 12px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi a.card { color: inherit; display: block; }
.kpi a.card:hover { border-color: var(--brand); text-decoration: none; }

.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; font-size: 14px; line-height: 1.4; white-space: nowrap; }
.btn:hover { border-color: #b8bec6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f1b7b7; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
.t th, .t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t th { background: #f8f9fb; font-weight: 600; color: #374151; font-size: 13px; white-space: nowrap; }
.t tbody tr:hover { background: #fafbfc; }
.t .num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tfoot td { font-weight: 600; background: #f8f9fb; }
.t .muted { color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap .t { border: 0; }
.table-wrap .t tr:last-child td { border-bottom: 0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef0f3; color: #4b5563; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], input[type=email], select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 6px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3ff; border-color: var(--brand); }
textarea { width: 100%; min-height: 60px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-size: 13px; color: #374151; margin-bottom: 4px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 2px; }
.field .err, .errorlist { color: var(--bad); font-size: 12px; margin: 2px 0 0; padding: 0; list-style: none; }
.field.check label { display: flex; align-items: center; gap: 6px; margin-top: 22px; }
ul.checks { list-style: none; padding: 0; margin: 0; display: flex; gap: 14px; flex-wrap: wrap; }
ul.checks label { display: flex; gap: 4px; align-items: center; }

.msgs { margin-bottom: 12px; }
.msg { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; background: var(--brand-soft); color: var(--brand); }
.msg.success { background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warning { background: var(--warn-soft); color: var(--warn); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; }
.kv div span { color: var(--muted); margin-right: 6px; }
.big-num { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 0; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs .thumb { width: 120px; text-align: center; font-size: 12px; }
.thumbs img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* 录单 */
.lines input { width: 100%; padding: 4px 6px; }
.lines td { padding: 4px 6px; }
.lines .c-no { width: 34px; text-align: center; color: var(--muted); }
.lines .c-qty { width: 90px; }
.lines .c-unit { width: 80px; }
.lines .c-price { width: 110px; }
.lines .c-amt { width: 110px; }
.lines .c-w { width: 80px; }
.lines .c-op { width: 40px; text-align: center; }
.picker { position: relative; }
.picker .drop { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #cfd4da; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; min-width: 360px; }
.picker .opt { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.picker .opt:hover, .picker .opt.hi { background: var(--brand-soft); }
.picker .opt small { color: var(--muted); white-space: nowrap; }
.picker .opt.new { color: var(--brand); border-top: 1px solid var(--line); }
.x { background: none; border: 0; color: #9ca3af; cursor: pointer; font-size: 18px; line-height: 1; }
.x:hover { color: var(--bad); }
.sum-bar { display: flex; gap: 24px; justify-content: flex-end; flex-wrap: wrap; align-items: center; padding: 12px 4px 0; }
.sum-bar b { font-size: 18px; font-variant-numeric: tabular-nums; }
.sticky-foot { position: sticky; bottom: 0; background: rgba(244,245,247,.95); padding: 12px 0; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 12px; }

/* 登录 */
.login { max-width: 360px; margin: 12vh auto; background: #fff; padding: 28px; border-radius: 12px; border: 1px solid var(--line); }
.login h1 { margin-bottom: 18px; }
.login .field { margin-bottom: 12px; }

/* 打印 */
.print-page { background: #fff; max-width: 900px; margin: 0 auto; padding: 24px; color: #000; }
.print-page h1 { text-align: center; font-size: 22px; letter-spacing: 2px; margin-bottom: 6px; }
.print-page .sub { text-align: center; color: #333; margin-bottom: 14px; }
.print-page table { width: 100%; border-collapse: collapse; }
.print-page th, .print-page td { border: 1px solid #333; padding: 5px 6px; font-size: 13px; }
.print-page .meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 8px; font-size: 13px; }
.print-page .num { text-align: right; font-variant-numeric: tabular-nums; }
.print-page .sign { display: flex; justify-content: space-between; margin-top: 28px; font-size: 13px; }
.print-tools { text-align: center; padding: 12px; background: #f4f5f7; }
@media print {
  .print-tools, .no-print { display: none !important; }
  body { background: #fff; }
  .print-page { padding: 0; max-width: none; }
  @page { size: A4; margin: 12mm; }
}
