* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, "Microsoft YaHei", sans-serif; color: #243447; background: #f4f6f8; }
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #173b65; }
.login-card { width: 390px; background: #fff; padding: 38px; border-radius: 12px; box-shadow: 0 16px 45px rgba(0,0,0,.25); }
.brand { color: #bb8a2e; font-weight: bold; letter-spacing: 2px; }
.login-card h1 { margin: 8px 0 2px; color: #173b65; }
.company { margin: 0 0 28px; color: #6b7785; font-size: 13px; }
label { display: block; margin: 15px 0 6px; font-weight: bold; }
input { width: 100%; padding: 12px; border: 1px solid #ccd3da; border-radius: 6px; }
button { width: 100%; margin-top: 22px; padding: 12px; border: 0; border-radius: 6px; color: #fff; background: #173b65; cursor: pointer; }
.alert { padding: 11px; border-radius: 6px; color: #a62020; background: #fdeaea; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; color: #fff; background: #173b65; }
.topbar span { margin-left: 15px; color: #c9d5e1; font-size: 13px; }
.user-area { display: flex; align-items: center; gap: 15px; }
.user-area form { margin: 0; }
.logout-button { width: auto; margin: 0; padding: 8px 14px; background: #bb8a2e; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 66px); }
aside { padding: 20px 12px; background: #fff; border-right: 1px solid #e1e5e9; }
aside a { display: block; padding: 13px 16px; color: #33475b; text-decoration: none; border-radius: 6px; }
aside a.active { color: #fff; background: #173b65; }
main { padding: 30px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 18px; margin-top: 25px; }
.card { padding: 25px; background: #fff; border-radius: 9px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.card strong { display: block; color: #173b65; font-size: 30px; }
.card span { color: #687785; }
@media (max-width: 800px) {
    .layout { grid-template-columns: 1fr; }
    aside { display: none; }
    .cards { grid-template-columns: repeat(2, 1fr); }
}
.top-link { color: #fff; text-decoration: none; }
.page-heading { display: flex; justify-content: space-between; align-items: center; }
.primary-link { padding: 11px 18px; color: #fff; background: #173b65; border-radius: 6px; text-decoration: none; }
.table-box, .form-box { margin-top: 22px; padding: 24px; background: #fff; border-radius: 9px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px; text-align: left; border-bottom: 1px solid #e5e8eb; }
th { color: #526170; background: #f6f8fa; }
.empty { padding: 35px; text-align: center; color: #7d8994; }
.success-message { margin-top: 15px; padding: 12px; color: #18763b; background: #e8f6ed; border-radius: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
textarea { width: 100%; min-height: 80px; padding: 12px; border: 1px solid #ccd3da; border-radius: 6px; resize: vertical; }
.form-box button { max-width: 220px; }

select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccd3da;
    border-radius: 6px;
    background: #fff;
}

.sales-items {
    overflow-x: auto;
}
.sales-items table {
    min-width: 1250px;
}
.sales-items input {
    min-width: 105px;
    padding: 8px;
}
.line-total {
    min-width: 100px;
    text-align: right;
}
.totals-box {
    margin-bottom: 40px;
}
.total-display {
    margin: 22px 0;
    padding: 18px;
    background: #f1f6fb;
    font-size: 18px;
    line-height: 1.8;
}

.search-box {
    display: grid;
    grid-template-columns: 2fr repeat(6, 1fr);
    gap: 12px;
    margin-top: 22px;
    padding: 18px;
    background: #fff;
    border-radius: 9px;
}
.search-box label {
    font-size: 13px;
}
.search-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}
.search-actions button {
    width: auto;
    margin: 0;
    padding: 12px 20px;
}
.search-actions a {
    padding: 11px;
    color: #526170;
}
@media (max-width: 1100px) {
    .search-box {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* JCP-CUSTOMER-COMPACT-V1 */
.customer-page {
    height: calc(100vh - 66px);
    padding: 12px 24px;
    overflow: hidden;
}

.customer-toolbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 8px 0 10px;
    background: #f4f6f8;
}

.customer-toolbar .page-heading {
    min-height: 48px;
}

.customer-toolbar .page-heading h1 {
    margin: 0 0 4px;
    font-size: 25px;
}

.customer-toolbar .page-heading p {
    margin: 0;
    font-size: 13px;
}

.customer-toolbar .primary-link {
    padding: 9px 15px;
}

.customer-toolbar .search-box {
    display: grid;
    grid-template-columns: 360px 180px auto;
    width: max-content;
    max-width: 100%;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
}

.customer-toolbar .search-box label {
    margin: 0 0 4px;
}

.customer-toolbar .search-box input,
.customer-toolbar .search-box select {
    height: 36px;
    padding: 7px 10px;
}

.customer-toolbar .search-actions button {
    height: 36px;
    padding: 7px 18px;
}

.customer-toolbar .search-actions a {
    padding: 8px 6px;
}

.customer-table-box {
    height: calc(100vh - 235px);
    margin-top: 8px;
    padding: 12px 16px;
    overflow: auto;
}

.customer-table-box thead th {
    position: sticky;
    top: 0;
    z-index: 20;
}

.customer-table-box th,
.customer-table-box td {
    padding: 10px 12px;
}

@media (max-width: 800px) {
    .customer-page {
        padding: 10px;
    }

    .customer-toolbar .search-box {
        width: 100%;
        grid-template-columns: 1fr 150px auto;
    }
}
/* JCP-CUSTOMER-FIXED-V2 */
body.customer-body {
    height: 100vh !important;
    overflow: hidden !important;
}

.customer-body .topbar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.customer-body main.customer-page {
    height: 100vh !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.customer-body .customer-toolbar {
    position: fixed !important;
    top: 66px !important;
    left: 0;
    right: 0;
    z-index: 900;
    height: 139px;
    padding: 10px 24px !important;
    background: #f4f6f8 !important;
    border-bottom: 1px solid #dde3e8;
}

.customer-body .customer-toolbar .page-heading {
    height: 48px;
    min-height: 48px !important;
}

.customer-body .customer-toolbar h1 {
    margin: 0 0 3px !important;
    font-size: 24px !important;
}

.customer-body .customer-toolbar p {
    margin: 0 !important;
    font-size: 13px;
}

.customer-body .customer-toolbar .primary-link {
    padding: 8px 14px !important;
}

.customer-body .customer-toolbar .search-box {
    display: grid !important;
    grid-template-columns: 340px 180px auto !important;
    width: 700px !important;
    max-width: calc(100vw - 48px) !important;
    gap: 10px !important;
    margin: 7px 0 0 !important;
    padding: 8px 12px !important;
    border-radius: 7px;
}

.customer-body .customer-toolbar .search-box label {
    margin: 0 0 3px !important;
    font-size: 12px;
}

.customer-body .customer-toolbar input,
.customer-body .customer-toolbar select {
    height: 34px !important;
    padding: 6px 9px !important;
}

.customer-body .customer-toolbar .search-actions button {
    height: 34px !important;
    margin: 0 !important;
    padding: 6px 17px !important;
}

.customer-body .customer-toolbar .search-actions a {
    padding: 7px !important;
}

.customer-body .customer-table-box {
    position: fixed !important;
    top: 213px !important;
    bottom: 10px !important;
    left: 24px !important;
    right: 24px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 16px !important;
    overflow-x: auto !important;
    overflow-y: scroll !important;
}

.customer-body .customer-table-box thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 30;
}

.customer-body .customer-table-box th,
.customer-body .customer-table-box td {
    padding: 9px 12px !important;
}

@media (max-width: 800px) {
    .customer-body .customer-toolbar {
        padding: 8px 10px !important;
    }

    .customer-body .customer-toolbar .search-box {
        width: 100% !important;
        grid-template-columns: 1fr 130px auto !important;
        max-width: 100% !important;
    }

    .customer-body .customer-table-box {
        left: 10px !important;
        right: 10px !important;
    }
}
/* JCP-CUSTOMER-DETAIL-FIXED-V3 */
body.customer-detail-body {
    height: 100vh;
    overflow: hidden;
}

.customer-detail-body .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.customer-detail-page {
    height: 100vh;
    padding: 0 !important;
    overflow: hidden;
}

.customer-detail-fixed {
    position: fixed;
    top: 66px;
    left: 0;
    right: 0;
    z-index: 900;
    height: 210px;
    padding: 10px 24px;
    overflow: hidden;
    background: #f4f6f8;
    border-bottom: 1px solid #dce2e8;
}

.customer-detail-fixed .page-heading {
    min-height: 48px;
}

.customer-detail-fixed .page-heading h1 {
    margin: 0 0 3px;
    font-size: 25px;
    line-height: 1.2;
}

.customer-detail-fixed .page-heading p {
    margin: 0;
    font-size: 13px;
}

.customer-detail-fixed > .card {
    margin: 7px 0 0;
    padding: 9px 18px;
    border-radius: 8px;
}

.customer-detail-fixed > .card p {
    margin: 6px 0;
    line-height: 1.25;
    font-size: 13px;
}

.customer-detail-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: nowrap;
}

.customer-detail-actions form {
    display: flex;
    margin: 0;
    padding: 0;
}

.customer-detail-actions .primary-link,
.customer-detail-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 40px;
    margin: 0;
    padding: 0 16px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1;
}

.customer-detail-scroll {
    position: fixed;
    top: 276px;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 8px 24px 24px;
    overflow-x: hidden;
    overflow-y: auto;
}

.customer-detail-scroll .cards {
    margin: 0;
}

.customer-detail-scroll .card {
    margin: 8px 0;
}

@media (max-width: 800px) {
    .customer-detail-fixed {
        padding: 8px 10px;
    }

    .customer-detail-scroll {
        padding: 8px 10px 20px;
    }
}
/* JCP-CUSTOMER-LAYOUT-V4 */

/* 固定区改成一排 */
.customer-body .customer-toolbar {
    display: grid !important;
    grid-template-columns: 300px minmax(500px, 720px) 1fr !important;
    align-items: center !important;
    gap: 18px !important;
    height: 80px !important;
    padding: 8px 16px !important;
}

/* 解除原标题容器，让里面内容直接进入固定区布局 */
.customer-body .customer-toolbar .page-heading {
    display: contents !important;
}

.customer-body .customer-toolbar .page-heading > div {
    grid-column: 1;
    grid-row: 1;
}

.customer-body .customer-toolbar .page-heading h1 {
    margin: 0 0 3px !important;
    font-size: 23px !important;
    line-height: 1.1 !important;
}

.customer-body .customer-toolbar .page-heading p {
    margin: 0 !important;
    font-size: 12px !important;
    white-space: nowrap;
}

/* 搜索栏放在客户管理后面 */
.customer-body .customer-toolbar .search-box {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: grid !important;
    grid-template-columns: minmax(230px, 1fr) 170px auto !important;
    align-items: end !important;
    width: 100% !important;
    max-width: none !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 7px 10px !important;
    box-shadow: none !important;
}

.customer-body .customer-toolbar .search-box label {
    margin: 0 0 3px !important;
    font-size: 11px !important;
}

.customer-body .customer-toolbar .search-box input,
.customer-body .customer-toolbar .search-box select {
    height: 33px !important;
    padding: 5px 9px !important;
}

.customer-body .customer-toolbar .search-actions {
    height: 33px;
    align-items: center !important;
}

.customer-body .customer-toolbar .search-actions button {
    height: 33px !important;
    padding: 5px 16px !important;
}

/* 新增客户放在最右侧同一排 */
.customer-body .customer-toolbar .primary-link {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    align-self: center !important;
    padding: 9px 15px !important;
    white-space: nowrap;
}

/* 客户列表占据剩余高度 */
.customer-body .customer-table-box {
    top: 154px !important;
    bottom: 8px !important;
    left: 12px !important;
    right: 12px !important;
    padding: 0 15px 10px !important;
    overflow-x: auto !important;
    overflow-y: scroll !important;
}

/* border-collapse会影响sticky，改成分离边框 */
.customer-body .customer-table-box table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/* 整行表头锁死 */
.customer-body .customer-table-box thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
}

.customer-body .customer-table-box thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 101 !important;
    padding: 10px 12px !important;
    background: #f3f6f9 !important;
    border-bottom: 1px solid #d7dee5 !important;
    box-shadow: 0 1px 0 #d7dee5;
}

/* 只有客户资料行滚动 */
.customer-body .customer-table-box tbody td {
    padding: 9px 12px !important;
    background: #ffffff;
}

@media (max-width: 1000px) {
    .customer-body .customer-toolbar {
        grid-template-columns: 220px 1fr auto !important;
        gap: 10px !important;
    }

    .customer-body .customer-toolbar .search-box {
        grid-template-columns: 1fr 130px auto !important;
    }
}
/* JCP-CUSTOMER-CONTACT-V5 */
.customer-body .customer-table-box table {
    min-width: 1120px;
    table-layout: fixed;
}

.customer-body .customer-table-box thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 200 !important;
}

.customer-body .customer-table-box thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 201 !important;
    height: 42px;
    vertical-align: middle;
    background: #f3f6f9 !important;
}

.customer-body .customer-table-box th:nth-child(1),
.customer-body .customer-table-box td:nth-child(1) {
    width: 110px;
}

.customer-body .customer-table-box th:nth-child(2),
.customer-body .customer-table-box td:nth-child(2) {
    width: 130px;
}

.customer-body .customer-table-box th:nth-child(3),
.customer-body .customer-table-box td:nth-child(3) {
    width: 360px;
}

.customer-body .customer-table-box th:nth-child(4),
.customer-body .customer-table-box td:nth-child(4) {
    width: 150px;
}

.customer-body .customer-table-box th:nth-child(5),
.customer-body .customer-table-box td:nth-child(5),
.customer-body .customer-table-box th:nth-child(6),
.customer-body .customer-table-box td:nth-child(6) {
    width: 150px;
}

.customer-body .customer-table-box th:nth-child(7),
.customer-body .customer-table-box td:nth-child(7),
.customer-body .customer-table-box th:nth-child(8),
.customer-body .customer-table-box td:nth-child(8) {
    width: 130px;
}
/* JCP-CUSTOMER-HEADER-V6 */

/* 固定表头区域 */
.customer-body .customer-header-box {
    position: fixed;
    top: 146px;
    left: 12px;
    right: 12px;
    z-index: 850;
    height: 43px;
    padding: 0 15px;
    overflow: hidden;
    background: #ffffff;
    border-radius: 8px 8px 0 0;
}

.customer-body .customer-header-box table {
    width: 100%;
    min-width: 1120px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.customer-body .customer-header-box th {
    height: 43px;
    padding: 9px 12px;
    vertical-align: middle;
    background: #f3f6f9;
    border-bottom: 1px solid #d7dee5;
}

/* 客户资料从固定表头下方开始 */
.customer-body .customer-table-box {
    top: 189px !important;
    padding: 0 15px 10px !important;
    border-radius: 0 0 8px 8px !important;
}

.customer-body .customer-table-box table {
    width: 100%;
    min-width: 1120px;
    table-layout: fixed;
}

/* 固定表头与资料使用完全相同的列宽 */
.customer-body .customer-header-box th:nth-child(1),
.customer-body .customer-table-box td:nth-child(1) {
    width: 110px;
}

.customer-body .customer-header-box th:nth-child(2),
.customer-body .customer-table-box td:nth-child(2) {
    width: 130px;
}

.customer-body .customer-header-box th:nth-child(3),
.customer-body .customer-table-box td:nth-child(3) {
    width: 360px;
}

.customer-body .customer-header-box th:nth-child(4),
.customer-body .customer-table-box td:nth-child(4) {
    width: 150px;
}

.customer-body .customer-header-box th:nth-child(5),
.customer-body .customer-table-box td:nth-child(5) {
    width: 150px;
}

.customer-body .customer-header-box th:nth-child(6),
.customer-body .customer-table-box td:nth-child(6) {
    width: 150px;
}

.customer-body .customer-header-box th:nth-child(7),
.customer-body .customer-table-box td:nth-child(7) {
    width: 130px;
}

.customer-body .customer-header-box th:nth-child(8),
.customer-body .customer-table-box td:nth-child(8) {
    width: 130px;
}

/* 原表格不再保留滚动表头 */
.customer-body .customer-table-box thead {
    display: none !important;
}
/* R14 login fits narrow windows without changing business documents. */
@media screen and (max-width:480px){.login-body{padding:72px 16px 24px}.login-card{width:100%;max-width:390px;padding:24px}.login-body>.jcp-language{right:16px;top:18px}}
