/* ===== 基础 ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 32px 30px 40px;
    background: #f4f6f9;
    color: #2c3e50;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 18px;
}

a {
    color: #3498db;
    text-decoration: none;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

.back-link {
    margin: 0 0 18px;
}
.back-link a {
    color: #3498db;
    font-size: 14px;
    text-decoration: none;
}
.back-link a:hover {
    text-decoration: underline;
}

.entry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.entry-card {
    display: block;
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(15, 35, 70, 0.05);
    text-decoration: none;
    color: #2c3e50;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.entry-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 35, 70, 0.09);
}
.entry-card strong {
    display: block;
    font-size: 17px;
    margin-bottom: 6px;
}
.entry-card span {
    font-size: 13px;
    color: #8a94a6;
}

.top-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.top-btn {
    padding: 10px 22px;
    border: 1px solid #d9dee5;
    border-radius: 10px;
    background: #fff;
    color: #34495e;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}
.top-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

/* ===== 顶部导航 ===== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    padding: 10px 24px;
    box-shadow: 0 2px 10px rgba(15, 35, 70, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #e8ecf1;
    min-height: 52px;
}

nav a {
    color: #566071;
    font-weight: 500;
    font-size: 14px;
    padding: 7px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

nav a:hover {
    background: #ebf5fb;
    color: #3498db;
}

nav a.active {
    background: #3498db;
    color: #fff;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.35);
}

/* ===== 月份选择 ===== */
.month-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.month-selector label {
    color: #6b7688;
    font-size: 14px;
}

.month-selector select {
    padding: 8px 12px;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    min-width: 140px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.month-selector select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* ===== 加载 / 错误 ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 0;
    color: #8a94a6;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e3e8ef;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    padding: 18px 20px;
    margin: 18px 0;
    background: #fdf0ef;
    border: 1px solid #f5c6c2;
    border-radius: 10px;
    color: #c0392b;
    font-weight: 500;
}

.header-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7688;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #95a5a6;
    display: inline-block;
}

.dot.online {
    background: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2);
}

.refresh-btn {
    padding: 7px 16px;
    border: 1px solid #d9dee5;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #566071;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    border-color: #3498db;
    color: #3498db;
    background: #f4faff;
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-item {
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 2px 10px rgba(15, 35, 70, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 35, 70, 0.09);
}

.stat-label {
    font-size: 13px;
    color: #8a94a6;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

.stat-number.danger {
    color: #e74c3c;
}

.stat-number.success {
    color: #27ae60;
}

/* ===== 卡片 ===== */
.card {
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(15, 35, 70, 0.05);
    overflow: hidden;
}

.card-title {
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid #f0f2f6;
    color: #34495e;
}

.table-wrapper {
    overflow-x: auto;
    padding: 0 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #566071;
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid #e8ecf1;
    white-space: nowrap;
}

td {
    padding: 11px 16px;
    border-bottom: 1px solid #f0f2f6;
    color: #2c3e50;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: #f7fafd;
}

tbody tr:last-child td {
    border-bottom: none;
}

.text-left  { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 状态徽章 ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-paid {
    background: #e8f6ef;
    color: #1e8449;
}

.badge-over {
    background: #fef3e2;
    color: #b9770e;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border: 1px solid #d9dee5;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    color: #34495e;
    transition: all 0.2s ease;
}

.btn:hover {
    border-color: #b8c0cc;
    background: #f8fafc;
}

.btn-success {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.25);
}

.btn-success:hover {
    background: #229954;
    border-color: #229954;
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-outline {
    background: #fff;
    border-color: #d9dee5;
    color: #566071;
}

.btn-outline:hover {
    border-color: #3498db;
    color: #3498db;
}

/* ===== 客商链接 ===== */
.buyer-link {
    color: #2f6f9f;
    font-weight: 600;
    border-bottom: 1px dashed #b9d7ee;
    cursor: pointer;
    transition: color 0.15s ease;
}

.buyer-link:hover {
    color: #1f4f74;
    border-bottom-color: #1f4f74;
}

/* ===== 表单 ===== */
.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #6b7688;
    font-weight: 500;
}

.form-field input,
.form-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus,
.form-field select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* ===== 客商联想列表 ===== */
.suggest-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 35, 70, 0.12);
    margin-top: 4px;
}

.suggest-item {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.12s ease;
}

.suggest-item:hover,
.suggest-item.active {
    background: #ebf5fb;
    color: #2f6f9f;
}

/* ===== 右侧抽屉 ===== */
.side-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: none;
    justify-content: flex-end;
    align-items: stretch;
    z-index: 2000;
}

.side-box {
    background: #fff;
    width: min(640px, 92vw);
    height: 100vh;
    padding: 24px 28px;
    overflow-y: auto;
    box-shadow: -10px 0 34px rgba(15, 23, 42, 0.18);
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.side-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f2f6;
}

.side-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}

.side-close {
    border: none;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #8a94a6;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.side-close:hover {
    background: #f4f6f9;
    color: #2c3e50;
}

/* ===== 响应式 ===== */
/* ===== 平板 ≤900px ===== */
@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-item {
        padding: 14px 16px;
    }
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== 手机 ≤640px ===== */
@media (max-width: 640px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        padding: 24px 12px 24px;
    }

    h1 {
        font-size: 19px;
        margin-bottom: 14px;
    }

    nav {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 8px 12px;
        gap: 6px;
    }
    nav a {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .stat-number {
        font-size: 22px;
    }

    .card-title {
        padding: 12px 14px;
        font-size: 14px;
    }
    .table-wrapper {
        padding: 0 2px;
    }
    table {
        font-size: 12.5px;
    }
    th,
    td {
        padding: 9px 10px;
        white-space: nowrap;
    }

    .month-selector {
        flex-wrap: wrap;
        gap: 8px;
    }
    .month-selector select {
        flex: 1 1 100%;
        min-height: 40px;
        font-size: 16px;
    }
    .month-selector label {
        font-size: 14px;
    }

    .btn,
    .refresh-btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 15px;
        touch-action: manipulation;
    }

    .side-box {
        width: 100vw;
        padding: 16px;
    }
    .side-header {
        margin-bottom: 14px;
    }
    .side-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 24px;
    }

    .form-field input,
    .form-field select {
        min-height: 44px;
        font-size: 16px;
        padding: 10px 12px;
    }
    .form-field label {
        font-size: 14px;
    }

    .suggest-list {
        max-height: 160px;
    }

    .detail-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .detail-stats .stat-number {
        font-size: 18px;
    }
    .entry-grid {
        grid-template-columns: 1fr;
    }
    .entry-card {
        padding: 16px;
    }
}

/* ===== 大屏 ≥1600px ===== */
@media (min-width: 1600px) {
    body {
        padding-left: 48px;
        padding-right: 48px;
    }
    .container {
        max-width: 1440px;
    }
}
