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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 32px;
    padding: 24px;
    /* overflow-x: auto;  ← 已删除，滚动由内部的 .table-wrapper 负责 */
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.12);
}

.main-title {
    text-align: center;
    margin-bottom: 30px;
}
.main-title h1 {
    font-size: 28px;
    color: #0f3b4f;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    background: #2c7da0;
    color: white;
    padding: 8px 16px;
    border-radius: 40px;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
    font-size: 14px;
}
.btn-logout {
    background: #6c9a9f;
}
.btn-cancel {
    background: #cbd5e1;
    color: #1e293b;
}

.table-wrapper {
    overflow-x: auto;
    position: relative;
    margin-top: 16px;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
}

.data-table th,
.data-table td {
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    background-color: white;
}

.data-table th {
    background-color: #f8fafc;
    font-weight: 600;
    font-size: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

/* 左侧固定列：客户编号 */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    position: sticky;
    left: 0;
    background-color: white;
    z-index: 30;
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
    min-width: 100px;
    width: 100px;
}

/* 左侧固定列：客户简称 */
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    position: sticky;
    left: 100px;
    background-color: white;
    z-index: 30;
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
    min-width: 100px;
    width: 100px;
}

/* 右侧固定列（操作列） */
.data-table > thead > tr > th:last-child,
.data-table > tbody > tr > td:last-child {
    position: sticky !important;
    right: 0 !important;
    background-color: white !important;
    z-index: 31 !important;
    box-shadow: -2px 0 5px -2px rgba(0,0,0,0.1) !important;
    transform: translateZ(0);
}

/* 表头操作列背景 */
.data-table > thead > tr > th:last-child {
    background-color: #f8fafc !important;
}

.flash {
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 8px;
}
.flash.success {
    background: #e6f7e6;
    color: #2e7d32;
}
.flash.error {
    background: #ffe6e6;
    color: #c62828;
}

form div {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
}
form div label {
    width: 130px;
    font-weight: 500;
    flex-shrink: 0;
}
form div input,
form div select,
form div textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2c7da0, #1e5a74);
}
.login-card {
    background: white;
    padding: 40px;
    border-radius: 28px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #cbd5e1;
    border-radius: 40px;
}
.login-card button {
    width: 100%;
    background: #2c7da0;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 40px;
    cursor: pointer;
}
.error {
    color: #e53e3e;
    margin-top: 12px;
}

.form-card {
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border-radius: 28px;
    padding: 30px 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.form-card h2 {
    font-size: 24px;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}
.form-section {
    margin-bottom: 28px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 20px 24px;
    background: #fefefe;
}
.form-section legend {
    font-weight: 600;
    font-size: 18px;
    padding: 0 12px;
    width: auto;
    color: #2c7da0;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 16px;
}
.form-group {
    flex: 1;
    min-width: 200px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 14px;
}
.form-buttons {
    margin-top: 28px;
    text-align: center;
    display: flex;
    gap: 16px;
    justify-content: center;
}

@media (max-width: 768px) {
    .form-card {
        padding: 20px;
    }
    .form-row {
        gap: 12px;
    }
    .form-group {
        min-width: 100%;
    }
    .data-table th,
    .data-table td {
        padding: 6px 8px;
    }
    .data-table td {
        font-size: 14px;
    }
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* 打印样式 */
/* 打印样式 - 所有页面统一边距 */
@media print {
    /* 对每一页都生效的边距 */
    @page {
        size: A4;
        margin: 2cm 1.5cm 1.5cm 1.5cm;
    }

    /* 强制 body 边距（兼容不支持 @page 的浏览器） */
    body {
        margin: 2cm 1.5cm 1.5cm 1.5cm !important;
        padding: 0 !important;
        background: white;
        font-size: 12pt;
    }

    /* 隐藏不需要打印的元素 */
    .no-print,
    .action-bar,
    .btn,
    .btn-logout,
    .form-buttons,
    .button-group,
    .actions a,
    .no-print * {
        display: none !important;
    }

    /* 容器重置 */
    .container,
    .detail-card,
    .form-card {
        max-width: 100%;
        margin: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    /* 表格打印样式 */
    .data-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 11pt;
    }
    .data-table th,
    .data-table td {
        border: 1px solid #aaa;
        padding: 6px 8px;
        text-align: left;
        vertical-align: top;
        white-space: normal;
        word-break: break-word;
    }
    .data-table th {
        background: #f0f0f0;
        font-weight: bold;
    }
    /* 移除固定列效果，避免打印异常 */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1),
    .data-table th:nth-child(2),
    .data-table td:nth-child(2),
    .data-table th:last-child,
    .data-table td:last-child {
        position: static;
        box-shadow: none;
    }

    /* 详情页区块样式 */
    .section {
        margin-bottom: 20px;
        border: 1px solid #ccc;
        border-radius: 0;
        padding: 12px;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .section-title {
        font-weight: bold !important;
        font-size: 14pt;
        margin-bottom: 12px;
        border-bottom: 1px solid #aaa;
        padding-bottom: 4px;
    }
    .row {
        display: flex;
        margin-bottom: 8px;
    }
    .label {
        width: 140px;
        font-weight: 600;
    }
    .value {
        flex: 1;
    }

    /* 表格行尽量不跨页 */
    .data-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .data-table thead {
        display: table-header-group;
    }

    h2, .main-title h1 {
        font-size: 18pt;
        margin-bottom: 16px;
        text-align: center;
    }
    .flash {
        display: none;
    }
}