:root {
  --brand: #e02e24;
  --brand-dark: #bf241b;
  --brand-soft: #fff0ef;
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2329;
  --muted: #8a9099;
  --line: #e6e8eb;
  --ok: #16a34a;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--info); text-decoration: none; cursor: pointer; }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 208px; background: #1d1f24; color: #c8ccd3; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 20px 16px; color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.brand i { width: 28px; height: 28px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; font-style: normal; font-size: 15px; }
.nav { flex: 1; padding: 6px 10px; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; color: inherit; margin-bottom: 2px; }
.nav a:hover { background: #2a2d34; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .sep { margin: 14px 12px 6px; font-size: 12px; color: #6b7280; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: 14px; }
.content { padding: 20px 24px 40px; }
h2.title { margin: 0 0 16px; font-size: 18px; display: flex; align-items: center; justify-content: space-between; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 2fr 1fr; margin-bottom: 16px; }
@media (max-width: 1000px) { .grid.two { grid-template-columns: 1fr; } .sidebar { width: 64px; } .sidebar .label, .brand span, .nav .sep { display: none; } }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat .v.alert { color: var(--brand); }
.stat a { font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar .grow { flex: 1; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
textarea { width: 100%; resize: vertical; min-height: 70px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: #dc2626; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions a { margin-right: 10px; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.money { font-variant-numeric: tabular-nums; font-weight: 500; }
.goods-line { max-width: 320px; }
.goods-line div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; background: #eef0f3; color: #4b5563; }
.badge.s1 { background: #fff4e5; color: var(--warn); }
.badge.s2 { background: #e8f0fe; color: var(--info); }
.badge.s3, .badge.ok { background: #e7f6ec; color: var(--ok); }
.badge.bad { background: #fdeceb; color: #dc2626; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal.wide { width: 700px; }
.modal header { padding: 16px 20px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
.field input, .field select { width: 100%; }
.form-error { color: #dc2626; margin-top: 4px; min-height: 20px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; margin-bottom: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast div { background: #1f2329; color: #fff; padding: 9px 18px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.err { background: #dc2626; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #fff0ef, #f4f5f7 60%); }
.login-box { width: 380px; background: #fff; padding: 34px 32px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-box h1 { margin: 0 0 6px; font-size: 22px; }
.login-box p { margin: 0 0 22px; color: var(--muted); }
.login-box .btn { width: 100%; padding: 10px; }

.chart text { font-size: 11px; fill: var(--muted); }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .name { width: 56px; color: var(--muted); }
.bar-row .bar { flex: 1; height: 10px; background: #f0f1f3; border-radius: 5px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.banner { background: #fff8e6; border: 1px solid #fde4a3; color: #8a5a00; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 5px 14px; border-radius: 16px; background: #fff; color: var(--text); border: 1px solid var(--line); }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
