/* Hộp "Đổi dịch vụ" dùng chung (khách + admin). Không phụ thuộc CSS của từng trang. */
.cs-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    box-sizing: border-box;
    width: min(880px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: none;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    color: #2c2a26;
    background: #fff;
    font-family: inherit;
    overflow: hidden;
}

.cs-dialog[open] {
    display: flex;
    flex-direction: column;
}

.cs-dialog::backdrop { background: rgba(20, 18, 15, 0.55); }
.cs-dialog :is(button,input,select,h2) { font-family: inherit; }
.cs-header, .cs-selected, .cs-search, .cs-footer { flex-shrink: 0; }

.cs-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px 10px;
    border-bottom: 1px solid #efe9df;
}

.cs-header h2 { margin: 0; font-size: 20px; }
.cs-header p { margin: 4px 0 0; color: #7a7266; font-size: 13px; }

.cs-close {
    color: inherit;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #f4f0e8;
    font-size: 22px;
    cursor: pointer;
    flex-shrink: 0;
}

.cs-selected {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 20px 0;
}

.cs-selected-label { font-size: 13px; color: #7a7266; }
.cs-warn { color: #b42318; }

.cs-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid #d8c9a3;
    border-radius: 999px;
    background: #fbf7ee;
    color: #5b4a24;
    font-size: 13px;
    cursor: pointer;
}

.cs-chip-new { background: #edf7f0; border-color: #a9d3b6; color: #23583a; }
.cs-chip span { font-size: 15px; line-height: 1; }

.cs-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 20px 8px;
}

.cs-search-icon {
    position: absolute;
    left: 14px;
    top: 23px;
    transform: translateY(-50%);
    font-size: 18px;
    color: #9a9182;
}

.cs-search input {
    flex: 1;
    min-width: 0;
    color: inherit;
    min-height: 46px;
    padding: 0 14px 0 40px;
    border: 1.5px solid #e2d9c8;
    border-radius: 12px;
    font-size: 15px;
    background: #fff;
}

.cs-search input:focus {
    outline: none;
    border-color: #C9A961;
    box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.25);
}

.cs-search small { color: #6b6257; white-space: nowrap; font-size: 12px; }

.cs-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    padding: 4px 20px 14px;
    min-height: 160px;
    align-content: start;
    grid-auto-rows: max-content;
}

.cs-card {
    border: 1.5px solid #ece5d8;
    border-radius: 12px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.cs-card.is-on {
    border-color: #C9A961;
    box-shadow: 0 0 0 2px rgba(201, 169, 97, 0.2);
    background: #fffcf4;
}

.cs-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.cs-card-main:focus-visible { outline: 3px solid #C9A961; outline-offset: -3px; border-radius: 12px; }

.cs-card-main img {
    width: 76px;
    height: 76px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f4f0e8;
}

.cs-card-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.cs-card-body strong { font-size: 14px; line-height: 1.3; }
.cs-card-meta { font-size: 13px; color: #7a7266; }

.cs-tag {
    align-self: flex-start;
    padding: 1px 8px;
    border-radius: 999px;
    background: #f1ece2;
    color: #6b5a30;
    font-size: 11px;
    font-weight: 600;
}

.cs-tag-pkg { background: #e8f4ec; color: #23583a; }

.cs-check {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid #d8c9a3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    color: #C9A961;
}

.cs-card.is-on .cs-check { background: #C9A961; border-color: #C9A961; color: #fff; }

.cs-pay {
    width: calc(100% - 20px);
    min-height: 40px;
    margin: 0 10px 10px;
    border: 1px solid #d8c9a3;
    border-radius: 8px;
    padding: 0 8px;
    background: #fff;
}

.cs-empty { grid-column: 1 / -1; text-align: center; color: #6b6257; padding: 30px 0; }

.cs-footer {
    border-top: 1px solid #efe9df;
    padding: 12px 20px 16px;
    background: #fdfbf7;
}

.cs-compare {
    display: grid;
    grid-template-columns: 1fr auto 1fr 1.3fr;
    align-items: center;
    gap: 10px;
}

.cs-col, .cs-diff { display: flex; flex-direction: column; gap: 2px; }
.cs-col span, .cs-diff span { font-size: 12px; color: #6b6257; text-transform: uppercase; letter-spacing: 0.04em; }
.cs-col strong, .cs-diff strong { font-size: 18px; }
.cs-col small, .cs-diff small { font-size: 12px; color: #7a7266; }
.cs-arrow { font-size: 20px; color: #C9A961; }
.cs-diff { padding: 8px 12px; border-radius: 10px; background: #f4f0e8; }
.cs-diff.up { background: #fff4e5; }
.cs-diff.up strong { color: #b54708; }
.cs-diff.down { background: #ecf7ef; }
.cs-diff.down strong { color: #23583a; }

.cs-message { min-height: 1.2em; margin: 6px 0 0; color: #b42318; font-size: 13px; }

.cs-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.cs-btn {
    min-height: 44px;
    padding: 0 22px;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.cs-btn-ghost { border: 1.5px solid #d8c9a3; background: #fff; color: #5b4a24; }
.cs-btn-primary { border: none; background: var(--customer-primary, #3d5a45); color: #fff; }
.cs-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
    .cs-dialog { width: 100%; max-width: 100%; max-height: 100vh; height: 100vh; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
    .cs-grid { grid-template-columns: 1fr; padding: 4px 12px 12px; }
    .cs-header, .cs-footer { padding-left: 12px; padding-right: 12px; }
    .cs-search { margin: 10px 12px 6px; flex-wrap: wrap; }
    .cs-search small { width: 100%; text-align: right; }
    .cs-selected { padding: 8px 12px 0; }
    .cs-compare { grid-template-columns: 1fr auto 1fr; }
    .cs-diff { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
    .cs-actions .cs-btn-primary { flex: 1; }
}

body.dark-theme .cs-dialog { background: #1f1d1a; color: #f1ece2; }
body.dark-theme .cs-card, body.dark-theme .cs-search input, body.dark-theme .cs-pay { background: #2a2723; color: #f1ece2; border-color: #4a4337; }
body.dark-theme .cs-footer { background: #24211d; }
