/* 会员预约管理系统 —— 全局样式 */
:root {
    --brand: #0e7490;
    --brand-2: #0891b2;
    --brand-dark: #0b3b4a;
    --brand-soft: #e6f4f7;
    --ink: #1f2937;
    --ink-2: #4b5563;
    --muted: #9ca3af;
    --line: #e5e9ee;
    --bg: #f4f7fa;
    --ok: #059669;
    --warn: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 224px;
    background: linear-gradient(180deg, #0b3b4a 0%, #0d4b5c 60%, #0b3b4a 100%);
    color: #e6f4f7; display: flex; flex-direction: column; z-index: 20;
}
.sidebar-close {
    display: none; position: absolute; top: 12px; right: 10px; z-index: 2;
    width: 30px; height: 30px; padding: 0; border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px; background: rgba(255, 255, 255, .14); color: #fff;
    font-size: 20px; font-weight: 600; line-height: 1; cursor: pointer; place-items: center;
}
.sidebar-close:hover { background: rgba(255, 255, 255, .18); }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 15;
    border: 0; padding: 0; background: rgba(4, 24, 32, .5); cursor: pointer;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, #14b8a6, #0891b2);
    display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff;
}
.brand-text strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.brand-text small { color: #8fc4d1; font-size: 11px; letter-spacing: .5px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0;
    border-radius: 8px; color: #cfe7ee; font-size: 14px; transition: .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; }
.nav-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .12); margin: 8px 12px; }
.nav-portal { color: #9ad4e2; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .1); display: flex; align-items: center; justify-content: space-between; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; font-size: 13px; }
.who strong { display: block; font-size: 13px; line-height: 1.2; }
.who small { color: #8fc4d1; font-size: 11px; }
.logout { color: #9ad4e2; font-size: 12px; }

.main { margin-left: 224px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 34px; height: 32px; cursor: pointer; }
.topbar-title h1 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); display: inline-block; }
.page { padding: 18px 22px 30px; flex: 1; }
.foot { padding: 12px 22px 22px; color: var(--muted); font-size: 12px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--brand-soft); opacity: .5; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--brand-dark); }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat.accent { background: linear-gradient(135deg, #0e7490, #0b5e75); color: #fff; border: none; }
.stat.accent .label, .stat.accent .hint, .stat.accent .value small { color: rgba(255, 255, 255, .78); }
.stat.accent .value { color: #fff; }
.stat.accent::after { background: rgba(255, 255, 255, .15); opacity: 1; }

.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); font-size: 13px; cursor: pointer; white-space: nowrap;
    transition: .15s; line-height: 1.4; font-family: inherit;
}
.btn:hover { border-color: #cfd8e3; background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #0b6279; border-color: #0b6279; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #047857; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow-x: auto; }
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); vertical-align: middle; }
table.tbl th { background: #f8fafc; color: var(--ink-2); font-weight: 600; white-space: nowrap; font-size: 12.5px; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #fafcfd; }
table.tbl td.nowrap, table.tbl th.nowrap { white-space: nowrap; }
.tbl-empty { padding: 30px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.link-name { font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; line-height: 1.6; white-space: nowrap; }
.badge-ok { background: #e7f6ef; color: #047857; }
.badge-muted { background: #f1f3f6; color: #6b7280; }
.badge-warn { background: #fff4e6; color: #b45309; }
.badge-danger { background: #fdeceb; color: #b91c1c; }
.badge-info { background: #e8f1fe; color: #1d4ed8; }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.form-row { display: flex; flex-wrap: wrap; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 180px; flex: 1; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field label .req { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=search], select, textarea {
    padding: 8px 10px; border: 1px solid #d8dee6; border-radius: 8px; font-size: 13px;
    font-family: inherit; background: #fff; color: var(--ink); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(8, 145, 178, .12); }
textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar .field { flex: 0 1 180px; min-width: 140px; }
.hint { color: var(--muted); font-size: 12px; }

.flash { margin: 12px 22px 0; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.flash-ok { background: #e7f6ef; color: #065f46; border: 1px solid #c6ebd8; }
.flash-err { background: #fdeceb; color: #991b1b; border: 1px solid #f7cfcc; }
.flash-info { background: #e8f1fe; color: #1e40af; border: 1px solid #cddffb; }
.flash-warn { background: #fff8e6; color: #8a6116; border: 1px solid #f5e3b8; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding: 12px 4px 0; font-size: 13px; }
.pager a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink-2); }
.pager a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager-info { color: var(--muted); font-size: 12px; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.slot {
    border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; cursor: pointer;
    transition: .15s; text-align: left; font-family: inherit; font-size: 13px;
}
.slot:hover { border-color: var(--brand-2); box-shadow: 0 2px 8px rgba(8, 145, 178, .12); }
.slot.selected { border-color: var(--brand); background: var(--brand-soft); }
.slot.full { opacity: .5; cursor: not-allowed; }
.slot .t { font-weight: 600; }
.slot .m { color: var(--muted); font-size: 12px; margin-top: 2px; }

.date-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.date-tab {
    flex: none; border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; background: #fff;
    text-align: center; min-width: 84px; color: var(--ink-2);
}
.date-tab:hover { border-color: var(--brand-2); text-decoration: none; }
.date-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-tab small { display: block; font-size: 11px; opacity: .8; }

.todo-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.todo-item:last-child { border-bottom: none; }
.todo-item .t { flex: 1; min-width: 0; }
.todo-item .t strong { display: block; font-size: 13px; }
.todo-item .t small { color: var(--muted); font-size: 12px; }

.profile-head { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.profile-head .big-avatar {
    width: 54px; height: 54px; border-radius: 14px; background: var(--brand-soft); color: var(--brand);
    display: grid; place-items: center; font-size: 20px; font-weight: 700; flex: none;
}
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 60px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-track { height: 10px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #14b8a6, #0e7490); border-radius: 6px; }
.bar-val { color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b3b4a, #0e7490 60%, #0891b2); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(3, 30, 40, .35); overflow: hidden; }
.login-head { padding: 28px 28px 10px; }
.login-head .logo { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #14b8a6, #0891b2); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.login-head h1 { font-size: 19px; margin: 14px 0 4px; }
.login-head p { color: var(--muted); font-size: 12.5px; margin: 0; }
.login-body { padding: 16px 28px 28px; }
.login-body .field { margin-bottom: 14px; }
.login-body input { padding: 10px 12px; }
.login-foot { padding: 14px 28px; background: #f8fafc; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }

@media (max-width: 1100px) {
    .stats, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: .2s; }
    .sidebar.open { transform: translateX(0); box-shadow: 10px 0 40px rgba(0, 0, 0, .2); }
    .sidebar-close { display: grid; }
    .sidebar .brand { padding-right: 46px; }
    .sidebar-backdrop.show { display: block; }
    body.sidebar-open { overflow: hidden; }
    .main { margin-left: 0; }
    .menu-btn { display: block; }
    .topbar-meta { display: none; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page { padding: 14px; }
}

/* 会员详情：手机端卡片式排版 */
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.card-actions form { display: inline-flex; }
.period-part { display: block; }

@media (max-width: 640px) {
    body:has(.member-detail) { overflow-x: hidden; }
    .member-detail .profile-head { gap: 12px; align-items: flex-start; }
    .member-detail .profile-head .big-avatar { width: 46px; height: 46px; border-radius: 11px; font-size: 19px; }
    .member-detail .profile-main { flex: 1 1 210px; min-width: 0; }
    .member-detail .profile-badges { gap: 6px 8px !important; }
    .member-detail .profile-meta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; font-size: 12.5px; line-height: 1.65; }
    .member-detail .profile-meta span { overflow-wrap: anywhere; }
    .member-detail .member-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px; margin-top: 2px; }
    .member-detail .member-actions .btn { width: 100%; padding: 8px 8px; text-align: center; }
    .member-detail .member-actions .btn:only-child { grid-column: 1 / -1; }
    .member-detail .card-body { padding: 14px; }

    .member-detail .member-cards,
    .member-detail .member-records,
    .member-detail .member-appts { display: block; width: 100%; font-size: 13px; }
    .member-detail .member-cards thead,
    .member-detail .member-records thead,
    .member-detail .member-appts thead { display: none; }
    .member-detail .member-cards tbody,
    .member-detail .member-records tbody,
    .member-detail .member-appts tbody { display: block; }

    .member-detail .member-cards tr {
        display: grid; grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "card card" "remain status" "dates dates" "actions actions";
        gap: 8px 10px; padding: 13px 14px; border-bottom: 1px solid var(--line);
    }
    .member-detail .member-cards tr:last-child { border-bottom: 0; }
    .member-detail .member-cards td { display: block; padding: 0; border: 0; min-width: 0; }
    .member-detail .member-cards .cell-card { grid-area: card; }
    .member-detail .member-cards .cell-remain { grid-area: remain; }
    .member-detail .member-cards .cell-status { grid-area: status; justify-self: end; align-self: start; }
    .member-detail .member-cards .cell-dates { grid-area: dates; display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--muted); font-size: 12px; }
    .member-detail .member-cards .cell-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
    .member-detail .member-cards .cell-actions.is-empty { display: none; }
    .member-detail .member-cards .cell-actions .card-actions { width: 100%; }
    .member-detail .member-cards .cell-actions .card-actions .btn { flex: 1 1 auto; text-align: center; }
    .member-detail .member-cards .cell-actions .card-add-box { flex: 1 1 100%; width: 100%; }
    .member-detail .member-cards .cell-actions .card-add-box form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .member-detail .member-cards .cell-actions .card-add-box form .btn { grid-column: 1 / -1; }
    .member-detail .member-cards .cell-card strong { overflow-wrap: anywhere; }

    .member-detail .member-records tr {
        display: grid; grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line);
    }
    .member-detail .member-records tr:last-child { border-bottom: 0; }
    .member-detail .member-records td { display: block; padding: 0; border: 0; min-width: 0; }
    .member-detail .member-records .cell-date { color: var(--muted); font-size: 12px; }
    .member-detail .member-records .cell-date { grid-row: 1; grid-column: 1; }
    .member-detail .member-records .cell-project { grid-row: 2; grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
    .member-detail .member-records .cell-times { grid-row: 1; grid-column: 2; text-align: right; font-size: 12px; }
    .member-detail .member-records .cell-times::before { content: "扣 "; color: var(--muted); font-weight: 400; }
    .member-detail .member-records .cell-times::after { content: " 次"; color: var(--muted); font-weight: 400; }
    .member-detail .member-records .cell-staff { grid-row: 3; grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
    .member-detail .member-records .cell-staff::before { content: attr(data-label) "："; }
    .member-detail .member-cards td[colspan],
    .member-detail .member-records td[colspan],
    .member-detail .member-appts td[colspan] { grid-column: 1 / -1; }
    .member-detail .member-cards .tbl-empty,
    .member-detail .member-records .tbl-empty,
    .member-detail .member-appts .tbl-empty { padding: 26px 12px; }
    .member-detail .empty-row { display: block; padding: 0; }

    .member-detail .member-appts tr {
        display: grid; grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line);
    }
    .member-detail .member-appts tr:last-child { border-bottom: 0; }
    .member-detail .member-appts td { display: block; padding: 0; border: 0; min-width: 0; }
    .member-detail .member-appts .cell-appt-date { grid-row: 1; grid-column: 1; font-weight: 600; }
    .member-detail .member-appts .cell-appt-status { grid-row: 1; grid-column: 2; justify-self: end; align-self: start; }
    .member-detail .member-appts .cell-appt-time { grid-row: 2; grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; }
    .member-detail .member-appts .cell-appt-time::before { content: attr(data-label) "："; color: var(--muted); }
    .member-detail .member-appts .cell-appt-source { grid-row: 3; grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
    .member-detail .member-appts .cell-appt-source::before { content: attr(data-label) "："; }
    .member-detail .profile-main .small.muted { overflow-wrap: anywhere; }
}

@media print {
    .sidebar, .topbar, .foot, .no-print { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; }
}
