/* =========================================================
 * 康悦养生 · 设计系统与共享组件
 * ========================================================= */
:root {
  --green-900: #173d34;
  --green-800: #1f5145;
  --green-700: #2b6b5b;
  --green-600: #35816e;
  --green-500: #4a9b83;
  --green-100: #dceee7;
  --green-50:  #eef7f3;
  --sand-600:  #a9763f;
  --sand-500:  #c08d51;
  --sand-100:  #f5e9d7;
  --ink-900:  #182521;
  --ink-700:  #35453f;
  --ink-500:  #6b7d76;
  --ink-400:  #93a39c;
  --line:     #e4eae6;
  --line-2:   #d3ddd7;
  --bg:       #f5f7f4;
  --card:     #ffffff;
  --red:      #c1544c;
  --red-50:   #fbeeec;
  --amber:    #b8812f;
  --amber-50: #fbf3e4;
  --blue:     #3f6fa5;
  --blue-50:  #eaf1fa;
  --radius:   14px;
  --radius-s: 10px;
  --shadow:   0 1px 2px rgba(23,61,52,.04), 0 8px 24px rgba(23,61,52,.055);
  --shadow-l: 0 12px 40px rgba(23,61,52,.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
svg.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-s);
  background: var(--green-700); color: #fff; font-weight: 500; white-space: nowrap;
  transition: background .16s, border-color .16s, transform .12s, box-shadow .16s;
}
.btn:hover { background: var(--green-800); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); box-shadow: 0 4px 14px rgba(43,107,91,.24); }
.btn-ghost { background: #fff; color: var(--ink-700); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--green-50); border-color: var(--green-500); color: var(--green-700); }
.btn-soft { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); }
.btn-soft:hover { background: var(--green-100); }
.btn-sand { background: var(--sand-500); color: #fff; }
.btn-sand:hover { background: var(--sand-600); }
.btn-danger { background: #fff; color: var(--red); border-color: #ecd4d1; }
.btn-danger:hover { background: var(--red-50); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; border-radius: 9px; color: var(--ink-500);
  font-size: 20px; line-height: 1; transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--green-50); color: var(--green-700); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .form-label { font-size: 12.5px; font-weight: 500; color: var(--ink-700); }
.field .hint { font-size: 11.5px; color: var(--ink-400); }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: #fff; color: var(--ink-900); outline: none; transition: border-color .16s, box-shadow .16s;
}
textarea { height: auto; min-height: 74px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(74,155,131,.14); }
input::placeholder, textarea::placeholder { color: var(--ink-400); }
select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7d76' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-700); cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--green-600); }

/* ---------- 卡片 / 通用 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sec-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.sec-head p { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.muted { color: var(--ink-500); }
.tiny { font-size: 12px; }
.divider { height: 1px; background: var(--line); }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-400); }
.empty .icon { width: 34px; height: 34px; stroke-width: 1.3; margin-bottom: 10px; }
.empty p { font-size: 13px; }

/* ---------- 状态标签 ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-wait { background: var(--amber-50); color: var(--amber); }
.pill-claim { background: #f4ecfb; color: #8a6aa8; }
.pill-confirm { background: var(--blue-50); color: var(--blue); }
.pill-done { background: var(--green-50); color: var(--green-700); }
.pill-cancel { background: #f1f2f1; color: var(--ink-400); }
.pill-on { background: var(--green-50); color: var(--green-700); }
.pill-off { background: #f1f2f1; color: var(--ink-400); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--green-50); color: var(--green-700); font-size: 11.5px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 500; color: var(--ink-500); font-size: 12px; padding: 11px 12px; background: #fafbfa; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fafcfb; }
table.tbl tbody tr.row-selected { background: var(--green-50); }
.cell-strong { font-weight: 600; color: var(--ink-900); }
.cell-sub { font-size: 11.5px; color: var(--ink-400); }
.cell-actions { display: flex; gap: 5px; white-space: nowrap; }
.checkbox { width: 16px; height: 16px; accent-color: var(--green-600); cursor: pointer; vertical-align: middle; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(16,35,30,.44); backdrop-filter: blur(2px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .16s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: var(--shadow-l); overflow: hidden; animation: popIn .18s ease; }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.985) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-body p { color: var(--ink-700); font-size: 13.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfa; }
.modal.wide { max-width: 680px; }

/* ---------- Toast ---------- */
.toast-box { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 999px; background: var(--green-800); color: #fff; font-size: 13px; box-shadow: var(--shadow-l); animation: popIn .2s ease; transition: opacity .24s, transform .24s; }
.toast.err { background: var(--red); }
.toast.warn { background: var(--sand-600); }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- 分段控件 ---------- */
.segment { display: inline-flex; padding: 3px; gap: 2px; background: #eef1ee; border-radius: 10px; }
.segment button { height: 30px; padding: 0 13px; border: 0; background: transparent; color: var(--ink-500); border-radius: 8px; font-size: 12.5px; font-weight: 500; transition: .16s; }
.segment button.active { background: #fff; color: var(--green-700); box-shadow: 0 1px 4px rgba(23,61,52,.1); }

/* ---------- 照片上传控件 ---------- */
[hidden] { display: none !important; }
.span-2 { grid-column: 1 / -1; min-width: 0; }
.photo-uploader { width: 100%; }
.pu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pu-item { position: relative; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--green-50); }
.pu-img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; }
.pu-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pu-del { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(16,35,30,.74); color: #fff; font-size: 17px; line-height: 1; display: grid; place-items: center; }
.pu-del:hover { background: var(--red); }
.pu-set { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; border: 0; background: rgba(16,35,30,.74); color: #fff; font-size: 11px; }
.pu-set:hover { background: var(--green-700); }
.pu-cover-tag { position: absolute; top: 6px; left: 6px; padding: 2px 7px; border-radius: 6px; background: var(--green-700); color: #fff; font-size: 10px; }
.pu-add { aspect-ratio: 4 / 3; border: 1.5px dashed var(--line-2); border-radius: 10px; background: #fbfcfb; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-500); cursor: pointer; transition: .16s; }
.pu-add:hover, .pu-drag .pu-add { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.pu-plus { font-size: 25px; line-height: 1; }
.pu-add b { font-size: 12px; font-weight: 500; }
.pu-add small { font-size: 10.5px; color: var(--ink-400); }
/* 尚无照片时，把添加区放大成一个明确的拖放区 */
.pu-grid > .pu-add:only-child { grid-column: span 2; aspect-ratio: auto; min-height: 116px; }
.pu-help { font-size: 11.5px; color: var(--ink-400); line-height: 1.65; margin-top: 10px; }

/* ---------- 大图灯箱 ---------- */
.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(10,22,19,.93); display: flex; align-items: center; justify-content: center; padding: 56px 74px 96px; animation: fadeIn .16s ease; }
.lb-stage { display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: 100%; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 170px); object-fit: contain; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.lb-close { position: absolute; top: 16px; right: 22px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; font-size: 24px; line-height: 1; }
.lb-close:hover { background: rgba(255,255,255,.2); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; font-size: 28px; line-height: 1; }
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-nav.prev { left: 18px; } .lb-nav.next { right: 18px; }
.lb-meta { position: absolute; bottom: 62px; left: 0; right: 0; text-align: center; color: #fff; }
.lb-meta b { font-size: 13.5px; font-weight: 500; display: block; }
.lb-meta span { font-size: 11.5px; color: rgba(255,255,255,.62); }
.lb-thumbs { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; gap: 8px; justify-content: center; }
.lb-thumb { width: 46px; height: 34px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: none; opacity: .5; }
.lb-thumb.active { border-color: #fff; opacity: 1; }
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- 通用缩略图 / 存储提示 ---------- */
.thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; border: 1px solid var(--line); background: var(--green-50); display: inline-block; vertical-align: middle; }
.thumb-sm { width: 30px; height: 30px; border-radius: 50%; }
.thumb-count { font-size: 10.5px; color: var(--ink-400); margin-left: 6px; white-space: nowrap; }
.storage-note { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--bg); font-size: 11.5px; color: var(--ink-500); line-height: 1.7; }
.storage-bar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; margin: 8px 0 6px; }
.storage-bar i { display: block; height: 100%; border-radius: 999px; background: var(--green-600); transition: width .3s; }
.storage-bar i.warn { background: var(--sand-500); }
.storage-bar i.danger { background: var(--red); }

/* ---------- 通用结果弹窗（book.css / theme.css 可继续覆盖细节） ---------- */
.success-box { text-align: center; padding: 18px 6px 4px; }
.success-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--green-50); color: var(--green-700); display: grid; place-items: center; margin: 0 auto 16px; }
.success-icon .icon { width: 27px; height: 27px; stroke-width: 2.2; }
.success-box h3 { font-size: 19px; font-weight: 600; margin: 0; }
.success-box p { color: var(--ink-500); font-size: 13px; line-height: 1.8; margin-top: 8px; }
.success-detail { background: var(--bg); border-radius: 12px; padding: 14px 18px; margin: 20px auto 0; max-width: 400px; text-align: left; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 8px 0; }
.summary-row span { color: var(--ink-500); }
.summary-row b { font-weight: 500; text-align: right; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-body { padding: 18px; }
  .modal-head, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .pu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .lightbox { padding: 56px 10px 96px; }
  .lb-nav { width: 34px; height: 34px; font-size: 22px; }
  .lb-nav.prev { left: 6px; } .lb-nav.next { right: 6px; }
  .lb-thumb { width: 38px; height: 28px; }
}
