.cm-app,
.cm-admin {
    --cm-border: #d8dee8;
    --cm-bg: #f7f9fc;
    --cm-text: #172033;
    --cm-muted: #647084;
    --cm-accent: #0d6efd;
    --cm-ok: #12845f;
    color: var(--cm-text);
}

.cm-app *,
.cm-app *::before,
.cm-app *::after,
.cm-admin *,
.cm-admin *::before,
.cm-admin *::after {
    box-sizing: border-box;
}

.cm-app {
    max-width: 1180px;
    margin: 24px auto;
    padding: 0 16px;
}

.cm-auth-grid,
.cm-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.cm-panel {
    background: #fff;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    padding: 18px;
}

.cm-panel h2,
.cm-sticker-list h3 {
    margin-top: 0;
}

.cm-panel label {
    display: grid;
    gap: 6px;
    margin: 0 0 12px;
    font-weight: 600;
}

.cm-panel input,
.cm-panel select,
.cm-panel textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--cm-border);
    border-radius: 6px;
    padding: 7px 10px;
    max-width: 100%;
}

.cm-panel textarea {
    min-height: 86px;
}

.cm-panel button,
.cm-app button {
    cursor: pointer;
}

.cm-panel button[type="submit"],
.cm-auth-grid button[type="submit"] {
    width: 100%;
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    background: var(--cm-accent);
    color: #fff;
    font-weight: 700;
}

.cm-notice {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--cm-border);
}

.cm-notice.success {
    background: #eaf7f1;
    color: #07563c;
}

.cm-notice.error {
    background: #fff1f0;
    color: #8a1f11;
}

.cm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--cm-border);
    margin-bottom: 16px;
    padding-bottom: 14px;
}

.cm-header h2,
.cm-header p {
    margin: 0;
}

.cm-header p,
.cm-stats span,
.cm-sticker span {
    color: var(--cm-muted);
}

.cm-link,
.cm-tabs a {
    text-decoration: none;
}

.cm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.cm-app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.cm-app-nav a {
    border: 1px solid var(--cm-border);
    border-radius: 6px;
    color: var(--cm-text);
    font-weight: 700;
    padding: 9px 12px;
    text-decoration: none;
}

.cm-app-nav a.active {
    background: var(--cm-accent);
    border-color: var(--cm-accent);
    color: #fff;
}

.cm-tabs a {
    border: 1px solid var(--cm-border);
    border-radius: 999px;
    color: var(--cm-text);
    padding: 8px 12px;
}

.cm-tabs a.active {
    background: var(--cm-text);
    border-color: var(--cm-text);
    color: #fff;
}

.cm-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    background: var(--cm-bg);
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 14px;
}

.cm-stats strong {
    font-size: 1.35rem;
}

.cm-sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.cm-section {
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 12px;
    overflow: hidden;
}

.cm-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 14px 16px;
    cursor: pointer;
    font-size: 1.32rem;
    font-weight: 800;
    list-style: none;
}

.cm-section-title {
    flex: 1 1 auto;
}

.cm-section-count {
    color: var(--cm-muted);
    font-size: 1.05rem;
    font-weight: 800;
}

.cm-section summary::-webkit-details-marker {
    display: none;
}

.cm-section-toggle {
    position: relative;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 1px solid #9aa8bb;
    border-radius: 6px;
    background: #172033;
}

.cm-section .cm-section-toggle {
    width: 42px;
    height: 42px;
}

.cm-section-toggle::before,
.cm-section-toggle::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 3px;
    border-radius: 999px;
    background: #fff;
    content: "";
    transform: translate(-50%, -50%);
}

.cm-section .cm-section-toggle::before,
.cm-section .cm-section-toggle::after {
    width: 20px;
    height: 4px;
}

.cm-section-toggle::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.cm-section[open] .cm-section-toggle::after {
    display: none;
}

.cm-section .cm-sticker-grid {
    padding: 0 14px 14px;
}

.cm-sticker {
    display: grid;
    gap: 8px;
    min-height: 112px;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.cm-sticker-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    border: 1px solid var(--cm-border);
    border-radius: 6px;
    object-fit: cover;
    background: var(--cm-bg);
}

.cm-sticker.owned {
    border-color: #8dd7bd;
    background: #f0fbf7;
}

.cm-sticker strong {
    font-size: 1.05rem;
}

.cm-qty-form {
    display: grid;
    grid-template-columns: 38px minmax(28px, 1fr) 38px;
    gap: 6px;
    align-items: center;
}

.cm-qty-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-height: 38px;
    border: 1px solid #3e4b60;
    border-radius: 6px;
    background: #172033;
    color: #fff;
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 800;
    padding: 0;
}

.cm-qty-form.cm-saving {
    opacity: 0.72;
}

.cm-qty-form button:disabled {
    cursor: progress;
}

.cm-qty-form output {
    text-align: center;
    font-weight: 700;
}

.cm-admin .cm-panel {
    max-width: 100%;
    margin: 14px 0;
}

.cm-admin-single {
    max-width: 520px;
}

.cm-check {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 8px;
}

.cm-check input {
    width: auto;
    min-height: 0;
}

.cm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cm-actions form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cm-admin-tree {
    display: grid;
    gap: 14px;
}

.cm-admin-collection,
.cm-admin-section {
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #fff;
    padding: 0;
}

.cm-admin-collection > summary,
.cm-admin-section > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    font-weight: 700;
    list-style: none;
    padding: 12px 14px;
}

.cm-admin-collection > summary::-webkit-details-marker,
.cm-admin-section > summary::-webkit-details-marker {
    display: none;
}

.cm-admin-collection > summary {
    background: var(--cm-bg);
    font-size: 1.08rem;
}

.cm-admin-section {
    margin: 12px 14px;
}

.cm-admin-section > summary {
    border-bottom: 1px solid var(--cm-border);
    font-size: 1.18rem;
}

.cm-admin-section > summary b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 28px;
    border-radius: 6px;
    background: var(--cm-text);
    color: #fff;
    font-size: 0.95rem;
    margin-right: 8px;
}

.cm-admin-collection small,
.cm-admin-section small {
    color: var(--cm-muted);
    font-weight: 600;
}

.cm-admin-editor,
.cm-admin-add,
.cm-admin-stickers {
    padding: 14px;
}

.cm-admin-editor {
    border-bottom: 1px solid var(--cm-border);
}

.cm-admin-add {
    background: #fbfcfe;
    border-bottom: 1px solid var(--cm-border);
}

.cm-admin-section-body {
    background: #fff;
    border-left: 4px solid #d8dee8;
}

.cm-admin-section-tools {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
}

.cm-admin-add-sticker {
    margin: 0 14px 14px;
    border: 1px dashed #9aa8bb;
    border-radius: 8px;
}

.cm-admin-add-section {
    border-top: 1px solid var(--cm-border);
}

.cm-admin-add h3 {
    margin: 0 0 10px;
}

.cm-admin-inline-form,
.cm-admin-row-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
}

.cm-admin-inline-form label,
.cm-admin-row-form label {
    display: grid;
    gap: 5px;
    margin: 0;
    font-weight: 600;
}

.cm-admin-inline-form input,
.cm-admin-inline-form textarea,
.cm-admin-row-form input,
.cm-admin-row-form select {
    width: 100%;
    min-height: 36px;
}

.cm-admin-inline-form textarea {
    min-height: 72px;
}

.cm-danger-form {
    margin-top: 10px;
}

.cm-admin-sticker-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
    border-top: 1px solid var(--cm-border);
    padding: 10px 0;
}

.cm-admin-thumb {
    width: 54px;
    height: 72px;
    border: 1px solid var(--cm-border);
    border-radius: 6px;
    object-fit: cover;
    background: var(--cm-bg);
}

.cm-empty-thumb {
    display: block;
}

.cm-social-section {
    display: grid;
    gap: 14px;
}

.cm-social-section h3 {
    margin: 8px 0 0;
    font-size: 1.35rem;
}

.cm-profile-form,
.cm-message-form,
.cm-proposal-form {
    display: grid;
    gap: 12px;
}

.cm-profile-form label,
.cm-message-form label,
.cm-proposal-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.cm-profile-form input,
.cm-profile-form textarea,
.cm-message-form select,
.cm-message-form textarea,
.cm-proposal-form textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--cm-border);
    border-radius: 6px;
    padding: 8px 10px;
}

.cm-profile-form textarea,
.cm-message-form textarea,
.cm-proposal-form textarea {
    min-height: 88px;
}

.cm-profile-form button,
.cm-message-form button,
.cm-proposal-form button,
.cm-inline-action button {
    border: 0;
    border-radius: 6px;
    background: var(--cm-accent);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
    min-height: 40px;
    padding: 8px 12px;
}

.cm-match-card,
.cm-trade-card,
.cm-message {
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.cm-match-card h4,
.cm-trade-card h4 {
    margin: 0;
    font-size: 1.12rem;
}

.cm-match-card p,
.cm-trade-card p,
.cm-message p {
    margin: 6px 0;
}

.cm-match-notes {
    color: var(--cm-muted);
}

.cm-chip-group {
    display: grid;
    gap: 6px;
    margin: 10px 0;
}

.cm-chip-group div,
.cm-trade-items,
.cm-trade-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cm-chip,
.cm-trade-items span,
.cm-trade-card header span {
    border: 1px solid var(--cm-border);
    border-radius: 999px;
    background: var(--cm-bg);
    color: var(--cm-text);
    font-weight: 700;
    padding: 5px 9px;
}

.cm-trade-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cm-inline-action {
    display: inline-flex;
}

.cm-empty {
    color: var(--cm-muted);
    margin: 0;
}

.cm-admin-sticker-row:first-child {
    border-top: 0;
    padding-top: 0;
}

@media (max-width: 640px) {
    .cm-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .cm-sticker-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cm-admin-sticker-row {
        grid-template-columns: 1fr;
    }

    .cm-admin-section-tools {
        grid-template-columns: 1fr;
    }
}
