.crm-customer-module {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-customer-status {
    min-height: 18px;
    margin: 0 2px;
    color: #5e6c84;
    font-size: 0.82rem;
    line-height: 1.35;
}

.crm-customer-status.is-error {
    color: #b42318;
}

.crm-customer-status.is-loading {
    color: #5b3df5;
}

.crm-customer-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-customer-hero,
.crm-customer-card {
    border: 1px solid #e5ebf4;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.045);
}

.crm-customer-hero {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(220px, 0.8fr);
    gap: 12px;
    background:
        radial-gradient(circle at right top, rgba(69, 34, 94, 0.07), transparent 38%),
        linear-gradient(180deg, #ffffff 0%, #f8fafe 100%);
}

.crm-customer-hero__main {
    display: flex;
    gap: 10px;
    min-width: 0;
    align-items: flex-start;
}

.crm-customer-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(135deg, #45225e 0%, #6b3fa0 100%);
    color: #fff;
    font-size: 0.98rem;
    font-weight: 800;
    box-shadow: 0 8px 16px rgba(69, 34, 94, 0.16);
}

.crm-customer-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.crm-customer-hero__copy {
    min-width: 0;
}

.crm-customer-hero__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-customer-hero h2 {
    margin: 0;
    color: #1f2a44;
    font-size: clamp(1.12rem, 1.8vw, 1.5rem);
    line-height: 1.08;
}

.crm-customer-hero__meta {
    margin-top: 4px;
    color: #5d6c84;
    font-size: 0.84rem;
    line-height: 1.4;
}

.crm-customer-hero__actions {
    margin-top: 6px;
}

.crm-customer-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.crm-customer-badge {
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 0.64rem;
    font-weight: 800;
}

.crm-customer-badge--vip {
    background: #fff4d6;
    color: #9a6700;
}

.crm-customer-badge--blacklist {
    background: #fee2e2;
    color: #b42318;
}

.crm-customer-badge--trezor {
    background: #dbeafe;
    color: #1d4ed8;
}

.crm-customer-hero__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

/* Čtyři vedle sebe; šířka buněk řešená širším modalem + větší horizontální padding (ne výška boxu) */
.crm-customer-hero__stats--wide {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 14px;
}

.crm-customer-hero__stats--wide .crm-customer-chip {
    min-height: 58px;
    padding: 8px 14px;
    border-radius: 12px;
}

@media (max-width: 900px) {
    .crm-customer-hero__stats--wide {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.crm-customer-chip {
    min-height: 58px;
    border-radius: 12px;
    border: 1px solid #dfe6f1;
    padding: 8px 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f3f7fd 100%);
}

.crm-customer-chip span {
    display: block;
    color: #7a879c;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.crm-customer-chip strong {
    display: block;
    margin-top: 3px;
    color: #1f2a44;
    font-size: 0.94rem;
    line-height: 1.15;
}

.crm-customer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-customer-card {
    padding: 12px;
}

.crm-customer-card--wide,
.crm-customer-orders-card {
    grid-column: 1 / -1;
}

.crm-customer-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.crm-customer-card__head h3 {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #23324c;
    font-size: 0.88rem;
}

.crm-customer-kv {
    display: grid;
    gap: 2px;
}

.crm-customer-kv-row {
    display: grid;
    grid-template-columns: minmax(78px, 0.6fr) minmax(0, 1.4fr);
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #eef2f7;
}

.crm-customer-kv-row:last-child {
    border-bottom: 0;
}

.crm-customer-kv-label {
    color: #7a879c;
    font-size: 0.74rem;
}

.crm-customer-kv-value {
    color: #1f2a44;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: right;
}

.crm-customer-links {
    display: grid;
    gap: 8px;
}

.crm-customer-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.crm-customer-link-copy,
.crm-customer-link-open {
    min-height: 36px;
    border-radius: 10px;
}

.crm-customer-link-copy {
    border: 1px solid #e2e8f1;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #1f2a44;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
}

.crm-customer-link-open {
    width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #45225e;
    color: #fff;
    text-decoration: none;
}

.crm-customer-order-link,
.crm-customer-inline-link,
.mi-edit-toggle {
    border: 0;
    padding: 0;
    background: transparent;
    color: #45225e;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}

.crm-customer-note {
    color: #64748b;
    font-size: 0.78rem;
}

.crm-customer-orders-wrap {
    overflow-x: auto;
    border: 1px solid #e7edf5;
    border-radius: 12px;
    background: #fff;
}

.crm-customer-orders-table {
    width: 100%;
    border-collapse: collapse;
}

.crm-customer-orders-table th,
.crm-customer-orders-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #edf2f8;
    vertical-align: top;
}

.crm-customer-orders-table thead th {
    font-size: 0.64rem;
    color: #7c8aa5;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: #f8fbff;
}

.crm-customer-orders-table tbody tr:hover {
    background: #fafcff;
}

.crm-customer-order-meta {
    margin-top: 2px;
    color: #73839c;
    font-size: 0.7rem;
}

.crm-customer-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    background: #eef2ff;
    color: #4338ca;
}

.crm-customer-status-pill.is-ok {
    background: #dcfce7;
    color: #166534;
}

.crm-customer-status-pill.is-bad {
    background: #fee2e2;
    color: #b42318;
}

.ryb-wallet-container {
    display: block;
}

.ryb-wallet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ryb-wallet-item {
    background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
    border: 1px solid #dfe7f1;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.ryb-wallet-item.active {
    border-left: 4px solid #45225e;
}

.ryb-wallet-item.inactive {
    background: #f8fafc;
    opacity: 0.88;
}

.ryb-item-info {
    flex: 1;
    min-width: 0;
}

.ryb-coupon-header {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.ryb-coupon-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: #1f2a44;
}

.ryb-badge-shipping {
    font-size: 0.58rem;
    padding: 3px 6px;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ryb-status-badge,
.ryb-status-label {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 6px;
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ryb-status-active {
    background: #dcfce7;
    color: #166534;
}

.ryb-status-used {
    background: #e5e7eb;
    color: #4b5563;
}

.ryb-status-expired,
.ryb-status-scheduled {
    background: #fef3c7;
    color: #92400e;
}

.ryb-status-deleted {
    background: #fee2e2;
    color: #b91c1c;
}

.ryb-coupon-discount {
    margin-bottom: 3px;
    color: #45225e;
    font-size: 0.94rem;
    font-weight: 900;
}

.ryb-wallet-item.inactive .ryb-coupon-discount {
    color: #64748b;
}

.ryb-coupon-meta {
    color: #64748b;
    font-size: 0.72rem;
}

.ryb-coupon-meta-error {
    color: #b42318;
    margin-top: 4px;
}

.ryb-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 5px 8px;
    border-radius: 10px;
    background: #f8fbff;
}

.ryb-code-display {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.76rem;
    font-weight: 700;
    color: #1f2a44;
}

.ryb-wallet-btn-small {
    border: 0;
    border-radius: 8px;
    background: #45225e;
    color: #fff;
    padding: 6px 9px;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
}

.ryb-wallet-btn-small.copied {
    background: #15803d;
}

.ryb-expired-separator {
    margin: 12px 0 4px;
    text-align: center;
    border-top: 1px dashed #cbd5e1;
}

.ryb-expired-toggle-btn {
    border: 0;
    background: #fff;
    color: #64748b;
    padding: 3px 8px;
    transform: translateY(-10px);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
}

.ryb-arrow.rotated {
    display: inline-block;
    transform: rotate(180deg);
}

.crm-customer-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.52);
    padding: 18px;
}

.crm-customer-modal__panel {
    /* Širší než dřív → čtyři statistiky v řádku nejsou „prsty“ úzké (cca 2× šířka buňky oproti ~1040px) */
    width: min(1680px, 100%);
    max-height: min(90vh, 920px);
    overflow: auto;
    background: #f4f7fb;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
    padding: 14px;
}

.crm-customer-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    min-width: 0;
}

.crm-customer-modal__head-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2a44;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 10px;
    line-height: 1.25;
}

.crm-customer-modal__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 0;
    background: #e8edf5;
    color: #1f2a44;
    cursor: pointer;
}

/* Kompaktní hero uvnitř modalu */
.crm-customer-modal .crm-customer-hero--modal-compact {
    padding: 10px 12px;
}

.crm-customer-modal .crm-customer-hero__main {
    align-items: center;
}

/* Fotka v modalu 2× větší průměr oproti výchozím 48px */
.crm-customer-modal .crm-customer-avatar {
    width: 96px;
    height: 96px;
    border-radius: 28px;
    font-size: 1.45rem;
}

.crm-customer-modal .crm-customer-hero__stats--wide .crm-customer-chip {
    min-height: 58px;
    padding: 8px 16px;
}

@media (max-width: 980px) {
    .crm-customer-hero,
    .crm-customer-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .crm-customer-hero,
    .crm-customer-card {
        padding: 10px;
    }

    .crm-customer-hero__main {
        align-items: flex-start;
    }

    .crm-customer-hero__stats {
        grid-template-columns: 1fr 1fr;
    }

    .crm-customer-hero__stats--wide {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-customer-kv-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .crm-customer-kv-value {
        text-align: left;
    }

    .crm-customer-link-row {
        grid-template-columns: 1fr;
    }

    .crm-customer-link-open {
        width: 100%;
    }

    .ryb-wallet-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .ryb-item-actions {
        width: 100%;
        justify-content: space-between;
    }
}
