.helpPopup {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid var(--border-color);
    background: var(--surface-elevated);
    color: var(--text-primary);
    padding: 20px;
    z-index: 100020;

    max-width: 80vw;
    max-height: 80vh;

    width: 600px;
    height: auto;

    overflow: auto;

    box-shadow: var(--shadow-popup);
    border-radius: var(--radius-lg, 12px);
    font-family: var(--font-ui, ui-sans-serif, system-ui, sans-serif);
    font-size: 14px;
}

.helpPopup:has(table) {
    width: min(920px, 90vw);
}

.helpPopup:has(#dataset-info-body) {
    width: 80%;
    max-width: 80vw;
}

#dataset-info-body {
    padding: 16px;
    border-radius: 8px;
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

#dataset-info-body > :first-child {
    margin-top: 0;
}

#dataset-info-body > :last-child {
    margin-bottom: 0;
}

#dataset-info-body h1,
#dataset-info-body h2,
#dataset-info-body h3,
#dataset-info-body h4 {
    margin: 0.6em 0 0.3em;
}

#dataset-info-body h1 { font-size: 1.25em; }
#dataset-info-body h2 { font-size: 1.15em; }
#dataset-info-body h3,
#dataset-info-body h4 { font-size: 1.05em; }

#dataset-info-body p,
#dataset-info-body ul,
#dataset-info-body ol,
#dataset-info-body pre,
#dataset-info-body blockquote {
    margin: 0.35em 0;
}

#dataset-info-body ul,
#dataset-info-body ol {
    padding-left: 1.2em;
}

#dataset-info-body img[alt="Insights button"] {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: text-bottom;
    margin: 0 4px;
}

#dataset-info-body code {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 0.92em;
}

#dataset-info-body pre {
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    background: var(--surface-elevated);
}

#dataset-info-body pre code {
    font-size: inherit;
}

#dataset-info-body blockquote {
    margin-left: 0;
    padding-left: 12px;
    border-left: 3px solid var(--border-color);
}

.dataset-info-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.dataset-info-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.dataset-info-toggle[hidden] {
    display: none !important;
}

.dataset-info-toggle input[type="checkbox"] {
    accent-color: var(--text-accent);
}

.help-guide-print {
    position: absolute;
    right: 36px;
    top: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill, 999px);
    background: var(--surface-muted);
    cursor: pointer;
}

.help-guide-print[hidden] {
    display: none !important;
}

.help-guide-print img {
    display: block;
    width: 18px;
    height: 18px;
    filter: var(--action-button-foreground-filter);
}

#helpPopup:has(#helpGuidePrint:not([hidden])) #helpTopic {
    padding-right: 56px;
}

@media print {
    body.is-printing-help-guide .container > *:not(#helpPopup) {
        display: none !important;
    }

    body.is-printing-help-guide #main-viewport,
    body.is-printing-help-guide #main-viewport * {
        display: none !important;
        visibility: hidden !important;
    }

    body.is-printing-help-guide #helpPopup,
    body.is-printing-help-guide #helpPopup * {
        visibility: visible !important;
    }

    body.is-printing-help-guide #helpPopup {
        display: block !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        background: #fff !important;
        color: #111 !important;
    }

    body.is-printing-help-guide #helpPopup .popup-close-button,
    body.is-printing-help-guide #helpPopup .help-guide-print,
    body.is-printing-help-guide #helpPopup .dataset-info-footer {
        display: none !important;
    }

    body.is-printing-help-guide #dataset-info-body,
    body.is-printing-help-guide #helpTopic {
        border: none !important;
        background: transparent !important;
        color: #111 !important;
        overflow: visible !important;
        padding-right: 0 !important;
    }
}

.popup-close-button {
    cursor: pointer;
    position: absolute;
    right: 10px;
    top: 5px;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
}

.popup-close-button:hover {
    color: var(--text-primary);
}

#productDescriptionPopup h2 {
    padding-right: 56px;
}

#product-description-edit-btn {
    position: absolute;
    top: 8px;
    right: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.5;
    color: var(--text-secondary);
    line-height: 1;
}

#product-description-edit-btn:hover {
    opacity: 1;
    color: var(--text-primary);
}

html[data-theme='dark'] #product-description-edit-btn img {
    filter: invert(1);
}

#product-description-edit-area {
    display: none;
    margin: 1em 0;
    box-sizing: border-box;
}

#product-description-textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    font-size: inherit;
    font-family: inherit;
    background: var(--surface-muted, var(--surface-elevated));
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    box-sizing: border-box;
    display: block;
    line-height: 1.5;
}

.product-description-edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
}

.product-description-edit-actions button {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.product-description-edit-actions .product-description-save-btn {
    background: var(--accent-color, #4a90d9);
    color: #fff;
    border: none;
}

.helpPopup h1,
.helpPopup h2,
.helpPopup h3,
.helpPopup h4,
.helpPopup p,
.helpPopup li,
.helpPopup label,
.helpPopup strong,
.helpPopup b {
    color: inherit;
}

.helpPopup a {
    color: var(--link-color);
}

.helpPopup .highlight {
    background-color: var(--surface-hover-soft) !important;
    color: var(--text-primary) !important;
}

.helpPopup .contact {
    background-color: var(--surface-bg) !important;
    border-left-color: var(--theme-hover-border) !important;
}

.helpPopup .last-updated {
    color: var(--text-secondary) !important;
}

.helpPopup hr {
    border-color: var(--border-color);
}

.helpPopup table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 14px;
    font-size: 13px;
}

.helpPopup th,
.helpPopup td {
    border-bottom: 1px solid var(--border-color);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.helpPopup th {
    font-weight: 600;
}

.helpPopup code {
    font-size: 12px;
}
