:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2f5bd3;
  --brand-soft: #eef2fe;
  --ok: #12805c;
  --ok-soft: #e7f6ef;
  --warn: #b45309;
  --warn-soft: #fef4e6;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button, input, select { font: inherit; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #e8eeff, #f4f5f7 60%);
}
.login-card {
  width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card .accounts { display: grid; gap: 8px; margin-bottom: 16px; }
.account-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  background: #fff; text-align: left; width: 100%;
}
.account-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.account-item small { color: var(--muted); }

.layout { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar { background: #101828; color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 600; font-size: 15px; padding: 0 8px 18px; border-bottom: 1px solid #1f2a3c; margin-bottom: 14px; }
.brand small { display: block; color: #7d8ba1; font-weight: 400; font-size: 11px; margin-top: 4px; }
.nav a {
  display: block; padding: 9px 10px; color: #cbd5e1; text-decoration: none; border-radius: 8px; margin-bottom: 2px; font-size: 13px;
}
.nav a:hover { background: #1b2536; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.sidebar .who { position: absolute; bottom: 18px; left: 14px; right: 14px; font-size: 12px; color: #7d8ba1; }
.sidebar .who b { color: #e2e8f0; display: block; font-weight: 500; }

.main { padding: 22px 26px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 19px; }
.topbar .hint { color: var(--muted); font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.card .value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.card .foot { margin-top: 6px; font-size: 12px; color: var(--muted); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 14px 16px; }
.panel-body.tight { padding: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input[type="text"], input[type="date"], select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); min-width: 0;
}
button {
  border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 13px;
  border-radius: 8px; cursor: pointer;
}
button:hover { border-color: var(--brand); color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: #2549b3; color: #fff; }
button.ghost { background: transparent; }
button.tiny { padding: 3px 9px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
th { background: #fafbfc; color: var(--muted); font-weight: 500; white-space: nowrap; font-size: 12px; }
tbody tr:hover { background: #fbfcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow: auto; max-height: 60vh; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 18px; white-space: nowrap; }
.tag.gray { background: #f1f3f6; color: var(--muted); }
.tag.blue { background: var(--brand-soft); color: var(--brand); }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.tag.orange { background: var(--warn-soft); color: var(--warn); }
.tag.red { background: var(--danger-soft); color: var(--danger); }

.meter { height: 6px; border-radius: 999px; background: #eef1f5; overflow: hidden; min-width: 120px; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.meter > i.warn { background: #d97706; }
.meter > i.danger { background: var(--danger); }

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }
.err { color: var(--danger); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 商品字典：行点击 + 详情/编辑弹窗 ---------- */
tr.clickable-row { cursor: pointer; transition: background .15s ease; }
tr.clickable-row:hover { background: var(--brand-soft); }
tr.clickable-row:hover .link { border-bottom-color: var(--brand); }
.link { color: var(--brand); cursor: pointer; border-bottom: 1px dashed rgba(47, 91, 211, .45); }
.link:hover { color: #1e40af; }

.modal-mask {
  position: fixed; inset: 0; z-index: 120; padding: 24px;
  background: rgba(15, 23, 42, .48);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .hint { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--card); position: sticky; bottom: 0;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 13px;
}
.form-grid input:disabled { background: #f7f8fa; color: var(--muted); }
.modal .notice {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: var(--brand-soft); color: #1e3a8a; font-size: 12px; line-height: 1.6;
}
.modal .notice.orange { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-mask { padding: 12px; }
}

.toast {
  position: fixed; right: 22px; bottom: 22px; background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px);
  transition: all .18s ease; pointer-events: none; max-width: 420px; z-index: 99;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #991b1b; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 16px; color: var(--muted); font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }
