/* ---- Base ---- */
html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    /* Root size for the WHOLE app — every MudBlazor and app.css size is in rem, so this one
       number scales everything. 15px (vs the 16px browser default) ≈ 6% smaller: comfortable
       on laptop screens without users having to zoom out. Browser zoom still works normally. */
    font-size: 15px;
}

.mud-typography, .mud-nav-link, .mud-button-root, .mud-input, .mud-table {
    font-family: 'Inter', sans-serif !important;
}

/* ---- ONE green only ----
   MudBlazor's Color.Secondary means "the teal brand accent", but this app uses it as
   "muted text" (157 MudText + 6 MudIcon usages) — which put a second, near-identical green
   directly beside the success green in every page header: "LIVE · SAGE" (success #3E9E5B)
   next to the company name (teal #2FA39B). Point secondary TEXT and ICONS at the muted
   grey-blue instead, so the only green in the UI chrome is the success green.
   Deliberate teal accents reference --mud-palette-secondary directly (the filled
   "Draft with AI" button, the demo login card tint) and are NOT affected by this rule. */
.mud-secondary-text {
    color: var(--mud-palette-text-secondary) !important;
    --mud-ripple-color: var(--mud-palette-text-secondary) !important;
}

/* ---- App bar ---- */
.app-bar {
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--mud-palette-divider);
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.brand-text { font-weight: 700; letter-spacing: -.2px; color: var(--mud-palette-primary) !important; }
.brand-text b { font-weight: 800; color: var(--mud-palette-primary) !important; }

.company-switch { font-weight: 600; border-color: var(--mud-palette-divider); }

/* ---- Company multi-select picker ---- */
.company-picker { min-width: 300px; padding-bottom: 2px; }
.picker-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px 4px 6px;
    cursor: pointer;
    border-radius: 8px;
    margin: 1px 4px;
}
.picker-row:hover { background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent); }
.picker-text { flex: 1; min-width: 0; line-height: 1.2; }
.picker-row .only-btn {
    opacity: 0;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--mud-palette-primary);
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.picker-row:hover .only-btn { opacity: 1; }
.picker-row .only-btn:hover { background: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent); }
.picker-foot { display: flex; align-items: center; }

.user-avatar {
    font-size: .8rem;
    font-weight: 700;
    border: 2px solid var(--mud-palette-background);
}

/* ---- Drawer / nav ---- */
.app-drawer { border-right: 1px solid var(--mud-palette-divider); }

.app-nav .mud-nav-link {
    border-radius: 10px;
    margin: 2px 4px;
    font-weight: 500;
    font-size: .9rem;
}

.app-nav .mud-nav-link.active {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent);
    color: var(--mud-palette-primary) !important;
    font-weight: 600;
}

.app-nav .mud-nav-link.active .mud-icon-root { color: var(--mud-palette-primary) !important; }

.nav-section {
    display: block;
    padding: 14px 16px 4px;
    font-size: .8rem;                       /* was .68rem — slightly bigger, easier to scan */
    letter-spacing: .1em;
    font-weight: 700;
    color: var(--mud-palette-success);      /* green section dividers */
    opacity: 1;
}

/* Section heading row with the optional "move to top" up-arrow on the right. */
.nav-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 8px;
}
.nav-section-row .nav-section { padding-right: 0; }
.nav-section-up {
    opacity: .55;
    transition: opacity .12s, transform .12s;
}
.nav-section-up:hover {
    opacity: 1;
    transform: translateY(-1px);
    color: var(--mud-palette-primary);
}

.drawer-foot {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--mud-palette-divider);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ---- Page ---- */
.main-content { background: var(--mud-palette-background); min-height: 100vh; }
.page-title { font-weight: 800; letter-spacing: -.5px; }
.muted-sub { color: var(--mud-palette-text-secondary); font-weight: 400; }

/* ---- KPI cards ---- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}
@media (max-width: 1200px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
    border: 1px solid var(--mud-palette-divider);
    border-radius: 16px;
    background: var(--mud-palette-surface);
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(20, 20, 40, .08);
}
.kpi-label {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    font-size: .68rem;
}
.kpi-value {
    font-weight: 800;
    letter-spacing: -.5px;
    margin-top: 4px;
    line-height: 1.1;
}

.delta-up { color: var(--mud-palette-success); font-weight: 600; }
.delta-down { color: var(--mud-palette-error); font-weight: 600; }

/* ---- Panels ---- */
.panel {
    border: 1px solid var(--mud-palette-divider);
    border-radius: 16px;
    background: var(--mud-palette-surface);
    height: 100%;
}

/* ---- Legend ---- */
.legend-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}
.legend-rev { background: #256A9E; }
.legend-prior { background: #AEC4D6; }
.legend-exp { background: #F59F00; }
.legend-label { font-size: .8rem; color: var(--mud-palette-text-secondary); }

/* Year-on-Year toggle pill */
.yoy-toggle {
    font-size: .72rem; font-weight: 600; letter-spacing: .02em; cursor: pointer;
    padding: 2px 9px; border-radius: 999px; user-select: none;
    white-space: nowrap; flex-shrink: 0;   /* never wrap or get squeezed on narrow screens */
    border: 1px solid var(--mud-palette-lines-default); color: var(--mud-palette-text-secondary);
    transition: background .12s, color .12s, border-color .12s;
}
.yoy-toggle.on {
    background: var(--mud-palette-primary); color: #fff; border-color: var(--mud-palette-primary);
}

/* Clickable age bands (Aged Analysis) — double as legend + filter control */
.bucket-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bucket-chip {
    display: flex; flex-direction: column; gap: 1px; cursor: pointer; user-select: none;
    padding: 6px 12px; border-radius: 8px; min-width: 92px;
    border: 1px solid var(--mud-palette-lines-default); background: var(--mud-palette-background-gray);
    transition: background .12s, border-color .12s;
}
.bucket-chip:hover { border-color: var(--mud-palette-primary); }
.bucket-chip.on { background: var(--mud-palette-primary); border-color: var(--mud-palette-primary); }
.bucket-chip.on .bucket-chip-label, .bucket-chip.on .bucket-chip-val { color: #fff; }
.bucket-chip-label { font-size: .72rem; color: var(--mud-palette-text-secondary); text-transform: uppercase; letter-spacing: .03em; }
.bucket-chip-val { font-size: .9rem; font-weight: 600; color: var(--mud-palette-text-primary); }

.trend-chart .mud-chart-line { stroke-linecap: round; }

/* ---- Click-a-month-to-filter (Sales dashboard) ---- */
.drill-hint { font-size: .78rem; color: var(--mud-palette-text-secondary); font-style: italic; }
.drill-chart .mud-chart-bar { cursor: pointer; }

/* Hand-rolled clickable revenue bar chart (Sales dashboard) */
.rev-wrap { display: flex; gap: 8px; }
.rev-yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 280px; }
.rev-ylabel { font-size: .72rem; color: var(--mud-palette-text-secondary); line-height: 1; white-space: nowrap; }
.rev-plot { flex: 1; min-width: 0; }
.rev-chart { display: block; width: 100%; height: 280px; }
.rev-grid { stroke: var(--mud-palette-lines-default); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.rev-bar-cur { fill: #256A9E; transition: fill .12s; }
.rev-bar-pri { fill: #AEC4D6; }
.rev-hit { fill: transparent; cursor: pointer; }
.rev-col:hover .rev-hit { fill: var(--mud-palette-primary); opacity: .07; }
.rev-col:hover .rev-bar-cur { fill: #1C557F; }
.rev-col.sel .rev-bar-cur { fill: #184366; }
.rev-xaxis { display: flex; margin-top: 6px; }
.rev-xlabel { flex: 1; text-align: center; font-size: .72rem; color: var(--mud-palette-text-secondary); white-space: nowrap; overflow: hidden; }

/* Clickable month strip under the Sales revenue chart */
/* ---- Donut ---- */
.donut { display: block; }
.donut-total {
    font-size: 26px;
    font-weight: 800;
    fill: var(--mud-palette-text-primary);
    font-family: 'Inter', sans-serif;
}
.donut-cap {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    fill: var(--mud-palette-text-secondary);
    font-family: 'Inter', sans-serif;
}

/* ---- P&L table ---- */
.pnl-table table { width: 100%; }
.pnl-table th {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .06em;
    color: var(--mud-palette-text-secondary);
    font-weight: 700;
    border-bottom: 1px solid var(--mud-palette-divider) !important;
}
.pnl-table td { font-size: .88rem; }
.pnl-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl-table .muted { color: var(--mud-palette-text-secondary); }
.pnl-table .row-header td {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--mud-palette-text-secondary);
    padding-top: 14px;
    border-bottom: none !important;
}
.pnl-table .row-subtotal td {
    font-weight: 800;
    border-top: 1px solid var(--mud-palette-divider) !important;
    border-bottom: 2px solid var(--mud-palette-divider) !important;
}

/* ---- Horizontal bar list (categories) ---- */
.bar-row { margin-bottom: 14px; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.bar-label { font-size: .85rem; font-weight: 500; }
.bar-val { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 6px; background: var(--mud-palette-lines-default); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }

/* ---- Report select ---- */
.report-radios { display: flex; flex-direction: column; gap: 2px; }
/* MudRadioGroup lays its radios out in a flex ROW that wraps — force a column */
.report-radios .mud-radio-group {
    flex-direction: column !important;
    flex-wrap: nowrap;
    /* MudBlazor's own .mud-radio-group sets align-items:center, which floats each
       content-width radio to the middle — the staggered look. Must win here. */
    align-items: flex-start !important;
    gap: 8px;
}
.report-radios .mud-radio { width: 100%; margin: 0; }
.report-radios .report-radio { width: 100%; }
.report-radio .report-name { font-weight: 600; font-size: .9rem; display: block; }
.report-radio .report-types {
    font-size: .72rem; color: var(--mud-palette-text-secondary);
    display: block; line-height: 1.2;
}

/* ---- Pivot table ---- */
.pivot-select { min-width: 190px; }
.pivot-scroll { overflow: auto; max-height: 68vh; border-radius: 12px; }
.pivot-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .82rem; }
.pivot-table th, .pivot-table td { padding: 8px 12px; white-space: nowrap; }
.pivot-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--mud-palette-surface);
    border-bottom: 2px solid var(--mud-palette-divider);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    font-weight: 700; color: var(--mud-palette-text-secondary);
    text-align: right;
}
.pivot-table thead th.corner { text-align: left; left: 0; z-index: 3; }
.pivot-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pivot-table .rowhead {
    position: sticky; left: 0; z-index: 1;
    background: var(--mud-palette-surface);
    font-weight: 600; text-align: left;
    max-width: 260px; overflow: hidden; text-overflow: ellipsis;
    border-right: 1px solid var(--mud-palette-divider);
}
.pivot-table tbody tr:hover td { background: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent); }
.pivot-table tbody tr.group-row td {
    background: color-mix(in srgb, var(--mud-palette-primary) 9%, var(--mud-palette-surface));
    font-weight: 800;
    border-top: 1px solid var(--mud-palette-divider);
}
.pivot-table tbody tr.group-row .rowhead {
    background: color-mix(in srgb, var(--mud-palette-primary) 9%, var(--mud-palette-surface));
}
.pivot-table .grp-caret { color: var(--mud-palette-primary); font-size: .7rem; margin-right: 4px; }
.pivot-table .drillable { cursor: pointer; }
.pivot-table .drillable:hover { outline: 2px solid var(--mud-palette-primary); outline-offset: -2px; border-radius: 4px; }
.view-seg { align-self: center; }

/* ---- Analysis Categories sortable headers ---- */
.ancat-sort { cursor: pointer; user-select: none; }
.ancat-sort:hover { color: var(--mud-palette-primary); }

/* ---- Pivot Views dropdown ---- */
.pivot-view-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px; cursor: pointer;
    font-size: .875rem; color: var(--mud-palette-text-primary);
}
.pivot-view-item:hover { background: var(--mud-palette-action-default-hover); }
.view-del { display: inline-flex; align-items: center; cursor: pointer; color: var(--mud-palette-text-secondary); }
.view-del:hover { color: var(--mud-palette-error); }

/* ---- Drill-through ---- */
.drill-scroll { overflow: auto; max-height: 62vh; }
.drill-table { font-size: .82rem; }
.drill-table thead th { text-align: left; }
.drill-table thead th.num { text-align: right; }
.drill-table td { border-bottom: 1px solid var(--mud-palette-divider); }
.drill-table .drill-item { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-table tfoot td { border-top: 2px solid var(--mud-palette-divider); font-weight: 800; }
.pivot-table .cell { border-radius: 4px; }
.pivot-table .total-col {
    font-weight: 800;
    border-left: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface);
}
.pivot-table tfoot td {
    position: sticky; bottom: 0;
    background: var(--mud-palette-surface);
    border-top: 2px solid var(--mud-palette-divider);
    font-weight: 800;
}

.nav-soon {
    text-transform: none;
    letter-spacing: 0;
    font-size: .62rem;
    font-weight: 600;
    opacity: .6;
    margin-left: 4px;
}

.invisible { visibility: hidden; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ---- Company picker (pure Blazor dropdown — no popover JS) ---- */
.co-picker { position: relative; display: inline-block; }
.co-picker-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: var(--mud-default-borderradius, 8px);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit; font-weight: 600; font-size: .85rem;
    cursor: pointer;
}
.co-picker-btn:hover { border-color: var(--mud-palette-primary); }
.co-picker-overlay { position: fixed; inset: 0; z-index: 1399; }
/* In the app bar, anchor the panel to the right edge so it can't overflow the window. */
.app-bar .co-picker-panel { left: auto; right: 0; }
.co-picker-panel {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 1400;
    min-width: 320px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(20, 20, 40, .18);
    padding-bottom: 2px;
}
.co-picker-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px 6px;
    border-bottom: 1px solid var(--mud-palette-divider);
}
.co-picker-title { font-size: .8rem; font-weight: 700; }
.co-picker-all {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--mud-palette-primary); cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.co-picker-all:hover { background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent); }
.co-picker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; margin: 2px 4px;
    border-radius: 8px; cursor: pointer;
}
.co-picker-row:hover { background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent); }
.co-check {
    width: 18px; height: 18px; flex: 0 0 18px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--mud-palette-lines-inputs, #aaa);
    border-radius: 4px; color: #fff;
}
.co-check.on { background: var(--mud-palette-primary); border-color: var(--mud-palette-primary); }
.co-name { flex: 1; font-size: .88rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-only {
    opacity: 0; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--mud-palette-primary); padding: 2px 8px; border-radius: 6px; cursor: pointer;
}
.co-picker-row:hover .co-only { opacity: 1; }
.co-only:hover { background: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent); }
.co-picker-foot {
    display: flex; align-items: center;
    padding: 8px 14px; margin-top: 2px;
    border-top: 1px solid var(--mud-palette-divider);
    font-size: .74rem; color: var(--mud-palette-text-secondary);
}

/* ---- First-login "preparing data" splash ---- */
.prep-splash {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 24px;
    background: var(--mud-palette-background);
}

/* ---- Dashboard filter bar ---- */
.filter-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 10px 12px; margin-bottom: 20px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 14px;
    background: var(--mud-palette-surface);
}
.filter-bar-icon { color: var(--mud-palette-text-secondary); margin-right: 2px; }
.filter-bar .co-picker-btn { padding: 7px 12px; font-size: .8rem; font-weight: 600; }
.filter-bar .co-picker-btn.filter-on {
    border-color: var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-surface));
    color: var(--mud-palette-primary);
}
.filter-panel { min-width: 260px; }
.filter-search {
    width: calc(100% - 16px); margin: 8px; padding: 8px 10px;
    border: 1px solid var(--mud-palette-divider); border-radius: 8px;
    background: var(--mud-palette-background); color: var(--mud-palette-text-primary);
    font: inherit; font-size: .85rem; outline: none;
}
.filter-search:focus { border-color: var(--mud-palette-primary); }
.filter-list { max-height: 320px; overflow-y: auto; }
.filter-clear {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: .78rem; font-weight: 600; color: var(--mud-palette-error);
    cursor: pointer; padding: 4px 8px; border-radius: 8px; margin-left: auto;
}
.filter-clear:hover { background: color-mix(in srgb, var(--mud-palette-error) 12%, transparent); }

/* Cap long ranked tables (e.g. Sales Reps) to roughly the Top-10 Customers height;
   header stays pinned while the rows scroll. */
.rank-scroll { max-height: 420px; overflow-y: auto; }
.rank-scroll thead th { position: sticky; top: 0; background: var(--mud-palette-surface); z-index: 1; }

/* ---- Sync result table ---- */
.sync-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.sync-table th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--mud-palette-text-secondary); font-weight: 700; padding: 4px 8px; border-bottom: 1px solid var(--mud-palette-divider); }
.sync-table td { padding: 4px 8px; border-bottom: 1px solid var(--mud-palette-divider); }
.sync-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Errors ---- */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ---- Login page ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #EBF2F7 0%, #F5F8FB 60%, #E8F4EE 100%);
}

.login-card-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    padding: 16px;
    width: 100%;
    max-width: 900px;
}

.login-card {
    border-radius: 20px !important;
    flex: 1 1 360px;
    max-width: 420px;
}

/* Demo card gets a subtle tint to visually distinguish it */
.login-demo-card {
    border: 1px solid var(--mud-palette-secondary) !important;
    background: color-mix(in srgb, var(--mud-palette-background) 96%, var(--mud-palette-secondary) 4%) !important;
    flex-basis: 460px;
    max-width: 520px;
}

.login-body { padding: 40px 36px 16px !important; }

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(51,153,204,.25);
}

.login-title {
    color: var(--mud-palette-primary) !important;
    font-weight: 700 !important;
    letter-spacing: -.3px;
}

.login-title b { font-weight: 800 !important; }

.login-subtitle {
    margin-top: 2px;
    color: var(--mud-palette-text-secondary);
}

.login-btn { border-radius: 12px !important; font-weight: 700 !important; letter-spacing: .02em; }

.login-footer {
    padding: 8px 36px 24px !important;
    text-align: center;
}


/* -- Operational screens -------------------------------------------- */
.selected-row td { background: rgba(var(--mud-palette-primary-rgb), 0.08) !important; }
.text-muted { color: var(--mud-palette-text-secondary) !important; }
.fw-bold  { font-weight: 700 !important; }
.gap-3    { gap: 12px !important; }
.gap-4    { gap: 16px !important; }

/* -- Financial statements ------------------------------------------- */
.fin-toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px;
    padding: 14px 16px; margin-bottom: 18px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
}
/* Uniform control heights: buttons and button-groups match the dense outlined inputs (40px),
   so every control in the toolbar sits on the same line instead of three different heights.
   Applies to the financial fin-toolbar and the operational .ops-toolbar cards alike. */
.fin-toolbar > .mud-button-root,
.ops-toolbar .mud-button-root { height: 40px; }
.fin-toolbar .mud-button-group-root,
.ops-toolbar .mud-button-group-root { height: 40px; }
.fin-toolbar .mud-button-group-root .mud-button-root,
.ops-toolbar .mud-button-group-root .mud-button-root { height: 100%; }
.fin-toolbar .mud-switch { margin-bottom: 4px; }
/* Inputs/selects/pickers: pin the dense outlined frame to the same 40px so no component
   renders a stray pixel taller than its neighbours. */
.fin-toolbar .mud-input-control-input-container > .mud-input.mud-input-outlined,
.ops-toolbar .mud-input-control-input-container > .mud-input.mud-input-outlined { height: 40px; }
.ops-toolbar .mud-checkbox { margin-bottom: 0; }
.fin-live {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--mud-palette-success);
}
.fin-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mud-palette-success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mud-palette-success) 18%, transparent); }
.fin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.fin-table th {
    text-align: right; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--mud-palette-text-secondary);
    padding: 8px 12px; border-bottom: 2px solid var(--mud-palette-lines-default);
}
.fin-table th.fin-desc { text-align: left; }
.fin-table td { padding: 6px 12px; border-bottom: 1px solid var(--mud-palette-lines-default); }
.fin-table td.fin-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-table tr:hover td { background: rgba(var(--mud-palette-primary-rgb), .04); }
.fin-desc-cell { display: flex; align-items: center; gap: 4px; }
.fin-caret { cursor: pointer; width: 18px; display: inline-flex; justify-content: center; color: var(--mud-palette-text-secondary); }
.fin-row-total td { font-weight: 700; border-top: 1px solid var(--mud-palette-lines-default); }
.fin-row-total td.fin-num { border-bottom: 2px double var(--mud-palette-text-primary); }
.fin-neg { color: #f03e3e; }
.fin-pos { color: var(--mud-palette-success); }
.fin-scroll { overflow-x: auto; }

/* Report picker: stack the radios left-aligned instead of the ragged centred column. */
.report-radios { display: flex !important; flex-direction: column; align-items: flex-start; gap: 6px; }
.report-radios .report-radio { margin: 0; }
.report-radios .mud-radio { align-items: flex-start; }

/* Angle long x-axis labels (e.g. Top Analytics customer names) so they don't overlap.
   SVG text: pivot each label around its own anchor point and swing it down-left. */
.angled-x-labels .mud-charts-xaxis text {
    transform: rotate(-35deg);
    transform-box: fill-box;
    transform-origin: right center;
    text-anchor: end;
    font-size: 11px;
}

/* ---- Item Demands table: identity columns pinned, weekly schedule cross-scrolls.
   Sticky cells need border-collapse:separate (same pattern as .pivot-table); the first three
   columns get fixed widths so their sticky left offsets line up exactly. ---- */
.demand-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.demand-table th, .demand-table td { white-space: nowrap; }
.demand-table thead th { position: sticky; top: 0; z-index: 2; background: var(--mud-palette-surface); }
.demand-table th:nth-child(-n+3), .demand-table td:nth-child(-n+3) {
    position: sticky; z-index: 1; background: var(--mud-palette-surface);
    overflow: hidden; text-overflow: ellipsis;
}
.demand-table th:nth-child(1), .demand-table td:nth-child(1) { left: 0;     min-width: 130px; max-width: 130px; }
.demand-table th:nth-child(2), .demand-table td:nth-child(2) { left: 130px; min-width: 110px; max-width: 110px; }
.demand-table th:nth-child(3), .demand-table td:nth-child(3) { left: 240px; min-width: 240px; max-width: 240px;
    border-right: 2px solid var(--mud-palette-lines-default); }
.demand-table thead th:nth-child(-n+3) { z-index: 3; } /* corner cells win over both scroll axes */
/* Solid hover tint on pinned cells — the translucent row tint would let scrolled columns show through. */
.demand-table tr:hover td:nth-child(-n+3) {
    background: color-mix(in srgb, var(--mud-palette-primary) 4%, var(--mud-palette-surface));
}
.fin-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.fin-kpi {
    background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px; padding: 14px 16px;
}
.fin-kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--mud-palette-text-secondary); }
.fin-kpi-value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.fin-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.fin-hub-card {
    display: flex; flex-direction: column; gap: 8px; text-decoration: none;
    background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default);
    border-radius: 14px; padding: 18px 20px; color: inherit; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.fin-hub-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(20,20,40,.14); border-color: var(--mud-palette-primary); }
.fin-hub-icon { width: 42px; height: 42px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent); color: var(--mud-palette-primary); }
.fin-hub-title { font-weight: 700; font-size: 1.02rem; }
.fin-hub-sub { font-size: .8rem; color: var(--mud-palette-text-secondary); line-height: 1.35; }
.builder-row { padding: 6px 4px; border-bottom: 1px solid var(--mud-palette-lines-default); }
.builder-row:last-child { border-bottom: none; }
.co-group-head { background: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent); cursor: pointer; }
.co-group-head:hover { background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent); }

/* -- Demo panel notes -- */
.demo-notes-list {
    margin: 6px 0 0; padding-left: 18px;
    font-size: .87rem; line-height: 1.5;
    color: var(--mud-palette-text-secondary);
}
.demo-notes-list li { margin-bottom: 7px; }
.pack-upload { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 8px; cursor: pointer; font-size: .82rem; }
.pack-upload:hover { border-color: var(--mud-palette-primary); }

/* -- Management pack document -- */
.pack-doc { background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default); border-radius: 10px; }
.pack-section { padding: 28px 34px; border-bottom: 1px solid var(--mud-palette-lines-default); }
.pack-section:last-of-type { border-bottom: none; }
.pack-h { font-size: 1.3rem; font-weight: 700; margin: 0 0 14px; color: var(--accent, #3399CC); border-bottom: 2px solid var(--accent, #3399CC); padding-bottom: 6px; }
.pack-cover { text-align: center; padding: 40px 20px; }
.pack-cover-logo { max-height: 72px; margin-bottom: 22px; }
.pack-cover-title { font-size: 2rem; font-weight: 800; color: var(--accent, #3399CC); }
.pack-cover-co { font-size: 1.3rem; margin-top: 6px; }
.pack-cover-period { color: var(--mud-palette-text-secondary); margin-top: 4px; }
.pack-cover-meta { color: var(--mud-palette-text-secondary); margin-top: 14px; font-size: .9rem; }
.pack-contents { display: inline-block; text-align: left; margin-top: 30px; padding: 16px 26px; border: 1px solid var(--mud-palette-lines-default); border-radius: 10px; }
.pack-contents-h { font-weight: 700; margin-bottom: 8px; color: var(--accent, #3399CC); }
.pack-contents-i { padding: 3px 0; color: var(--mud-palette-text-secondary); }
.pack-commentary { white-space: pre-wrap; line-height: 1.55; font-size: .95rem; }

/* ── MudBlazor date-picker popup fix: the inline picker popup (.mud-picker-popover-paper)
      is position:absolute INSIDE the 185px-wide picker root with overflow-x:hidden, so it
      shrink-wraps to the input's width and clips the calendar (weekdays cut off, header
      wrapping). Force the popup to its natural width. ── */
.mud-picker-popover-paper {
    width: max-content !important;
    min-width: 310px !important;
    max-width: min(96vw, 420px);
}
.mud-popover:has(.mud-picker-content) {
    width: max-content !important;
    max-width: min(96vw, 420px);
}
.mud-popover .mud-picker-content, .mud-picker-popover-paper .mud-picker-content { max-width: none; }

/* ── AI Insights commentary (rendered markdown) ── */
.ai-commentary { line-height: 1.6; font-size: .93rem; }
.ai-commentary p { margin: 6px 0; }
.ai-commentary h3, .ai-commentary h4, .ai-commentary h5, .ai-commentary h6 {
    margin: 14px 0 4px; font-size: .95rem; font-weight: 700;
}
.ai-commentary h3:first-child, .ai-commentary h4:first-child { margin-top: 2px; }
.ai-commentary ul, .ai-commentary ol { margin: 6px 0 6px 4px; padding-left: 20px; }
.ai-commentary li { margin: 4px 0; }
.ai-commentary code { font-size: .85em; background: var(--mud-palette-background-gray); padding: 1px 5px; border-radius: 4px; }
.ai-commentary hr { border: none; border-top: 1px solid var(--mud-palette-divider); margin: 10px 0; }
.ai-md-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: 8px 0; }
.ai-md-table th {
    text-align: left; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--mud-palette-text-secondary);
    padding: 6px 10px; border-bottom: 2px solid var(--mud-palette-lines-default);
}
.ai-md-table td { padding: 6px 10px; border-bottom: 1px solid var(--mud-palette-lines-default); vertical-align: top; }
.ai-flag {
    display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
    padding: 1px 8px; border-radius: 10px; vertical-align: text-bottom; white-space: nowrap;
}
.ai-flag-red { color: #e03131; background: rgba(224, 49, 49, .12); }
.ai-flag-amber { color: #b8860b; background: rgba(245, 159, 0, .15); }
.ai-flag-grey { color: var(--mud-palette-text-secondary); background: var(--mud-palette-background-gray); }
.pack-warn { margin-top: 8px; color: #f59f00; font-size: .82rem; }
.pack-foot { text-align: center; color: var(--mud-palette-text-secondary); font-size: .72rem; padding: 12px; }

@media print {
    .pack-doc { border: none; border-radius: 0; }
    .pack-section { page-break-before: always; border: none; padding: 0 0 12px; }
    .pack-section:first-of-type { page-break-before: avoid; }
    .pack-cover { min-height: 88vh; display: flex; flex-direction: column; justify-content: center; }
    .pack-foot { display: none; }
}

@media print {
    .app-bar, .app-drawer, .fin-toolbar, .mud-nav-menu, .no-print { display: none !important; }
    .main-content, .mud-main-content { margin: 0 !important; padding: 0 !important; }
    .fin-table td, .fin-table th { padding: 3px 8px; }
    body { background: #fff !important; }
}

