:root {
    color-scheme: light;
    font-family:
        "Microsoft YaHei",
        "PingFang SC",
        "Segoe UI",
        Arial,
        sans-serif;
    color: #20242b;
    background: #f3f5f7;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 720px;
    min-height: 100%;
    background: #f3f5f7;
}

body {
    min-height: 100vh;
    margin: 0;
    background: #f3f5f7;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

.app-header {
    min-height: 68px;
    border-bottom: 1px solid #d9dee5;
    background: #ffffff;
}

.app-header__inner {
    display: flex;
    align-items: center;
    width: min(1120px, calc(100% - 48px));
    min-height: 68px;
    margin: 0 auto;
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: 0;
}

.workspace {
    width: min(1440px, calc(100% - 48px));
    margin: 28px auto 48px;
    border: 1px solid #d9dee5;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(32, 36, 43, 0.06);
}

.workspace > .message-bar:first-child {
    border-radius: 5px 5px 0 0;
}

.message-bar {
    min-height: 44px;
    padding: 11px 24px;
    border-bottom: 1px solid transparent;
    font-size: 14px;
    line-height: 22px;
}

.message-bar.is-success {
    border-color: #a9d8c3;
    color: #12613e;
    background: #eaf7f1;
}

.message-bar.is-error {
    border-color: #efb3ad;
    color: #9f251c;
    background: #fff0ee;
}

.message-bar.is-info {
    border-color: #b6d4ed;
    color: #15578a;
    background: #edf6fd;
}

.workspace-section {
    padding: 24px;
    border-bottom: 1px solid #e4e8ed;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    margin-bottom: 16px;
    gap: 16px;
}

.section-heading h2,
.amount-section h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
    line-height: 28px;
    letter-spacing: 0;
}

.result-count {
    flex: 0 0 auto;
    color: #66717f;
    font-size: 13px;
    line-height: 20px;
}

.member-panel-grid {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
}

.member-panel-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.member-panel-right {
    display: flex;
    min-width: 0;
}

.member-panel-right .member-table-wrap {
    flex: 1;
}

.new-member-block h3 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 650;
    color: #4e5865;
    line-height: 22px;
}

.new-member-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.new-member-form label {
    color: #6f7a87;
    font-size: 12px;
    line-height: 18px;
}

.new-member-form input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #b9c1cc;
    border-radius: 5px;
    color: #20242b;
    background: #ffffff;
    font-size: 14px;
    outline: none;
}

.new-member-form input:focus {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

.new-member-form input::placeholder {
    color: #8993a0;
}

.search-form {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.search-form > label {
    color: #3e4651;
    font-size: 14px;
    font-weight: 600;
}

.search-control {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) 88px;
    gap: 5px;
    height: 40px;
}

.search-control input {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #b9c1cc;
    border-radius: 5px 0 0 5px;
    color: #20242b;
    background: #ffffff;
    outline: none;
}

.search-control input + input {
    border-radius: 0;
}

.search-control input::placeholder {
    color: #8993a0;
}

.search-control input:focus {
    position: relative;
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

.search-control button {
    height: 40px;
    border: 1px solid #1769aa;
    border-radius: 0 5px 5px 0;
    color: #ffffff;
    background: #1769aa;
    font-weight: 600;
}

.search-control button:hover:not(:disabled) {
    border-color: #11578f;
    background: #11578f;
}

.search-control button:disabled {
    border-color: #8caec9;
    background: #8caec9;
}

.member-table-wrap {
    min-height: 170px;
    overflow: hidden;
    border: 1px solid #d9dee5;
    border-radius: 5px;
}

.member-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.member-table th,
.member-table td {
    height: 44px;
    padding: 9px 14px;
    overflow: hidden;
    border-bottom: 1px solid #e4e8ed;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-table th {
    color: #4e5865;
    background: #f6f8fa;
    font-size: 13px;
    font-weight: 650;
}

.member-table td {
    color: #29313a;
    font-size: 14px;
}

.member-table th:nth-child(1),
.member-table td:nth-child(1) {
    width: 22%;
}

.member-table th:nth-child(2),
.member-table td:nth-child(2) {
    width: 18%;
}

.member-table th:nth-child(4),
.member-table td:nth-child(4) {
    width: 14%;
    text-align: center;
}

.member-table tbody tr {
    cursor: pointer;
    outline: none;
}

.member-table tbody tr:hover {
    background: #f0f7fc;
}

.member-table tbody tr:focus-visible {
    box-shadow: inset 0 0 0 2px #1769aa;
}

.member-table tbody tr.is-selected {
    background: #e4f1fa;
}

.member-table tbody tr:last-child td {
    border-bottom: 0;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 124px;
    padding: 24px;
    color: #7a8592;
    font-size: 14px;
    text-align: center;
}

.member-table-wrap.has-results .empty-state {
    display: none;
}

.select-status {
    color: #7a8592;
    font-size: 13px;
}

.select-status.is-selected {
    color: #12613e;
    font-weight: 600;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.project-option {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid #cdd3db;
    border-radius: 5px;
    background: #ffffff;
    cursor: pointer;
    user-select: none;
}

.project-option:hover {
    border-color: #7ba9cd;
    background: #f7fbfe;
}

.project-option.is-selected {
    border-color: #1769aa;
    background: #eaf4fb;
    box-shadow: inset 0 0 0 1px #1769aa;
}

.project-checkbox {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #1769aa;
}

.project-name {
    min-width: 0;
    padding-left: 10px;
    color: #20242b;
    font-size: 15px;
    font-weight: 600;
}

.project-price {
    color: #53606d;
    font-size: 14px;
}

.amount-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.amount-section p {
    margin: 4px 0 0;
    color: #77818e;
    font-size: 13px;
    line-height: 20px;
}

.amount-control {
    display: grid;
    grid-template-columns: 38px 180px 42px;
    align-items: center;
    height: 44px;
    overflow: hidden;
    border: 1px solid #b9c1cc;
    border-radius: 5px;
    background: #ffffff;
}

.amount-control:focus-within {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

.amount-control > span {
    color: #5d6875;
    font-size: 14px;
    text-align: center;
}

.amount-control input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 0;
    border-right: 1px solid #d9dee5;
    border-left: 1px solid #d9dee5;
    color: #20242b;
    background: #ffffff;
    font-size: 20px;
    font-weight: 650;
    text-align: right;
    outline: none;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 24px;
    background: #f8fafb;
}

.save-message {
    flex: 0 0 auto;
    min-width: 0;
    color: #53606d;
    font-size: 14px;
    font-weight: 650;
    line-height: 22px;
}

.save-message.is-success {
    color: #12613e;
}

.save-message.is-error {
    color: #9f251c;
}

.save-message.is-info {
    color: #15578a;
}

.save-button {
    width: 156px;
    height: 42px;
    border: 1px solid #1769aa;
    border-radius: 5px;
    color: #ffffff;
    background: #1769aa;
    font-weight: 650;
}

.save-button:hover:not(:disabled) {
    border-color: #11578f;
    background: #11578f;
}

.save-button:focus-visible,
.search-control button:focus-visible {
    outline: 3px solid rgba(23, 105, 170, 0.22);
    outline-offset: 2px;
}

.save-button:disabled {
    border-color: #c4cad1;
    color: #7a8592;
    background: #e3e7eb;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(20, 24, 30, 0.5);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 16px 40px rgba(20, 24, 30, 0.24);
}

.modal h2 {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 650;
    line-height: 26px;
}

.confirm-info {
    display: grid;
    gap: 8px;
    margin: 0 0 22px;
    padding: 16px;
    border: 1px solid #e4e8ed;
    border-radius: 5px;
    background: #f8fafb;
}

.confirm-info > div {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.confirm-info dt {
    color: #6f7a87;
    font-size: 13px;
    line-height: 20px;
}

.confirm-info dd {
    margin: 0;
    color: #20242b;
    font-size: 15px;
    font-weight: 650;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-cancel,
.modal-confirm {
    min-width: 88px;
    height: 40px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
}

.modal-cancel {
    border: 1px solid #b9c1cc;
    color: #3e4651;
    background: #ffffff;
}

.modal-cancel:hover {
    border-color: #8f9aa7;
    background: #f6f8fa;
}

.modal-confirm {
    border: 1px solid #1769aa;
    color: #ffffff;
    background: #1769aa;
}

.modal-confirm:hover {
    border-color: #11578f;
    background: #11578f;
}

@media (max-width: 820px) {
    html {
        min-width: 0;
    }

    .app-header__inner,
    .workspace {
        width: calc(100% - 28px);
    }

    .workspace {
        margin-top: 16px;
    }

    .member-panel-grid {
        grid-template-columns: 1fr;
    }

    .search-form {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .member-table-wrap {
        overflow-x: auto;
    }

    .member-table {
        min-width: 680px;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .amount-section {
        align-items: flex-start;
        flex-direction: column;
    }

    .amount-control {
        width: 100%;
        grid-template-columns: 38px minmax(0, 1fr) 42px;
    }
}

/* 右侧会员详情侧边栏 */
.workspace-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    column-gap: 28px;
    align-items: stretch;
}

.workspace-main {
    min-width: 0;
}

.member-sidebar {
    min-width: 0;
    border-left: 1px solid #e4e8ed;
    background: #f9fbfc;
}

.member-sidebar-inner {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

.sidebar-heading h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
    line-height: 28px;
}

.sidebar-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
    border: 1px dashed #ccd4dd;
    border-radius: 6px;
    color: #7a8592;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
}

.sidebar-empty[hidden],
.sidebar-content[hidden],
.sidebar-table-empty[hidden] {
    display: none;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.sidebar-member {
    margin: 0;
    color: #53606d;
    font-size: 13px;
    line-height: 20px;
    word-break: break-all;
}

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-stats > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid #e4e8ed;
    border-radius: 5px;
    background: #ffffff;
}

.sidebar-stats span {
    flex: 0 0 auto;
    color: #6f7a87;
    font-size: 12px;
    line-height: 18px;
}

.sidebar-stats strong {
    color: #20242b;
    font-size: 18px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.sidebar-stats strong.is-remain {
    color: #12613e;
}

.sidebar-block h3 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 650;
    line-height: 22px;
    color: #4e5865;
}

.sidebar-table-wrap {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e4e8ed;
    border-radius: 5px;
    background: #ffffff;
}

.sidebar-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.sidebar-table th,
.sidebar-table td {
    height: 36px;
    padding: 6px 10px;
    overflow: hidden;
    border-bottom: 1px solid #eef1f4;
    color: #29313a;
    font-size: 13px;
    line-height: 20px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #4e5865;
    background: #f2f5f8;
    font-weight: 650;
}

.sidebar-table tbody tr:last-child td {
    border-bottom: 0;
}

.sidebar-table td.amount-column {
    color: #20242b;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    text-align: right;
}

.sidebar-project-table th:nth-child(1),
.sidebar-project-table td:nth-child(1) {
    width: 40%;
}

.sidebar-project-table th:nth-child(2),
.sidebar-project-table td:nth-child(2),
.sidebar-project-table th:nth-child(3),
.sidebar-project-table td:nth-child(3) {
    width: 30%;
    text-align: right;
}

.sidebar-detail-table th,
.sidebar-detail-table td {
    padding: 6px 8px;
}

.sidebar-detail-table th:nth-child(1),
.sidebar-detail-table td:nth-child(1) {
    width: 34%;
}

.sidebar-detail-table th:nth-child(2),
.sidebar-detail-table td:nth-child(2) {
    width: 22%;
}

.sidebar-detail-table th:nth-child(3),
.sidebar-detail-table td:nth-child(3) {
    width: 20%;
}

.sidebar-detail-table th:nth-child(4),
.sidebar-detail-table td:nth-child(4) {
    width: 24%;
}

.sidebar-detail-table tr.is-refund td {
    color: #b06a2c;
    background: #fdf6ec;
}

.sidebar-detail-table td.memo-column {
    color: #8a6d3b;
    white-space: nowrap;
}

.sidebar-table-empty {
    padding: 18px 12px;
    color: #7a8592;
    font-size: 13px;
    line-height: 20px;
    text-align: center;
}

@media (max-width: 1120px) {
    .workspace-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .member-sidebar {
        border-top: 1px solid #e4e8ed;
        border-left: 0;
    }

    .member-sidebar-inner {
        position: static;
    }

    .sidebar-table-wrap {
        max-height: none;
    }
}
