html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Inter", "Aptos", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-shell {
    min-height: 100vh;
}

a {
    text-decoration: none;
}

/* ── App bar ── */

.top-shell {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    color: inherit !important;
    text-decoration: none !important;
}

.brand-link:hover {
    opacity: 0.92;
}

.brand-title {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Typography helpers ── */

.drawer-kicker,
.section-kicker,
.metric-label {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
}

/* ── Layout ── */

.main-content-shell {
    padding: 1.5rem 1.25rem 3rem;
}

.page-grid {
    margin-top: 0.25rem;
    row-gap: 0.75rem !important;
}

/* ── Panels ── */

.hero-panel,
.data-panel,
.scenario-paper,
.metric-tile,
.empty-state-panel {
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

.hero-panel {
    padding: 1.5rem 1.75rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--mud-palette-primary);
}

.data-panel,
.scenario-paper,
.empty-state-panel {
    padding: 1.25rem 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* ── Section helpers ── */

.compact-grid {
    margin-top: 0.25rem;
}

.section-divider {
    margin: 1.25rem 0;
}

/* ── Metric tiles ── */

.metric-tile {
    padding: 1rem 1.25rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.35rem;
}

.metric-helper {
    opacity: 0.6;
    font-size: 0.78rem;
}

.accent-primary {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.3) !important;
    background: rgba(var(--mud-palette-primary-rgb), 0.03) !important;
}

.accent-secondary {
    border-color: rgba(var(--mud-palette-secondary-rgb), 0.3) !important;
    background: rgba(var(--mud-palette-secondary-rgb), 0.03) !important;
}

/* ── Scenario cards ── */

.scenario-head,
.scenario-footer {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
}

.scenario-head {
    margin-bottom: 0.65rem;
}

.scenario-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* ── Summary tables ── */

.summary-table td {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    font-size: 0.88rem;
}

.summary-table td:last-child {
    text-align: right;
    font-weight: 700;
}

.comparison-table-wrapper {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
}

.comparison-table thead th {
    padding: 0.9rem 0.85rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-secondary);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    vertical-align: bottom;
    white-space: nowrap;
}

.comparison-table tbody td {
    padding: 0.85rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    font-size: 0.92rem;
    vertical-align: middle;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
    min-width: 220px;
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--mud-palette-surface);
}

.comparison-table tbody td:first-child {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.comparison-table th:not(:first-child),
.comparison-table td:not(:first-child) {
    min-width: 220px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.comparison-table tbody tr:hover td {
    background: rgba(var(--mud-palette-primary-rgb), 0.04);
}

.comparison-table tbody tr:hover td:first-child {
    background: var(--mud-palette-surface);
}

.comparison-deal-header {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.comparison-deal-title {
    color: var(--mud-palette-text-primary);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
}

.comparison-deal-subtitle {
    color: var(--mud-palette-text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.realtor-offer-sheet {
    padding: 1.2rem;
    border: 1px solid rgba(var(--mud-palette-primary-rgb), 0.14);
    background:
        linear-gradient(180deg, rgba(var(--mud-palette-primary-rgb), 0.045), rgba(var(--mud-palette-primary-rgb), 0.015)),
        var(--mud-palette-surface);
}

.realtor-offer-notes {
    padding-top: 0.35rem;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.pipeline-lane {
    min-height: 100%;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.pipeline-lane-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.pipeline-chip {
    width: fit-content;
    margin-bottom: 0;
    color: #0f172a !important;
    font-weight: 700;
}

.pipeline-chip-researching {
    background: #bfdbfe !important;
}

.pipeline-chip-touring {
    background: #fde68a !important;
}

.pipeline-chip-toured {
    background: #fdba74 !important;
}

.pipeline-chip-offered {
    background: #c4b5fd !important;
}

.pipeline-chip-under-contract {
    background: #86efac !important;
}

.pipeline-chip-passed {
    background: #cbd5e1 !important;
}

.pipeline-card {
    cursor: pointer;
    min-height: unset;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.pipeline-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-right: 0.15rem;
    border-radius: 0.55rem;
    cursor: grab;
    color: var(--mud-palette-text-secondary);
    transition: background 120ms ease, color 120ms ease;
}

.pipeline-drag-handle:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
    color: var(--mud-palette-primary);
}

.pipeline-drag-handle:active {
    cursor: grabbing;
}

.pipeline-drag-icon {
    opacity: 0.9;
}

.pipeline-card:hover:not(.pipeline-card-dragging) {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.4) !important;
    background: rgba(var(--mud-palette-primary-rgb), 0.025) !important;
    transform: translateY(-1px);
}

.pipeline-card-dragging {
    opacity: 0.55;
}

.pipeline-lane-active {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.45) !important;
    background: rgba(var(--mud-palette-primary-rgb), 0.06) !important;
    transform: translateY(-2px);
}

.dashboard-chip {
    font-weight: 700;
}

.dashboard-chip-neutral {
    background: rgba(148, 163, 184, 0.16) !important;
    color: #475569 !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
}

.dashboard-chip-strong-buy {
    background: rgba(34, 197, 94, 0.18) !important;
    color: #166534 !important;
    border-color: rgba(34, 197, 94, 0.4) !important;
}

.dashboard-chip-upcoming {
    background: rgba(59, 130, 246, 0.16) !important;
    color: #1d4ed8 !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
}

.dashboard-chip-stretch {
    background: rgba(245, 158, 11, 0.18) !important;
    color: #b45309 !important;
    border-color: rgba(245, 158, 11, 0.35) !important;
}

.dashboard-chip-pass,
.dashboard-chip-overdue {
    background: rgba(239, 68, 68, 0.16) !important;
    color: #b91c1c !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
}

.dashboard-chip-today {
    background: rgba(251, 191, 36, 0.18) !important;
    color: #92400e !important;
    border-color: rgba(251, 191, 36, 0.35) !important;
}

.decision-panel .metric-tile,
.offer-band-panel .metric-tile {
    min-height: 112px;
}

/* ── Pipeline card status accents ── */

.pipeline-card-researching { border-left: 3px solid #93c5fd !important; }
.pipeline-card-touring     { border-left: 3px solid #fcd34d !important; }
.pipeline-card-toured      { border-left: 3px solid #fb923c !important; }
.pipeline-card-offered     { border-left: 3px solid #a78bfa !important; }
.pipeline-card-under-contract { border-left: 3px solid #4ade80 !important; }
.pipeline-card-passed      { border-left: 3px solid #94a3b8 !important; }

/* ── Misc ── */

.tabs-panel {
    padding-top: 1rem;
}

.loading-indicator {
    display: block;
    margin: 6rem auto 0;
}

.empty-state-panel {
    display: grid;
    gap: 0.9rem;
    place-items: start;
}

.shell-chip {
    margin-right: 0.5rem;
}

.text-right {
    text-align: right;
}

/* ── Value color classes ── */

.value-positive {
    color: #16a34a;
}

.value-negative {
    color: #dc2626;
}

.value-neutral {
    color: var(--mud-palette-text-secondary);
}

/* ── Price sensitivity table ── */

.sensitivity-marker-row td {
    background: rgba(var(--mud-palette-primary-rgb), 0.06) !important;
}

/* ── Markdown output ── */

.markdown-output > :first-child {
    margin-top: 0;
}

.markdown-output > :last-child {
    margin-bottom: 0;
}

.markdown-output p,
.markdown-output ul,
.markdown-output ol,
.markdown-output h1,
.markdown-output h2,
.markdown-output h3,
.markdown-output h4 {
    margin-top: 0.65rem;
    margin-bottom: 0.65rem;
}

.markdown-output ul,
.markdown-output ol {
    padding-left: 1.2rem;
}

.notes-editor .mud-input-control-input-container textarea {
    min-height: 20rem;
    line-height: 1.55;
}

.notes-preview {
    min-height: 20rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--mud-palette-lines-default);
    background: rgba(var(--mud-palette-surface-rgb), 0.55);
}

.notes-preview-title {
    margin-bottom: 0.45rem;
}

.notes-markdown-output blockquote {
    margin: 0.9rem 0;
    padding: 0.25rem 0 0.25rem 0.9rem;
    border-left: 3px solid rgba(var(--mud-palette-primary-rgb), 0.55);
    opacity: 0.9;
}

.notes-markdown-output code {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 0.92em;
}

.notes-markdown-output pre {
    overflow-x: auto;
    padding: 0.85rem;
    border-radius: 0.85rem;
    background: rgba(var(--mud-palette-dark-rgb), 0.08);
}

.ai-snapshot-surface {
    padding: 0;
    border: 1px solid var(--mud-palette-lines-default);
    background: rgba(var(--mud-palette-surface-rgb), 0.55);
}

.ai-snapshot-text {
    margin: 0;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
    font-size: 0.9rem;
    font-family: "Cascadia Code", Consolas, monospace;
}

/* ── Blazor error UI ── */

#blazor-error-ui {
    background: #991b1b;
    color: #fff;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.75rem 1rem;
    position: fixed;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
    font-weight: 700;
    margin-left: 0.75rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ── Responsive ── */

@media (max-width: 960px) {
    .hero-panel,
    .panel-header,
    .scenario-head,
    .scenario-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .shell-chip {
        display: none;
    }

    .main-content-shell {
        padding: 1rem 0.75rem 2.5rem;
    }

    .hero-panel h3,
    .hero-panel .mud-typography-h3 {
        font-size: 1.4rem !important;
        line-height: 1.3 !important;
    }

    .notes-editor .mud-input-control-input-container textarea {
        min-height: 10rem;
    }

    .notes-preview {
        min-height: 10rem;
    }

    .summary-table {
        display: block;
        overflow-x: auto;
    }

    .comparison-table {
        min-width: 720px;
    }

    .comparison-table th:first-child,
    .comparison-table td:first-child {
        min-width: 180px;
    }

    .comparison-table th:not(:first-child),
    .comparison-table td:not(:first-child) {
        min-width: 190px;
    }

    .pipeline-lane {
        padding: 1rem;
    }

    .metric-tile {
        padding: 0.9rem 1rem;
    }

    .decision-panel .metric-tile,
    .offer-band-panel .metric-tile {
        min-height: 96px;
    }
}
