/* ===== 全局变量和主题（冷调马卡龙色系） ===== */
:root {
    --primary: #6B8E7B;          /* 鼠尾草马卡龙 */
    --primary-light: #8FB09E;    /* 淡鼠尾草 */
    --primary-dark: #4A6B5A;     /* 深鼠尾草 */
    --accent: #6B8EAE;           /* 石板蓝马卡龙 */
    --accent-light: #94B4CF;     /* 淡石板蓝 */
    --bg: #F0F4F2;               /* 冷灰绿背景 */
    --card: #ffffff;
    --text: #2C3630;             /* 深灰绿文字 */
    --text-secondary: #7A8B82;   /* 灰绿副文字 */
    --border: #D4DDD7;           /* 冷灰绿边框 */
    --danger: #C4786C;           /* 赤陶马卡龙 */
    --success: #5E9B7A;          /* 深鼠尾草 */
    --warning: #D4A85B;          /* 琥珀马卡龙 */
    --radius: 12px;
    --shadow: 0 2px 8px rgba(107,142,123,0.12);
    --tab-height: 56px;
    --header-height: 50px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ===== 固定顶部标题栏 ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(107,142,123,0.2);
}
.app-header .back-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    padding: 6px;
    cursor: pointer;
}

/* ===== 主内容区域 ===== */
.app-content {
    padding-top: calc(var(--header-height) + 12px);
    padding-bottom: calc(var(--tab-height) + 16px);
    min-height: 100vh;
    padding-left: 16px;
    padding-right: 16px;
}

/* 无底部Tab的页面 */
.app-content.no-tab {
    padding-bottom: 80px;
}

/* ===== 底部Tab栏 ===== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: #fff;
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 90;
    box-shadow: 0 -1px 6px rgba(107,142,123,0.08);
}
.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    transition: color 0.2s;
    padding: 4px 0;
}
.tab-item.active {
    color: var(--accent);
}
.tab-item i {
    font-size: 22px;
    margin-bottom: 2px;
}

/* ===== 底部悬浮操作栏 ===== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 95;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 6px rgba(107,142,123,0.08);
}
.bottom-bar .btn {
    flex: 1;
    flex-shrink: 0;
}

/* ===== 工资表展开卡片 ===== */
.wage-table-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
    border-left: 3px solid transparent;
    transition: border-color 0.2s;
}
.wage-table-card.expanded {
    border-left: 3px solid var(--accent);
}
.wage-table-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.wage-table-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wage-table-summary {
    font-size: 13px;
    color: var(--text-secondary);
}
.wage-table-body {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid var(--border);
}
.wage-table-card.expanded .wage-table-body {
    display: block;
}
.wage-table-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}
.mini-wage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.mini-wage-table th,
.mini-wage-table td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.mini-wage-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    border-bottom: 2px solid var(--border);
}
.mini-wage-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    padding-top: 8px;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
    transition: transform 0.15s;
}
.card:active {
    transform: scale(0.98);
}

.card-header {
    padding: 14px 16px 8px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px;
}
.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}
.card-body {
    padding: 0 16px 14px;
}
.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border);
}


/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:active {
    background: var(--primary-light);
}
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:active {
    background: var(--bg);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-ghost {
    background: transparent;
    color: var(--accent);
}
.btn-block {
    width: 100%;
}
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}
.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus {
    border-color: var(--accent);
}
.form-input[type="number"] {
    -moz-appearance: textfield;
}
.form-input::-webkit-inner-spin-button,
.form-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}
.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: var(--text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

/* ===== 搜索框 ===== */
.search-box {
    position: relative;
    margin-bottom: 12px;
}
.search-box input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    font-size: 15px;
    background: #fff;
    outline: none;
}
.search-box input:focus {
    border-color: var(--accent);
}
.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 18px;
}

/* ===== 进度条步骤 ===== */
.steps {
    display: flex;
    align-items: center;
    padding: 0 4px;
    margin-bottom: 16px;
}
.step {
    flex: 1;
    text-align: center;
    position: relative;
}
.step::after {
    content: '';
    position: absolute;
    top: 14px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.step:last-child::after { display: none; }
.step.active::after { background: var(--accent); }
.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    margin-bottom: 4px;
}
.step.active .step-dot {
    background: var(--accent);
    color: #fff;
}
.step.done .step-dot {
    background: var(--success);
    color: #fff;
}
.step-label {
    font-size: 11px;
    color: var(--text-secondary);
}
.step.active .step-label { color: var(--accent); font-weight: 600; }

/* ===== 成员选择卡片 ===== */
.member-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    cursor: pointer;
}
.member-card.selected {
    border-color: var(--accent);
    background: #EAF3EE;
}
.member-card .member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}
.member-card.selected .member-avatar {
    background: var(--accent);
}
.member-card .member-info {
    flex: 1;
    min-width: 0;
}
.member-card .member-name {
    font-size: 16px;
    font-weight: 600;
}
.member-card .member-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.member-card .check-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    color: transparent;
    transition: all 0.2s;
}
.member-card.selected .check-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== 工资输入行 ===== */
.wage-row {
    background: var(--card);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}
.wage-row .seq {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.wage-row .name {
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 48px;
}
.wage-row .team-input {
    width: 60px;
    padding: 8px 6px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    flex-shrink: 0;
}
.wage-row .wage-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    text-align: right;
    font-weight: 600;
    color: var(--primary);
    background: #fff;
    outline: none;
}
.wage-row .wage-input:focus {
    border-color: var(--accent);
}

/* ===== 统一工资设置 ===== */
.batch-bar {
    background: #EAF3EE;
    border: 1.5px solid var(--accent);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.batch-bar input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    text-align: right;
    outline: none;
    background: #fff;
}

/* ===== 底部合计 ===== */
.total-bar {
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    margin-bottom: 80px;
}
.total-bar .total-label { font-size: 15px; }
.total-bar .total-amount { font-size: 22px; font-weight: 700; }

/* ===== 成员管理卡片 ===== */
.member-list-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    overflow: hidden;
    border-left: 3px solid transparent;
    transition: border-color 0.2s;
}
.member-list-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.member-list-header .name {
    font-size: 16px;
    font-weight: 600;
}
.member-list-header .actions {
    display: flex;
    gap: 8px;
}
.member-list-body {
    padding: 10px 16px 14px;
    display: none;
    border-top: 1px solid var(--border);
}
.member-list-card.expanded .member-list-body {
    display: block;
}
.member-list-card.expanded {
    border-left: 3px solid var(--accent);
}
.member-list-card .info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.member-list-card .info-row:last-child { border-bottom: none; }
.member-list-card .info-label { color: var(--text-secondary); }
.member-list-card .info-value { font-weight: 500; }

/* ===== 弹出操作面板 ===== */
.action-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44,54,48,0.4);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.action-sheet-overlay.show { display: flex; }
.action-sheet {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 8px 0 calc(env(safe-area-inset-bottom, 12px) + 8px);
    animation: slideUp 0.2s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.action-sheet .action-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    font-size: 16px;
    color: var(--text);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.action-sheet .action-item:active { background: var(--bg); }
.action-sheet .action-item i { font-size: 20px; color: var(--accent); }
.action-sheet .action-item.danger { color: var(--danger); }
.action-sheet .action-item.danger i { color: var(--danger); }
.action-sheet .divider {
    height: 8px;
    background: var(--bg);
}

/* ===== Toast 提示 ===== */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    width: 90%;
    max-width: 400px;
}
.toast {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    text-align: center;
    box-shadow: 0 4px 12px rgba(107,142,123,0.15);
    animation: fadeInDown 0.3s ease;
    margin-bottom: 8px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); }
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 加载状态 ===== */
.loading-mask {
    position: fixed;
    inset: 0;
    background: rgba(240,244,242,0.85);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}
.loading-mask.show { display: flex; }
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-right-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 预览表格 ===== */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}
.preview-table th,
.preview-table td {
    border: 1px solid #B4C8BC;
    padding: 8px 6px;
    text-align: center;
    vertical-align: middle;
}
.preview-table th {
    background: #D6E5DB;
    font-weight: 600;
    font-size: 13px;
}
.preview-table .title-row {
    font-size: 16px;
    font-weight: 700;
    padding: 12px 8px;
    background: #fff;
    border: 1px solid #B4C8BC;
}
.preview-table .total-cell {
    font-weight: 700;
    text-align: right;
    padding-right: 12px;
}
.preview-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; }

/* ===== 横屏适配 ===== */
@media (orientation: landscape) {
    .app-content { padding-left: 24px; padding-right: 24px; }
    .member-card { display: inline-flex; width: calc(50% - 4px); margin-right: 8px; }
    .wage-row { display: flex; }
    .preview-table { font-size: 12px; }
}

/* ===== 确认对话框 ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44,54,48,0.4);
    z-index: 250;
    display: none;
    align-items: center;
    justify-content: center;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(107,142,123,0.2);
}
.confirm-box h4 { margin: 0 0 8px; font-size: 17px; }
.confirm-box p { color: var(--text-secondary); font-size: 14px; margin: 0 0 20px; }
.confirm-box .btn-group { display: flex; gap: 10px; }

/* ===== 性别标识 ===== */
.gender-tag {
    display: inline-block;
    font-size: 14px;
    font-weight: 700;
    margin-left: 4px;
    color: var(--accent);
}
.gender-tag.female {
    color: #C4786C;
}

/* ===== 头像女色 ===== */
.member-avatar.female {
    background: #C4786C !important;
}

/* ===== 信息标签 ===== */
.tag-id {
    display: inline-block;
    background: #edf2f7;
    color: var(--text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
    letter-spacing: 0.3px;
}
.tag-phone {
    display: inline-block;
    background: #EAF3EE;
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    letter-spacing: 0.3px;
}

/* ===== 预览表格不换行 ===== */
.preview-table td {
    white-space: nowrap;
    word-break: keep-all;
}
.preview-table th {
    white-space: nowrap;
}
.confirm-box .btn-group .btn { flex: 1; }

/* ===== 搜索下拉框 ===== */
.sd-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(107,142,123,0.15);
    z-index: 300;
    -webkit-overflow-scrolling: touch;
}
.sd-option {
    padding: 10px 14px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.sd-option:last-child { border-bottom: none; }
.sd-option:active,
.sd-option:hover {
    background: #EAF3EE;
    color: var(--primary);
}
