:root {
    --page-card-radius: 20px;
    --page-card-border: 1px solid rgba(147, 197, 253, 0.14);
    --page-card-bg: linear-gradient(180deg, rgba(8, 22, 31, 0.98), rgba(7, 16, 24, 0.96));
    --page-card-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
    --page-card-shadow-strong: 0 30px 72px rgba(2, 8, 23, 0.32);
    --page-chip-bg: rgba(255, 255, 255, 0.04);
    --page-chip-border: 1px solid rgba(255, 255, 255, 0.08);
    --page-input-bg: rgba(14, 30, 41, 0.94);
    --page-button-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    --page-button-bg-active: linear-gradient(180deg, rgba(79, 209, 197, 0.18), rgba(255, 255, 255, 0.04));
    --page-button-border: 1px solid rgba(255, 255, 255, 0.08);
}

body.drawer-open,
body.rules-detail-open {
    overflow: hidden;
}

.page-shell,
.content,
.home-shell {
    position: relative;
    z-index: 1;
}

.page-shell,
.page-shell.page-shell-wide {
    padding-bottom: 96px;
}

.page-header,
.hero,
.home-hero {
    position: relative;
    overflow: hidden;
}

.header {
    position: sticky;
    top: 0;
    z-index: 48;
    padding: 14px var(--page-gutter) 10px;
    background: linear-gradient(180deg, rgba(7, 16, 24, 0.97), rgba(7, 16, 24, 0.92) 72%, rgba(7, 16, 24, 0.72));
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(147, 197, 253, 0.12);
}

.header-top {
    width: min(100%, var(--page-shell-max));
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.header .logo {
    gap: 4px;
}

.header .logo-label {
    font-size: 10px;
    letter-spacing: 2.4px;
}

.header .logo-title {
    font-size: clamp(20px, 2.4vw, 24px);
}

.page-header,
.hero {
    margin: 12px 0 16px;
    padding: 20px 18px;
    border-radius: 22px;
    border: 1px solid rgba(147, 197, 253, 0.14);
    background:
        radial-gradient(circle at top left, rgba(79, 209, 197, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(246, 173, 85, 0.10), transparent 34%),
        linear-gradient(155deg, rgba(8, 22, 31, 0.98), rgba(7, 16, 24, 0.98));
    box-shadow: var(--page-card-shadow-strong);
}

.page-header::after,
.hero::after {
    content: '';
    position: absolute;
    inset: auto -72px -112px auto;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 209, 197, 0.14), transparent 68%);
    pointer-events: none;
}

.page-header > *,
.hero > * {
    position: relative;
    z-index: 1;
}

.page-header,
.hero-top,
.hero-head,
.hero-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title,
.hero-title {
    font-size: clamp(24px, 3vw, 30px);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.page-copy,
.hero-copy,
.section-copy,
.panel-copy,
.hero-subtitle {
    margin-top: 8px;
    max-width: 820px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.68;
}

.hero-kicker,
.section-kicker,
.page-kicker {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.header-side,
.hero-actions,
.hero-meta {
    display: grid;
    gap: 10px;
    min-width: min(100%, 180px);
}

[id="environmentHeader"] {
    display: none !important;
}

.header-side,
.hero-actions {
    justify-items: end;
}

.hero-meta,
.hero-meta-line,
.refresh-info,
.hero-status,
.meta-line {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
    font-family: 'JetBrains Mono', monospace;
}

.page-actions,
.action-section,
.ops-row,
.hero-actions-row,
.toolbar,
.search-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
}

.page-top-section {
    margin-bottom: 16px;
}

.page-top-section[data-page-top-section="compact"] {
    margin: 8px 0 14px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(147, 197, 253, 0.12);
    background:
        radial-gradient(circle at right center, rgba(246, 173, 85, 0.10), transparent 34%),
        radial-gradient(circle at left center, rgba(79, 209, 197, 0.08), transparent 28%),
        linear-gradient(145deg, rgba(8, 22, 31, 0.98), rgba(7, 16, 24, 0.98));
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.page-top-section[data-page-top-section="compact"]::after {
    inset: auto -56px -80px auto;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(79, 209, 197, 0.1), transparent 70%);
}

.page-top-section-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.page-top-section-main {
    min-width: 0;
    flex: 1 1 420px;
}

.page-top-section-side {
    display: grid;
    gap: 10px;
    min-width: min(100%, 220px);
    justify-items: end;
}

.page-top-section-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
}

.page-top-section-meta {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.page-top-section-status {
    margin-top: 14px;
}

.page-top-section[data-page-top-section="compact"] .page-top-section-row {
    gap: 12px;
}

.page-top-section[data-page-top-section="compact"] .page-top-section-main {
    flex: 1 1 360px;
}

.page-top-section[data-page-top-section="compact"] .page-kicker {
    font-size: 10px;
    letter-spacing: 2px;
}

.page-top-section[data-page-top-section="compact"] .page-title {
    font-size: clamp(20px, 2vw, 24px);
    line-height: 1.12;
}

.page-top-section[data-page-top-section="compact"] .page-copy {
    margin-top: 6px;
    max-width: 640px;
    font-size: 12px;
    line-height: 1.55;
}

.page-toolbar-row,
.search-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.page-toolbar-row > *,
.search-toolbar > * {
    min-width: 0;
}

.page-toolbar-row #datePicker,
.search-toolbar #datePicker {
    flex: 1 1 280px;
    min-width: 0;
}

.page-toolbar-row .date-picker,
.search-toolbar .date-picker {
    width: 100%;
    min-width: 0;
    margin-bottom: 0;
}

.page-toolbar-row .refresh-control,
.search-toolbar .refresh-control {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.page-toolbar-row .refresh-select,
.search-toolbar .refresh-select {
    flex: 1 1 96px;
    min-width: 0;
    width: auto;
}

.page-toolbar-row .interval-filter,
.search-toolbar .interval-filter {
    flex: 0 1 88px;
    min-width: 72px;
}

.ops-row,
.action-section {
    margin-top: 16px;
}

.search-row {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.refresh-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toolbar,
.search-row,
.action-toolbar,
.ops-row {
    min-width: 0;
}

.summary-grid,
.metric-grid,
.panel-grid,
.dual-grid,
.chart-grid,
.overview-columns,
.ticket-grid,
.meta-grid,
.stats-grid {
    gap: 12px;
}

.summary-card,
.metric-card,
.surface-card,
.stat-card,
.detail-section,
.panel,
.section,
.group-card,
.config-item,
.config-section,
.chart-container,
.orders-section-card,
.rules-panel,
.latency-card,
.focus-card,
.focus-summary-card,
.snapshot-card,
.list-card,
.event-card,
.signal-card,
.indicator-card,
.sample-card,
.legend-card {
    background: var(--page-card-bg);
    border: var(--page-card-border);
    border-radius: var(--page-card-radius);
    box-shadow: var(--page-card-shadow);
}

.summary-card,
.metric-card,
.surface-card,
.stat-card,
.detail-section,
.chart-container,
.orders-section-card,
.rules-panel,
.latency-card,
.focus-card,
.focus-summary-card,
.snapshot-card,
.list-card,
.event-card,
.signal-card,
.indicator-card,
.sample-card,
.legend-card {
    padding: 14px;
}

.panel,
.section,
.group-card {
    overflow: hidden;
}

.panel-header,
.section-header,
.section-head,
.group-header,
.home-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px 12px;
}

.panel-header,
.section-header,
.section-head {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-title,
.section-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}

.panel-meta,
.section-meta,
.panel-subtitle {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.panel-body,
.section-body {
    padding: 14px 16px 16px;
}

.chip-row,
.hero-chips,
.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip,
.status-chip,
.hero-chip,
.list-chip,
.mini-chip,
.highlight-chip,
.warn-chip,
.chip-muted {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: var(--page-chip-border);
    background: var(--page-chip-bg);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.status-chip .dot,
.chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 12px currentColor;
}

:where(
    .refresh-btn,
    .action-btn,
    .toolbar-btn,
    .btn,
    .btn-login,
    .ops-btn,
    .home-inline-btn,
    .home-ghost-btn,
    .mini-btn,
    .save-btn,
    .reset-all-btn,
    .reset-btn,
    .apply-date-btn,
    .date-range-btn,
    .filter-btn,
    .btn-secondary,
    .back-btn,
    .symbol-page-btn,
    .auth-banner-btn,
    .home-tool-chip,
    .home-target-action,
    .config-tab,
    .stepper-btn,
    .status-tab,
    .filter-chip,
    .subview-tab,
    .domain-tab,
    .rules-rail-btn,
    .chart-layer-btn,
    .chart-range-btn,
    .btn-view,
    .btn-details,
    .btn-dismiss,
    .btn-execute,
    .btn-chart,
    .btn-pagechart,
    .btn-cancel,
    .btn-close,
    .load-more-btn
) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 14px;
    border-radius: 12px;
    border: var(--page-button-border);
    background: var(--page-button-bg);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

:where(
    .refresh-btn,
    .action-btn,
    .toolbar-btn,
    .btn,
    .btn-login,
    .ops-btn,
    .home-inline-btn,
    .home-ghost-btn,
    .mini-btn,
    .save-btn,
    .reset-all-btn,
    .reset-btn,
    .apply-date-btn,
    .date-range-btn,
    .filter-btn,
    .btn-secondary,
    .back-btn,
    .symbol-page-btn,
    .auth-banner-btn,
    .home-tool-chip,
    .home-target-action,
    .config-tab,
    .stepper-btn,
    .status-tab,
    .filter-chip,
    .subview-tab,
    .domain-tab,
    .rules-rail-btn,
    .chart-layer-btn,
    .chart-range-btn,
    .btn-view,
    .btn-details,
    .btn-dismiss,
    .btn-execute,
    .btn-chart,
    .btn-pagechart,
    .btn-cancel,
    .btn-close,
    .load-more-btn
):hover {
    transform: translateY(-1px);
    border-color: rgba(99, 179, 237, 0.34);
    background: var(--page-button-bg-active);
    box-shadow: 0 10px 24px rgba(2, 8, 23, 0.16);
}

:where(
    .refresh-btn,
    .action-btn,
    .toolbar-btn,
    .btn,
    .btn-login,
    .ops-btn,
    .home-inline-btn,
    .home-ghost-btn,
    .mini-btn,
    .save-btn,
    .reset-all-btn,
    .reset-btn,
    .apply-date-btn,
    .date-range-btn,
    .filter-btn,
    .btn-secondary,
    .back-btn,
    .symbol-page-btn,
    .auth-banner-btn,
    .home-tool-chip,
    .home-target-action,
    .config-tab,
    .stepper-btn,
    .status-tab,
    .filter-chip,
    .subview-tab,
    .domain-tab,
    .rules-rail-btn,
    .chart-layer-btn,
    .chart-range-btn,
    .btn-view,
    .btn-details,
    .btn-dismiss,
    .btn-execute,
    .btn-chart,
    .btn-pagechart,
    .btn-cancel,
    .btn-close,
    .load-more-btn
):disabled {
    opacity: 0.62;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

.refresh-btn.page-refresh-trigger.page-refresh-trigger,
.toolbar-btn.page-refresh-trigger.page-refresh-trigger,
.btn.page-refresh-trigger.page-refresh-trigger {
    border-color: rgba(99, 179, 237, 0.28);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.18), rgba(255, 255, 255, 0.04));
    color: #dbeafe;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 12px 26px rgba(2, 8, 23, 0.14);
}

.refresh-btn.page-refresh-trigger.page-refresh-trigger:hover,
.toolbar-btn.page-refresh-trigger.page-refresh-trigger:hover,
.btn.page-refresh-trigger.page-refresh-trigger:hover {
    border-color: rgba(99, 179, 237, 0.42);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.28), rgba(255, 255, 255, 0.06));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 14px 30px rgba(2, 8, 23, 0.18);
}

.refresh-btn.page-refresh-trigger.page-refresh-trigger:active,
.toolbar-btn.page-refresh-trigger.page-refresh-trigger:active,
.btn.page-refresh-trigger.page-refresh-trigger:active {
    transform: translateY(0);
    border-color: rgba(125, 211, 252, 0.5);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.24), rgba(255, 255, 255, 0.05));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 8px 18px rgba(2, 8, 23, 0.14);
}

.refresh-btn.page-refresh-trigger.page-refresh-trigger:disabled,
.toolbar-btn.page-refresh-trigger.page-refresh-trigger:disabled,
.btn.page-refresh-trigger.page-refresh-trigger:disabled {
    border-color: rgba(99, 179, 237, 0.16);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.1), rgba(255, 255, 255, 0.03));
}

.refresh-btn.page-refresh-trigger.page-refresh-trigger.is-compact {
    min-width: 42px;
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1;
}

.refresh-control > .refresh-btn.page-refresh-trigger.page-refresh-trigger.is-compact {
    flex: 0 0 auto;
}

:where(.btn.primary, .toolbar-btn.primary, .action-primary, .ops-btn.primary, .save-btn, .btn-login) {
    border-color: rgba(99, 179, 237, 0.34);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.24), rgba(255, 255, 255, 0.05));
}

:where(.btn.danger, .action-danger, .ops-btn.danger, .reset-all-btn) {
    border-color: rgba(252, 129, 129, 0.34);
    background: linear-gradient(180deg, rgba(252, 129, 129, 0.18), rgba(255, 255, 255, 0.04));
}

:where(.btn.warn, .ops-btn.warn) {
    border-color: rgba(246, 173, 85, 0.34);
    background: linear-gradient(180deg, rgba(246, 173, 85, 0.18), rgba(255, 255, 255, 0.04));
}

:where(.ops-btn.trade, .btn.trade) {
    border-color: rgba(72, 187, 120, 0.34);
    background: linear-gradient(180deg, rgba(72, 187, 120, 0.18), rgba(255, 255, 255, 0.04));
}

:where(
    .status-tab.active,
    .filter-chip.active,
    .subview-tab.active,
    .domain-tab.active,
    .rules-rail-btn.active,
    .chart-layer-btn.active,
    .chart-range-btn.active,
    .btn-view.active
) {
    border-color: rgba(99, 179, 237, 0.4);
    background: linear-gradient(180deg, rgba(99, 179, 237, 0.24), rgba(255, 255, 255, 0.05));
    color: var(--text);
    box-shadow: 0 10px 24px rgba(2, 8, 23, 0.18);
}

:where(
    .search-input,
    .ticket-input,
    .ticket-select,
    .config-input,
    .symbol-input,
    .date-input,
    .interval-select,
    .refresh-select,
    .stepper-input,
    select,
    input[type="text"],
    input[type="date"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    textarea
) {
    min-height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(99, 179, 237, 0.14);
    background: var(--page-input-bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

:where(
    .search-input,
    .ticket-input,
    .ticket-select,
    .config-input,
    .symbol-input,
    .date-input,
    .interval-select,
    .refresh-select,
    .stepper-input,
    select,
    input[type="text"],
    input[type="date"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    textarea
):focus {
    border-color: rgba(99, 179, 237, 0.36);
    box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.12);
}

.section-scroll,
.section-scroll-body,
.panel-scroll-body,
.card-scroll-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(79, 209, 197, 0.24) transparent;
}

.page-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 16, 24, 0.78);
    backdrop-filter: blur(10px);
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.page-loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loading-card {
    width: min(440px, 100%);
    padding: 20px 18px;
    border-radius: 18px;
    border: 1px solid rgba(147,197,253,0.14);
    background:
        radial-gradient(circle at top right, rgba(246,173,85,0.14), transparent 36%),
        radial-gradient(circle at left center, rgba(79,209,197,0.10), transparent 28%),
        linear-gradient(180deg, rgba(8,22,31,0.98), rgba(14,30,41,0.94));
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.28);
}

.page-loading-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.page-loading-copy {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.page-loading-bars {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.page-loading-bar {
    position: relative;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
}

.page-loading-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(79,209,197,0.42), transparent);
    animation: ibkrPageLoadingShimmer 1.35s infinite;
}

.page-loading-bar:nth-child(2)::after {
    animation-delay: 0.18s;
}

.page-loading-bar:nth-child(3)::after {
    animation-delay: 0.36s;
}

@media (max-width: 900px) {
    .page-header,
    .hero {
        padding: 18px 16px;
    }

    .page-top-section[data-page-top-section="compact"] {
        padding: 14px 16px;
        border-radius: 16px;
    }

    .page-top-section[data-page-top-section="compact"] .page-title {
        font-size: 20px;
    }

    .header-side,
    .hero-actions,
    .page-top-section-side {
        width: 100%;
        justify-items: start;
    }

    .page-top-section-actions {
        justify-content: flex-start;
    }

    .page-top-section-meta {
        text-align: left;
    }

    .panel-header,
    .section-header,
    .section-head,
    .group-header {
        padding: 14px 14px 10px;
    }

    .panel-body,
    .section-body {
        padding: 12px 14px 14px;
    }
}

@media (max-width: 640px) {
    .page-title,
    .hero-title {
        font-size: 22px;
    }

    .page-copy,
    .hero-copy {
        font-size: 12px;
    }

    .page-header,
    .hero {
        border-radius: 20px;
    }

    :where(
        .refresh-btn,
        .action-btn,
        .toolbar-btn,
        .btn,
        .ops-btn,
        .mini-btn,
        .save-btn,
        .reset-all-btn,
        .reset-btn,
        .apply-date-btn,
        .date-range-btn,
        .filter-btn,
        .btn-secondary,
        .back-btn,
        .symbol-page-btn,
        .auth-banner-btn,
        .config-tab,
        .stepper-btn
    ) {
        width: 100%;
    }

    .refresh-control,
    .page-actions,
    .action-section,
    .ops-row,
    .toolbar,
    .search-toolbar,
    .page-toolbar-row {
        width: 100%;
    }

    .page-toolbar-row #datePicker,
    .search-toolbar #datePicker,
    .page-toolbar-row .refresh-control,
    .search-toolbar .refresh-control {
        flex: 1 1 100%;
        width: 100%;
    }

    .page-toolbar-row .refresh-control,
    .search-toolbar .refresh-control {
        justify-content: stretch;
    }

    .refresh-control > .refresh-btn,
    .refresh-control > .refresh-btn.page-refresh-trigger {
        width: auto;
        flex: 0 0 auto;
    }

    .page-toolbar-row .refresh-select,
    .search-toolbar .refresh-select,
    .page-toolbar-row .interval-filter,
    .search-toolbar .interval-filter {
        flex: 1 1 0;
        width: auto;
    }

    .hero-meta,
    .panel-meta,
    .section-meta,
    .page-top-section-meta {
        text-align: left;
    }
}

@keyframes ibkrPageLoadingShimmer {
    100% { transform: translateX(100%); }
}
