/* 沿长 · 运营后台 v0.5
   暗色稳重风，与诊所端的米色暖色形成视觉区分，避免混淆 */
:root {
  --bg: #0e1820;
  --panel: #18242d;
  --panel-2: #1e2c36;
  --line: #2a3a45;
  --text: #e6edf2;
  --muted: #8aa0ad;
  --primary: #4cb3a3;
  --primary-2: #3a9989;
  --danger: #d96c5b;
  --warn: #d4a64b;
  --ok: #4cb3a3;
  --shadow: 0 4px 16px rgba(0,0,0,.32);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px / 1.55 -apple-system, "PingFang SC", "Microsoft Yahei", system-ui, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* ==== 布局 ==== */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #182530, #0e1820);
  border-right: 1px solid #1f2c36;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4cb3a3, #2c7669);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
}
.brand-text .title { font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.brand-text .subtitle { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #b9c8d3;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.active {
  background: rgba(76,179,163,.14);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav-item .ico { width: 22px; text-align: center; opacity: .85; }
.sidebar-footer { margin-top: auto; padding: 10px 6px; color: rgba(255,255,255,.35); font-size: 12px; }
.user-chip {
  margin: 12px 6px 4px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid #233340;
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .name { font-weight: 600; font-size: 13px; }
.user-chip .role { font-size: 11px; color: var(--muted); }
.user-chip .out {
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid #2a3a45;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}
.user-chip .out:hover { color: var(--danger); border-color: var(--danger); }

.main {
  padding: 24px 28px 80px;
  min-width: 0;
}
.page-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.page-h h1 { font-size: 22px; margin: 0; }
.page-h .meta { color: var(--muted); font-size: 13px; }
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ==== 通用控件 ==== */
.input, select.input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  outline: none;
  min-width: 0;
}
.input:focus { border-color: var(--primary); }
.input.sm { padding: 6px 8px; font-size: 13px; }
label small { color: var(--muted); font-weight: normal; margin-left: 4px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > label { font-size: 13px; color: var(--muted); }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #06241e; border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: rgba(217,108,91,.4); }
.btn.danger:hover { background: rgba(217,108,91,.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card .desc { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tbl th, table.tbl td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
table.tbl th {
  font-weight: 600;
  color: var(--muted);
  background: rgba(255,255,255,.02);
  position: sticky; top: 0;
}
table.tbl tr:hover td { background: rgba(76,179,163,.04); }
table.tbl td .row-actions { display: flex; gap: 6px; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 50px 0; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(76,179,163,.15);
  color: var(--primary);
}
.badge.warn { background: rgba(212,166,75,.15); color: var(--warn); }
.badge.danger { background: rgba(217,108,91,.15); color: var(--danger); }
.badge.muted { background: rgba(150,170,180,.12); color: var(--muted); }

.code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  background: rgba(255,255,255,.04);
  padding: 2px 6px;
  border-radius: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 120px;
  padding-top: 10px;
}
.chart .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
}
.chart .bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.pager {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 12px;
  color: var(--muted); font-size: 13px;
}

.toast-host {
  position: fixed; right: 16px; top: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  min-width: 220px;
  font-size: 13px;
}
.toast.ok { border-left: 4px solid var(--ok); }
.toast.error { border-left: 4px solid var(--danger); }

/* ==== 模态框 ==== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(8,12,16,.65);
  display: grid; place-items: center;
  z-index: 999;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(560px, 92vw);
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.modal .body { padding: 16px 18px; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ==== 登录页 ==== */
body.login-page #app { grid-template-columns: 1fr; }
body.login-page .sidebar { display: none; }
body.login-page .main { padding: 0; }
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(76,179,163,.08), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .logo {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4cb3a3, #2c7669);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 20px;
}
.auth-brand .title { font-size: 17px; font-weight: 600; }
.auth-brand .subtitle { font-size: 12px; color: var(--muted); }
.auth-form .field { margin-bottom: 14px; }
.auth-btn { width: 100%; padding: 11px 16px; font-size: 14px; }
.auth-tip { color: var(--muted); font-size: 12px; margin-top: 12px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }

/* ==== 移动端 ==== */
@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 1 1 30%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 16px; }
}
