/* 养生堂中医药健康管理系统 */
:root {
  --ink: #0e2f28;
  --ink-2: #16453a;
  --ink-3: #1f5a4b;
  --paper: #f7f4ee;
  --card: #ffffff;
  --line: #e6e0d4;
  --text: #23291f;
  --muted: #7c8479;
  --gold: #b9924f;
  --gold-soft: #f0e5cf;
  --red: #b3402f;
  --red-soft: #fbeae6;
  --green: #2f7a5f;
  --green-soft: #e6f3ec;
  --blue: #2f6f9e;
  --blue-soft: #e6eff6;
  --amber: #a9761b;
  --amber-soft: #fbf1dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 34, .05), 0 12px 28px -18px rgba(20, 40, 34, .28);
  --sidebar: 224px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfc8b9; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 登录 ---------------- */
#login {
  position: fixed; inset: 0; display: flex; background: var(--ink);
  z-index: 50;
}
#login.hide { display: none; }
.login-brand {
  flex: 1.15; position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 15% 10%, #1d5a49 0%, #0e2f28 55%, #081f1a 100%);
  display: flex; flex-direction: column; justify-content: center; padding: 0 clamp(40px, 6vw, 96px);
  color: #f2ede1;
}
.login-brand::after {
  content: ""; position: absolute; right: -160px; bottom: -160px; width: 460px; height: 460px;
  border-radius: 50%; border: 1px solid rgba(185, 146, 79, .35);
  box-shadow: 0 0 0 60px rgba(185, 146, 79, .05), 0 0 0 130px rgba(185, 146, 79, .04);
}
.login-brand .seal {
  width: 64px; height: 64px; border-radius: 14px; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700;
  letter-spacing: 2px; box-shadow: 0 10px 24px -10px rgba(179, 64, 47, .9); margin-bottom: 28px;
}
.login-brand h1 { font-size: clamp(26px, 2.4vw, 38px); line-height: 1.35; margin: 0 0 14px; font-weight: 600; letter-spacing: 1px; }
.login-brand p { color: #b9c6bd; line-height: 2; margin: 0; max-width: 620px; font-size: 14px; }
.login-brand .meta { margin-top: 46px; display: flex; gap: 30px; color: #8fa79c; font-size: 13px; }
.login-brand .meta b { display: block; color: #e8dcc2; font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-form-wrap { width: 460px; background: var(--paper); display: flex; flex-direction: column; justify-content: center; padding: 0 56px; }
.login-form-wrap h2 { margin: 0 0 6px; font-size: 22px; }
.login-form-wrap .sub { color: var(--muted); margin: 0 0 30px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; outline: none; transition: .18s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(31, 90, 75, .1); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; transition: .16s; white-space: nowrap;
}
.btn:hover { border-color: #cfc6b4; background: #fbf9f4; }
.btn.primary { background: var(--ink-2); border-color: var(--ink-2); color: #f4efe2; }
.btn.primary:hover { background: var(--ink-3); }
.btn.danger { color: var(--red); border-color: #e8c8c1; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- 框架 ---------------- */
#app { display: none; height: 100%; }
#app.on { display: flex; }
aside {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--ink); color: #dfe7e2;
  display: flex; flex-direction: column; position: relative;
}
aside .brand { padding: 22px 20px 18px; display: flex; gap: 11px; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, .07); }
aside .brand .mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
}
aside .brand b { display: block; font-size: 14.5px; color: #f3eee1; letter-spacing: .5px; }
aside .brand span { font-size: 11px; color: #86a196; letter-spacing: 1.2px; }
nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
nav .grp { font-size: 11px; color: #64817a; letter-spacing: 1.5px; padding: 14px 12px 8px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #c3d2cb; font-size: 13.5px; margin-bottom: 2px; transition: .15s; position: relative;
}
nav a svg { width: 17px; height: 17px; opacity: .8; }
nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
nav a.active { background: rgba(185, 146, 79, .16); color: #f4e8cd; }
nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px;
  background: var(--gold); border-radius: 0 3px 3px 0;
}
aside .foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 11px; color: #6f8c84; letter-spacing: .2px; }
aside .foot div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header {
  height: 62px; flex: 0 0 62px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 8;
}
header h2 { font-size: 16.5px; margin: 0; font-weight: 600; }
header .crumb { color: var(--muted); font-size: 12.5px; }
header .spacer { flex: 1; }
header .who { display: flex; align-items: center; gap: 9px; font-size: 13px; white-space: nowrap; }
header .who, header .who * { white-space: nowrap; }
header .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink-2); color: #f0e6d2;
  display: flex; align-items: center; justify-content: center; font-size: 12.5px;
}
.content { padding: 20px 22px 40px; overflow-y: auto; flex: 1; }
.hidden { display: none !important; }

/* ---------------- 通用组件 ---------------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi { padding: 15px 16px 14px; position: relative; overflow: hidden; }
.kpi .lab { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 25px; font-weight: 600; letter-spacing: -.4px; margin: 9px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .delta { font-size: 12px; padding: 1px 7px; border-radius: 20px; margin-left: 6px; }
.up { color: var(--red); background: var(--red-soft); }
.down { color: var(--green); background: var(--green-soft); }
.kpi.accent::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px;
  background: radial-gradient(circle, rgba(185, 146, 79, .16), transparent 70%);
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.panel .head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.panel .head .tip { font-size: 12px; color: var(--muted); }
.panel .head .spacer { flex: 1; }
.panel .body { padding: 16px 18px; }
.panel .body.flush { padding: 0; }

table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dt th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 10px 12px; background: #fbf9f4; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.dt td { padding: 11px 12px; border-bottom: 1px solid #f1ece2; vertical-align: middle; }
table.dt tbody tr:hover { background: #fcfaf5; }
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt .num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt th.num { text-align: right; }
table.dt tfoot td { padding: 11px 12px; background: #fbf9f4; font-weight: 600; }
.link { color: var(--ink-3); border-bottom: 1px dashed #b9c9c2; cursor: pointer; }
.link:hover { color: var(--gold); border-color: var(--gold); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 1.7; white-space: nowrap; }
.tag.wait { background: var(--amber-soft); color: var(--amber); }
.tag.ship { background: var(--blue-soft); color: var(--blue); }
.tag.done { background: var(--green-soft); color: var(--green); }
.tag.void { background: #eeece7; color: #96938a; text-decoration: line-through; }
.tag.gold { background: var(--gold-soft); color: #8a6a2f; }
.tag.red { background: var(--red-soft); color: var(--red); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar input[type=date], .toolbar input[type=search], .toolbar select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--ink-3); }
.toolbar .grow { flex: 1; }
.search { min-width: 210px; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 16px; color: var(--muted); font-size: 12.5px; }
.pager .btn { padding: 4px 10px; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 15px; color: #9a9f93; margin-bottom: 6px; }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(14, 32, 27, .42); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 60; padding: 6vh 16px; overflow-y: auto;
}
.modal {
  width: 620px; max-width: 100%; background: #fff; border-radius: 16px;
  box-shadow: 0 30px 70px -20px rgba(9, 30, 24, .55); overflow: hidden; animation: pop .18s ease-out;
}
.modal.wide { width: 860px; }
.modal.narrow { width: 440px; }
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: .6; } to { transform: none; opacity: 1; } }
.modal .mhead { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .mhead h3 { margin: 0; font-size: 15.5px; flex: 1; }
.modal .mhead .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px; }
.modal .mbody { padding: 18px 20px; max-height: 68vh; overflow-y: auto; }
.modal .mfoot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: #fbf9f4; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.sec-title { font-size: 12.5px; color: var(--gold); letter-spacing: 1px; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; }
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--gold-soft); }

/* ---------------- 提示 ---------------- */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast-item {
  padding: 10px 18px; border-radius: 10px; background: #17332c; color: #f0ebe0; font-size: 13px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); animation: drop .2s ease-out;
}
.toast-item.err { background: #8f3325; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

/* ---------------- 图表 ---------------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.donut-row { display: flex; align-items: center; gap: 18px; }
.donut-legend { flex: 1; font-size: 12.5px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #f0ebe1; }
.donut-legend div:last-child { border: none; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.donut-legend i { width: 9px; height: 9px; border-radius: 2px; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-item .top { display: flex; font-size: 12.5px; margin-bottom: 5px; }
.bar-item .top b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.bar-track { height: 7px; background: #f2eee5; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #2c6b58, #4f9678); }

.matrix td { text-align: right; font-variant-numeric: tabular-nums; }
.matrix td.month { text-align: left; color: var(--muted); }
.matrix td.zero { color: #c9c5bb; }

.split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* 客户卡片 */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cust-card { padding: 16px; cursor: pointer; transition: .16s; }
.cust-card:hover { border-color: #d6c9ae; transform: translateY(-1px); }
.cust-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cust-card .ava {
  width: 38px; height: 38px; border-radius: 11px; background: var(--ink-2); color: #f2e8d3;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.cust-card .nm { font-weight: 600; font-size: 14.5px; }
.cust-card .sm { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cust-card .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.cust-card .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.cust-card .bal { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.cust-card .bal span { font-size: 12px; color: var(--muted); }
.cust-card .bal b { font-size: 19px; }

.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.profile-head .ava { width: 54px; height: 54px; border-radius: 14px; background: var(--ink-2); color: #f2e8d3; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.profile-head .nm { font-size: 18px; font-weight: 600; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.mini-stat { background: #fbf9f4; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.mini-stat span { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 4px; }
.mini-stat b { font-size: 16px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs div { padding: 8px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs div.on { color: var(--ink); border-color: var(--gold); font-weight: 500; }

.img-thumb { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); cursor: pointer; }

@media (max-width: 1180px) {
  .split, .split-3 { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-wrap { width: 100%; }
}
@media (max-width: 860px) {
  :root { --sidebar: 64px; }
  aside .brand b, aside .brand span, nav .grp, aside .foot { display: none; }
  nav a span { display: none; }
  nav a { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .content { padding: 14px; }
}
@media print {
  aside, header, .toolbar, .pager { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
