#payment-history {
    margin: 0;
    padding: 0;
    border: 0;
}

#payment-history .history-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#payment-history .history-eyebrow {
    display: block;
    margin-bottom: 6px;
    color: #8299bb;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1.6px;
}

#payment-history #history-title {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.4px;
}

#payment-history .history-description {
    max-width: 620px;
    margin: 9px 0 0;
    color: #8e9cb1;
    font-size: 13px;
    line-height: 1.55;
}

#payment-history .history-refresh {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid #2f3c50;
    border-radius: 11px;
    background: #131c28;
    color: #a6b8d2;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease;
}

#payment-history .history-refresh:hover:not(:disabled) {
    border-color: #4d6382;
    background: #192536;
    color: #dbe7fa;
}

#payment-history .history-refresh svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#payment-history .history-message {
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px solid #2c394c;
    border-radius: 12px;
    background: #111a27;
    color: #aab8ca;
    font-size: 13px;
}

#payment-history .history-message:empty {
    display: none;
}

#payment-history .history-list {
    display: grid;
    gap: 8px;
    margin: 20px 0 12px;
}

#payment-history .history-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-width: 0;
    padding: 15px 16px;
    border: 1px solid #293649;
    border-radius: 15px;
    background: #0f1722;
    transition:
        border-color .15s ease,
        background .15s ease,
        transform .15s ease;
}

#payment-history .history-row:hover {
    border-color: #3b4e69;
    background: #111b29;
}

#payment-history .history-icon {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 10px;
    place-items: center;
    border: 1px solid #2d3c51;
    border-radius: 13px;
    background: #162131;
    color: #9ebbe9;
}

#payment-history .history-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#payment-history .history-main {
    min-width: 0;
}

#payment-history .history-main h3 {
    margin: 0;
    color: #e6edf8;
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

#payment-history .history-meta {
    margin: 4px 0 0;
    color: #7f8da3;
    font-size: 11px;
    line-height: 1.4;
}

#payment-history .history-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

#payment-history .history-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 7px;
    border: 1px solid #334158;
    border-radius: 999px;
    background: #151d29;
    color: #91a1b8;
    font-size: 9px;
    font-weight: 650;
    line-height: 1.25;
}

#payment-history .history-status.is-ok {
    border-color: #275744;
    background: #16372d;
    color: #a1e5bd;
}

#payment-history .history-status.is-warning {
    border-color: #66522d;
    background: #302718;
    color: #e6c67d;
}

#payment-history .history-status.is-error {
    border-color: #67404c;
    background: #30202a;
    color: #ffc5cf;
}

#payment-history .history-status.is-muted {
    color: #8d9ab0;
}

#payment-history .history-side {
    display: grid;
    min-width: 150px;
    justify-items: end;
    gap: 9px;
}

#payment-history .history-price {
    color: #edf1f8;
    font-size: 15px;
    font-weight: 650;
    white-space: nowrap;
}

#payment-history .history-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

#payment-history .history-action {
    min-height: 30px;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #9fb9e4;
    font: inherit;
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

#payment-history .history-action:hover:not(:disabled) {
    background: #1a2637;
    color: #d8e6fb;
}

#payment-history .history-action-primary {
    border: 1px solid #425675;
    background: #1b2a40;
    color: #c5d9fa;
}

#payment-history .history-more {
    width: 100%;
    margin-top: 4px;
}

@media (max-width: 600px) {
    #payment-history .history-top {
        align-items: flex-start;
    }

    #payment-history .history-refresh span {
        display: none;
    }

    #payment-history .history-refresh {
        width: 38px;
        padding: 9px;
        justify-content: center;
    }

    #payment-history .history-row {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        padding: 14px;
    }

    #payment-history .history-icon {
        width: 40px;
        height: 40px;
    }

    #payment-history .history-side {
        grid-column: 2;
        min-width: 0;
        width: 100%;
        justify-items: stretch;
        gap: 8px;
    }

    #payment-history .history-price {
        font-size: 14px;
    }

    #payment-history .history-actions {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    #payment-history .history-row,
    #payment-history .history-refresh {
        transition: none;
    }
}


/* v5 loading / empty states */

#payment-history .history-refresh.is-spinning svg {
    animation: history-spin .8s linear infinite;
}

#payment-history .history-skeleton {
    display: grid;
    gap: 8px;
    margin: 20px 0 12px;
}

#payment-history .history-skeleton-row {
    position: relative;
    display: block;
    height: 94px;
    overflow: hidden;
    border: 1px solid #293649;
    border-radius: 15px;
    background:
        linear-gradient(#182332 0 0) 16px 16px / 42px 42px no-repeat,
        linear-gradient(#182332 0 0) 72px 18px / 34% 12px no-repeat,
        linear-gradient(#151f2d 0 0) 72px 40px / 48% 9px no-repeat,
        linear-gradient(#151f2d 0 0) 72px 62px / 28% 20px no-repeat,
        #0f1722;
}

#payment-history .history-skeleton-row::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-110%);
    background: linear-gradient(
        90deg,
        transparent,
        rgb(255 255 255 / 6%),
        transparent
    );
    animation: history-shimmer 1.2s ease-in-out infinite;
}

#payment-history .history-empty {
    display: grid;
    justify-items: center;
    max-width: 480px;
    margin: 28px auto 8px;
    padding: 28px 20px;
    border: 1px dashed #334157;
    border-radius: 18px;
    background: #0d151f;
    text-align: center;
}

#payment-history .history-empty-icon {
    display: grid;
    width: 48px;
    height: 48px;
    padding: 12px;
    place-items: center;
    border: 1px solid #32435a;
    border-radius: 15px;
    background: #162131;
    color: #9ebbe9;
}

#payment-history .history-empty-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#payment-history .history-empty strong {
    margin-top: 14px;
    color: #e8eef8;
    font-size: 16px;
}

#payment-history .history-empty p {
    max-width: 340px;
    margin: 7px 0 16px;
    color: #8898af;
    font-size: 12px;
    line-height: 1.55;
}

#payment-history .history-empty .button {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 12px;
}

@keyframes history-spin {
    to { transform: rotate(360deg); }
}

@keyframes history-shimmer {
    to { transform: translateX(110%); }
}

@media (prefers-reduced-motion: reduce) {
    #payment-history .history-refresh.is-spinning svg,
    #payment-history .history-skeleton-row::after {
        animation: none;
    }
}

/* =========================================================
   Payment detail sheet v16
   ========================================================= */

#payment-history .history-row[role="button"] {
    cursor: pointer;
}

#payment-history .history-row[role="button"]:focus-visible {
    outline: 3px solid rgb(139 194 255 / 52%);
    outline-offset: 3px;
    border-color: #58729a;
}

.history-detail-dialog {
    width: min(560px, calc(100vw - 28px));
    max-width: 560px;
    margin: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    color: #e9eff8;
}

.history-detail-dialog::backdrop {
    background: rgb(3 6 10 / 72%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.history-detail-sheet {
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 10%);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgb(255 255 255 / 2.5%), transparent 26%),
        #0d141e;
    box-shadow:
        0 32px 90px rgb(0 0 0 / 48%),
        inset 0 1px 0 rgb(255 255 255 / 4%);
}

.history-detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
}

.history-detail-heading {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 11px;
}

.history-detail-heading > span:last-child {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.history-detail-heading small {
    color: #7f94b4;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 1.5px;
}

.history-detail-heading strong {
    overflow: hidden;
    color: #edf2fa;
    font-size: 15px;
    font-weight: 690;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-detail-mark {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    padding: 10px;
    place-items: center;
    border: 1px solid #31415a;
    border-radius: 13px;
    background: #151f2d;
    color: #a9c6f2;
}

.history-detail-mark svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-detail-close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    padding: 0;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: #8191a9;
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.history-detail-close:hover {
    border-color: #2e3b4f;
    background: #151e2a;
    color: #e0e8f5;
}

.history-detail-hero {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin: 0 18px;
    padding: 16px;
    border: 1px solid #2e3b4f;
    border-radius: 17px;
    background: #111a26;
}

.history-detail-state-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid #3a4b65;
    border-radius: 13px;
    background: #172231;
    color: #b4c8e8;
    font-size: 16px;
    font-weight: 800;
}

.history-detail-state-copy {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.history-detail-state-copy strong {
    color: #ecf2fa;
    font-size: 14px;
    font-weight: 660;
}

.history-detail-state-copy small {
    color: #8797ad;
    font-size: 11px;
    line-height: 1.35;
}

.history-detail-amount {
    color: #f0f4fa;
    font-size: 18px;
    font-weight: 720;
    white-space: nowrap;
}

.history-detail-hero.is-ok {
    border-color: #285742;
    background: linear-gradient(135deg, rgb(49 134 85 / 15%), #111a26 58%);
}

.history-detail-hero.is-ok .history-detail-state-icon {
    border-color: #2c604a;
    background: #173429;
    color: #a7e6bf;
}

.history-detail-hero.is-warning {
    border-color: #62502e;
    background: linear-gradient(135deg, rgb(142 104 38 / 14%), #111a26 58%);
}

.history-detail-hero.is-warning .history-detail-state-icon {
    border-color: #685630;
    background: #302718;
    color: #edce87;
}

.history-detail-hero.is-error {
    border-color: #65404b;
    background: linear-gradient(135deg, rgb(139 57 73 / 14%), #111a26 58%);
}

.history-detail-hero.is-error .history-detail-state-icon {
    border-color: #69434f;
    background: #30202a;
    color: #ffc5cf;
}

.history-detail-list {
    display: grid;
    margin: 16px 18px 0;
    border: 1px solid #273447;
    border-radius: 16px;
    background: #0e1620;
}

.history-detail-list > div {
    display: grid;
    grid-template-columns: minmax(110px, .65fr) minmax(0, 1.35fr);
    gap: 18px;
    align-items: center;
    min-height: 48px;
    padding: 11px 14px;
    border-bottom: 1px solid #202c3c;
}

.history-detail-list > div:last-child {
    border-bottom: 0;
}

.history-detail-list dt,
.history-detail-list dd {
    margin: 0;
}

.history-detail-list dt {
    color: #7889a0;
    font-size: 11px;
}

.history-detail-list dd {
    min-width: 0;
    color: #dbe4f1;
    font-size: 12px;
    font-weight: 570;
    line-height: 1.4;
    text-align: right;
    overflow-wrap: anywhere;
}

.history-detail-list code {
    color: #a9c3ea;
    font-family: var(--cvpn-font-mono, monospace);
    font-size: 10px;
    font-weight: 550;
    word-break: break-all;
}

.history-detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 16px 18px 0;
}

.history-detail-actions .button {
    min-height: 42px;
    margin: 0;
    padding: 10px 12px;
    font-size: 11px;
    text-align: center;
}

.history-detail-actions .primary:not([hidden]) {
    grid-column: 1 / -1;
    grid-row: 1;
}

.history-detail-help {
    margin: 13px 18px 0;
    padding: 0 0 18px;
    color: #74859c;
    font-size: 10px;
    line-height: 1.55;
}

.history-detail-help a {
    color: #9dbce9;
    text-decoration: none;
}

.history-detail-help a:hover {
    color: #d6e5fb;
}

.history-detail-dialog.is-busy .history-detail-actions {
    opacity: .66;
}

@media (max-width: 600px) {
    .history-detail-dialog {
        width: 100%;
        max-width: none;
        margin: auto 0 0;
    }

    .history-detail-sheet {
        max-height: min(86dvh, 760px);
        overflow-y: auto;
        border-radius: 24px 24px 0 0;
        border-bottom: 0;
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .history-detail-top {
        padding: 14px 14px 12px;
    }

    .history-detail-hero {
        grid-template-columns: 40px minmax(0, 1fr);
        margin: 0 14px;
        padding: 14px;
    }

    .history-detail-state-icon {
        width: 40px;
        height: 40px;
    }

    .history-detail-amount {
        grid-column: 2;
        font-size: 17px;
    }

    .history-detail-list {
        margin: 14px 14px 0;
    }

    .history-detail-list > div {
        grid-template-columns: minmax(92px, .75fr) minmax(0, 1.25fr);
        gap: 12px;
        padding: 10px 12px;
    }

    .history-detail-actions {
        grid-template-columns: 1fr;
        padding: 14px 14px 0;
    }

    .history-detail-actions .primary:not([hidden]) {
        grid-column: auto;
        grid-row: auto;
    }

    .history-detail-help {
        margin: 12px 14px 0;
        padding-bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .history-detail-close {
        transition: none;
    }
}

#payment-history .history-more.is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#payment-history .history-more.is-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid rgb(255 255 255 / 18%);
    border-top-color: #aac8f4;
    border-radius: 999px;
    animation: history-spin .8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    #payment-history .history-more.is-loading::before {
        animation: none;
    }
}
