: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,
body {
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    background: #f3f5f7;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

.workspace {
    width: min(1440px, calc(100% - 48px));
    margin: 24px auto 40px;
    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: 22px 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 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
    line-height: 28px;
}

.result-count {
    color: #66717f;
    font-size: 13px;
    line-height: 20px;
}

.member-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field > span {
    color: #4a5360;
    font-size: 13px;
    font-weight: 600;
    line-height: 20px;
}

.field input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #b9c1cc;
    border-radius: 5px;
    color: #20242b;
    background: #ffffff;
    outline: none;
}

.field input:focus {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

.field input[readonly] {
    color: #29313a;
    background: #f6f8fa;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.project-row {
    display: grid;
    grid-template-columns: 24px minmax(80px, 1fr) 72px minmax(88px, 1.6fr) 104px;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #cdd3db;
    border-radius: 5px;
    background: #ffffff;
    cursor: pointer;
    user-select: none;
}

.project-row:hover {
    border-color: #7ba9cd;
    background: #f7fbfe;
}

.project-row.is-selected {
    border-color: #1769aa;
    background: #eaf4fb;
    box-shadow: inset 0 0 0 1px #1769aa;
}

.project-check {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #1769aa;
}

.project-row-name {
    color: #20242b;
    font-size: 15px;
    font-weight: 600;
}

.project-row-unit {
    color: #53606d;
    font-size: 13px;
}

.project-count {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #b9c1cc;
    border-radius: 5px;
    color: #20242b;
    background: #ffffff;
    text-align: center;
    outline: none;
}

.project-count:focus {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

.project-row-amount {
    color: #12613e;
    font-size: 15px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.amount-control {
    display: inline-grid;
    grid-template-columns: 24px 200px 32px;
    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 {
    min-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 {
    outline: 3px solid rgba(23, 105, 170, 0.22);
    outline-offset: 2px;
}

.save-button:disabled {
    border-color: #c4cad1;
    color: #7a8592;
    background: #e3e7eb;
}

@media (max-width: 720px) {
    .member-form {
        grid-template-columns: 1fr;
    }

    .project-list {
        grid-template-columns: 1fr;
    }

    .project-row {
        grid-template-columns: 24px 1fr auto;
        grid-template-areas:
            "check name unit"
            "check count amount";
        row-gap: 8px;
    }

    .project-check {
        grid-area: check;
    }

    .project-row-name {
        grid-area: name;
    }

    .project-row-unit {
        grid-area: unit;
    }

    .project-count {
        grid-area: count;
    }

    .project-row-amount {
        grid-area: amount;
    }
}

/* 右侧会员详情侧边栏 */
.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 (min-width: 1000px) and (max-width: 1399px) {
    .project-list {
        grid-template-columns: 1fr;
    }

    .project-row {
        grid-template-columns: 24px minmax(80px, 1fr) 72px minmax(88px, 128px) 104px;
    }
}

/* 窄屏：侧边栏下移 */
@media (max-width: 999px) {
    .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;
    }
}