:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #475569;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.18);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    --panel-w: 520px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}


/* ---------- Layout ---------- */

.layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.cart-col { min-width: 0; }

.page-title {
    margin: 0 0 24px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.product-card {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.product-image {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
}
.product-image svg { width: 100%; height: 100%; display: block; }

.product-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.product-title { margin: 0; font-size: 18px; font-weight: 600; }
.product-desc { margin: 0; color: var(--text-muted); font-size: 14px; }

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.qty-btn {
    width: 32px;
    height: 32px;
    border: 0;
    background: var(--surface);
    cursor: not-allowed;
    color: var(--text-muted);
    font-size: 16px;
}
.qty-btn:disabled { opacity: 0.6; }
.qty-num {
    width: 32px;
    text-align: center;
    font-weight: 500;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    height: 32px;
    line-height: 32px;
}

.product-price { font-weight: 600; font-size: 18px; }

.summary {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.summary h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 14px;
}
.summary-total {
    border-top: 1px solid var(--border);
    margin-top: 10px;
    padding-top: 12px;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

/* ---------- Demo notice (payment disabled) ---------- */

.demo-notice {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top: 14px;
    padding: 10px 12px;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 8px;
    color: #854d0e;
    font-size: 13px;
    line-height: 1.45;
}
.demo-notice-icon {
    flex-shrink: 0;
    line-height: 1.45;
}

/* Demo lock: block clicks on Google Pay / Apple Pay / Pay buttons.
   pointer-events:none on the interactive children (SDK iframes / web component /
   button); cursor:not-allowed on the wrapper that still receives the event. */
#payment-block.demo-locked .wallet-box,
#payment-block.demo-locked #comgate-card-form-container-button {
    cursor: not-allowed;
}
#payment-block.demo-locked .wallet-box {
    position: relative;
}
#payment-block.demo-locked .wallet-box > *,
#payment-block.demo-locked #comgate-card-form-container-button button {
    pointer-events: none !important;
}
/* Apple Pay renders as <apple-pay-button> (web component, shadow DOM) whose
   inner button ignores inherited pointer-events:none — especially once the page
   itself is embedded in an iframe. A transparent overlay on the wallet box
   swallows the click regardless of the inner DOM (also covers the GP iframe). */
#payment-block.demo-locked .wallet-box::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Sit above the AP web component so the overlay (not the button's shadow
       DOM) is the hovered element — gives a consistent not-allowed cursor. */
    z-index: 2147483647;
    cursor: not-allowed;
}
/* Belt-and-suspenders: also force the cursor on the AP button host + its
   exposed shadow part, in case the button paints above the overlay. */
#payment-block.demo-locked .wallet-box--applepay apple-pay-button,
#payment-block.demo-locked .wallet-box--applepay apple-pay-button::part(button) {
    cursor: not-allowed !important;
}

/* ---------- Card form area inside summary ---------- */

.checkout-divider {
    margin: 20px -20px 14px;
    padding: 14px 20px 0;
    border-top: 1px solid var(--border);
}

.or-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px auto;
    max-width: 200px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.or-divider[hidden] {
    display: none;
}
.checkout-divider > span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ---------- Wallet buttons (Apple Pay / Google Pay) ---------- */

.wallets-mount {
    --wallet-btn-w: 200px;
    --wallet-btn-h: 44px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: auto;
    margin-left: -20px;
    margin-right: -20px;
}
.wallets-mount[hidden] {
    display: none;
}

.wallet-box {
    line-height: 0;
    flex: 0 0 var(--wallet-btn-w);
    width: var(--wallet-btn-w);
    height: var(--wallet-btn-h);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}
.wallet-box iframe {
    max-width: 100%;
}
.wallet-box apple-pay-button {
    width: var(--wallet-btn-w);
    max-width: 100%;
    --apple-pay-button-width: var(--wallet-btn-w);
}
.wallet-box--googlepay iframe {
    width: var(--wallet-btn-w) !important;
    height: var(--wallet-btn-h) !important;
}
.wallet-box > * {
    max-width: 100%;
    box-sizing: border-box;
}
.wallet-box:empty {
    display: none;
}
.wallet-box[hidden] {
    display: none;
}

/* Explanatory note shown only on mobile (GP type forced to logo-only there,
   see checkout-init.js buildGooglePayConfig). Hidden on desktop. */
.wallet-mobile-note {
    display: none;
    margin: 0 0 12px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
    background: var(--surface-2);
    border-radius: 6px;
}

/* Mobile: keep both wallet buttons side by side without overflow. Drop the
   desktop negative margins + fixed 200px boxes; each box flexes to an equal
   share of the row. Apple Pay (web component) reflows its label; Google Pay
   is forced to a logo-only type so it fits the narrow box without spilling. */
@media (max-width: 560px) {
    .wallet-mobile-note {
        display: block;
    }
    .wallets-mount {
        gap: 10px;
        margin-left: 0;
        margin-right: 0;
    }
    .wallet-box {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }
    .wallet-box apple-pay-button {
        width: 100%;
        --apple-pay-button-width: 100%;
    }
    /* GP DOM: .cg-gp-btn > button.gpay-card-info-container > iframe (logo).
       The <button> uses Google's 'size-match-height' layout, so it keeps the
       logo's intrinsic width and parks it at one edge of the wider wrapper —
       forcing only the iframe to 100% doesn't help (the button stays narrow).
       Force every layer to fill the box and flex-center so the (buttonSizeMode
       'fill') logo lands in the middle. */
    .wallet-box--googlepay .cg-gp-btn,
    .wallet-box--googlepay .gpay-card-info-container {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .wallet-box--googlepay .gpay-card-info-iframe {
        width: 100% !important;
        height: 100% !important;
    }
}

.checkout-divider--card {
    margin-top: 16px;
}
.checkout-divider--card > span {
    font-weight: 500;
    color: var(--text-muted);
}

.card-mount {
    position: relative;
}

/* Officially supported per docs (40-implementace.mdx:746-749) — override SDK-injected
   default outer wrapper styles. SDK injects:
     #<containerId> { border: 1px solid #f0f0f0; background: #f2f2f2; padding: 15px; }
   Merchant overrides via own CSS. Constraint: prvky musí zůstat funkční (řádek 740-744). */
#comgate-card-form-container {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    max-width: var(--cf-form-max-width, 420px);
    margin: 0 auto;
}

#comgate-card-form-container-ibox iframe {
    width: 100%;
    border: 0;
    display: block;
}

/* Custom height — host CSS override SDK auto-resize (inline style.height). Only when
   user explicitly zadal hodnotu, jinak SDK přizpůsobuje obsahu. */
#comgate-card-form-container[data-custom-height] #comgate-card-form-container-ibox {
    min-height: var(--cf-form-height) !important;
}
#comgate-card-form-container[data-custom-height] #comgate-card-form-container-ibox iframe {
    height: var(--cf-form-height) !important;
}
#comgate-card-form-container-button {
    display: flex;
    justify-content: center;
}
#comgate-card-form-container-button button {
    transition: background-color 0.1s ease-in-out, filter 0.1s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--cf-button-width, 100%);
    height: var(--cf-button-height, 44px);
    padding: 14px 10px;
    margin-top: 10px;
    border: var(--cf-button-border-width, 0) solid var(--cf-button-border-color, transparent);
    border-radius: 5px;
    background: var(--cf-button-bg, #16a34a);
    color: var(--cf-button-color, #fff);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
#comgate-card-form-container-button button:hover {
    background: var(--cf-button-bg, #16a34a);
    filter: brightness(0.92);
}
#comgate-card-form-container-button button .cg-button-lock,
#comgate-card-form-container-button button .cg-button-tick {
    flex-shrink: 0;
    margin-right: 6px;
}
#comgate-card-form-container-button button .cg-button-lock { width: 17px; }
#comgate-card-form-container-button button .cg-button-tick { width: 14px; height: 14px; }
/* Lock icon swapped from <img> to <span> so it can inherit text color via
   CSS mask (raw <img> can't be recolored). Tick icon is inline SVG with
   fill=currentColor already, so it follows the button color natively. */
#comgate-card-form-container-button button span.cg-button-lock {
    display: inline-block;
    height: 17px;
    background-color: currentColor;
    -webkit-mask: var(--cf-lock-src) no-repeat center / contain;
    mask: var(--cf-lock-src) no-repeat center / contain;
}
#comgate-card-form-container-button button.disabled-btn,
#comgate-card-form-container-button button.disabled-btn:hover,
#comgate-card-form-container-button button.disabled-btn:active,
#comgate-card-form-container-button button.disabled-btn:focus {
    opacity: 0.65;
    cursor: default;
    background: var(--cf-button-bg, #16a34a);
    filter: none;
    transform: none;
    box-shadow: none;
}
#comgate-card-form-container-button button .cg-button-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cg-card-spin .6s linear infinite;
    vertical-align: middle;
}
.cg-card-icons {
    display: flex;
    gap: 6px;
    padding: 5px 0;
    margin-top: 8px;
    align-items: center;
}
.cg-card-icons .cg-card-icon {
    width: 30px;
    height: 19px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cg-card-icons .cg-card-icon img {
    width: 30px;
    height: 19px;
    object-fit: contain;
}
.cg-hidden { display: none !important; }
@keyframes cg-card-spin { to { transform: rotate(360deg); } }

/* ---------- Payment status banner ---------- */

.payment-status {
    display: flex;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
}
.payment-status[hidden] { display: none; }
.payment-status-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}
.payment-status-body {
    flex: 1;
    min-width: 0;
}
.payment-status-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
}
.payment-status-message {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.payment-status-retry {
    margin-top: 4px;
}
.payment-status--paid {
    border-color: #bbf7d0;
    background: #f0fdf4;
}
.payment-status--paid .payment-status-icon { background: var(--success); }
.payment-status--paid .payment-status-title { color: #14532d; }

.payment-status--cancelled {
    border-color: #fecaca;
    background: #fef2f2;
}
.payment-status--cancelled .payment-status-icon { background: var(--danger); }
.payment-status--cancelled .payment-status-title { color: #7f1d1d; }

.payment-status--pending {
    border-color: #bfdbfe;
    background: #eff6ff;
}
.payment-status--pending .payment-status-icon { background: #2563eb; }
.payment-status--pending .payment-status-title { color: #1e3a8a; }

.payment-status--error {
    border-color: #fed7aa;
    background: #fff7ed;
}
.payment-status--error .payment-status-icon { background: var(--warning); }
.payment-status--error .payment-status-title { color: #7c2d12; }

/* ---------- Settings toggle (floating) ---------- */

.settings-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.15s ease;
}
.settings-toggle:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ---------- Off-canvas panel ---------- */

.config-backdrop {
    display: none;
}

.config-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(var(--panel-w), 95vw);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow-y: auto;
    overflow-x: visible;
    padding: 24px 24px 48px;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.config-panel.is-open {
    transform: translateX(0);
}

.config-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.config-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
}
.lang-btn {
    background: transparent;
    border: 0;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn:hover { background: var(--surface-2); color: var(--text); }
.lang-btn.is-active {
    background: var(--primary);
    color: #fff;
}
.config-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.config-sub {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.config-sub code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.btn-icon {
    background: transparent;
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-icon:hover {
    background: var(--surface-2);
    color: var(--text);
}

.config-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-primary, .btn-ghost {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { padding: 4px 8px; font-size: 12px; }

/* ---------- Sections ---------- */

.section {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.section[open] { background: #fafbfc; }
.section > summary {
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    list-style: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before {
    content: '▸';
    margin-right: 8px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}
.section[open] > summary::before { transform: rotate(90deg); }
.section-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.section > .form-grid {
    padding: 4px 18px 18px;
}

.hint {
    margin: 0 18px 14px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
}
.hint code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--text);
}
.hint strong {
    color: var(--text);
    font-weight: 600;
}

/* ---------- Theme presets ---------- */

.theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 0 14px 14px;
}
.theme-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--theme-bg, var(--surface));
    color: var(--theme-text, var(--text));
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-transform: capitalize;
    transition: border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.theme-btn:hover {
    border-color: var(--theme-swatch);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-swatch) 15%, transparent);
}
.theme-btn:active { transform: translateY(1px); }
.theme-btn.is-active {
    border-color: var(--theme-swatch);
    box-shadow: 0 0 0 2px var(--theme-swatch) inset;
}
.theme-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--theme-swatch);
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ---------- Form fields ---------- */

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 1200px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
        column-gap: 14px;
        row-gap: 14px;
    }
}
.form-grid .field-full { grid-column: 1 / -1; }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 4px 0;
}
.field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.field-name {
    cursor: help;
    border-bottom: 1px dotted transparent;
}
.field-name:hover {
    border-bottom-color: var(--text-muted);
}

.field-info {
    cursor: help;
    font-size: 12px;
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    background: var(--surface-2);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.field-info:hover, .field-info:focus {
    background: var(--primary);
    color: #fff;
    outline: none;
}

/* Global tooltip — position: fixed, no clipping by panel */
.global-tooltip {
    position: fixed;
    background: #0f172a;
    color: #f1f5f9;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    max-width: 320px;
    width: max-content;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    text-align: left;
    left: 0;
    top: 0;
}
.global-tooltip.is-visible {
    visibility: visible;
}
.field-clear {
    margin-left: auto;
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0 4px;
}
.field-clear:hover { color: var(--danger); }

.field input[type="text"],
.field input[type="color"],
.field select,
.field textarea {
    font-family: inherit;
    font-size: 13px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
.field input[type="text"]:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field input[type="color"] {
    padding: 0;
    height: 38px;
    cursor: pointer;
}

.color-row {
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 8px;
    align-items: center;
}
.color-row input[type="color"] { width: 38px; height: 38px; }
.color-row input[type="text"] { width: 100%; font-family: var(--font-mono); font-size: 12px; }

/* ---------- Rules sub-sections ---------- */

.rule-group {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    background: var(--surface);
}
.rule-group > summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    list-style: none;
}
.rule-group > summary::-webkit-details-marker { display: none; }
.rule-group > summary::before {
    content: '▸';
    margin-right: 6px;
    color: var(--text-muted);
    font-size: 10px;
    transition: transform 0.15s ease;
}
.rule-group[open] > summary::before { transform: rotate(90deg); }
.rule-group .slot-selector {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}
.rule-group .slot-note {
    margin: 0 12px 10px;
    font-size: 11px;
}
.rule-group .form-grid {
    padding: 4px 12px 12px;
}

/* ---------- Events log ---------- */

.events-toolbar {
    padding: 0 14px 8px;
    display: flex;
    justify-content: flex-end;
}
.events-log {
    margin: 0 14px 14px;
    padding: 12px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    max-height: 240px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.events-log .ev-time { color: #64748b; }
.events-log .ev-paid { color: #4ade80; }
.events-log .ev-cancelled { color: #facc15; }
.events-log .ev-pending { color: #60a5fa; }
.events-log .ev-error { color: #f87171; }
.events-log .ev-info { color: #cbd5e1; }

/* ---------- Reload fade ---------- */
/* Mask white flash when settings change triggers window.location.reload().
   .is-loading is set in HTML and removed after JS applies the initial layout
   transform — without this, the cart visibly slides from center to its
   shifted position on every reload. */
.cart-col {
    opacity: 1;
    transition: opacity 0.22s ease;
}
body.is-loading .cart-col,
body.is-reloading .cart-col {
    opacity: 0;
}
body.is-loading .cart-col {
    transition: none;
}
body.is-reloading .cart-col {
    pointer-events: none;
}
body.is-loading .layout {
    transition: none;
}

/* ---------- Export code modal ---------- */
.export-modal {
    position: fixed;
    inset: 0;
    z-index: 200; /* above config panel (100) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.export-modal[hidden] {
    display: none;
}
.export-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.export-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 760px;
    max-height: 85vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.export-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.export-dialog-header h2 {
    margin: 0 0 4px;
    font-size: 17px;
}
.export-dialog-header p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}
.export-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px 0;
}
.export-tab {
    padding: 7px 14px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.export-tab.is-active {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.export-body {
    flex: 1;
    overflow: auto;
    padding: 0 20px 16px;
}
.export-pane {
    margin-top: 12px;
}
.export-pane[hidden] {
    display: none;
}
.export-block {
    position: relative;
    margin: 0;
}
.export-block pre {
    margin: 0;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre;
    overflow: auto;
}
.export-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.export-copy-btn {
    padding: 9px 18px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.export-copy-btn:hover {
    background: var(--primary-hover);
}
.export-copy-btn.is-copied {
    background: var(--success);
}
