/* ==========================================================================
   香港医美机构管理工作台 —— 样式
   不依赖任何外部字体或 CDN，断网可用。
   ========================================================================== */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1a1f2b;
  --ink2: #4a5265;
  --muted: #858da0;
  --line: #e6e9f0;
  --line2: #eef1f6;

  --accent: #2f5bd8;
  --accent-2: #1e3fa8;
  --accent-soft: #eef3ff;

  --ok: #178a5c;
  --ok-soft: #e8f7ef;
  --warn: #b5761a;
  --warn-soft: #fdf4e4;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --rose: #b8547a;
  --rose-soft: #fceef3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 6px 20px rgba(20, 30, 60, .06);
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .05);
  --sidebar: 238px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; }
button { font-family: inherit; }

.ta-r { text-align: right; }
.ta-c { text-align: center; }
.muted { color: var(--muted); }
.sm { font-size: 12.2px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   登录页
   ========================================================================== */
#loginView {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 12% -10%, #e6ecff 0%, rgba(230, 236, 255, 0) 62%),
    radial-gradient(900px 460px at 92% 6%, #fdeef4 0%, rgba(253, 238, 244, 0) 58%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 396px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 32px 28px;
}
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), #6d8bf0);
  color: #fff; font-weight: 700; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(47, 91, 216, .28);
}
.login-card h1 { font-size: 20px; margin-top: 16px; letter-spacing: .2px; }
.login-card .lg-sub { color: var(--muted); font-size: 12.8px; margin-top: 3px; }

.field { margin-top: 15px; }
.field label { display: block; font-size: 12.6px; color: var(--ink2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fbfbfd; color: var(--ink); font-size: 14px;
  font-family: inherit; outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 91, 216, .10);
}
.field .f-hint { font-size: 11.6px; color: var(--muted); margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13.4px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: #f7f8fc; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: var(--accent-2); color: #fff;
  box-shadow: 0 2px 8px rgba(47, 91, 216, .24);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: #f1f3f9; }
.btn.sm { padding: 6px 11px; font-size: 12.6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login-foot {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line2);
  font-size: 11.8px; color: var(--muted); line-height: 1.7;
}
.login-foot .cfg-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.login-foot input {
  flex: 1; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 11.8px; background: #fbfbfd; outline: none;
}
.login-err {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--danger-soft); border: 1px solid #f5c9c5;
  color: #8f2b20; font-size: 12.6px;
}

/* ==========================================================================
   应用外壳
   ========================================================================== */
#appView { display: none; min-height: 100vh; }
#appView.on { display: flex; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sb-brand { padding: 17px 15px 14px; display: flex; gap: 10px; align-items: center; }
.sb-brand .brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; flex: 0 0 36px; }
.sb-brand .brand-txt { min-width: 0; }
/* 名称可能比较长（如「香港医美机构管理工作台」），允许折成两行，别挤爆侧边栏 */
.sb-brand .nm {
  font-weight: 700; font-size: 13.6px; line-height: 1.34;
  letter-spacing: .1px; word-break: break-word;
}
.sb-brand .sb { font-size: 11.4px; color: var(--muted); margin-top: 1px; }

.org-switch {
  margin: 0 12px 12px; padding: 10px 11px;
  background: linear-gradient(180deg, #f7f9ff, #f2f5fd);
  border: 1px solid #e3e9fa; border-radius: var(--radius-sm);
}
.org-switch .os-l { font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: .3px; }
.org-switch select {
  width: 100%; padding: 7px 9px; border: 1px solid #d9e1f5; border-radius: 6px;
  background: #fff; font-size: 13px; font-weight: 600; color: var(--ink); outline: none;
}
.org-locked {
  margin: 0 12px 12px; padding: 9px 11px; border-radius: var(--radius-sm);
  background: #f7f8fc; border: 1px solid var(--line2);
  font-size: 12.2px; color: var(--ink2); display: flex; align-items: center; gap: 7px;
}
.org-locked b { font-weight: 650; }
.lock-ic { color: var(--muted); font-size: 11px; }

.nav { flex: 1; overflow-y: auto; padding: 2px 10px 16px; }
.nav-group { margin-top: 12px; }
.nav-group-label {
  font-size: 10.6px; letter-spacing: .9px; color: #a2a9ba;
  padding: 0 9px 6px; text-transform: uppercase; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink2); font-size: 13.2px; font-weight: 550;
  cursor: pointer; user-select: none; margin-bottom: 1px;
  border: 1px solid transparent;
}
.nav-item:hover { background: #f4f6fb; color: var(--ink); }
.nav-item.on {
  background: var(--accent-soft); color: var(--accent-2);
  border-color: #dbe4fb; font-weight: 650;
}
.nav-item .ni-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #c3cad9; flex: 0 0 6px;
}
.nav-item.on .ni-dot { background: var(--accent); }
.nav-item .ni-badge {
  margin-left: auto; font-size: 10.8px; font-weight: 700;
  background: var(--danger); color: #fff; border-radius: 99px;
  padding: 1px 6px; min-width: 17px; text-align: center;
}
.nav-item.locked { opacity: .42; cursor: not-allowed; }
.nav-item.locked:hover { background: transparent; }

.sb-user {
  border-top: 1px solid var(--line2); padding: 12px;
  display: flex; gap: 10px; align-items: center;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  background: linear-gradient(140deg, #7b8ff0, #4a63d8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 650; font-size: 13px;
}
.sb-user .u-nm { font-size: 13px; font-weight: 620; }
.sb-user .u-rl { font-size: 11.2px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-ctl { display: flex; align-items: center; gap: 7px; }
.tb-ctl label { font-size: 12.2px; color: var(--muted); }
.tb-ctl select, .tb-ctl input {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 12.8px; color: var(--ink); outline: none;
}
.burger { display: none; }

.content { padding: 20px 22px 46px; max-width: 1500px; width: 100%; }

.page-hd {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.page-hd h1 { font-size: 19.5px; letter-spacing: .2px; }
.page-hd .sub { color: var(--muted); font-size: 12.6px; margin-top: 3px; }
.hd-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ==========================================================================
   卡片 / KPI
   ========================================================================== */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 16px; overflow: hidden;
}
.card-hd {
  padding: 13px 16px 11px; border-bottom: 1px solid var(--line2);
  display: flex; align-items: baseline; gap: 10px;
}
.card-hd h2 { font-size: 14.2px; }
.card-hd .hint { margin-left: auto; font-size: 11.6px; color: var(--muted); }
.card-bd { padding: 14px 16px 16px; }
.card-bd.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }

.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px 14px;
  box-shadow: var(--shadow-sm);
}
.kpi .k-l { font-size: 12.2px; color: var(--muted); font-weight: 600; }
.kpi .k-v {
  font-size: 23px; font-weight: 700; margin-top: 5px;
  font-variant-numeric: tabular-nums; letter-spacing: -.4px;
}
.kpi .k-n { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi.k-accent { background: linear-gradient(180deg, #f6f9ff, #fff); border-color: #dfe7fb; }
.kpi.k-accent .k-v { color: var(--accent-2); }
.kpi.k-ok .k-v { color: var(--ok); }
.kpi.k-warn { background: linear-gradient(180deg, #fffdf7, #fff); border-color: #f3e6cd; }
.kpi.k-warn .k-v { color: var(--warn); }
.kpi.k-danger { background: linear-gradient(180deg, #fffaf9, #fff); border-color: #f6dedb; }
.kpi.k-danger .k-v { color: var(--danger); }

/* ==========================================================================
   表格
   ========================================================================== */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.1px; }
.tbl thead th {
  text-align: left; padding: 9px 12px;
  background: #f8f9fc; border-bottom: 1px solid var(--line);
  font-size: 11.9px; font-weight: 700; color: var(--ink2);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fafbfe; }
.tbl tbody tr.row-alert { background: #fffaf3; }
.tbl tbody tr.row-alert:hover { background: #fdf5e9; }
.tbl .c-strong { font-weight: 620; }
.tbl .c-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; font-size: 11.4px; font-weight: 700;
  background: #f0f2f8; color: var(--ink2);
}
.tbl .c-rank.top1 { background: #fff2d9; color: #a2711a; }
.tbl .c-rank.top2 { background: #eef1f6; color: #5a6479; }
.tbl .c-rank.top3 { background: #fbeee4; color: #9b6549; }

.pill {
  display: inline-block; padding: 1.5px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 620; white-space: nowrap;
  background: #f0f2f8; color: var(--ink2);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.mute { background: #f2f3f7; color: #6d7688; }
.pill.accent { background: var(--accent-soft); color: var(--accent-2); }
.pill.rose { background: var(--rose-soft); color: var(--rose); }

/* ==========================================================================
   条形 / 趋势
   ========================================================================== */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 108px 1fr 96px; gap: 11px; align-items: center; }
.bar .b-l { font-size: 12.3px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .b-t { height: 8px; background: #f0f2f7; border-radius: 99px; overflow: hidden; }
.bar .b-f { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6d8bf0, var(--accent)); }
.bar .b-f.ok { background: linear-gradient(90deg, #5fc79a, var(--ok)); }
.bar .b-f.rose { background: linear-gradient(90deg, #e0789a, var(--rose)); }
.bar .b-v { text-align: right; font-size: 12.3px; font-weight: 640; color: var(--ink2); font-variant-numeric: tabular-nums; }

.trend {
  display: flex; align-items: flex-end; gap: 10px;
  height: 190px; padding: 6px 2px 0;
}
.t-group { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.t-stack { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.t-col { width: 12px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #8ba4f2, var(--accent)); min-height: 2px; }
.t-col.rose { background: linear-gradient(180deg, #e594b0, var(--rose)); }
.t-col.ok { background: linear-gradient(180deg, #6fd3ab, var(--ok)); }
.t-x {
  text-align: center; font-size: 11px; color: var(--muted);
  margin-top: 6px; white-space: nowrap; overflow: hidden;
}
.legend { display: flex; gap: 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line2); }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11.8px; color: var(--ink2); }
.legend .lg i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: block; }
.legend .lg i.rose { background: var(--rose); }
.legend .lg i.ok { background: var(--ok); }

/* ==========================================================================
   提示 / 空态 / 加载
   ========================================================================== */
.note {
  padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 12.7px; line-height: 1.65;
  background: var(--accent-soft); border: 1px solid #dbe4fb; color: #23386e;
}
.note b { font-weight: 700; }
.note.warn { background: var(--warn-soft); border-color: #f0e0c2; color: #7d5514; }
.note.danger { background: var(--danger-soft); border-color: #f5cdc9; color: #8f2b20; }
.note.ok { background: var(--ok-soft); border-color: #c8ebda; color: #10664a; }
.note + .note { margin-top: 9px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: 13px; }
.empty .e-ic { font-size: 22px; color: #ccd2e0; margin-bottom: 6px; }
.empty .e-act { margin-top: 12px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 40px; color: var(--muted); font-size: 13px; }
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #dfe4ef; border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.errbox {
  padding: 14px 15px; border-radius: var(--radius-sm);
  background: var(--danger-soft); border: 1px solid #f5cdc9; color: #8f2b20;
  font-size: 12.9px; line-height: 1.7;
}
.errbox b { display: block; margin-bottom: 3px; }
.errbox button { margin-top: 9px; }

.perm-note {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: #fbfcff; border: 1px dashed #d3dcf3;
  font-size: 12.5px; color: #3c4a6e;
}
.perm-note .pn-ic { font-size: 13px; }

/* ==========================================================================
   弹窗
   ========================================================================== */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(22, 28, 42, .34);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border-radius: 14px;
  width: 100%; max-width: 500px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(16, 22, 40, .26);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-hd {
  padding: 15px 18px 12px; border-bottom: 1px solid var(--line2);
  display: flex; align-items: center;
}
.modal-title { font-size: 15.2px; font-weight: 680; }
.modal-x {
  margin-left: auto; border: none; background: transparent;
  font-size: 21px; line-height: 1; color: var(--muted); cursor: pointer;
  padding: 0 3px; border-radius: 5px;
}
.modal-x:hover { background: #f1f3f9; color: var(--ink); }
.modal-bd { padding: 16px 18px; overflow-y: auto; }
.modal-ft {
  padding: 12px 18px; border-top: 1px solid var(--line2);
  display: flex; justify-content: flex-end; gap: 8px;
}
.confirm-body { font-size: 13.4px; line-height: 1.7; color: var(--ink2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .field.full { grid-column: 1 / -1; }

/* ==========================================================================
   提示条（toast）
   ========================================================================== */
#toastHost {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 15px; border-radius: 99px;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(16, 22, 40, .14);
  font-size: 13px; font-weight: 550; color: var(--ink);
  opacity: 0; transform: translateY(-8px);
  transition: opacity .22s, transform .22s;
  max-width: 90vw;
}
.toast.in { opacity: 1; transform: none; }
.toast .t-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 7px; }
.toast.ok .t-dot { background: var(--ok); }
.toast.error .t-dot { background: var(--danger); }
.toast.warn .t-dot { background: var(--warn); }

/* ==========================================================================
   小工具
   ========================================================================== */
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { border: 0; border-top: 1px solid var(--line2); margin: 14px 0; }
.scroll-y { max-height: 380px; overflow-y: auto; }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.text-muted { color: var(--muted); }
.fw6 { font-weight: 620; }

.def-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13px; }
.def-list dt { color: var(--muted); font-size: 12.4px; }
.def-list dd { margin: 0; font-weight: 560; }

/* ==========================================================================
   窄屏（手机浏览器 / 添加到主屏幕）
   ========================================================================== */
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar: 250px; }
  #appView.on { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 120;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(16, 22, 40, .2);
  }
  .sidebar.open { transform: none; }
  .burger { display: inline-flex; }
  .sb-backdrop {
    position: fixed; inset: 0; background: rgba(22, 28, 42, .3);
    z-index: 110; display: none;
  }
  .sb-backdrop.on { display: block; }
  .content { padding: 15px 13px 40px; }
  .topbar { padding: 9px 13px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 84px 1fr 78px; }
  .tbl { font-size: 12.6px; }
  .tbl thead th, .tbl tbody td { padding: 8px 9px; }
  .page-hd h1 { font-size: 17.5px; }
  .trend { height: 150px; }
  .t-col { width: 8px; }
}

@media print {
  .sidebar, .topbar, .hd-actions, #toastHost { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; }
}
