/**
 * 随礼簿 Web 端样式
 * 移动端优先、卡片风格，主色 #F14977（贴近小程序视觉）
 */

:root {
    --primary: #F14977;
    --primary-light: #FF7EB3;
    --blue: #4A90E2;
    --text: #333;
    --text-sub: #888;
    --border: #eee;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    background: #fff;
}
input:focus, select:focus { border-color: var(--primary); }

/* ==================== 通用按钮 ==================== */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 14px;
}
.btn-primary:hover { background: #e13a68; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-plain {
    background: #fff;
    color: var(--text);
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 14px;
}
.btn-plain:hover { border-color: var(--primary); color: var(--primary); }
.btn-plain:disabled { color: #bbb; border-color: #e5e5e5; cursor: not-allowed; }

.btn-danger {
    background: #fff;
    color: #e64340;
    border: 1px solid #e64340;
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 14px;
}
.btn-danger:hover { background: #e64340; color: #fff; }

.mini-btn {
    background: #fff;
    border: 1px solid #ddd;
    color: var(--text);
    border-radius: 14px;
    padding: 3px 12px;
    font-size: 12px;
    white-space: nowrap;
}
.mini-btn:hover { border-color: var(--primary); color: var(--primary); }
.mini-btn-danger { color: #e64340; }
.mini-btn-danger:hover { border-color: #e64340; color: #e64340; }
.mini-btn-primary { color: var(--primary); border-color: var(--primary); }

/* ==================== 登录页 ==================== */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #F14977 0%, #FF7EB3 60%, #FFB6C1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.login-logo { text-align: center; }
.login-logo img { height: 64px; width: auto; }
.login-title { text-align: center; font-size: 24px; margin-top: 12px; }
.login-subtitle { text-align: center; color: var(--text-sub); font-size: 13px; margin-top: 14px; }
.login-form { margin-top: 28px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.login-field input { width: 100%; padding: 10px 12px; }
.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }
.send-btn {
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 13px;
    white-space: nowrap;
}
.send-btn:disabled { border-color: #ccc; color: #bbb; cursor: not-allowed; }
.dev-code-tip {
    background: #fff8e1;
    color: #8d6e00;
    font-size: 12px;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 12px;
}
.remember-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 14px;
    cursor: pointer;
    user-select: none;
}
.remember-label input { width: auto; margin: 0; accent-color: var(--primary); }
.login-btn {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 12px 0;
    font-size: 16px;
    margin-top: 8px;
}
.login-btn:hover { background: #e13a68; }
.login-btn:disabled { background: #f0a5bc; cursor: not-allowed; }
.login-tip { text-align: center; color: var(--text-sub); font-size: 12px; margin-top: 14px; }
.login-back { text-align: center; margin-top: 10px; font-size: 13px; }

/* ==================== 应用外壳 ==================== */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.app-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: bold; }
.app-brand img { height: 28px; width: auto; }
.app-user-tag {
    font-size: 12px;
    font-weight: normal;
    color: var(--primary);
    background: #ffeef3;
    border-radius: 10px;
    padding: 2px 10px;
    margin-left: 4px;
}
.app-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.app-nav a {
    color: var(--text);
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 14px;
}
.app-nav a:hover { color: var(--primary); }
.app-nav a.active { background: var(--primary); color: #fff; }
.app-main { max-width: 960px; width: 100%; margin: 0 auto; padding: 16px; flex: 1; }
.app-footer { text-align: center; color: #aaa; font-size: 12px; padding: 16px; }

/* ==================== 通用区块 ==================== */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.toolbar-search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.toolbar-search input { min-width: 160px; flex: 1; max-width: 320px; }
.toolbar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.total-tip { color: var(--text-sub); font-size: 13px; margin-bottom: 8px; }
.empty-tip {
    text-align: center;
    color: #bbb;
    padding: 40px 16px;
    font-size: 14px;
    line-height: 1.8;
}
.load-more-wrap { text-align: center; padding: 12px 0 24px; }
.form-tip { color: var(--text-sub); font-size: 12px; margin: 8px 0; line-height: 1.6; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.confirm-text { line-height: 1.8; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-sub); }
.form-grid input, .form-grid select { width: 100%; }

/* 标签 */
.tag {
    display: inline-block;
    font-size: 12px;
    border-radius: 10px;
    padding: 1px 10px;
    background: #eee;
    color: #666;
}
.tag-pink { background: #ffeef3; color: var(--primary); }
.tag-grey { background: #f0f0f0; color: #666; }
.tag-green { background: #e8f7ee; color: #2e9e5b; }
.tag-orange { background: #fff3e0; color: #e68a00; }
.tag-blue { background: #e8f1fc; color: var(--blue); }
.tag-family { background: #e8f1fc; color: var(--blue); }

/* ==================== Toast / Loading ==================== */
#toastBox {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.web-toast {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.25s;
    max-width: 80vw;
}
.web-toast.show { opacity: 1; transform: translateY(0); }

.loading-box {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.loading-spin {
    width: 32px;
    height: 32px;
    border: 3px solid #ffe0ea;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: webSpin 0.8s linear infinite;
}
@keyframes webSpin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-sub); font-size: 13px; }

/* ==================== 模态框 ==================== */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}
.modal-mask.show { opacity: 1; }
.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: bold; }
.modal-close { font-size: 22px; color: #999; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==================== 礼簿列表 ==================== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    border: 1px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.2s;
}
.book-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.book-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.book-name { font-size: 16px; font-weight: bold; flex: 1; }
.book-card-meta { color: var(--text-sub); font-size: 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.book-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.book-sum { display: flex; gap: 16px; color: var(--text-sub); font-size: 13px; }
.book-sum b { color: var(--primary); }

.trash-list { display: flex; flex-direction: column; gap: 10px; }
.trash-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.trash-name { font-weight: bold; }
.trash-meta { color: var(--text-sub); font-size: 12px; margin-top: 4px; }
.confirm-user {
    background: #e8f7ee;
    color: #2e9e5b;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 10px;
    font-size: 13px;
}

/* ==================== 记录行（收礼/送礼通用） ==================== */
.block-title { font-size: 15px; margin: 16px 0 10px; }
.rec-list { display: flex; flex-direction: column; gap: 10px; }
#searchResult .rec-row { margin-bottom: 10px; }
.rec-row {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.rec-main { display: flex; align-items: center; justify-content: space-between; }
.rec-name { font-size: 15px; font-weight: bold; }
.rec-money { color: var(--primary); font-size: 16px; font-weight: bold; }
.rec-sub { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-sub); font-size: 12px; margin-top: 6px; }
.rec-ops { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; }

/* 批量录入行 */
.batch-row {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
@media (max-width: 560px) {
    .batch-row { grid-template-columns: 1fr 1fr; }
}

.fuzzy-label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.fuzzy-label input { width: auto; }

/* ==================== 统计 ==================== */
.stat-year-label { color: var(--text-sub); font-size: 13px; white-space: nowrap; }
#statYear { width: 90px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-bottom: 12px;
}
.stat-grid .stat-card { margin-bottom: 0; }
.stat-card-title { font-size: 15px; font-weight: bold; margin-bottom: 12px; }
.stat-total { color: var(--text-sub); font-size: 13px; margin-top: 10px; }

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-top: 18px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-val { font-size: 10px; color: var(--text-sub); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { width: 70%; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-label { font-size: 10px; color: #aaa; margin-top: 4px; }

.stat-all-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-all-item {
    flex: 1;
    min-width: 140px;
    background: #fafafa;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-all-label { color: var(--text-sub); font-size: 12px; }
.stat-all-num { font-size: 18px; font-weight: bold; color: var(--primary); }

.ratio-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-top: 14px; background: #eee; }
.ratio-home { background: var(--primary); }
.ratio-pers { background: var(--blue); }
.ratio-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-sub); margin-top: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot-home { background: var(--primary); }
.dot-pers { background: var(--blue); }

.year-stat { margin-top: 16px; }
.year-stat-avg { font-size: 14px; margin-bottom: 10px; }
.year-stat-num { color: var(--primary); font-size: 18px; }
.year-stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.year-stat-card {
    flex: 1;
    min-width: 150px;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.year-stat-max { background: #ffeef3; }
.year-stat-min { background: #e8f1fc; }
.year-stat-card-label { font-size: 12px; color: var(--text-sub); }
.year-stat-card b { font-size: 18px; }
.year-stat-max b { color: var(--primary); }
.year-stat-min b { color: var(--blue); }

/* ==================== 择日 ==================== */
.lucky-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.lucky-tab {
    padding: 7px 20px;
    border-radius: 18px;
    background: #fff;
    color: var(--text);
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 14px;
}
.lucky-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lucky-tip { text-align: center; color: #aaa; font-size: 12px; margin: 20px 0; line-height: 1.8; }

.cal-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; font-size: 16px; }
.cal-yinli { color: var(--primary); font-size: 13px; }
.cal-rows { display: flex; flex-direction: column; gap: 8px; }
.cal-row { display: flex; gap: 10px; font-size: 13px; line-height: 1.6; }
.cal-label {
    flex-shrink: 0;
    width: 64px;
    color: var(--primary);
    font-weight: bold;
}
.cal-yi span:last-child { color: #2e9e5b; }
.cal-ji span:last-child { color: #666; }

.hour-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.hour-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.hour-range, .hour-ganzhi { color: var(--text-sub); font-size: 12px; }
.hour-luck { margin-left: auto; font-size: 12px; }
.luck-good { color: #2e9e5b; }
.luck-bad { color: #e64340; }
.hour-yiji { display: flex; gap: 8px; font-size: 12px; margin-top: 6px; color: var(--text-sub); line-height: 1.6; }
.yi-tag {
    flex-shrink: 0;
    background: #ffeef3;
    color: var(--primary);
    border-radius: 4px;
    padding: 0 6px;
    font-size: 12px;
}
.ji-tag {
    flex-shrink: 0;
    background: #f0f0f0;
    color: #666;
    border-radius: 4px;
    padding: 0 6px;
    font-size: 12px;
}

.result-title { font-weight: bold; margin: 14px 0 10px; }
.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid transparent;
}
.result-card:hover { border-color: var(--primary); }
.result-date-row { display: flex; align-items: center; gap: 10px; }
.result-view-tip { margin-left: auto; color: var(--primary); font-size: 12px; }
.result-info-row { display: flex; gap: 18px; color: var(--text-sub); font-size: 12px; margin: 6px 0; flex-wrap: wrap; }

/* ==================== 家庭组 ==================== */
.group-empty { text-align: center; padding: 32px 16px; }
.group-empty-icon { font-size: 44px; }
.group-empty-title { font-size: 17px; font-weight: bold; margin: 10px 0; }
.group-empty-desc { color: var(--text-sub); font-size: 13px; line-height: 1.8; }
.group-empty .form-actions { justify-content: center; }

.group-header-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
}
.group-name { font-size: 20px; font-weight: bold; }
.group-meta { font-size: 13px; opacity: 0.9; margin-top: 6px; }

.inv-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.inv-item:last-child { border-bottom: none; }
.inv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffeef3;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}
.inv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.inv-info { flex: 1; min-width: 0; font-size: 14px; }
.inv-home { color: var(--text-sub); font-size: 12px; margin-top: 2px; }
.inv-btns { display: flex; gap: 8px; }

.member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }

.invite-row { display: flex; gap: 10px; }
.invite-row input { flex: 1; }
.sent-invite-list { margin-top: 12px; }

/* ==================== 个人中心 ==================== */
.me-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: #fff;
    margin-bottom: 12px;
}
.me-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    overflow: hidden;
    flex-shrink: 0;
}
.me-avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 18px; font-weight: bold; }
.me-sub { font-size: 12px; opacity: 0.9; margin-top: 4px; }
.me-sign-btn { background: #fff; color: var(--primary); border: none; font-weight: bold; }
.me-sign-btn:disabled { color: #bbb; background: rgba(255, 255, 255, 0.85); }

.me-menu {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-bottom: 12px;
}
.me-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 16px;
}
.me-menu-item:last-child { border-bottom: none; }
.me-menu-item:hover { background: #fafafa; }
.me-menu-danger { color: #e64340; }
.me-arrow { color: #ccc; font-size: 18px; }

.sms-row { display: flex; gap: 8px; }
.sms-row input { flex: 1; }
.sms-send-btn { white-space: nowrap; flex-shrink: 0; }

.score-head { text-align: center; padding: 10px 0 16px; }
.score-balance { font-size: 40px; font-weight: bold; color: var(--primary); }
.score-streak { color: var(--text-sub); font-size: 13px; margin-top: 4px; }
.score-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.score-tab {
    flex: 1;
    text-align: center;
    padding: 7px 0;
    border-radius: 18px;
    background: #f5f5f5;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 13px;
}
.score-tab.active { background: var(--primary); color: #fff; }
.score-record {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.score-record:last-child { border-bottom: none; }
.score-record-time { color: #bbb; font-size: 12px; margin-top: 3px; }
.score-plus { color: var(--primary); }
.score-minus { color: var(--blue); }

/* ==================== 移动端适配 ==================== */
@media (max-width: 640px) {
    .app-header-inner { padding: 8px 12px; gap: 8px; }
    .app-nav a { padding: 5px 10px; font-size: 13px; }
    .app-main { padding: 12px; }
    .page-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-search input { max-width: none; }
    .toolbar-btns { justify-content: flex-end; }
    .stat-grid { grid-template-columns: 1fr; }
}
