/* style.css - Old4 CRM 全局统一样式 */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --pos-color: #2563eb;
    --neg-color: #dc2626;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* 保证全屏不被撑宽横晃 */
    background-color: var(--bg-page);
    color: var(--text-main);
}

body {
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    flex: 1 0 auto;
}

/* 统一页头与导航栏 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.navbar h1 {
    font-size: 20px;
    font-weight: 700;
}
.navbar h1 a {
    color: var(--text-main);
    text-decoration: none;
}
.nav-links {
    font-size: 13px;
    color: var(--text-muted);
}
.nav-links a {
    color: var(--primary);
    text-decoration: none;
    margin-left: 10px;
    transition: color 0.15s ease;
}
.nav-links a:hover {
    color: var(--primary-hover);
}
.nav-links a.active {
    font-weight: 700;
    text-decoration: underline;
}
.nav-links a.logout {
    color: #dc2626;
}

/* 副本提示横条 */
.tenant-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* 卡片通用 */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

/* 栅格布局 */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1.8fr;
    gap: 20px;
    width: 100%;
}
.grid-layout > .card {
    min-width: 0;
}

/* 表单输入与按钮 */
.form-group, .form-row {
    margin-bottom: 14px;
}
.form-group label, .form-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: #fff;
    -webkit-appearance: none;
    transition: border-color 0.2s ease;
}
.form-input:focus {
    border-color: var(--primary);
}

.btn, .btn-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    height: 42px;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn:hover, .btn-submit:hover {
    background: var(--primary-hover);
}
.btn:disabled, .btn-submit:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed !important;
}

/* 快捷记账行 */
.quick-entry-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.5fr auto;
    gap: 14px;
    align-items: flex-end;
}
.quick-entry-grid .form-row {
    margin-bottom: 0;
}

/* 提示通知栏 */
.toast {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 18px;
}
.toast-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.toast-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
}

/* 核心修复：表格与双向触控滑动 */
.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible; /* 允许竖向手势向上冒泡，不截断上下滑动 */
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    display: block;
    touch-action: pan-x pan-y; /* 关键：允许横滑表格同时绝不阻止屏幕上下滑动 */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 520px;
}
th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
td {
    padding: 12px 14px;
    font-size: 14px;
    border-bottom: 1px solid #f1f5f9;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background-color: #f8fafc;
}

/* 字段排版 */
.amount-font {
    font-family: "SF Pro Text", monospace;
    font-weight: 700;
}
.color-pos {
    color: var(--pos-color);
}
.color-neg {
    color: var(--neg-color);
}
.no-font {
    font-family: "SF Pro Text", monospace;
    font-weight: 700;
    color: #64748b;
}

.cust-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.cust-link:hover {
    text-decoration: underline;
}
.tag-short {
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.tag-current {
    background: #eff6ff;
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    display: inline-block;
}
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.badge-active {
    background: #ecfdf5;
    color: #065f46;
}
.badge-disabled {
    background: #fef2f2;
    color: #dc2626;
}

/* 操作链接与按钮 */
.btn-action {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 6px;
    text-decoration: none;
}
.btn-action.btn-edit {
    color: var(--primary);
}
.btn-action.btn-edit:hover {
    text-decoration: underline;
}
.btn-action.btn-delete {
    color: var(--danger);
}
.btn-action.btn-delete:hover {
    text-decoration: underline;
}

.btn-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
    margin-right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.btn-link:hover {
    text-decoration: underline;
}
.btn-link-danger {
    color: #dc2626;
}

/* 分页控件 */
.section-header {
    margin-top: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.pagination-links {
    display: flex;
    align-items: center;
    gap: 6px;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
}
.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}
.page-btn.disabled {
    color: #cbd5e1;
    pointer-events: none;
    background: #f8fafc;
}
.per-page-select {
    height: 32px;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

/* 模态弹窗 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 16px;
}
.modal-btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 客户独立明细卡片 */
.profile-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    flex-wrap: wrap;
    gap: 14px;
}
.profile-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.stat-num {
    font-size: 26px;
}

/* 居中页脚 */
.main-footer {
    width: 100%;
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
    padding: 24px 0 12px 0;
    margin-top: 30px;
    border-top: 1px solid #f1f5f9;
}

/* 移动端深度适配 */
@media (max-width: 768px) {
    body { padding: 10px; }
    .navbar h1 { font-size: 18px; }
    .grid-layout { grid-template-columns: 100%; gap: 14px; }
    .card { padding: 14px; }
    .quick-entry-grid { grid-template-columns: 1fr; gap: 10px; }
    .pagination-bar { flex-direction: column; align-items: stretch; text-align: center; }
    .pagination-links { justify-content: center; }
    .modal-btn-group { flex-direction: column-reverse; }
    .modal-btn-group button { width: 100% !important; margin: 0 !important; }
}