:root {
    --shell-bg: linear-gradient(180deg, #f4f7fb 0%, #edf2f7 100%);
    --shell-card: rgba(255, 255, 255, 0.82);
    --shell-border: rgba(15, 23, 42, 0.08);
    --shell-accent: #1749b1;
    --shell-accent-soft: #dfe8ff;
    --shell-text: #14213d;
    --shell-muted: #52627a;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Georgia, "Times New Roman", serif;
    background: var(--shell-bg);
    color: var(--shell-text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.shell-loading {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-shell-bar {
    backdrop-filter: blur(16px);
    background: rgba(20, 33, 61, 0.92) !important;
}

.app-shell-topbar {
    position: relative;
    width: 100%;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-shell-left,
.app-shell-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.app-shell-app-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-shell-title-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.app-shell-title-stack {
    line-height: 1;
}

.app-logo {
    display: block;
    flex: 0 0 auto;
}

.app-logo-topbar {
    width: 56px;
    height: 56px;
}

.app-logo-login {
    width: 54px;
    height: 54px;
    margin-bottom: 4px;
}

.app-shell-version {
    opacity: 0.72;
}

.app-shell-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.app-shell-center > * {
    pointer-events: auto;
}

.app-shell-org-button {
    text-transform: none;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.app-shell-top-button {
    text-transform: none;
}

.topbar-btn {
    min-width: 44px;
    padding: 4px 4px;
    text-transform: none;
}

.topbar-button-stack {
    line-height: 1;
}

.topbar-icon-caption {
    opacity: 0.82;
    margin-top: 2px;
    text-transform: none;
}

.topbar-menu-caption {
    opacity: 0.82;
    margin-top: -6px;
    text-transform: none;
}

.topbar-user-caption {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mud-popover .mud-list,
.mud-popover .mud-list-item,
.mud-popover .mud-list-item-text,
.mud-popover .mud-typography {
    color: var(--mud-palette-text-primary) !important;
}

.topbar-menu-readonly {
    min-width: 220px;
    cursor: default;
    color: var(--mud-palette-text-primary) !important;
}

.topbar-menu-readonly:hover {
    background-color: transparent !important;
}

.topbar-menu-title {
    color: var(--mud-palette-text-primary) !important;
    overflow-wrap: anywhere;
}

.topbar-menu-muted {
    color: var(--mud-palette-text-secondary) !important;
    overflow-wrap: anywhere;
}

.config-menu-item {
    min-width: 180px;
}

.user-menu-item {
    max-width: 280px;
}

.app-shell-main {
    min-height: calc(100vh - 64px);
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #fff;
}

.auth-card {
    width: min(100%, 400px);
    border: 1px solid var(--shell-border);
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.22);
}

.auth-footer {
    margin-top: 16px;
    text-align: center;
    color: var(--shell-muted);
}

.login-divider {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    width: 100%;
}

.login-divider .mud-typography {
    white-space: nowrap;
    min-width: max-content;
}

.auth-provider-button {
    min-width: 130px;
    gap: 6px;
    text-transform: uppercase;
}

.auth-provider-logo {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-empty-state {
    min-height: 360px;
    border-radius: 8px;
    border: 1px dashed var(--shell-border);
    background: var(--shell-card);
    display: grid;
    place-items: center;
    text-align: center;
    gap: 12px;
    padding: 32px;
}

.dashboard-filter-panel {
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
    border-radius: 8px;
    padding: 12px;
}

.status-card {
    min-height: 360px;
    border-radius: 8px;
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
}

.analysis-metric {
    border: 1px solid var(--shell-border);
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent);
    border-radius: 8px;
    padding: 12px;
    min-height: 82px;
}

.analysis-price-chart {
    display: grid;
    gap: 8px;
    margin: 12px 0 16px;
}

.analysis-price-chart svg {
    width: 100%;
    height: 220px;
    display: block;
    border: 1px solid var(--shell-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--mud-palette-surface) 92%, transparent);
}

.analysis-price-chart-grid {
    fill: none;
    stroke: color-mix(in srgb, var(--shell-border) 70%, transparent);
    stroke-width: 1;
}

.analysis-price-chart-area {
    fill: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
    stroke: none;
}

.analysis-price-chart-line {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.analysis-price-chart-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.84rem;
    flex-wrap: wrap;
}

.shell-empty-state {
    min-height: 360px;
    border-radius: 8px;
    border: 1px dashed var(--shell-border);
    background: var(--shell-card);
    display: grid;
    place-items: center;
    text-align: center;
    gap: 12px;
    padding: 32px;
}

.dashboard-panel {
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
    border-radius: 8px;
    padding: 14px;
    min-height: 520px;
}

.dashboard-list-item {
    border: 1px solid var(--shell-border);
    background: color-mix(in srgb, var(--mud-palette-surface) 90%, transparent);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
}

.dashboard-list-item:hover {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 44%, var(--shell-border));
    background: color-mix(in srgb, var(--mud-palette-primary) 7%, var(--mud-palette-surface));
}

.dashboard-item-header,
.dashboard-item-footer,
.dashboard-chip-row {
    gap: 8px;
    flex-wrap: wrap;
}

.orgs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.org-card {
    border-radius: 20px;
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
}

.log-level-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.log-pane {
    height: 70vh;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
}

.log-detail-pane {
    padding: 12px;
}

.log-entry-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-entry-detail {
    white-space: pre-wrap;
    color: var(--mud-palette-text-primary);
}

.log-entry-row {
    border-left: 4px solid transparent;
    color: var(--mud-palette-text-primary) !important;
}

.log-entry-row .mud-typography {
    color: var(--mud-palette-text-primary) !important;
}

.log-entry-selected {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-surface)) !important;
}

.log-entry-error {
    border-left-color: var(--mud-palette-error);
    background-color: color-mix(in srgb, var(--mud-palette-error) 8%, var(--mud-palette-surface)) !important;
}

.log-entry-warning {
    border-left-color: var(--mud-palette-warning);
    background-color: color-mix(in srgb, var(--mud-palette-warning) 8%, var(--mud-palette-surface)) !important;
}

.log-entry-information {
    border-left-color: var(--mud-palette-success);
    background-color: color-mix(in srgb, var(--mud-palette-success) 8%, var(--mud-palette-surface)) !important;
}

.log-entry-activity {
    border-left-color: var(--mud-palette-info);
    background-color: color-mix(in srgb, var(--mud-palette-info) 8%, var(--mud-palette-surface)) !important;
}

.research-header {
    gap: 16px;
}

.research-search-band,
.research-panel {
    border: 1px solid var(--shell-border);
    background: var(--shell-card);
    border-radius: 8px;
    padding: 16px;
}

.research-search-row {
    width: 100%;
}

.research-search-input {
    flex: 1 1 320px;
}

.research-result-list {
    max-height: 62vh;
    overflow: auto;
}

.research-result-selected {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent) !important;
}

.research-empty {
    min-height: 420px;
    text-align: center;
}

.research-price-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.research-range-group {
    flex: 0 1 auto;
}

.research-range-group .mud-button-root {
    min-width: 54px;
}

.research-range-group .mud-button-root.research-range-active,
.research-range-group .research-range-active {
    font-weight: 800 !important;
    font-size: 1.02rem !important;
    letter-spacing: 0.01em;
    background-color: var(--mud-palette-success) !important;
    color: var(--mud-palette-success-text) !important;
    border-color: var(--mud-palette-success) !important;
}

.research-chart {
    min-height: 210px;
}

.research-price-table {
    max-height: 420px;
    overflow: auto;
}

.research-section-header {
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.compact-status-card {
    min-height: 0;
}

.cursor-pointer .mud-table-row {
    cursor: pointer;
}

.ai-pred-checklist {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--shell-border);
    border-radius: 4px;
    padding: 4px 8px;
}

.research-collapse-all {
    align-self: flex-start;
}

.research-profile-stats {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
}

.research-evidence-card {
    border: 1px solid var(--shell-border);
    background: color-mix(in srgb, var(--mud-palette-surface) 86%, transparent);
    border-radius: 8px;
    padding: 12px;
}

.research-inline-form {
    flex-wrap: wrap;
}

.research-inline-input {
    flex: 1 1 220px;
}

.research-topic-query {
    flex: 1 1 360px;
}

.research-evidence-table {
    max-height: 360px;
    overflow: auto;
}

.research-ai-result {
    white-space: pre-wrap;
}

.research-topic-link-input {
    flex: 1 1 220px;
}

.research-topic-link-select {
    flex: 1 1 240px;
}

.research-topic-link-relationship {
    flex: 0 1 160px;
}

.instrument-analysis-grid .status-card {
    height: 100%;
}

.instrument-selector {
    width: 100%;
}

.instrument-selection-empty {
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.instrument-description-panel,
.instrument-price-panel,
.instrument-price-table-panel {
    min-height: 610px;
}

.instrument-summary-line {
    min-width: 0;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    white-space: nowrap;
}

.instrument-analysis-grid .instrument-summary-card {
    height: auto;
    min-height: 0;
}

.instrument-description-copy {
    margin-top: 10px;
    line-height: 1.65;
    color: var(--mud-palette-text-secondary);
}

.instrument-facts {
    display: grid;
    gap: 14px;
}

.instrument-facts > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
}

.instrument-facts span {
    color: var(--mud-palette-text-secondary);
    font-size: 0.8rem;
}

.instrument-facts strong {
    text-align: right;
    overflow-wrap: anywhere;
}

.instrument-latest-price {
    margin: 4px 0;
}

.instrument-chart-header {
    flex-wrap: wrap;
}

.instrument-range-group .mud-button-root {
    min-width: 52px;
}

.instrument-range-group .instrument-range-active {
    background-color: var(--mud-palette-success) !important;
    border-color: var(--mud-palette-success) !important;
    color: var(--mud-palette-success-text) !important;
    font-weight: 700;
}

.instrument-chart-empty {
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--mud-palette-text-secondary);
}

.analysis-tool-grid > .mud-grid-item {
    min-width: 0;
}

.analysis-tool-row {
    min-width: 0;
    flex-wrap: nowrap !important;
    padding: 4px 6px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
}

.analysis-tool-label {
    flex: 0 0 auto;
    white-space: nowrap;
}

.analysis-tool-input {
    min-width: 64px;
    flex: 1 1 86px;
}

.analysis-tool-window {
    min-width: 54px;
}

.analysis-tool-periods {
    min-width: 76px;
}

.analysis-tool-spacer {
    flex: 1 1 auto;
}

.analysis-tool-row .mud-icon-button {
    flex: 0 0 auto;
}

@media (max-width: 960px) {
    .app-shell-topbar {
        min-height: 104px;
        align-items: flex-start;
        padding-top: 8px;
        flex-wrap: wrap;
    }

    .app-shell-center {
        position: static;
        transform: none;
        order: 3;
        width: 100%;
        display: flex;
        justify-content: center;
        padding-bottom: 8px;
    }

    .app-shell-right {
        margin-left: auto;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .app-shell-app-group {
        gap: 6px;
    }

    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .research-search-row,
    .research-header,
    .research-price-actions,
    .research-section-header,
    .research-inline-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .instrument-description-panel,
    .instrument-price-panel,
    .instrument-price-table-panel {
        min-height: auto;
    }

    .instrument-chart-header {
        align-items: stretch !important;
        flex-direction: column !important;
    }

    .instrument-range-group {
        overflow-x: auto;
    }

    .analysis-tool-row {
        width: 100%;
    }
}
