#otc-contract-panel-host {
    display: contents;
}

/* Radzen can transform the page body. Keep the drag coordinates relative to the viewport. */
html body:has(.otc-contract-panel-layer) .rz-body.app-body {
    transform: none !important;
}

.otc-contract-panel-layer {
    position: fixed;
    inset: 0;
    z-index: 1001;
    pointer-events: none;
}

.otc-contract-panel {
    position: absolute;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: min(22rem, calc(100vw - 12px));
    max-width: calc(100vw - 12px);
    min-height: min(12rem, calc(100dvh - 64px));
    max-height: calc(100dvh - 12px);
    padding-bottom: 5px;
    overflow: hidden;
    resize: both;
    pointer-events: auto;
    color: var(--otc-text);
    background: var(--otc-surface);
    border: 1px solid var(--otc-border-strong);
    border-radius: 6px;
    box-shadow: var(--otc-shadow-raised);
}

.otc-contract-panel[hidden] {
    display: none;
}

.otc-contract-panel-layer:has(.otc-contract-panel-switcher:not([hidden])) .otc-contract-panel {
    max-height: calc(100dvh - 64px);
}

/* Once measured, the frame supplies its own height. A native resize sets the panel's inline height. */
.otc-contract-panel:has(> .otc-contract-panel__frame:not([height])) {
    height: var(--otc-contract-panel-opening-height);
}

.otc-contract-panel.is-active {
    border-color: var(--otc-primary);
    box-shadow: var(--otc-shadow-dialog);
}

.otc-contract-panel__header {
    display: flex;
    align-items: center;
    flex: none;
    color: var(--otc-text);
    background: var(--otc-surface-subtle);
    border-bottom: 1px solid var(--otc-border);
}

.otc-contract-panel.is-active .otc-contract-panel__header {
    background: var(--otc-primary-soft);
}

.otc-contract-panel .otc-contract-panel__handle {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 8px 12px;
    overflow: hidden;
    font: 600 14px/20px var(--otc-control-font-family, "Segoe UI", sans-serif);
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.otc-contract-panel__handle:active {
    cursor: grabbing;
}

.otc-contract-panel__minimize,
.otc-contract-panel__close,
.otc-contract-panel__tab {
    color: var(--otc-text);
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}

.otc-contract-panel__minimize,
.otc-contract-panel__close {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    font: 20px/1 sans-serif;
}

.otc-contract-panel__close {
    margin-right: 4px;
}

.otc-contract-panel__minimize:hover,
.otc-contract-panel__close:hover,
.otc-contract-panel__tab:hover {
    background: var(--otc-primary-soft-hover);
}

.otc-contract-panel-layer :is(button, h2):focus-visible {
    outline: 2px solid var(--otc-primary);
    outline-offset: -2px;
}

.otc-contract-panel__frame {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
    background: var(--otc-surface);
}

.otc-contract-panel-layer:has(.otc-contract-panel.is-dragging) iframe {
    pointer-events: none;
}

.otc-contract-panel-switcher:not([hidden]) {
    position: absolute;
    bottom: 6px;
    left: 50%;
    display: flex;
    gap: 3px;
    max-width: calc(100% - 12px);
    padding: 3px;
    overflow: auto;
    transform: translateX(-50%);
    pointer-events: auto;
    background: var(--otc-surface);
    border: 1px solid var(--otc-border-strong);
    border-radius: 5px;
    box-shadow: var(--otc-shadow-raised);
}

.otc-contract-panel__tab {
    flex: 0 0 auto;
    max-width: min(21rem, 40vw);
    padding: 4px 10px;
    overflow: hidden;
    font: 500 13px/20px var(--otc-control-font-family, "Segoe UI", sans-serif);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.otc-contract-panel__tab[aria-pressed="true"] {
    color: var(--otc-primary);
    background: var(--otc-primary-soft);
    border-color: var(--otc-primary);
}

.otc-contract-panel__tab[aria-expanded="false"] {
    border-style: dashed;
    border-color: var(--otc-border-strong);
}
