.pf-market {
    --pf-brown: #351f18;
    --pf-wine: #9b1235;
    --pf-cream: #fbf7f2;
    --pf-line: #e3d7c7;
    --pf-muted: #74655d;

    min-height: 100vh;

    padding: 42px 20px 36px;

    background: #f4dfaa;
    color: var(--pf-brown);
}

.pf-market * {
    box-sizing: border-box;
}

.pfm-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
}

.pfm-heading {
    max-width: 760px;

    margin: 0 auto 40px;

    text-align: center;
}

.pfm-eyebrow {
    display: block;

    margin-bottom: 8px;

    color: var(--pf-wine);

    font-size: 12px;
    font-weight: 800;

    letter-spacing: .16em;
    text-transform: uppercase;
}

.pfm-heading h1 {
    margin: 0 0 12px;

    font-size: clamp(38px, 5vw, 56px);
    line-height: 1.05;
}

.pfm-heading p {
    margin: 0;

    color: var(--pf-muted);

    font-size: 17px;
}

.pfm-section-title {
    margin: 0 0 18px;

    font-size: 21px;
}

.pfm-product-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 34px;
}

.pfm-product-card {
    position: relative;

    display: block;

    min-height: 405px;

    border: 1px solid var(--pf-line);
    border-radius: 22px;

    background: rgba(251,247,242,.95);

    cursor: pointer;

    box-shadow:
        0 12px 34px rgba(53,31,24,.07);
}

.pfm-product-card.is-selected {
    border: 2px solid var(--pf-wine);
}

.pfm-product-card > input {
    position: absolute;
    opacity: 0;
}

.pfm-product-card__body {
    display: flex;

    height: 100%;

    flex-direction: column;

    padding: 28px 22px 24px;
}

.pfm-product-card small {
    display: block;

    margin-bottom: 8px;

    color: var(--pf-wine);

    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.pfm-product-card strong {
    display: block;

    margin-bottom: 14px;

    font-size: 22px;
    text-align: center;
}

.pfm-price {
    display: block;

    margin-bottom: 20px;

    color: var(--pf-wine);

    font-size: 25px;
    font-weight: 800;
    text-align: center;
}

.pfm-features {
    display: grid;
    gap: 7px;

    color: var(--pf-muted);

    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.pfm-select-row {
    display: grid;

    grid-template-columns: 22px 1fr;

    gap: 10px;

    align-items: center;

    margin-top: auto;
    padding-top: 20px;
}

.pfm-radio {
    display: block;

    width: 21px;
    height: 21px;

    border: 2px solid #b6a89f;
    border-radius: 50%;

    background: #fff;

    box-shadow:
        inset 0 0 0 5px #fff;
}

.pfm-radio.is-selected {
    border-color: var(--pf-wine);

    background: var(--pf-wine);
}

.pfm-select {
    border: 1px solid #ab998d;
    border-radius: 10px;

    padding: 10px 12px;

    background: #fff;

    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.pfm-select.is-selected {
    border-color: var(--pf-wine);

    background: var(--pf-wine);
    color: #fff;
}

.pfm-layout {
    display: grid;

    grid-template-columns:
        minmax(0, 1.7fr)
        minmax(300px, .65fr);

    gap: 24px;

    align-items: start;
}

.pfm-main {
    display: grid;
    gap: 18px;
}

.pfm-panel,
.pfm-summary {
    border: 1px solid var(--pf-line);
    border-radius: 22px;

    background: rgba(251,247,242,.96);

    box-shadow:
        0 10px 26px rgba(53,31,24,.06);
}

.pfm-panel {
    padding: 26px;
}

.pfm-panel h2,
.pfm-summary h2 {
    margin: 0 0 20px;

    font-size: 22px;
}

.pfm-fields {
    display: grid;
    gap: 16px;
}

.pfm-fields--two {
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
}

.pfm-span-2 {
    grid-column: 1 / -1;
}

.pfm-fields label > span {
    display: block;

    margin-bottom: 7px;

    font-size: 13px;
    font-weight: 700;
}

.pfm-fields input,
.pfm-fields select {
    width: 100%;

    border: 1px solid #d8cabd;
    border-radius: 12px;

    padding: 12px 13px;

    background: #fff;

    color: var(--pf-brown);

    font: inherit;
}

.pfm-note {
    margin: 16px 0 0;

    border-radius: 12px;

    padding: 11px 13px;

    background: #f3e8dd;

    color: var(--pf-muted);

    font-size: 12px;
}

.pfm-summary {
    position: sticky;

    top: 24px;

    align-self: start;

    padding: 25px;
}

.pfm-summary ul {
    margin: 0 0 20px;

    padding-left: 20px;

    color: var(--pf-muted);

    font-size: 14px;
}

.pfm-summary-row {
    display: flex;

    justify-content: space-between;

    gap: 18px;

    border-top: 1px solid var(--pf-line);

    padding: 12px 0;
}

.pfm-summary-row--total {
    margin-bottom: 16px;

    font-size: 19px;
}

.pfm-summary-row--total strong {
    color: var(--pf-wine);
}

.pfm-button {
    width: 100%;

    border: 0;
    border-radius: 999px;

    padding: 14px 18px;

    background: var(--pf-wine);
    color: #fff;

    font-weight: 800;

    opacity: .45;
}

.pfm-checkout-note {
    margin: 12px 0 0;

    color: var(--pf-muted);

    font-size: 12px;
    text-align: center;
}

@media (max-width: 1000px) {
    .pfm-product-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .pfm-layout {
        grid-template-columns: 1fr;
    }

    .pfm-summary {
        position: static;
    }
}

@media (max-width: 620px) {
    .pf-market {
        padding-right: 14px;
        padding-left: 14px;
    }

    .pfm-product-grid,
    .pfm-fields--two {
        grid-template-columns: 1fr;
    }

    .pfm-span-2 {
        grid-column: auto;
    }
}

/* =========================================================
   MARKET R2 · Product-specific options
   Quantity + grind apply only to Media libra.
   ========================================================= */

.pf-market [data-pfm-coffee-options][hidden] {
    display: none !important;
}

/* =========================================================
   MARKET R2 · Gift Cards keep grind selection.
   Only quantity is product-specific to Media libra.
   ========================================================= */

.pf-market [data-pfm-quantity-field][hidden] {
    display: none !important;
}

/* PORF-066 · post-payment confirmation */
.pfm-postpay {
    width: min(100%, 760px);
    margin: 32px auto;
    padding: 32px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

.pfm-postpay__title {
    margin: 8px 0 10px;
}

.pfm-postpay__lead {
    margin: 0 0 24px;
}

.pfm-postpay__summary {
    margin-top: 24px;
}

.pfm-postpay__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.pfm-postpay__actions .pfm-button {
    width: auto;
    min-width: 180px;
    text-decoration: none;
    text-align: center;
}

.pfm-postpay__actions .pfm-button--secondary {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
}

@media (max-width: 640px) {
    .pfm-postpay {
        margin: 18px auto;
        padding: 22px;
        border-radius: 16px;
    }

    .pfm-postpay__actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .pfm-postpay__actions .pfm-button {
        width: 100%;
        min-width: 0;
    }
}

/* ==========================================================
   PORF-SHIP-02B · controlled saved / alternate delivery UX
   ========================================================== */

.pf-market .pfm-auth-profile-card {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    padding: 18px 20px;
    margin: 0 0 14px;
    border: 1px solid rgba(55, 35, 25, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.pf-market .pfm-auth-profile-card strong {
    display: block;
    margin-bottom: 3px;
    font-size: 1rem;
}

.pf-market .pfm-auth-profile-card span {
    display: block;
    line-height: 1.45;
}

.pf-market .pfm-auth-profile-card__note {
    display: block;
    margin-top: 4px;
    line-height: 1.45;
    opacity: 0.72;
}

.pf-market .pfm-delivery-mode-button {
    align-self: flex-start;
    min-height: 42px;
    margin-top: 8px;
    padding: 9px 16px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pf-market .pfm-delivery-alt-recipient {
    min-width: 0;
}

.pf-market [hidden] {
    display: none !important;
}

/* ==========================================================
   PORF-SHIP-02C-C-R2 · pre-checkout confirmation modal
   ========================================================== */

body.pfm-confirm-open {
    overflow: hidden;
}

.pfm-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 24px;
    background:
        rgba(24, 16, 12, 0.64);
}

.pfm-confirm-dialog {
    width: min(620px, 100%);
    max-height:
        calc(100vh - 48px);
    overflow: auto;
    box-sizing: border-box;
    padding: 26px;
    border-radius: 20px;
    background: #fff;
    box-shadow:
        0 22px 70px
        rgba(0, 0, 0, 0.28);
}

.pfm-confirm-title {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.2;
}

.pfm-confirm-intro {
    margin: 8px 0 20px;
    line-height: 1.5;
    opacity: 0.72;
}

.pfm-confirm-body {
    display: grid;
    gap: 14px;
}

.pfm-confirm-section {
    padding: 15px 17px;
    border: 1px solid
        rgba(55, 35, 25, 0.12);
    border-radius: 14px;
    background:
        rgba(248, 246, 243, 0.72);
}

.pfm-confirm-section__title {
    margin: 0 0 7px;
    font-size: 0.96rem;
}

.pfm-confirm-section__line {
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.pfm-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.pfm-confirm-button {
    min-height: 44px;
    padding: 10px 17px;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pfm-confirm-button--secondary {
    border: 1px solid
        rgba(55, 35, 25, 0.35);
    background: transparent;
}

.pfm-confirm-button--primary {
    border: 1px solid #25211f;
    background: #25211f;
    color: #fff;
}

@media (max-width: 640px) {
    .pfm-confirm-overlay {
        align-items: flex-end;
        padding: 12px;
    }

    .pfm-confirm-dialog {
        max-height:
            calc(100vh - 24px);
        padding: 20px;
        border-radius: 18px;
    }

    .pfm-confirm-actions {
        flex-direction:
            column-reverse;
    }

    .pfm-confirm-button {
        width: 100%;
    }
}

/* ==========================================================
   PORF-SHIP-02C-F-R3
   Compra única · paridad visual con La Ramita
   ========================================================== */

.pfm-confirm-dialog {
    width: min(700px, calc(100vw - 32px));
    max-height: calc(100vh - 36px);
    padding: 24px;
    border-radius: 24px;
}

.pfm-confirm-intro {
    margin: 6px 0 16px;
}

.pfm-confirm-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/*
 * El DOM actual es:
 * 1 comprador
 * 2 entregar a
 * 3 dirección
 * 4 tu pedido
 * 5 resumen
 *
 * Solo cambiamos el orden visual.
 */

.pfm-confirm-body > .pfm-confirm-section:nth-child(4) {
    order: 1;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(5) {
    order: 2;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(1) {
    order: 3;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(2) {
    order: 4;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(3) {
    order: 5;
}

.pfm-confirm-section {
    margin: 0;
    padding: 13px 16px;
    border-radius: 16px;
}

.pfm-confirm-section__title {
    margin: 0 0 7px;
    font-size: .76rem;
    line-height: 1.2;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #89142d;
}

.pfm-confirm-section__line {
    line-height: 1.4;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(4) {
    background: #fffaf2;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(4)
.pfm-confirm-section__line:first-of-type {
    font-size: 1.08rem;
    font-weight: 700;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(5) {
    background: #fff8eb;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(5)
.pfm-confirm-section__line:last-child {
    margin-top: 8px;
    padding-top: 9px;
    border-top: 1px solid rgba(60, 35, 25, .14);
    font-size: 1.15rem;
    font-weight: 800;
    color: #a10e32;
}

.pfm-confirm-body > .pfm-confirm-section:nth-child(1),
.pfm-confirm-body > .pfm-confirm-section:nth-child(2) {
    padding-top: 11px;
    padding-bottom: 11px;
}

.pfm-confirm-actions {
    position: sticky;
    bottom: -1px;
    margin-top: 14px;
    padding-top: 11px;
    background: #fff;
}

.pfm-confirm-button {
    min-height: 46px;
}

.pfm-confirm-button--primary {
    background: #651421;
    border-color: #651421;
}

@media (max-width: 640px) {
    .pfm-confirm-overlay {
        padding: 8px;
        align-items: center;
    }

    .pfm-confirm-dialog {
        width: 100%;
        max-height: calc(100vh - 16px);
        padding: 17px 14px 14px;
        border-radius: 18px;
    }

    .pfm-confirm-section {
        padding: 11px 13px;
    }

    .pfm-confirm-actions {
        gap: 8px;
        margin-top: 10px;
    }
}
