/* 太和安华 · 内容管理后台 */
:root {
  --brand: #36b8a9;
  --brand-600: #1f9d8e;
  --brand-700: #147468;
  --mint: #eef8f6;
  --ink: #17292b;
  --body: #5d6f71;
  --muted: #8b9a9b;
  --line: rgba(23, 41, 43, 0.1);
  --bg: #f5f7f6;
  --danger: #d9534f;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Microsoft YaHei",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--body);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* 登录 */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(54, 184, 169, 0.16), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(54, 184, 169, 0.12), transparent 45%),
    #f2f7f6;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 22px;
  padding: 40px 36px 34px;
  box-shadow: 0 30px 70px -35px rgba(16, 70, 64, 0.4);
  border: 1px solid rgba(23, 41, 43, 0.06);
}
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(140deg, #45c8b8, #17958a);
  display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text b { display: block; font-size: 16px; color: var(--ink); letter-spacing: 0.06em; }
.brand-text span { font-size: 9.5px; letter-spacing: 0.26em; color: var(--muted); }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card p { font-size: 12.5px; color: var(--muted); margin: 0 0 22px; }
.login-card input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(54, 184, 169, 0.15); }
.login-card .btn { margin-top: 16px; width: 100%; }
.login-msg { font-size: 12.5px; color: var(--danger); min-height: 20px; margin-top: 10px; }
.login-tip { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted); }

/* 布局 */
.admin { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--body);
  text-align: left;
  transition: background 0.2s, color 0.2s;
}
.side nav button svg { width: 17px; height: 17px; opacity: 0.7; }
.side nav button:hover { background: var(--mint); color: var(--brand-700); }
.side nav button.on { background: var(--brand); color: #fff; font-weight: 600; }
.side nav button.on svg { opacity: 1; }
.side-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side-foot a, .side-foot button {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  background: none; border: 0; padding: 6px 8px; border-radius: 8px; text-align: left;
}
.side-foot a:hover, .side-foot button:hover { background: var(--mint); color: var(--brand-700); }
.side-foot svg { width: 15px; height: 15px; }

.main { padding: 0 32px 60px; max-width: 1280px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 247, 246, 0.9);
  backdrop-filter: blur(10px);
  padding: 20px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.topbar h1 { font-size: 21px; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12px; color: var(--muted); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; background: #fff; color: var(--ink);
  transition: all 0.2s;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-line { border-color: var(--line); }
.btn-line:hover { border-color: var(--brand); color: var(--brand-700); }
.btn-danger { background: #fdf1f0; color: var(--danger); border-color: #f6d8d6; }
.btn-danger:hover { background: #fbe4e2; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 卡片 */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { font-size: 16px; }
.panel-head p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-size: 28px; color: var(--ink); font-weight: 500; margin-top: 6px; line-height: 1.2; }
.kpi em { font-style: normal; font-size: 13px; color: var(--brand-700); margin-left: 6px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; letter-spacing: 0.08em; color: var(--muted);
  font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 14px 12px; border-bottom: 1px solid rgba(23, 41, 43, 0.06); vertical-align: middle; font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.table .t-title { color: var(--ink); font-weight: 500; max-width: 420px; }
.table .t-title small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.thumb { width: 64px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--mint); }
.empty { text-align: center; padding: 46px 0; color: var(--muted); font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11px; background: #f1f4f3; color: var(--muted);
}
.badge.on { background: var(--mint); color: var(--brand-700); }
.badge.pin { background: #fff6df; color: #a67c00; }
.badge.warn { background: #fdf1f0; color: var(--danger); }

/* 图片管理 */
.img-groups { display: flex; flex-direction: column; gap: 26px; }
.img-group h3 { font-size: 13px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.img-group h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.img-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.img-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; transition: border-color 0.2s, box-shadow 0.2s; }
.img-card:hover { border-color: rgba(54, 184, 169, 0.5); box-shadow: 0 12px 30px -22px rgba(16, 70, 64, 0.5); }
.img-card .ph { aspect-ratio: 16 / 10; background: var(--mint); overflow: hidden; position: relative; }
.img-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.img-card .ph .busy {
  position: absolute; inset: 0; background: rgba(23, 41, 43, 0.55); color: #fff;
  display: grid; place-items: center; font-size: 12px;
}
.img-card .meta { padding: 12px 14px 14px; }
.img-card .meta b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 500; line-height: 1.5; }
.img-card .meta span { font-size: 11px; color: var(--muted); word-break: break-all; }
.img-card .meta .btn { margin-top: 10px; width: 100%; }
.img-card .meta .meta-ops { display: flex; gap: 8px; }
.img-card .meta .meta-ops .btn { width: auto; flex: 1; }
.img-card .ph .ph-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--muted); border-bottom: 1px dashed var(--line);
}
.img-card.is-empty .ph { background: repeating-linear-gradient(45deg, #f4faf8, #f4faf8 8px, #eef7f5 8px, #eef7f5 16px); }

/* 医生展示位 */
.doc-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.doc-slot {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  background: #fff; min-width: 0; cursor: grab; transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.doc-slot:active { cursor: grabbing; }
.doc-slot .slot-no {
  width: 20px; height: 20px; border-radius: 50%; background: var(--mint);
  color: #2f7d75; font-size: 11px; display: grid; place-items: center; flex: none;
}
.doc-slot > img, .doc-slot .slot-ph {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none;
  background: linear-gradient(140deg, #5cc9c2, #2f9790); color: #fff;
  font-size: 13px; display: grid; place-items: center;
}
.doc-slot .slot-meta { flex: 1; min-width: 0; line-height: 1.35; }
.doc-slot .slot-meta b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-slot .slot-meta span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-slot .slot-ops { display: flex; flex-direction: column; gap: 1px; }
.doc-slot .slot-ops button {
  border: 0; background: none; color: var(--muted); font-size: 11px; line-height: 1.35; padding: 0 3px;
}
.doc-slot .slot-ops button:hover { color: var(--brand); }
.doc-slot.is-empty { cursor: default; border-style: dashed; background: #fbfdfc; }
.doc-slot.is-empty .slot-meta span { color: #b7c5c3; }
.doc-slot.dragging { opacity: 0.4; }
.doc-slot.drag-over { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(54, 184, 169, 0.22); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f label { font-size: 12px; color: var(--ink); }
.f input, .f select, .f textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; font-family: inherit; color: var(--ink); outline: none; background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(54, 184, 169, 0.13); }
.f textarea { resize: vertical; min-height: 90px; line-height: 1.8; }
.f .hint { font-size: 11px; color: var(--muted); }
.f-row { display: flex; gap: 18px; align-items: center; }
.f-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.f-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.cover-box { display: flex; gap: 14px; align-items: flex-start; }
.cover-box .preview { width: 180px; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: var(--mint); flex: none; }
.cover-box .preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-box .side { display: flex; flex-direction: column; gap: 8px; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 30, 28, 0.45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
}
.modal-card {
  background: #fff; border-radius: 18px; width: 100%; max-width: 780px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.5);
}
.modal-head { padding: 20px 26px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 17px; }
.modal-close { border: 0; background: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-body { padding: 24px 26px; overflow: auto; }
.modal-foot { padding: 16px 26px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.modal-foot .right { display: flex; gap: 10px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (max-width: 1100px) {
  .img-grid { grid-template-columns: repeat(3, 1fr); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .doc-slots { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; min-width: 0; }
  .side .brand { display: none; }
  .side nav { flex-direction: row; }
  .side nav button { white-space: nowrap; width: auto; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .side-foot button, .side-foot a { width: 40px; height: 40px; justify-content: center; }
  .side-foot button span, .side-foot a span { display: none; }
  .main { padding: 0 16px 40px; min-width: 0; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar-actions { margin-left: auto; }
  .img-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-slots { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }

  /* 表格横向滚动，避免撑破页面 */
  .panel { padding: 18px 16px; overflow-x: auto; }
  .table { min-width: 560px; }
  .kpis { gap: 12px; }
  .kpi { padding: 16px; }
  .login-card { padding: 32px 24px 28px; }
  /* 防止 iOS 聚焦输入框时自动放大 */
  .f input, .f select, .f textarea, .login-card input { font-size: 16px; }
  .modal-body { padding: 18px 16px; }
  .modal-head, .modal-foot { padding: 14px 16px; }
  .cover-box { flex-direction: column; }
  .cover-box .preview { width: 100%; }
}

@media (max-width: 560px) {
  .doc-slots { grid-template-columns: minmax(0, 1fr); }
  .panel-head { flex-wrap: wrap; gap: 10px; }
  .panel-head .btn { white-space: nowrap; }
  .panel-head > div:last-child { display: flex; gap: 8px; width: 100%; }
  #doc-search { flex: 1; min-width: 0; width: auto; }
}
