:root {
    --ux-bg-soft: #f4f7fa;
    --ux-surface: #ffffff;
    --ux-border: rgba(26, 43, 58, 0.18);
    --ux-border-strong: rgba(26, 43, 58, 0.28);
    --ux-text: #1c2b36;
    --ux-subtle: #5a6d7c;
    --ux-hover: rgba(20, 46, 68, 0.04);
    --ux-steel-header: #d5dde5;
    --ux-steel-header-deep: #c7d0d9;
    --ux-radius-md: 14px;
    --ux-radius-lg: 18px;
}

.page-header {
    margin-bottom: 10px;
}

.standard-filters {
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-radius-lg);
    background: linear-gradient(180deg, #f8fafc 0%, var(--ux-bg-soft) 100%);
}

.standard-grid-shell {
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-radius-lg);
    overflow: hidden;
    background: var(--ux-surface);
}

.standard-grid .mud-table-head .mud-table-cell,
.standard-grid .mud-data-grid-header .mud-table-cell,
.standard-grid .mud-data-grid-header-cell {
    font-weight: 700;
    color: var(--ux-text);
    background: linear-gradient(180deg, var(--ux-steel-header) 0%, var(--ux-steel-header-deep) 100%);
    border-bottom: 1px solid var(--ux-border-strong);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

.standard-grid .mud-table-row,
.standard-grid .mud-data-grid-row {
    border-bottom: 1px solid var(--ux-border);
}

.standard-grid .mud-table-row:hover,
.standard-grid .mud-data-grid-row:hover {
    background: var(--ux-hover);
}

.standard-price-cell {
    font-weight: 700;
}

.standard-status-chip {
    font-weight: 700;
    letter-spacing: 0.2px;
    border-radius: 10px !important;
}

.standard-actions-col {
    min-width: 160px;
    text-align: right;
}

.standard-action-stack {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.standard-action-btn {
    border-radius: 10px !important;
    min-width: 34px;
    height: 32px;
    padding-inline: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.standard-action-btn-secondary {
    border-color: rgba(24, 42, 58, 0.34) !important;
    color: #1d3447 !important;
}

.standard-action-btn-primary {
    box-shadow: none !important;
}

/* Fallback standards for pages not yet fully refactored to standard-* classes. */
.mud-main-content .mud-table {
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-radius-lg);
    overflow: hidden;
    background: var(--ux-surface);
}

.mud-main-content .mud-table .mud-table-head .mud-table-cell {
    background: linear-gradient(180deg, var(--ux-steel-header) 0%, var(--ux-steel-header-deep) 100%);
    border-bottom: 1px solid var(--ux-border-strong);
    color: var(--ux-text);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.04em;
}

.mud-main-content .mud-table .mud-table-row {
    border-bottom: 1px solid var(--ux-border);
}

.mud-main-content .mud-table .mud-table-row:hover {
    background: var(--ux-hover);
}

.mud-main-content .mud-table .mud-table-cell {
    font-variant-numeric: tabular-nums;
}

.mud-main-content .mud-table .mud-button,
.mud-main-content .mud-table .mud-icon-button {
    border-radius: 10px !important;
}

/* Global rounded corners for page-level MudBlazor surfaces/inputs. */
.mud-main-content .mud-paper {
    border-radius: var(--ux-radius-lg) !important;
}

.mud-main-content .mud-input-outlined .mud-input-outlined-border,
.mud-main-content .mud-select-outlined .mud-input-outlined-border,
.mud-main-content .mud-input-slot {
    border-radius: var(--ux-radius-md) !important;
}

.mud-main-content .mud-button,
.mud-main-content .mud-icon-button {
    border-radius: 10px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card {
    position: relative;
    min-height: 128px;
    padding: 18px;
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-radius-lg);
    background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--stat-accent, #2563eb);
}

.stat-card-primary {
    --stat-accent: #2563eb;
}

.stat-card-success {
    --stat-accent: #16a34a;
}

.stat-card-info {
    --stat-accent: #0891b2;
}

.stat-card-warning {
    --stat-accent: #d97706;
}

.stat-card-danger {
    --stat-accent: #dc2626;
}

.stat-card-purple {
    --stat-accent: #7c3aed;
}

.stat-card-secondary {
    --stat-accent: #64748b;
}

.stat-icon {
    color: var(--stat-accent, #2563eb);
    font-size: 1.7rem !important;
    margin-bottom: 12px;
}

.stat-value {
    color: var(--ux-text);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    margin-top: 6px;
    color: var(--ux-subtle);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.section-card {
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-radius-lg);
    overflow: hidden;
    background: var(--ux-surface);
}

.section-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--ux-border);
    background: linear-gradient(180deg, #f7fafc 0%, #eef4f8 100%);
    color: var(--ux-text);
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card {
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-radius-md);
    padding: 14px 16px;
    background: #fff;
}

.metric-label {
    color: var(--ux-subtle);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    margin-top: 8px;
    color: var(--ux-text);
    font-size: 1.4rem;
    font-weight: 800;
}

.top-scroll-control {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 8px 0 8px 0;
    padding: 8px 10px;
    border: 1px solid #b7c7d7;
    border-radius: 12px;
    background: linear-gradient(180deg, #eef4fb 0%, #e1ebf5 100%);
    box-shadow: inset 0 1px 1px rgba(18, 36, 54, 0.12);
}

.top-scroll-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 30px;
    border: 1px solid #7ca5c9;
    border-radius: 8px;
    background: linear-gradient(180deg, #2f80c7 0%, #2568a1 100%);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.top-scroll-btn:hover {
    background: linear-gradient(180deg, #2a72b2 0%, #1f5a8b 100%);
}

.top-scroll-slider {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: #2f80c7;
    cursor: ew-resize;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
}

.top-scroll-slider::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(180deg, #d4e1ee 0%, #c6d6e6 100%);
    border-radius: 999px;
    border: 1px solid #a8bfd6;
}

.top-scroll-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2f80c7 0%, #1d5f98 100%);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(14, 34, 54, 0.35);
}

.top-scroll-slider::-moz-range-track {
    height: 8px;
    background: linear-gradient(180deg, #d4e1ee 0%, #c6d6e6 100%);
    border-radius: 999px;
    border: 1px solid #a8bfd6;
}

.top-scroll-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2f80c7 0%, #1d5f98 100%);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(14, 34, 54, 0.35);
}

.top-scrollbar {
    overflow-x: scroll !important;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    height: 22px;
    margin: 8px 0 10px 0;
    border: 1px solid #b7c7d7;
    border-radius: 999px;
    background: #e6eef6;
    box-shadow: inset 0 1px 2px rgba(20, 42, 61, 0.16);
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable both-edges;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    scrollbar-color: #2f80c7 #d7e0e9;
}

.top-scrollbar-inner {
    height: 8px;
    width: 100%;
}

.top-scrollbar::-webkit-scrollbar {
    height: 18px;
}

.top-scrollbar::-webkit-scrollbar-track {
    background: #d7e0e9;
    border-radius: 999px;
}

.top-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #0b5ea8 0%, #2f80c7 100%);
    border-radius: 999px;
    border: 2px solid #d7e0e9;
}

.top-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #0a4e8d 0%, #286faa 100%);
}

/* ── Global table scroll: sticky header + internal scrollbar ─────────────
   Applies to all MudTable and MudDataGrid instances in the main content.
   Tables with few rows show no scrollbar; long lists scroll within the box
   rather than forcing the whole page to scroll.
   Approx. row heights: Dense ~37 px, Normal ~52 px.
   max-height = 50 rows × 52 px + 42 px header ≈ 2642 px, but we also clamp
   to the visible viewport so the table never extends off-screen.          */
.mud-main-content .mud-table-container,
.mud-main-content .mud-data-grid .mud-table-container {
    max-height: min(2600px, calc(100vh - 260px));
    overflow-y: auto;
    /* nice thin scrollbar on webkit browsers */
    scrollbar-width: thin;
    scrollbar-color: #2f80c7 #e6eef6;
}

.mud-main-content .mud-table-container::-webkit-scrollbar,
.mud-main-content .mud-data-grid .mud-table-container::-webkit-scrollbar {
    width: 7px;
}

.mud-main-content .mud-table-container::-webkit-scrollbar-track,
.mud-main-content .mud-data-grid .mud-table-container::-webkit-scrollbar-track {
    background: #e6eef6;
    border-radius: 999px;
}

.mud-main-content .mud-table-container::-webkit-scrollbar-thumb,
.mud-main-content .mud-data-grid .mud-table-container::-webkit-scrollbar-thumb {
    background: #2f80c7;
    border-radius: 999px;
    border: 1px solid #e6eef6;
}

/* Sticky header — keeps column labels visible while scrolling rows */
.mud-main-content .mud-table-container .mud-table-head th,
.mud-main-content .mud-table-container .mud-table-head td,
.mud-main-content .mud-data-grid .mud-table-container .mud-table-head th,
.mud-main-content .mud-data-grid .mud-table-container .mud-table-head td {
    position: sticky;
    top: 0;
    z-index: 3;
}

.board-scroll-main {
    overflow-x: auto !important;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
    scrollbar-width: auto;
    scrollbar-color: #2f80c7 #d7e0e9;
}

.board-scroll-main::-webkit-scrollbar {
    height: 10px;
}

.board-scroll-main::-webkit-scrollbar-track {
    background: #d7e0e9;
    border-radius: 999px;
}

.board-scroll-main::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #0b5ea8 0%, #2f80c7 100%);
    border-radius: 999px;
    border: 1px solid #d7e0e9;
}

.board-scroll-main::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #0a4e8d 0%, #286faa 100%);
}

.board-shell {
    display: flex;
    gap: 18px;
    width: max-content;
    min-width: 100%;
    padding: 4px 20px 20px 4px;
    align-items: flex-start;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 4px 28px;
}

.board-shell::after {
    content: "";
    flex: 0 0 28px;
}

.board-column {
    --board-accent: #2f80c7;
    --board-bg-top: #f9fbfd;
    --board-bg-bottom: #edf3f8;
    --board-header-bg: rgba(255, 255, 255, 0.72);
    flex: 0 0 292px;
    min-width: 292px;
    max-width: 292px;
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-radius-lg);
    background: linear-gradient(180deg, var(--board-bg-top) 0%, var(--board-bg-bottom) 100%);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
    padding-bottom: 10px;
}

.board-column::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--board-accent), #11304b 35%) 0%, var(--board-accent) 100%);
}

.board-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ux-border);
    background: var(--board-header-bg);
}

.board-column .standard-status-chip {
    border-color: color-mix(in srgb, var(--board-accent), #172a3c 30%) !important;
    color: color-mix(in srgb, var(--board-accent), #172a3c 20%) !important;
    background: rgba(255, 255, 255, 0.68) !important;
}

.board-column-title {
    color: var(--ux-text);
    font-size: 0.95rem;
    font-weight: 800;
}

.board-empty-hint {
    margin: 10px 12px 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px dashed color-mix(in srgb, var(--board-accent), #ffffff 48%);
    background: color-mix(in srgb, var(--board-accent), #ffffff 92%);
    color: color-mix(in srgb, var(--board-accent), #1c2b36 38%);
    text-align: center;
}

.board-stage-default {
    --board-accent: #2f80c7;
    --board-bg-top: #f9fbfd;
    --board-bg-bottom: #edf3f8;
}

.board-stage-inquiry {
    --board-accent: #2f80c7;
    --board-bg-top: #f6fbff;
    --board-bg-bottom: #e7f2fc;
}

.board-stage-lead {
    --board-accent: #00a6b8;
    --board-bg-top: #f2feff;
    --board-bg-bottom: #e2f5f8;
}

.board-stage-analyzing {
    --board-accent: #8f5cf6;
    --board-bg-top: #faf7ff;
    --board-bg-bottom: #efe9ff;
}

.board-stage-negotiating {
    --board-accent: #f59f00;
    --board-bg-top: #fffaf2;
    --board-bg-bottom: #fdf0da;
}

.board-stage-under-contract {
    --board-accent: #ef6c3b;
    --board-bg-top: #fff7f3;
    --board-bg-bottom: #fde9df;
}

.board-stage-assigned {
    --board-accent: #0ea760;
    --board-bg-top: #f3fff8;
    --board-bg-bottom: #e1f6ea;
}

.board-stage-closed {
    --board-accent: #1f7a8c;
    --board-bg-top: #f2fdff;
    --board-bg-bottom: #e0f4f8;
}

.board-card {
    border: 1px solid rgba(17, 41, 62, 0.18);
    border-radius: var(--ux-radius-lg);
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.board-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(15, 23, 42, 0.12);
}

.board-card-title {
    color: var(--ux-text);
    font-size: 1rem;
    font-weight: 800;
}

.board-card-subtitle {
    margin-top: 4px;
    color: var(--ux-subtle);
    font-size: 0.82rem;
}

.board-card-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.summary-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.pipeline-kanban-lane {
    width: max-content;
    min-width: 100%;
}

@media (max-width: 768px) {
    .board-shell {
        gap: 12px;
        padding-right: 24px;
    }

    .board-column {
        flex-basis: 264px;
        min-width: 264px;
        max-width: 264px;
    }
}

/* ── Quill rich-text editor — visual unification with MudBlazor outlined fields ── */
/* Quill's snow theme draws separate borders on the toolbar and the editor container,
   producing a double-line look that visually fights MudBlazor's outlined inputs.
   Merge them into one rounded box and give the editor a usable min-height so the
   placeholder text doesn't visually collide with the toolbar. */
.ql-toolbar.ql-snow {
    border: 1px solid rgba(0, 0, 0, .23);
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background: #fafafa;
}

.ql-container.ql-snow {
    border: 1px solid rgba(0, 0, 0, .23);
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    font-family: inherit;
    font-size: .875rem;
    /* Quill ships a base rule `.ql-container { height: 100% }` that cascades
       from the parent's flex-stretched height and visually overflows the
       MudGrid row. Force it to size from its own children only. */
    height: auto;
}

.ql-container.ql-snow .ql-editor {
    min-height: 120px;
    max-height: 160px;
    overflow-y: auto;
}

.ql-container.ql-snow .ql-editor.ql-blank::before {
    color: rgba(0, 0, 0, .5);
    font-style: normal;
}

