/* OpenClinic 通用样式 */
:root {
  --c-primary: var(--c-primary);
  --c-primary-600: var(--c-primary-600);
  --c-primary-50: #e9f6f5;
  --c-primary-100: #cdeae7;
  --c-text: #18212b;
  --c-text-2: #4a5562;
  --c-muted: #8691a0;
  --c-border: #e2e7ed;
  --c-line: #eef1f5;
  --c-bg: #f3f5f8;
  --c-card: #ffffff;
  --c-ok: #15803d;      --c-ok-bg: #e7f6ec;
  --c-warn: #b45309;    --c-warn-bg: #fdf2e1;
  --c-err: #c62828;     --c-err-bg: #fdebeb;
  --c-info: #1d5fd1;    --c-info-bg: #e8effc;
  --c-gray: #5d6875;    --c-gray-bg: #edf0f3;
  --c-purple: #6d3fc7;  --c-purple-bg: #f0eafb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--c-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border); background: #fff; color: var(--c-text);
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; flex: none; }  /* 按钮被拉宽（竖排）时图标不跟着变大 */
.btn:hover { border-color: #c7cfd9; background: #f9fafb; text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-600); border-color: var(--c-primary-600); }
.btn-danger { color: var(--c-err); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--c-err-bg); border-color: #e9a5a5; }
.btn-danger.solid { background: var(--c-err); color: #fff; border-color: var(--c-err); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--c-primary); }
.btn-ghost:hover { background: var(--c-primary-50); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 16px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: 6px; font-size: 20px; color: var(--c-muted); }
.icon-btn:hover { background: var(--c-gray-bg); color: var(--c-text); }
.link-btn { border: 0; background: none; padding: 0; color: var(--c-primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--c-err); }

/* 表单 */
.input, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 12%, transparent); }
.input-sm { height: 30px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .label { font-size: 13px; color: var(--c-text-2); font-weight: 500; }
.field .req::after { content: " *"; color: var(--c-err); }
.field .hint { font-size: 12px; color: var(--c-muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 13px; font-weight: 600; color: var(--c-primary); border-top: 1px dashed var(--c-border); margin-top: 4px; padding-top: 12px; }
.form-grid > .form-section:first-child, .form-grid > .alert:first-child + .form-section { border-top: 0; margin-top: 0; padding-top: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--c-primary); }
.seg { display: inline-flex; border: 1px solid var(--c-border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg button, .seg label { border: 0; background: transparent; padding: 0 12px; height: 32px; cursor: pointer; display: inline-flex; align-items: center; border-right: 1px solid var(--c-border); }
.seg > :last-child { border-right: 0; }
.seg .on, .seg input:checked + span { background: var(--c-primary); color: #fff; }
.seg label { padding: 0; position: relative; }
.seg label span { padding: 0 12px; height: 32px; display: inline-flex; align-items: center; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--c-primary); outline-offset: -2px; }

/* 徽标 */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--c-gray-bg); color: var(--c-gray); }
.b-booked { background: var(--c-info-bg); color: var(--c-info); }
.b-pending { background: var(--c-purple-bg); color: var(--c-purple); }
.b-arrived { background: var(--c-warn-bg); color: var(--c-warn); }
.b-calling { background: var(--c-primary); color: #fff; animation: pulse 1.6s infinite; }
.b-done { background: var(--c-ok-bg); color: var(--c-ok); }
.b-cancelled { background: var(--c-gray-bg); color: var(--c-gray); }
.b-no_show { background: var(--c-err-bg); color: var(--c-err); }
.b-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.b-err { background: var(--c-err-bg); color: var(--c-err); }
.b-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.b-info { background: var(--c-info-bg); color: var(--c-info); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #c0c7d0; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

/* 提示 */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 10px 16px; border-radius: 8px; background: #1f2933; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; max-width: min(92vw, 520px); animation: toast-in .2s ease-out; }
.toast.ok { background: #136f45; }
.toast.err { background: #b3261e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); z-index: 500; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 88vh; }
.modal.modal-wide { max-width: 820px; }
.modal.modal-xl { max-width: 1040px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--c-line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--c-line); background: #fafbfc; border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* 就诊卡（85.6 × 54 mm 标准卡片比例） */
.visit-card { width: 100%; max-width: 380px; aspect-ratio: 85.6 / 54; border-radius: 14px; padding: 14px 16px 10px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0d7f7a 0%, #10637d 60%, #194a74 100%); box-shadow: 0 8px 24px rgba(13, 80, 100, .28); display: flex; flex-direction: column; gap: 6px; }
.visit-card::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; right: -90px; top: -110px; background: rgba(255, 255, 255, .08); }
.vc-head { display: flex; align-items: center; gap: 8px; position: relative; z-index: 1; }
.vc-head img { background: #fff; border-radius: 6px; }
.vc-head b { display: block; font-size: 14px; line-height: 1.2; }
.vc-head small { font-size: 10px; opacity: .8; letter-spacing: 1px; }
.vc-body { display: flex; justify-content: space-between; align-items: flex-end; position: relative; z-index: 1; }
.vc-name { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.vc-name small { display: block; font-size: 11px; font-weight: 400; opacity: .8; letter-spacing: 0; }
.vc-no { font-size: 11px; opacity: .9; text-align: right; }
.vc-no b { display: block; font-size: 16px; letter-spacing: 1.5px; font-family: ui-monospace, Consolas, monospace; }
.vc-code { background: #fff; border-radius: 8px; padding: 6px 8px; margin-top: auto; position: relative; z-index: 1; }
.vc-code .barcode { display: block; width: 100%; height: 44px; }
.vc-foot { font-size: 10px; opacity: .75; text-align: center; position: relative; z-index: 1; }

.empty { padding: 36px 16px; text-align: center; color: var(--c-muted); }
.loading { padding: 40px; text-align: center; color: var(--c-muted); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--c-info-bg); color: #1e3a6e; font-size: 13px; }
.alert.warn { background: var(--c-warn-bg); color: #7a3e06; }
.alert.err { background: var(--c-err-bg); color: #8a1c1c; }
.alert.ok { background: var(--c-ok-bg); color: #14532d; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: 14px 14px 0 0; }
}
/* 就诊卡颜色主题 */
.visit-card.vc-blue { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #0ea5e9 100%); }
.visit-card.vc-navy { background: linear-gradient(135deg, #0f172a 0%, #1e293b 45%, #1e3a8a 100%); }
.visit-card.vc-gold { background: linear-gradient(135deg, #5c4110 0%, #8a6418 45%, #c9a043 100%); }
.visit-card.vc-red { background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 50%, #e11d48 100%); }
.visit-card.vc-purple { background: linear-gradient(135deg, #3b0764 0%, #6d28d9 55%, #a855f7 100%); }
.visit-card.vc-green { background: linear-gradient(135deg, #14532d 0%, #15803d 55%, #22c55e 100%); }
.visit-card.vc-white { background: linear-gradient(135deg, #ffffff 0%, #f6faf9 100%); color: #18212b; border: 1px solid #e2e8ee; box-shadow: 0 8px 24px rgba(16, 24, 40, .1); }
.visit-card.vc-white::after { background: rgba(13, 127, 122, .06); }
.visit-card.vc-white::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: linear-gradient(180deg, #14b8a6, #0b6f8a); }
.visit-card.vc-white .vc-code { border: 1px solid #e8edf2; }
.vc-head img { object-fit: contain; padding: 2px; }

/* ===================== v1.5 皮肤 ===================== */
:root { --brand-a: #14b8a6; --brand-b: #0b6f8a; --nav-active: #2dd4bf; --side-1: #0b1825; --side-2: #0e2232; --side-3: #10293b; }
html[data-skin="teal"] { --c-primary: #0d7f7a; --c-primary-600: #0a6b67; --c-primary-50: #e9f6f5; --c-primary-100: #cdeae7; --brand-a: #14b8a6; --brand-b: #0b6f8a; --nav-active: #2dd4bf; --side-1: #0b1825; --side-2: #0e2232; --side-3: #10293b; }
html[data-skin="blue"] { --c-primary: #2563eb; --c-primary-600: #1d4ed8; --c-primary-50: #eef3fe; --c-primary-100: #d6e2fd; --brand-a: #3b82f6; --brand-b: #1e40af; --nav-active: #60a5fa; --side-1: #0b1530; --side-2: #0f1d40; --side-3: #13254f; }
html[data-skin="navy"] { --c-primary: #1e40af; --c-primary-600: #1e3a8a; --c-primary-50: #eef1fa; --c-primary-100: #d5ddf3; --brand-a: #4f6ee0; --brand-b: #172f6e; --nav-active: #93a8f8; --side-1: #0a1024; --side-2: #0e1733; --side-3: #121e42; }
html[data-skin="purple"] { --c-primary: #7c3aed; --c-primary-600: #6d28d9; --c-primary-50: #f4effe; --c-primary-100: #e4d8fd; --brand-a: #a78bfa; --brand-b: #5b21b6; --nav-active: #c4b5fd; --side-1: #150d2b; --side-2: #1d1238; --side-3: #251746; }
html[data-skin="orange"] { --c-primary: #ea580c; --c-primary-600: #c2410c; --c-primary-50: #fff2ea; --c-primary-100: #fdd9c2; --brand-a: #fb923c; --brand-b: #9a3412; --nav-active: #fdba74; --side-1: #1c120c; --side-2: #271810; --side-3: #311f14; }
html[data-skin="red"] { --c-primary: #c81e3a; --c-primary-600: #a3162f; --c-primary-50: #fdeef1; --c-primary-100: #f8cfd7; --brand-a: #f43f5e; --brand-b: #881337; --nav-active: #fda4af; --side-1: #1f0c12; --side-2: #2a1018; --side-3: #35141e; }
html[data-skin="green"] { --c-primary: #15803d; --c-primary-600: #166534; --c-primary-50: #ecf8f0; --c-primary-100: #cbeed6; --brand-a: #22c55e; --brand-b: #14532d; --nav-active: #86efac; --side-1: #0b1a10; --side-2: #0f2416; --side-3: #132e1c; }
html[data-skin="graphite"] { --c-primary: #334155; --c-primary-600: #1e293b; --c-primary-50: #f1f4f8; --c-primary-100: #dbe2ea; --brand-a: #64748b; --brand-b: #0f172a; --nav-active: #cbd5e1; --side-1: #0b0f17; --side-2: #111827; --side-3: #1a2232; }

/* 就诊卡：自定义颜色、版式、背景照片、圆形 Logo、背面 */
.visit-card.vc-custom { background: linear-gradient(135deg, var(--vc1) 0%, var(--vc2) 100%); }
.visit-card .vc-bgimg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; pointer-events: none; }
.visit-card.vc-has-bg::after { z-index: 0; }
.visit-card.vc-dark { color: #18212b; }
.visit-card.vc-dark .vc-foot, .visit-card.vc-dark .vc-name small { opacity: .75; }
.visit-card.vc-round .vc-head img { border-radius: 50%; }
.visit-card.vcl-banner, .visit-card.vcl-minimal { background: #fff; color: #18212b; border: 1px solid #e2e8ee; box-shadow: 0 8px 24px rgba(16, 24, 40, .1); }
.visit-card.vcl-banner::after, .visit-card.vcl-minimal::after { display: none; }
.visit-card.vcl-banner .vc-head { margin: -14px -16px 4px; padding: 10px 16px; background: linear-gradient(135deg, var(--vc1), var(--vc2)); color: #fff; }
.visit-card.vcl-banner.vc-dark .vc-head { color: #18212b; }
.visit-card.vcl-minimal::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: linear-gradient(180deg, var(--vc1), var(--vc2)); z-index: 1; }
.visit-card.vcl-minimal .vc-head b { color: var(--vc1); }
.visit-card.vcl-banner .vc-code, .visit-card.vcl-minimal .vc-code { border: 1px solid #e8edf2; }
.visit-card.vcl-banner .vc-bgimg, .visit-card.vcl-minimal .vc-bgimg { opacity: .12 !important; }
.vc-back-body { position: relative; z-index: 1; font-size: 11px; line-height: 1.55; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.vc-back-body p { margin: 0; white-space: pre-line; }
.vc-back-row { display: flex; gap: 6px; }
.vc-back-row span { opacity: .75; flex: none; }
.vc-back-row b { font-weight: 600; }

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .input:focus { box-shadow: 0 0 0 3px rgba(13, 127, 122, .15); }
}
.vc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.vc-qr { width: 64px; height: 64px; background: #fff; border-radius: 6px; padding: 3px; }
.vc-qr .qrcode { display: block; width: 100%; height: 100%; }
.cs-phone-in .vc-qr { width: 40px; height: 40px; padding: 2px; }
