/*
  Bradbury CRM — global styles.
  Built on Fluent 2 design tokens (the same ones Outlook and Teams use), with a few app-level rules:
  neutral surfaces, one brand accent, 1px borders instead of shadows, dense tables, 44px touch targets on tablets.
*/

:root {
    --app-gap: 16px;
    --app-gap-sm: 8px;
    --app-radius: var(--borderRadiusLarge, 6px);
    --app-border: 1px solid var(--colorNeutralStroke2, #e0e0e0);
    --app-surface: var(--colorNeutralBackground1, #ffffff);
    --app-canvas: var(--colorNeutralBackground2, #fafafa);
    --app-muted: var(--colorNeutralForeground3, #616161);
    --app-text: var(--colorNeutralForeground1, #242424);
    --app-text-2: var(--colorNeutralForeground2, #424242);
    --app-brand: var(--colorBrandForeground1, #0f6cbd);
    --app-contested: #5b5fc7; /* Reserved hue: "another Bradbury company is working this account". */
    --app-contested-bg: #ebebf8;
    --app-nda: #a3127f; /* Reserved hue: "under an NDA with the customer" (account-nda). */
    --app-nda-bg: #fbeef8;
    --app-danger: var(--colorPaletteRedForeground1, #bc2f32);
    --app-danger-bg: var(--colorPaletteRedBackground1, #fdf6f6);
    --app-success: var(--colorPaletteGreenForeground1, #0e700e);
    --app-warning: var(--colorPaletteDarkOrangeForeground1, #bc4b09);
    --app-row-height: 32px;
    --app-nav-width: 220px;
}

body[data-theme="dark"] {
    --app-contested: #9a9fff;
    --app-contested-bg: #2e2f52;
    --app-nda: #f08fd0;
    --app-nda-bg: #3d1a36;
}

body[data-density="comfortable"] { --app-row-height: 44px; }
body[data-density="touch"] { --app-row-height: 44px; }

html, body {
    background: var(--app-canvas);
    color: var(--app-text);
}

body {
    font-family: var(--fontFamilyBase, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif);
    -webkit-tap-highlight-color: transparent;
}

/* "body a" outranks Fluent's adopted default stylesheet, which underlines every link. */
body a { color: var(--app-brand); text-decoration: none; }
body a:hover { text-decoration: underline; }
body a.related-item, body a.related-item:hover, body a.kpi, body a.kpi:hover, body a.app-title, body a.app-title:hover { text-decoration: none; }

/* ---------- Splash / sign-in ---------- */

.app-splash {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100dvh;
    color: var(--app-muted);
    font-size: 14px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--colorBrandBackground, #0f6cbd);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    flex: none;
}

.signin { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.signin-card { width: min(440px, 100%); background: var(--app-surface); border: var(--app-border); border-radius: 8px; padding: 24px; display: grid; gap: 16px; }
.signin-brand { display: flex; align-items: center; gap: 12px; }
.signin-title { font-weight: 600; font-size: 18px; }
.signin-users { display: grid; gap: 8px; }
.signin-user {
    display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
    padding: 10px 12px; min-height: 52px; border: var(--app-border); border-radius: 6px;
    background: var(--app-surface); color: inherit; cursor: pointer; font: inherit;
}
.signin-user:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); border-color: var(--colorNeutralStroke1, #d1d1d1); }
.signin-user-text { display: grid; }

#blazor-error-ui {
    background: #fff4ce;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* Shown when a new release has downloaded; Reload switches to it. */
#update-ui {
    position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1000;
    display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
    padding: 8px 8px 8px 16px; border-radius: 8px; font-size: 14px;
    background: var(--colorNeutralBackground1, #fff); color: var(--app-text, #242424);
    border: var(--app-border); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
#update-ui[hidden] { display: none; }
#update-ui .reload {
    border: 0; border-radius: 4px; padding: 6px 14px; font: inherit; font-weight: 600; cursor: pointer;
    background: var(--colorBrandBackground, #0f6cbd); color: #fff;
}

/* ---------- Utilities ---------- */

.muted { color: var(--app-muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--app-gap-sm); min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--app-gap-sm); min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.gap-0 { gap: 0; }
.gap-4 { gap: 4px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Shell ---------- */

.app-header-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

body .app-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    color: inherit;
}
.app-title:hover { text-decoration: none; }
.app-title .module { color: color-mix(in srgb, currentColor 75%, transparent); font-weight: 400; }
/* Phones: the "B" mark alone links home, leaving room for search and the user menu. */
@media (max-width: 599px) { .app-title .app-title-text { display: none; } }

.global-search { flex: 1 1 auto; max-width: 560px; min-width: 0; }

/* FluentLayout fills its parent: pin the app root to the viewport so only the content area scrolls. */
body > #app { height: 100dvh; }
body .fluent-layout-item[area=content] { overflow: hidden; min-height: 0; }
body .fluent-layout-item[area=nav] { height: auto; }

.app-content {
    height: 100%;
    overflow: auto;
    background: var(--app-canvas);
    -webkit-overflow-scrolling: touch;
}

.page {
    padding: 16px 24px 32px;
    max-width: 1600px;
    margin: 0 auto;
}

/* The expired sign-in bar above a page: the page below brings its own top padding. */
.page.signin-lapsed {
    padding-bottom: 0;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    min-height: 36px;
}

.page-title {
    margin: 0;
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
}

.page-subtitle { color: var(--app-muted); font-size: 13px; }

/* ---------- Panels ---------- */

.panel {
    background: var(--app-surface);
    border: var(--app-border);
    border-radius: var(--app-radius);
    min-width: 0;
}

.panel-header {
    --panel-header-pad-y: 10px; /* read by .panel-toggle, which reaches over it */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--panel-header-pad-y) 14px;
    border-bottom: var(--app-border);
    min-height: 44px;
}

.panel-title { font-weight: 600; font-size: 14px; }
.panel-body { padding: 12px 14px; }
.panel-body.flush { padding: 0; }
.panel.readonly { background: var(--app-canvas); }

.empty {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 28px 16px;
    color: var(--app-muted);
    text-align: center;
}

/* ---------- Property lists ---------- */

.props {
    display: grid;
    grid-template-columns: minmax(110px, 38%) 1fr;
    gap: 6px 12px;
    font-size: 14px;
}

.props dt { color: var(--app-muted); font-size: 13px; }
.props dd { margin: 0; min-width: 0; word-break: break-word; }

/* ---------- Chips & badges ---------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 600;
    line-height: 22px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.chip-company { color: #fff; background: var(--chip-color, #0f6cbd); }
.chip-contested { color: var(--app-contested); background: var(--app-contested-bg); border-color: color-mix(in srgb, var(--app-contested) 30%, transparent); }
.chip-nda { color: var(--app-nda); background: var(--app-nda-bg); border-color: color-mix(in srgb, var(--app-nda) 30%, transparent); }
.chip-danger { color: var(--app-danger); background: var(--app-danger-bg); border-color: color-mix(in srgb, var(--app-danger) 30%, transparent); }
.chip-success { color: var(--app-success); background: var(--colorPaletteGreenBackground1, #f1faf1); }
.chip-warning { color: var(--app-warning); background: var(--colorPaletteDarkOrangeBackground1, #fdf6f3); }
.chip-neutral { color: var(--app-text-2); background: var(--colorNeutralBackground3, #f5f5f5); border-color: var(--colorNeutralStroke2, #e0e0e0); }
.chip-brand { color: var(--app-brand); background: var(--colorBrandBackground2, #ebf3fc); }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 4px 0 10px;
    border-radius: 14px;
    border: var(--app-border);
    background: var(--app-surface);
    font-size: 13px;
    white-space: nowrap;
}
.filter-chip button {
    border: 0; background: transparent; cursor: pointer; color: var(--app-muted);
    width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; font-size: 14px;
}
.filter-chip button:hover { background: var(--colorNeutralBackground3, #f0f0f0); color: var(--app-text); }

/* ---------- List pages ---------- */

.list-page > .list-header.page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 8px;
}
.list-header > .list-heading { grid-area: 1 / 1; }
.list-header > .list-header-actions { grid-area: 1 / 2; justify-content: end; }
.list-header > .list-context { grid-area: 2 / 1 / 3 / -1; margin: 0; }
.list-page .entity-list-toolbar > .entity-list-filters {
    flex: 0 1 auto;
    min-width: 120px;
    margin: 0;
}
.entity-list-toolbar > .entity-list-filters::-webkit-scrollbar { height: 4px; }
.list-selection > .labeled-tick {
    display: inline-flex; align-items: center; gap: 6px; padding-inline: 4px 8px;
    width: auto; min-height: 44px; border-radius: 6px; white-space: nowrap;
}
.list-selection > .labeled-tick:focus-visible { outline-offset: -2px; }

@media (min-width: 1280px) {
    .list-page > .list-header.page-header { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
    .list-header > .list-context { grid-area: 1 / 2; }
    .list-header > .list-header-actions { grid-area: 1 / 3; }
    .list-header .list-count-label { display: none; }
    .list-page .entity-list-toolbar:has(> .entity-list-filters) > .list-search { flex-basis: 222px; min-width: 120px; }
}

.app-header-bar .workspace-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 44px;
    min-height: 36px;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--borderRadiusMedium, 8px);
    background: transparent;
    color: var(--app-text-2);
    font-size: 13px;
    line-height: 1.2;
    text-align: start;
    cursor: pointer;
}
.app-header-bar .workspace-search-trigger:hover { background: var(--app-inset); color: var(--app-text); }
.app-header-bar .workspace-search-trigger.search-icon-only { flex: none; justify-content: center; width: 44px; }
.workspace-search-trigger > svg { flex: none; }
.app-header-bar .workspace-search-popover {
    position: fixed;
    inset: calc(52px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto auto;
    margin: 0;
    width: min(420px, calc(100vw - 24px));
    overflow: visible;
    padding: 8px;
    border: var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text);
    box-shadow: var(--app-shadow);
}
.app-header-bar .workspace-search-popover .workspace-search-results { inset-inline: 0; width: auto; }

@media (max-width: 743px) {
    .app-header-bar .workspace-search-trigger { min-height: 44px; padding-inline: 4px; font-size: 12px; }
    .app-header-bar .workspace-search-popover { top: calc(56px + env(safe-area-inset-top)); }

    .list-header-actions fluent-button.new-opportunity-action { min-width: 70px; min-height: 44px; }
    .phone-select-mode {
        min-width: 48px; min-height: 44px; padding: 0 6px; border: 0; border-radius: 6px;
        background: transparent; color: var(--app-brand); font-size: 13px; font-weight: 650; cursor: pointer;
    }
    .phone-select-mode:hover, .phone-select-mode[aria-pressed="true"] { background: var(--app-brand-tint); }
    .phone-select-mode:focus-visible { outline-offset: -2px; }
    .list-page .entity-list-toolbar .rollup-toggle { min-width: 116px; }
    .phone-filter-copy { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; line-height: 1.15; text-align: start; }
    .phone-filter-copy > strong { font-size: 12px; white-space: nowrap; }
    .phone-filter-copy > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--app-text-2); font-size: 11px; }
    .phone-record-wrap { position: relative; min-width: 0; }
    .grid-host.phone-rows .phone-row { height: 57px; }
    .phone-row-check { display: grid; place-items: center; flex: 0 0 24px; }
    .phone-row-meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
    .phone-row-meta small { flex: 1 1 auto; min-width: 0; }
    .phone-row-amount { flex: none; margin-inline-start: auto; text-align: end; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
    .grid-host.phone-rows .phone-opportunity-name {
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        white-space: normal; overflow: hidden; overflow-wrap: anywhere; line-height: 17px;
    }
    .phone-record-wrap:has(.phone-read-name:not([hidden])) .phone-opportunity-name { padding-inline-end: 30px; }
    .phone-read-name[hidden], .phone-name-popover:not(:popover-open) { display: none; }
    .phone-read-name:not([hidden]) {
        display: grid; place-items: center; position: absolute; inset: 0 0 auto auto; width: 44px; height: 44px;
        border: 0; border-radius: 6px; background: transparent; color: var(--app-brand); cursor: pointer;
    }
    .phone-name-popover {
        width: min(420px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 16px;
        border: var(--app-border); border-radius: 10px; background: var(--app-surface); color: var(--app-text);
        box-shadow: var(--app-shadow); overflow-wrap: anywhere;
    }
    .phone-name-popover:popover-open { display: block; }
    .phone-name-popover button {
        display: block; margin: 12px 0 0 auto; min-height: 44px; padding-inline: 12px;
        border: var(--app-border); border-radius: 6px; background: var(--app-inset); color: var(--app-text); cursor: pointer;
    }
}

@media (max-width: 374px) {
    .list-header > .list-heading { column-gap: 5px; }
    .list-page .list-heading .page-title { font-size: 21px; }
    .entity-list-toolbar:has(.reset-button) .list-search [slot="start"] { display: none; }
}

@media (pointer: coarse) {
    .app-header-bar .workspace-search-trigger { min-height: 44px; }
}

.list-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 12px 24px 0;
}

.list-page.embedded { padding: 0; height: auto; }

/* The title row keeps its height when the page is taller than the screen (a phone's map and list), so its wrapped
   buttons never slide under the toolbar. */
.list-page > .page-header { flex: none; }

.view-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: var(--app-border);
    margin-bottom: 10px;
    flex: none;
}
.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
    position: relative;
    border: 0;
    background: transparent;
    color: var(--app-text-2);
    font: inherit;
    font-size: 14px;
    padding: 8px 12px 10px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
}
.view-tab:hover { color: var(--app-text); background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.view-tab.active { color: var(--app-text); font-weight: 600; }
/* A hidden view that's open shows as a last, temporary tab (FR-245). */
.view-tab.temporary { font-style: italic; color: var(--app-muted); }
.view-tab.temporary.active { color: var(--app-text); }
.view-tab.active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 3px;
    border-radius: 2px;
    background: var(--colorBrandBackground, #0f6cbd);
}
.view-tab .shared { color: var(--app-muted); margin-left: 4px; font-size: 12px; }

/* Company switcher on list pages: which company's records are showing, tinted in its color, and a button per company. */
.company-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 10px;
    padding: 6px 8px 6px 12px;
    border: var(--app-border);
    border-left: 4px solid var(--company);
    border-radius: var(--app-radius);
    background: color-mix(in srgb, var(--company) 12%, var(--app-surface));
    flex: none;
}
.company-bar.all { border-left-color: var(--colorNeutralStroke1, #d1d1d1); background: var(--app-surface); }
.company-bar-now { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 220px; font-size: 15px; }
.company-bar-label { color: var(--app-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.company-buttons { display: flex; gap: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.company-buttons::-webkit-scrollbar { display: none; }
.company-btn {
    flex: none;
    height: 28px;
    min-width: 44px;
    padding: 0 10px;
    border: var(--app-border);
    border-radius: 14px;
    background: var(--app-surface);
    color: var(--app-text-2);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.company-btn:hover { border-color: var(--company); color: var(--app-text); }
.company-btn.active { border-color: var(--company); background: var(--company); color: #fff; }
.company-btn:focus-visible { outline: 2px solid var(--colorStrokeFocus2, #000); outline-offset: 1px; }

/* Fiscal-year and sale-type buttons under the company bar (opportunities). */
.list-switchers { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 10px; flex: none; }
.switch-group { display: flex; align-items: center; gap: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none; --company: var(--colorBrandBackground, #0f6cbd); }
.switch-group::-webkit-scrollbar { display: none; }
.switch-label { color: var(--app-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 6px; white-space: nowrap; }

/* A plain text box with a suggestion list (agent, "with"), styled to sit with the Fluent fields. */
.native-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.native-field label { font-size: 14px; color: var(--app-text); }
/* The asterisk Fluent's own labels show on a required field */
.field-required { margin-inline-start: 4px; color: var(--colorPaletteRedForeground1, #bc2f32); }
.native-input {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    border-bottom-color: var(--colorNeutralStrokeAccessible, #616161);
    border-radius: var(--borderRadiusMedium, 4px);
    background: var(--colorNeutralBackground1, #fff);
    color: var(--app-text);
    font: inherit;
    font-size: 14px;
    width: 100%;
    min-width: 0;
}
.native-input:hover { border-color: var(--colorNeutralStroke1Hover, #c7c7c7); border-bottom-color: var(--colorNeutralStrokeAccessibleHover, #575757); }
.native-input:focus { outline: none; border-bottom: 2px solid var(--colorCompoundBrandStroke, #0f6cbd); }

/* A picker's option drawn from a template (AccountPicker, UserPicker): Fluent's list picks an option only when the click
   lands on the option itself, so a click on the name or the detail under it did nothing and only the tick box picked.
   Clicks pass through what's inside to the option. */
fluent-option > * { pointer-events: none; }

.list-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    flex: none;
}

.list-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; flex: none; }

/* Reset reads as a word on wide screens; its icon is for the tablet toolbar, where the word is hidden. */
.reset-button > [slot="start"] { display: none; }

/* Table / Board / Map: one button per layout the page offers, the current one highlighted. */
.layout-choice { display: inline-flex; gap: 2px; }

/* A segmented choice (a fiscal year, who a goal is for, which people to show): joined buttons, the chosen one
   tinted. Pages adjust sizes in their own stylesheet. */
.segmented { display: inline-flex; border: var(--app-border); border-radius: var(--app-radius); overflow: hidden; }
.segmented button {
    border: 0; background: transparent; color: var(--app-text-2); padding: 5px 12px; font: inherit; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button + button { border-left: var(--app-border); }
.segmented button:hover:not(.on) { background: var(--colorNeutralBackground1Hover, #f5f5f5); color: var(--app-text); }
.segmented button.on { background: var(--colorBrandBackground2, #ebf3fc); color: var(--app-brand); font-weight: 600; }
.segmented button:focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }
@media (pointer: coarse) { .segmented button { min-height: 44px; } }

/* ---------- The Map layout's rolled-up filters ---------- */

/* The map takes the height: a tighter title, and no footer (the map's own list counts what's on it). */
.list-page.layout-map { padding-top: 18px; padding-bottom: 16px; }
.list-page.layout-map .page-header { margin-bottom: 12px; }
.list-page.layout-map .list-footer { display: none; }

/* The Filters button summarizes the rolled-up filters on a single line. */
.rollup-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: max-content;
    height: 32px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    border-radius: var(--borderRadiusMedium, 4px);
    background: var(--colorNeutralBackground1, #fff);
    color: var(--colorNeutralForeground1, #242424);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.rollup-toggle:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); border-color: var(--colorNeutralStroke1Hover, #c7c7c7); }
.rollup-toggle[aria-expanded="true"] { border-color: var(--colorBrandStroke1, #0f6cbd); background: var(--colorBrandBackground2, #ebf3fc); }
.rollup-toggle > svg { flex: none; }
.rollup-toggle-label { flex: none; font-weight: 600; }
.rollup-count {
    flex: none;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--colorBrandBackground, #0f6cbd);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}
.rollup-summary {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 8px;
    border-left: 1px solid var(--app-line, #e0e0e0);
    color: var(--app-text-2);
}
.rollup-summary:empty { display: none; }
.rollup-chevron { transition: transform .15s ease; }
.rollup-toggle[aria-expanded="true"] .rollup-chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .rollup-chevron { transition: none; } }

/* Rolled down: a panel under the toolbar, a labelled row for each kind of filter, broad to narrow. */
.list-rollup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 10px;
    padding: 12px 14px;
    background: var(--app-surface);
    border: var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow, none);
    flex: none;
}
.list-rollup[hidden] { display: none; }
.rollup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; min-width: 0; }
.rollup-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.rollup-row.rollup-views { flex-wrap: nowrap; }
.rollup-label {
    flex: none;
    min-width: 68px;
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* The company, fiscal-year and sale-type buttons sit in the panel's first row as plain button groups. */
.list-rollup .company-bar { flex: none; margin: 0; padding: 0; border: 0; background: none; }
.list-rollup .company-bar-now { display: none; }
.list-rollup .list-switchers { display: contents; }
.list-rollup .view-tabs { flex: 0 1 auto; min-width: 0; margin: 0; }

@media (max-width: 599px) {
    .rollup-label { min-width: 0; }
}

/* ---------- Filters rolled up by choice on the Table and Board layouts (FR-444) ---------- */

/* Roll up filters sits alongside the saved views and scope. */
.filters-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: none;
    margin-inline-start: auto;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--borderRadiusMedium, 4px);
    background: transparent;
    color: var(--app-text-2);
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
}
.filters-choice:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); color: var(--app-text); }
.filters-choice:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 1px; }
.filters-choice > svg { flex: none; }

.list-rollup .rollup-keep { margin-inline-start: auto; }

@media (min-width: 744px) and (max-width: 1279px) {
    .filters-choice { width: 44px; padding: 0; }
    .filters-choice-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.grid-host {
    flex: 1 1 auto;
    min-height: 240px;
    overflow: auto;
    background: var(--app-surface);
    border: var(--app-border);
    border-radius: var(--app-radius);
    -webkit-overflow-scrolling: touch;
}

.list-page.embedded .grid-host { max-height: 520px; }

/* Rows on their way (a screen opening, a new view, filter, search or sort, or rows further down): a bar over the
   table's top edge that stays put as the table scrolls. It waits a moment, so a quick fetch doesn't flash it. */
.grid-loading { position: sticky; top: 0; left: 0; z-index: 5; height: 0; }
.grid-loading fluent-progress-bar {
    position: absolute; top: 0; left: 0; width: 100%;
    animation: grid-loading-in 0s linear 150ms both;
}
@keyframes grid-loading-in { from { visibility: hidden; } to { visibility: visible; } }

.list-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 8px 4px 12px;
    font-size: 13px;
    color: var(--app-text-2);
    flex: none;
}
.list-footer strong { font-variant-numeric: tabular-nums; color: var(--app-text); }

.grid-host fluent-data-grid, .grid-host .fluent-data-grid { font-size: 14px; }

/* A list's selection column: plain buttons drawn from the selection, tinting the rows it holds. */
.row-tick {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: 4px; background: transparent; cursor: pointer;
}
body .grid-host .fluent-data-grid td.tick-cell { padding: 0; text-align: center; }
.row-tick:focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }
body .grid-host .fluent-data-grid tr.row-selected > td { background: var(--colorBrandBackground2, #ebf3fc); }
@media (pointer: coarse) { .row-tick { width: 44px; } }

/* Headers after the pinned first column can be dragged: the grid marks them reorderable, and they show a grip.
   The grid's column-options chevron only offers reordering here, so it is hidden to keep the headers clean. */
.grid-host th[reorderable='true'] { cursor: grab; }
.grid-host th[reorderable='true'] [col-options-button] { display: none; }
.grid-host th[reorderable='true'] > div:first-child::before {
    content: ""; flex: none; align-self: center; width: 16px; height: 16px; margin-inline-end: 2px;
    background: var(--app-muted);
    -webkit-mask: var(--grip-icon) center / 16px no-repeat; mask: var(--grip-icon) center / 16px no-repeat;
}
:root {
    /* Fluent's ReOrderDotsVertical (regular, 16px). */
    --grip-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 5a1 1 0 1 0 0-2 1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3-7a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-1 5a1 1 0 1 0 0-2 1 1 0 0 0 0 2'/%3E%3C/svg%3E");
}

/* Columns drawer: shown columns drag by their grip; FluentSortableList's bordered fixed-height rows are replaced. */
.columns-dialog .fluent-sortable-list { border: 0; padding: 0; min-height: 0; }
.columns-dialog .fluent-sortable-list .sortable-item {
    height: auto !important; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 6px;
}
.columns-dialog .fluent-sortable-list .sortable-item:focus { border: 0; background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.columns-dialog .fluent-sortable-list .sortable-item[aria-grabbed='true'] { border: 0; background: var(--colorBrandBackground2, #ebf3fc); }
.columns-dialog .fluent-sortable-list .sortable-ghost {
    background: var(--colorBrandBackground2, #ebf3fc) !important; border: 1px dashed var(--colorBrandStroke1, #0f6cbd) !important;
}
.column-row { display: flex; align-items: center; gap: 4px; min-height: 36px; }
.column-row fluent-field { margin-block: 0; }
.column-row.no-grip { padding-inline-start: 28px; }
.arrange-row { width: 100%; }
.arrange-row .spacer { flex: 1; }
.arrange-row .arrange-shared { white-space: nowrap; }
/* Arrange panels…: an empty side still takes a dropped row. */
.arrange-panels .fluent-sortable-list { min-height: 36px; }
.arrange-panels .arrange-side { margin-top: 8px; }

/* A task's Microsoft To Do lines under Priority and Reminder (tasks-in-microsoft-todo). */
.todo-lines { display: flex; flex-direction: column; gap: 4px; }
.todo-lines .todo-warning { color: var(--app-warning); }
.columns-dialog .fluent-sortable-list .column-grip {
    position: static; display: inline-flex; align-items: center; justify-content: center; align-self: stretch;
    width: 24px; height: auto; padding: 0; background: transparent; border-radius: 4px; cursor: grab; touch-action: none;
}
.columns-dialog .column-grip svg { fill: var(--app-muted) !important; }
.columns-dialog .column-grip:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); }
body .cell-link { color: var(--app-text); font-weight: 600; }
.cell-link:hover { color: var(--app-brand); }

/* ---------- Record pages ---------- */

.record { padding: 16px 24px 32px; max-width: 1600px; margin: 0 auto; }
.brief { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 24px 32px; max-width: 640px; margin: 0 auto; }

.record-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: var(--app-border);
}

.record-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--colorBrandBackground2, #ebf3fc);
    color: var(--app-brand);
    font-weight: 700;
    font-size: 16px;
    flex: none;
}

.record-titles { flex: 1 1 320px; min-width: 0; }
.record-title { margin: 0; font-size: 22px; line-height: 30px; font-weight: 600; word-break: break-word; }
.record-sub { color: var(--app-muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; font-size: 14px; }
.record-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.record-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.record.record-workspace { padding-block-start: 12px; }
.record-workspace > .record-header {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 6px 10px;
    align-items: start;
    padding-block-end: 10px;
    margin-block-end: 10px;
}
.record-workspace .record-header .record-icon { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
.record-workspace .record-header .record-title { font-size: clamp(19px, 2vw, 24px); line-height: 1.25; }
.record-workspace .record-header .record-sub { gap: 3px 8px; overflow-wrap: anywhere; }
.record-workspace .record-header .record-badges { gap: 3px 6px; margin-block-start: 4px; }
.record-workspace .record-header .record-badges:empty, .record-workspace .record-actions:empty { display: none; }
.record-workspace .record-badges > .chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.record-workspace .record-actions { gap: 4px; min-width: 0; }
.record-workspace .record-grid { gap: 12px; }
.record-workspace .record-grid > .col { gap: 12px; }
.record-workspace .record-grid .panel-header { --panel-header-pad-y: 7px; min-height: 40px; padding-inline: 12px; }
.record-workspace .record-grid .related-item { padding: 7px 12px; }
.record-workspace .record-grid .fluent-sortable-list { gap: 12px; }
.record-workspace > :is(.nda-banner, .credit-banner, .contested-banner) { padding: 7px 10px; margin-block-end: 10px; }
.record-workspace .record-grid > [tabindex="-1"] { scroll-margin-block-start: 8px; }

.record-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-block-end: 10px;
    border: var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
}
.record-facts-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.record-facts .kpi { padding: 6px 10px; border: 0; border-radius: 0; background: transparent; overflow-wrap: anywhere; }
.record-facts .kpi + .kpi { border-inline-start: var(--app-border); }
.record-facts .kpi-value { font-size: clamp(14px, 1.6vw, 18px); line-height: 1.3; }
.record-facts :is(.kpi-label, .kpi-note) { line-height: 1.35; }
.opportunity-record .stage-path { margin-block-end: 10px; }
.opportunity-record .stage-step:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--app-brand); }
.record-jumps { display: none; }

.record-workspace .trip-plan:has(.trip-route[hidden]) { grid-template-areas: "unplanned" "days" "dropped"; }
.record-workspace .trip-route-area:has(> .trip-route[hidden]) { display: none; }
@media (min-width: 1024px) {
    .record-workspace .trip-plan:has(.trip-route[hidden]) {
        grid-template-rows: auto 1fr;
        grid-template-areas: "days unplanned" "days dropped";
    }
}

@media screen and (max-width: 743px) {
    .record-workspace > .record-header { grid-template-columns: 32px minmax(0, 1fr); }
    .record-workspace > .record-header > .record-actions { grid-column: 1 / -1; }
    .record-workspace .record-facts .kpi { padding-inline: 7px; }
    .record-facts:not(.record-facts-three) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .record-facts:not(.record-facts-three) .kpi:nth-child(3) { border-inline-start: 0; }
    .record-facts:not(.record-facts-three) .kpi:nth-child(n+3) { border-block-start: var(--app-border); }
    .record-workspace .record-jumps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin-block: 0 6px; }
    .record-jumps a { display: inline-flex; align-items: center; min-height: 32px; font-weight: 600; }
}

@media (pointer: coarse) {
    .record-workspace .record-actions fluent-anchor-button, .record-jumps a { min-height: 44px; }
    .opportunity-record .stage-step { min-height: 44px; }
}

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--app-surface); border: var(--app-border); border-radius: var(--app-radius); padding: 10px 14px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--app-muted); }
.kpi-value { font-size: 22px; line-height: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12px; color: var(--app-muted); }

.record-grid {
    display: grid;
    gap: 16px;
    align-items: start;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(280px, 360px);
    grid-template-areas: "left center right";
}

.record-grid > .col { gap: 16px; min-width: 0; }
.record-left { grid-area: left; }
.record-center { grid-area: center; }
.record-right { grid-area: right; }

/* Laptops and iPad landscape: timeline beside details; related lists stack under details. */
@media (max-width: 1439px) {
    .record-grid {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        grid-template-areas: "left center" "right center";
    }
}

/* An account page side with no panels shown gives its room to the timeline (FR-278). */
.record-grid.no-left > .record-left, .record-grid.no-right > .record-right { display: none; }
@media (min-width: 1440px) {
    .record-grid.no-left { grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); grid-template-areas: "center right"; }
    .record-grid.no-right { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); grid-template-areas: "left center"; }
    .record-grid.no-left.no-right { grid-template-columns: minmax(0, 1fr); grid-template-areas: "center"; }
}
@media (max-width: 1439px) {
    .record-grid.no-left { grid-template-rows: auto; grid-template-areas: "right center"; }
    .record-grid.no-right { grid-template-rows: auto; grid-template-areas: "left center"; }
    .record-grid.no-left.no-right { grid-template-columns: minmax(0, 1fr); grid-template-areas: "center"; }
}

/* Phones: one column. Tablets (744 and wider) keep two; see the tablet tier below. */
@media (max-width: 743px) {
    .record-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas: "left" "center" "right";
    }
    .record-grid.no-left { grid-template-areas: "center" "right"; }
    .record-grid.no-right { grid-template-areas: "left" "center"; }
    .record-grid.no-left.no-right { grid-template-areas: "center"; }
    .record, .page, .brief { padding: 12px 12px 24px; }
    .list-page { padding: 8px 12px 0; }
}

/* Fluent inputs size to their content; make them fill the field wrapper (whose width the Width parameter sets). */
fluent-field > fluent-textarea, fluent-field > fluent-text-input { width: 100%; }
fluent-textarea::part(root) { width: 100%; box-sizing: border-box; }
fluent-textarea::part(control) { width: 100%; box-sizing: border-box; }

/* A focused input's underline reaches 1px past its border. At 150% display scaling that is a fraction of a pixel past a
   dialog's scrolling content, which then shows a horizontal scrollbar. A pixel of padding inside the content, given back
   by the margin, keeps the underline inside without moving anything. */
fluent-dialog-body::part(content) { padding-inline: 1px; margin-inline: -1px; }

/* Fluent inputs have intrinsic minimum widths; let them shrink to their container. */
fluent-text-input, fluent-textarea, fluent-dropdown, fluent-combobox, .fluent-select, .fluent-autocomplete { max-width: 100%; min-width: 0; }

/* Contested banner: another Bradbury company has open deals on this account. */
.contested-banner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 14px;
    border-radius: var(--app-radius);
    border: 1px solid color-mix(in srgb, var(--app-contested) 35%, transparent);
    background: var(--app-contested-bg);
    color: var(--app-text);
    margin-bottom: 16px;
}
.contested-banner .icon { color: var(--app-contested); flex: none; margin-top: 2px; }

.credit-banner {
    display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-radius: var(--app-radius);
    border: 1px solid color-mix(in srgb, var(--app-danger) 35%, transparent); background: var(--app-danger-bg); margin-bottom: 16px;
}

/* NDA banner: the customer is under an NDA, so its details stay inside the signing company (account-nda, FR-255). */
.nda-banner {
    display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-radius: var(--app-radius);
    border: 1px solid color-mix(in srgb, var(--app-nda) 40%, transparent); background: var(--app-nda-bg); color: var(--app-text);
    margin-bottom: 16px; overflow-wrap: anywhere;
}
.nda-banner .icon { color: var(--app-nda); flex: none; margin-top: 2px; }
.nda-banner strong { color: var(--app-nda); }

/* Related lists on record pages */
.related-list { display: grid; }
.related-item {
    display: grid;
    gap: 2px;
    padding: 10px 14px;
    border-bottom: var(--app-border);
    color: inherit;
    min-width: 0;
}
.related-item:last-child { border-bottom: 0; }
.related-item:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); text-decoration: none; }
.related-item .title { font-weight: 600; }
.related-item .meta { font-size: 12px; color: var(--app-muted); display: flex; gap: 8px; flex-wrap: wrap; }
/* A list's rows added up, under the list (the Sites panel). */
.related-total { padding: 8px 14px; border-top: var(--app-border); font-size: 12px; color: var(--app-muted); overflow-wrap: anywhere; }

/* Estimates: rows fit however narrow the panel. */
.estimate-list .related-item { overflow-wrap: anywhere; }
.estimate-list .chip { max-width: 100%; }

/* The account page's list panels: past their first five rows, Show all scrolls inside the panel rather than stretching
   the page (account-panel-layout, FR-274). */
.related-list.all { max-height: 480px; overflow-y: auto; }
.related-list.all:focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }

/* An account page panel's title rolls it up (FR-275): a plain button filling the title area, its chevron turned while
   rolled up. It reaches over the header's padding, so the whole header height is the target and the header is no
   taller than before. Rolled up, only the header shows. */
.panel-toggle {
    display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; align-self: stretch;
    margin: calc(-1 * var(--panel-header-pad-y, 10px)) 0; padding: var(--panel-header-pad-y, 10px) 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.panel-toggle .panel-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-toggle .panel-count { flex: none; white-space: nowrap; }
.account-panel .panel-header > fluent-button { flex: none; white-space: nowrap; }
.panel-toggle:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 2px; border-radius: 4px; }
.panel-chevron { flex: none; transition: transform 0.15s ease; }
.account-panel.collapsed .panel-chevron { transform: rotate(-90deg); }
.account-panel.collapsed .panel-header { border-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .panel-chevron { transition: none; } }

/* A card's six-dot grip drags it to another place on either side of the account page (FR-332). It is for the mouse and
   touch; Arrange panels... in the page header does the same from the keyboard. It reaches over the header's padding, so
   the whole header height grabs, and the header is no taller than before. Fluent's own grip look is taken off. */
.record-grid .fluent-sortable-list .panel-grip.sortable-grab {
    flex: none; display: inline-flex; align-items: center; justify-content: center; position: static; left: auto; right: auto;
    width: 20px; height: auto; align-self: stretch; margin: calc(-1 * var(--panel-header-pad-y, 10px)) -4px calc(-1 * var(--panel-header-pad-y, 10px)) -8px;
    padding: 0; border-radius: 4px; background: none; color: var(--app-muted); cursor: grab; touch-action: none; opacity: 0.6;
}
.record-grid .fluent-sortable-list .panel-header:hover .panel-grip.sortable-grab { opacity: 1; background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.record-grid .fluent-sortable-list .panel-grip.sortable-grab:active { cursor: grabbing; }
@media (pointer: coarse) {
    .record-grid .fluent-sortable-list .panel-grip.sortable-grab { width: 36px; opacity: 1; margin-left: -12px; }
}

/* Each side of the account page is a sortable list of cards (FR-332): no list chrome, each card as it was, 16px apart,
   and its text still selectable. */
.record-grid .fluent-sortable-list { display: flex; flex-direction: column; gap: 16px; border: 0 !important; padding: 0 !important; background: transparent !important; min-height: 0; }
.record-grid .fluent-sortable-list .sortable-item {
    display: block !important; height: auto !important; padding: 0 !important; margin: 0 !important; border: 0 !important;
    background: transparent !important; border-radius: var(--app-radius); -webkit-user-select: auto; user-select: auto;
}
.record-grid .fluent-sortable-list .sortable-item:focus, .record-grid .fluent-sortable-list .sortable-item[aria-grabbed='true'] { border: 0; background: transparent; }
.record-grid .fluent-sortable-list .sortable-item-content { padding: 0; min-width: 0; }
/* Where the card would land: its place, held by a dashed outline. */
.record-grid .fluent-sortable-list .sortable-ghost {
    background: var(--colorBrandBackground2, #ebf3fc) !important; outline: 2px dashed var(--colorBrandStroke1, #0f6cbd); outline-offset: -2px;
}
.record-grid .fluent-sortable-list .sortable-ghost > .sortable-item-content { opacity: 0.35; background: transparent !important; }
/* The card under the pointer. */
.record-grid .sortable-fallback .account-panel { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }

/* While a card is dragged, a side with no cards comes back as a place to drop one (FR-332). */
.record-grid:has(.sortable-ghost) > .record-left, .record-grid:has(.sortable-ghost) > .record-right { display: flex; }
.record-grid:has(.sortable-ghost) .fluent-sortable-list { min-height: 72px; border-radius: var(--app-radius); }
.record-grid:has(.sortable-ghost) .fluent-sortable-list:not(:has(.sortable-item)) { outline: 2px dashed var(--colorNeutralStroke1, #d1d1d1); outline-offset: -2px; }
@media (min-width: 1440px) {
    .record-grid.no-left:has(.sortable-ghost), .record-grid.no-right:has(.sortable-ghost) {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(280px, 360px); grid-template-areas: "left center right";
    }
}
@media (min-width: 744px) and (max-width: 1439px) {
    .record-grid.no-left:has(.sortable-ghost), .record-grid.no-right:has(.sortable-ghost) {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "left center" "right center";
    }
}
@media (max-width: 743px) {
    .record-grid:has(.sortable-ghost) { grid-template-areas: "left" "center" "right"; }
}

/* Rows that open something, a ticket or a visit (FR-327, FR-329): buttons that look like the list's other rows. */
button.related-item { width: 100%; margin: 0; text-align: left; font: inherit; background: none; border: 0; border-bottom: var(--app-border); cursor: pointer; }
button.related-item:last-child { border-bottom: 0; }
button.related-item:focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }

/* The On Site Visits card (FR-328). */
.visit-group {
    padding: 8px 14px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--app-muted);
    border-bottom: var(--app-border);
}
.related-list + .visit-group { border-top: var(--app-border); }
.visit-line .visit-icon { flex: none; color: var(--app-muted); }
.visit-line .title { overflow-wrap: anywhere; }
.visit-snippet {
    font-size: 12px; color: var(--app-text-2); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere;
}

/* A ticket's and a visit's drawers (FR-327, FR-329). */
.drawer-heading { font-size: 16px; font-weight: 600; line-height: 22px; overflow-wrap: anywhere; }
.drawer-list { border: var(--app-border); border-radius: var(--app-radius); }
.support-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.visit-summary { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--app-radius); background: var(--colorBrandBackground2, #ebf3fc); }
.visit-meeting { border: var(--app-border); border-radius: var(--app-radius); }
.visit-drawer .tl-report { margin-top: 0; }

/* An account's brief: one column built for a phone. Long names and numbers wrap, so nothing scrolls sideways. */
.brief .panel-title { margin: 0; line-height: 20px; }
.brief .related-item { overflow-wrap: anywhere; }
.brief .chip { max-width: 100%; }
.brief .credit-banner, .brief .contested-banner, .brief .nda-banner { margin-bottom: 0; }
.brief-header { display: grid; gap: 2px; min-width: 0; }
.brief-alerts { display: grid; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.brief-note { padding: 13px 18px; color: var(--app-muted); }
.brief-alerts .brief-note { padding: 0; }
.brief-phones { display: flex; flex-wrap: wrap; gap: 0 16px; }
.brief-write-up { margin-top: 4px; white-space: pre-wrap; }
.brief-more { padding: 13px 18px; border-top: var(--app-border); font-weight: 600; }

/* ---------- Stage path & probability ---------- */

.stage-path { display: flex; gap: 2px; overflow-x: auto; margin-bottom: 16px; scrollbar-width: thin; }
.stage-step {
    flex: 1 0 auto;
    min-width: 92px;
    border: 0;
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    background: var(--colorNeutralBackground3, #f0f0f0);
    color: var(--app-text-2);
    cursor: pointer;
    white-space: nowrap;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}
.stage-step:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 4px 0 0 4px; }
.stage-step.done { background: var(--colorBrandBackground2, #ebf3fc); color: var(--app-brand); }
.stage-step.current { background: var(--colorBrandBackground, #0f6cbd); color: #fff; font-weight: 600; }
.stage-step.won { background: var(--colorPaletteGreenBackground3, #107c10); color: #fff; }
.stage-step.lost { background: var(--colorPaletteRedBackground3, #d13438); color: #fff; }
.stage-step.inactive { background: var(--colorNeutralBackground5, #ebebeb); color: var(--app-text); font-weight: 600; }
.stage-step:disabled { cursor: default; }

.prob { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.prob-bar { width: 56px; height: 6px; border-radius: 3px; background: var(--colorNeutralBackground5, #e6e6e6); overflow: hidden; flex: none; }
.prob-bar > span { display: block; height: 100%; background: var(--colorBrandBackground, #0f6cbd); }
.prob-bar.commit > span { background: var(--colorPaletteGreenBackground3, #107c10); }
.prob-manual { font-size: 11px; color: var(--app-muted); }

/* ---------- Timeline ---------- */

.composer { display: grid; gap: 10px; padding: 12px 14px; }
.composer-types { display: flex; gap: 4px; flex-wrap: wrap; }
.record-activity .composer[hidden] { display: none; }
.record-activity .record-activity-header { justify-content: space-between; flex-wrap: wrap; }
.record-activity .record-activity-header h2 { margin: 0; }
.record-activity .composer-participant { flex: 1 1 200px; min-width: min(100%, 200px); }
.record-activity .composer-outcome { min-width: min(100%, 160px); }

.timeline { display: grid; }
.tl-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 12px 14px; border-top: var(--app-border); }
.tl-item.pinned { background: color-mix(in srgb, var(--colorBrandBackground2, #ebf3fc) 55%, var(--app-surface)); }
.tl-icon {
    width: 32px; height: 32px; border-radius: 16px; display: grid; place-items: center;
    background: var(--colorNeutralBackground3, #f0f0f0); color: var(--app-text-2);
}
.tl-icon.call { background: #e8f3ec; color: #0e700e; }
.tl-icon.meeting { background: #f0ebf8; color: #6b4ea8; }
.tl-icon.task { background: #fdf3e7; color: #a4581e; }
.tl-icon.email { background: #e8f1fb; color: #0f6cbd; }
body[data-theme="dark"] .tl-icon.call, body[data-theme="dark"] .tl-icon.meeting, body[data-theme="dark"] .tl-icon.task, body[data-theme="dark"] .tl-icon.email { background: var(--colorNeutralBackground3); }
/* Customer service tickets (customer-service-tickets): read-only, so no hover that suggests a click. */
.tl-icon.ticket { background: #fdecee; color: #b10e1c; }
body[data-theme="dark"] .tl-icon.ticket { background: var(--colorNeutralBackground3); color: var(--app-danger); }
.tl-ticket .tl-subject .chip { margin-left: 6px; vertical-align: 1px; }

/* Field service on the account timeline (account-service-history): visits, their reports, and scheduled visits. A report's
   answers are the tech's own words as plain text, line breaks kept and long text wrapped (AD-10). */
.tl-icon.field { background: #e9f2ef; color: #0b6a52; }
body[data-theme="dark"] .tl-icon.field { background: var(--colorNeutralBackground3); color: var(--app-success, #54b054); }
.tl-field .tl-subject .chip { margin-left: 6px; vertical-align: 1px; }
.tl-field-dates { font-weight: 600; }
.tl-report { margin-top: 8px; border: var(--app-border); border-radius: 6px; background: var(--app-surface); }
.tl-report > summary { cursor: pointer; padding: 6px 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.tl-report > summary:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 2px; border-radius: 6px; }
.tl-report-title { font-weight: 600; }
.tl-answers { margin: 0; padding: 4px 10px 10px; display: grid; gap: 2px; }
.tl-answers dt { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--app-muted); }
.tl-answers dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* The Service panel's field service lines (FR-289), below any tickets. */
.service-lines { display: grid; gap: 8px; padding: 10px 14px; border-top: var(--app-border); }
.service-line { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; align-items: start; overflow-wrap: anywhere; }
.service-line > svg { margin-top: 2px; color: var(--app-muted); }
.tl-show { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 14px; border-top: var(--app-border); }
.ticket-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The brief's ticket rows open nothing, so they don't light up; the card's and the drawer's do (FR-327). */
div.related-item.ticket-line:hover { background: transparent; }
/* A location (a SyteLine ship-to, FR-476) opens nothing, so it doesn't light up like a link, and a long address wraps. */
div.related-item.location-item:hover { background: transparent; }
div.related-item.location-item { overflow-wrap: anywhere; }
/* Its second line wraps on a narrow side panel: keep the wrapped lines close, as one row of facts. */
.location-item .meta { row-gap: 2px; }
.panel-foot { padding: 10px 18px; border-top: var(--app-border); }
.tl-subject { font-weight: 600; }
.tl-body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; color: var(--app-text-2); }
.tl-meta { margin-top: 4px; font-size: 12px; color: var(--app-muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
/* A customer visit's reason and documented state */
.tl-visit { margin-top: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--app-text-2); }
.tl-visit > span:first-child { min-width: 0; overflow-wrap: anywhere; }
/* Emails logged with their original message */
.tl-email-people { margin-top: 2px; font-size: 12px; color: var(--app-muted); overflow-wrap: anywhere; }
.email-attachments { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.email-head { display: grid; gap: 2px; font-size: 13px; margin-bottom: 10px; overflow-wrap: anywhere; }
.email-head .muted { display: inline-block; min-width: 44px; }
.email-blocked { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0; padding: 8px 12px; border: 1px solid var(--app-border); border-radius: var(--app-radius); font-size: 13px; color: var(--app-text-2); }
.tl-thread { margin-left: 6px; vertical-align: 1px; font-weight: 600; }
.email-thread { display: grid; gap: 4px; margin-bottom: 10px; }
.email-fold { display: grid; grid-template-columns: minmax(0, 12rem) auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; width: 100%;
    padding: 6px 10px; border: 1px solid var(--app-border); border-radius: var(--app-radius); background: var(--colorNeutralBackground2, #fafafa);
    color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.email-fold:hover, .email-fold:focus-visible { background: var(--colorNeutralBackground2Hover, #f0f0f0); }
.email-fold .email-fold-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-fold .email-fold-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--app-text-2); }
.email-open { border-top: 1px solid var(--app-border); padding-top: 10px; }
@media (max-width: 640px) {
    .email-fold { grid-template-columns: minmax(0, 1fr) auto; }
    .email-fold .email-fold-text { grid-column: 1 / -1; }
}
.email-frame { display: block; width: 100%; height: 60vh; min-height: 320px; margin-top: 10px; border: 1px solid var(--app-border); border-radius: var(--app-radius); background: #fff; }
.email-text { max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 10px; border: 1px solid var(--app-border); border-radius: var(--app-radius); color: var(--app-text-2); font-size: 13px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * + * { margin-left: 4px; }
.tl-done { text-decoration: line-through; color: var(--app-muted); }
.tl-overdue { color: var(--app-danger); font-weight: 600; }
.tl-more { padding: 10px 14px; border-top: var(--app-border); text-align: center; }

/* ---------- Pipeline board ---------- */

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; flex: 1 1 auto; min-height: 0; padding-bottom: 12px; }
.board-col { background: var(--colorNeutralBackground3, #f3f3f3); border-radius: var(--app-radius); display: flex; flex-direction: column; min-height: 0; }
.board-col-header { padding: 10px 12px 6px; position: relative; }
/* The header's drop zone (FR-188): an empty sortable list over the whole header. The card's placeholder never shows in it. */
.board-col-drop { position: absolute; inset: 0; z-index: 1; }
.board .board-col-drop .fluent-sortable-list { height: 100%; min-height: 0; overflow: hidden; }
.board .board-col-drop .fluent-sortable-list .sortable-item { visibility: hidden; height: 0 !important; margin: 0 !important; overflow: hidden; }
.board-col-title { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }
.board-col-sum { font-size: 12px; color: var(--app-muted); font-variant-numeric: tabular-nums; }
.board-col-note { margin-top: 2px; }
.board-cards { flex: 1 1 auto; overflow-y: auto; padding: 4px 8px 8px; min-height: 80px; display: flex; flex-direction: column; }
/* The cards list fills the column's body, so the space below the last card takes a drop (FR-188). */
.board-cards .fluent-sortable-list, .board-cards > div { min-height: 60px; flex: 1 0 auto; }
/* The column a dragged card would land in (FR-189): SortableJS keeps its placeholder in the list under the pointer. */
.board-col { outline: 2px solid transparent; outline-offset: -2px; transition: background-color 0.1s, outline-color 0.1s; }
.board-col:has(.sortable-ghost) { background: var(--colorBrandBackground2, #ebf3fc); outline-color: var(--colorBrandStroke1, #0f6cbd); }
/* FluentSortableList draws fixed-height bordered rows; the board uses its own cards. */
.board .fluent-sortable-list { border: 0 !important; background: transparent !important; padding: 0 !important; }
.board .fluent-sortable-list .sortable-item {
    height: auto !important; padding: 0 !important; border: 0 !important; background: transparent !important;
    margin: 0 0 8px !important; display: block !important; border-radius: 6px;
}
.board-card {
    display: grid; gap: 4px; background: var(--app-surface); border: var(--app-border); border-radius: 6px;
    padding: 10px; cursor: grab; touch-action: manipulation;
}
.board-card:hover { border-color: var(--colorNeutralStroke1, #d1d1d1); }
.board-card .title { font-weight: 600; font-size: 13px; }
.board-card .meta { font-size: 12px; color: var(--app-muted); display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Calendar ---------- */

.page.calendar-page { padding-block-start: 12px; }
.calendar-page > .calendar-header { gap: 4px 10px; margin-block-end: 6px; }
.calendar-header .page-title { font-size: clamp(19px, 2vw, 25px); line-height: 1.2; }
.cal-month-nav, .cal-header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.cal-header-actions { margin-inline-start: auto; }
.cal-view-options { display: grid; gap: 6px; padding: 8px 12px; margin-block-end: 8px; }
.cal-view-options[hidden] { display: none; }
.cal-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 12px; }
.cal-people { flex: 0 1 180px; min-width: min(100%, 160px); }
.cal-context { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; margin-block-end: 8px; }
.cal-scroll { overflow-x: auto; border-radius: var(--app-radius); }
.cal-scroll:focus-visible, .qrf-table-region:focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }
/* Salespeople / Visitors / Both: one group that wraps as a whole. */
.cal-mode { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.cal-companies { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.cal-companies .label { font-size: 12px; font-weight: 600; color: var(--app-muted); }
.calendar-page .cal { min-width: calc(var(--cols, 7) * 92px); }
.cal { position: relative; background: var(--app-surface); border: var(--app-border); border-radius: var(--app-radius); overflow: hidden; }

/* Shown while the month loads; it fades in after a moment so quick loads don't flash. */
.cal-loading {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 140px;
    background: color-mix(in srgb, var(--app-surface) 70%, transparent);
    color: var(--app-text-2); font-weight: 600;
    animation: cal-loading-in 0.2s ease 0.25s both;
}
@keyframes cal-loading-in { from { opacity: 0; } to { opacity: 1; } }
.cal-checking { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.cal-head { display: grid; grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr)); }
.cal-head div { padding: 8px; font-size: 12px; font-weight: 600; color: var(--app-muted); border-bottom: var(--app-border); }

/* One grid per week: day backgrounds underneath, then lanes of blocks that span days, then each day's own items. */
.cal-week { display: grid; grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr)); grid-auto-rows: auto; min-height: clamp(68px, 11dvh, 112px); border-bottom: var(--app-border); }
.cal-week:last-child { border-bottom: 0; }
.cal-cell { border-right: var(--app-border); min-width: 0; }
.cal-cell.last { border-right: 0; }
.cal-cell.other { background: var(--app-canvas); }
.cal-date {
    border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit;
    justify-self: start; align-self: start; margin: 4px 4px 2px; font-size: 12px; font-weight: 600;
    min-width: 28px; min-height: 28px; border-radius: 14px; display: grid; place-items: center; padding: 0 6px;
}
.cal-date.today { background: var(--colorBrandBackground, #0f6cbd); color: #fff; }
/* A company holiday (from SyteLine's absence records): a muted chip after the day number, instead of everyone shown out. */
.cal-date.holiday { grid-auto-flow: column; gap: 6px; padding-right: 4px; }
.cal-holiday {
    font-size: 10px; font-weight: 600; line-height: 16px; padding: 0 6px; border-radius: 8px;
    background: var(--colorNeutralBackground3, #f0f0f0); color: var(--colorNeutralForeground3, #616161);
}
.cal-date.today .cal-holiday { background: rgba(255, 255, 255, 0.25); color: #fff; }
body[data-theme="dark"] .cal-holiday { background: #3a3a3a; color: #c8c8c8; }
.cal-items { display: grid; align-content: start; gap: 2px; padding: 2px 4px 4px; min-width: 0; }
.cal-item, .cal-bar {
    display: block; width: 100%; text-align: left; border: 0; font: inherit; font-size: 12px; cursor: pointer;
    padding: 2px 6px; border-radius: 4px; background: var(--colorBrandBackground2, #ebf3fc); color: var(--app-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cal-item.task { background: #fdf3e7; }
.cal-item.done { opacity: 0.55; text-decoration: line-through; }
body[data-theme="dark"] .cal-item.task { background: #4a3520; }

/* Blocks that span days: inset in their first and last day, flush where they continue into the next or previous week. */
.cal-bar { width: auto; margin: 1px 4px; }
.cal-bar.cont-left { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* Trade shows. */
.cal-bar.show { background: #e9e3f7; color: #4b2f8f; font-weight: 600; }
body[data-theme="dark"] .cal-bar.show { background: #3b2d5c; color: #e3d9ff; }
/* A company event (FR-182): its own amber, apart from trade shows' violet and people's colors. */
.cal-bar.event { background: #fdf0d5; color: #7a4b00; font-weight: 600; }
body[data-theme="dark"] .cal-bar.event { background: #4a3a17; color: #ffe2a8; }
/* Each person's color (--person, set per entry): a tint as the fill, the full color as the stripe. Their entries, their time
   off (from SyteLine's absence records, only that they're out, never why) and their trips share it. Time off adds diagonal
   hatching so "away" reads differently from a meeting or a trip. */
.cal-item.person, .cal-bar.oof, .cal-bar.trip {
    color: var(--app-text);
    background-color: color-mix(in srgb, var(--person, #ca5010) 16%, var(--app-surface, #fff));
    border-left: 3px solid var(--person, #ca5010);
}
body[data-theme="dark"] .cal-item.person, body[data-theme="dark"] .cal-bar.oof, body[data-theme="dark"] .cal-bar.trip {
    background-color: color-mix(in srgb, var(--person, #ca5010) 32%, var(--app-surface, #292929));
}
.cal-item.person.task { border-left-style: dotted; }
.cal-bar.oof {
    font-weight: 600; cursor: default; border-left-width: 4px;
    background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--person, #ca5010) 18%, transparent) 7px 12px);
}
.cal-bar.oof.cont-left { border-left: 0; }
/* Travel: the traveler's color like their entries, led by a plane. No hatching, so a trip never reads as out. */
.cal-bar.trip { display: flex; align-items: center; gap: 4px; font-weight: 600; border-left-width: 4px; }
.cal-bar.trip.cont-left { border-left: 0; }
.cal-bar.trip svg { flex: none; }
.cal-bar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Visitors: customers coming to a Bradbury company. Not a person's entry, so not in a person's color: a teal outline
   and a building, so they stand apart from meetings, tasks and trips. A visitor here several days is a bar in the same look. */
:is(.cal-item, .cal-bar).visitor {
    display: flex; align-items: center; gap: 4px;
    background: color-mix(in srgb, #038387 10%, var(--app-surface, #fff)); color: #025b5d;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #038387 55%, transparent);
}
:is(.cal-item, .cal-bar).visitor svg { flex: none; }
body[data-theme="dark"] :is(.cal-item, .cal-bar).visitor { background: color-mix(in srgb, #038387 28%, var(--app-surface, #292929)); color: #a6e9eb; }
.cal-more { font-size: 12px; color: var(--app-muted); padding: 0 6px; }
/* What a hidden weekend holds, at the foot of Friday: a link-like button that shows the weekend (FR-178). */
.cal-weekend { font: inherit; font-size: 12px; color: var(--app-brand); background: none; border: 0; padding: 0 6px; cursor: pointer; text-align: left; }
.cal-weekend:hover { text-decoration: underline; }
.cal :is(button.cal-date, button.cal-item, button.cal-bar, .cal-weekend):focus-visible { outline: 2px solid var(--app-brand); outline-offset: -2px; }

@media (max-width: 899px) {
    .cal-week { min-height: 64px; }
    .cal-item, .cal-bar { font-size: 11px; padding: 1px 3px; }
}
@media screen and (max-width: 480px) {
    .calendar-header .page-title { flex: 1 1 auto; }
    .cal-header-actions { margin-inline-start: 0; }
}
@media screen and (pointer: coarse) {
    .cal button.cal-date { min-width: 44px; }
    .cal :is(button.cal-date, button.cal-item, button.cal-bar, .cal-weekend) { min-height: 44px; }
}

/* ---------- Dashboards ---------- */

.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.widget { background: var(--app-surface); border: var(--app-border); border-radius: var(--app-radius); display: flex; flex-direction: column; min-width: 0; min-height: 140px; }
.widget.size-Small { grid-column: span 3; }
.widget.size-Medium { grid-column: span 4; }
.widget.size-Large { grid-column: span 6; }
.widget.size-Wide { grid-column: span 12; }
@media (max-width: 1279px) {
    .widget.size-Small { grid-column: span 6; }
    .widget.size-Medium { grid-column: span 6; }
    .widget.size-Large { grid-column: span 12; }
}
@media (max-width: 767px) {
    .widget.size-Small, .widget.size-Medium, .widget.size-Large, .widget.size-Wide { grid-column: span 12; }
}
.widget-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; }
.widget-title { font-weight: 600; font-size: 14px; }
.widget-body { padding: 8px 14px 14px; flex: 1 1 auto; min-height: 0; }
.widget-number { font-size: 32px; line-height: 40px; font-weight: 600; font-variant-numeric: tabular-nums; }
.widget-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.widget-table td { padding: 6px 4px; border-bottom: var(--app-border); }
.widget-table tr:last-child td { border-bottom: 0; }
.widget-table a { color: inherit; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 40%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; color: inherit; }
.bar-row:hover { text-decoration: none; }
.bar-row:hover .bar-track > span { filter: brightness(0.92); }
.bar-track { height: 10px; border-radius: 5px; background: var(--colorNeutralBackground3, #f0f0f0); overflow: hidden; }
.bar-track > span { display: block; height: 100%; border-radius: 5px; background: var(--colorBrandBackground, #0f6cbd); }

/* The offer of a shared dashboard as home. The text keeps a line of its own on a phone, and a long name wraps rather than widening the page. */
.home-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; margin-bottom: 12px; }
.home-offer-text { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }

/* List tile: rows of records. A row is one link, so it's a grid rather than a table; cells truncate and never widen the tile. */
.list-tile { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.list-tile.cols-1 { --list-tile-grid: minmax(0, 1fr); }
.list-tile.cols-2 { --list-tile-grid: minmax(0, 1.6fr) minmax(0, 1fr); }
.list-tile.cols-3 { --list-tile-grid: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); }
.list-tile.cols-4 { --list-tile-grid: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); }
.list-tile-head, .list-tile-row { display: grid; grid-template-columns: var(--list-tile-grid); gap: 2px 10px; align-items: center; padding: 5px 4px; }
.list-tile-head { font-size: 12px; font-weight: 600; color: var(--app-muted); }
.list-tile-head, .list-tile-row { border-bottom: var(--app-border); }
.list-tile-row { color: inherit; }
.list-tile-row:hover { text-decoration: none; background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.list-tile-cell.end { text-align: right; }
.list-tile-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 6px; }
@media (max-width: 767px) {
    /* Four columns can't share a phone: the first takes its own line and the rest sit in pairs under it, with no header to line up with. */
    .list-tile-head { display: none; }
    .list-tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .list-tile-cell:first-child { grid-column: 1 / -1; }
    .list-tile-cell.end { text-align: left; }
}

/* Goal tile: total, share of goal, progress with a marker for how far through the fiscal year we are. */
.goal-tile { display: grid; gap: 6px; }
.goal-share { font-size: 14px; font-weight: 600; color: var(--app-muted); font-variant-numeric: tabular-nums; }
.goal-share.ahead { color: var(--colorPaletteGreenForeground1, #0e700e); }
.goal-share.behind { color: var(--colorPaletteDarkOrangeForeground1, #a4262c); }
.goal-track { position: relative; height: 12px; border-radius: 6px; background: var(--colorNeutralBackground3, #f0f0f0); overflow: visible; }
.goal-fill { display: block; height: 100%; border-radius: 6px; background: var(--colorBrandBackground, #0f6cbd); transition: width 0.3s ease; }
.goal-fill.ahead { background: var(--colorPaletteGreenBackground3, #107c10); }
.goal-fill.behind { background: var(--colorPaletteDarkOrangeBackground3, #c43e1c); }
.kpm-table th, .kpm-table td { white-space: nowrap; }
.kpm-table td.attention, .kpi-value.attention { color: var(--colorPaletteDarkOrangeForeground1, #a4262c); font-weight: 600; }
.goal-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--app-fg, #242424); opacity: 0.6; border-radius: 1px; }

/* Coverage: its own row under the top tiles, so those keep their meaning. */
.kpm-coverage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 8px; }
.kpm-coverage-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.kpm-coverage-note { margin: 0 0 16px; }

/* ---------- Home ---------- */

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1023px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }

.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 14px; border-top: var(--app-border); min-height: 44px; }
.task-row:first-child { border-top: 0; }

/* ---------- Simple tables (admin, logs) ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--app-muted); padding: 8px 12px; border-bottom: var(--app-border); white-space: nowrap; background: var(--app-surface); position: sticky; top: 0; z-index: 1; }
.table th.num { text-align: right; }
.table td { padding: 8px 12px; border-bottom: var(--app-border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.table-wrap { overflow: auto; }

.change-list { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; display: grid; gap: 2px; }
.change-list .field { color: var(--app-muted); }
.change-list .old { text-decoration: line-through; color: var(--app-muted); }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 599px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-section { font-size: 12px; font-weight: 600; color: var(--app-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; grid-column: 1 / -1; }
.form-errors { margin-bottom: 12px; }
.form-errors:focus { outline: none; }

.choice-list { display: grid; gap: 6px; }
.choice {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; text-align: left;
    padding: 10px 12px; border: var(--app-border); border-radius: 6px; background: var(--app-surface); cursor: pointer; font: inherit; color: inherit;
}
.choice.selected { border-color: var(--colorBrandStroke1, #0f6cbd); box-shadow: inset 0 0 0 1px var(--colorBrandStroke1, #0f6cbd); }

/* ---------- Touch / tablet ---------- */

@media (pointer: coarse) {
    .view-tab { padding: 12px 14px; }
    .company-btn { height: 44px; border-radius: 22px; }
    .filter-chip { height: 44px; border-radius: 22px; }
    .filter-chip button { width: 44px; height: 44px; border-radius: 22px; }
    .related-item { padding: 12px 14px; }
    .brief-more, .brief .related-item > a { min-height: 44px; display: flex; align-items: center; }
    .brief-phones a, .brief .record-sub a { display: inline-flex; align-items: center; min-height: 44px; }
    .tl-meta { align-items: center; }
    .tl-brief { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
    .cal-item { padding: 4px 6px; }
    .column-row { min-height: 44px; }
    .columns-dialog .fluent-sortable-list .column-grip { width: 44px; min-height: 44px; }
    .panel-toggle { min-height: 44px; }
    .tl-report > summary { min-height: 44px; }
    .column-row.no-grip { padding-inline-start: 48px; }
}

@media print {
    .no-print { display: none !important; }
}

/* ---------- Sales goals ---------- */

.goals-table th, .goals-table td { white-space: nowrap; }
.goals-table tr.goals-company td { background: var(--colorNeutralBackground2, #fafafa); padding-top: 10px; }
.goals-table tr.goals-total td { font-weight: 600; border-top: 1px solid var(--colorNeutralStroke1, #d1d1d1); }
.goals-table tr.goals-sub td { color: var(--app-muted); }
.goals-table tr.goals-grand td { border-top: 2px solid var(--colorNeutralStroke1, #d1d1d1); }
.goals-table tr.goals-compare td { color: var(--app-muted); font-size: 13px; }
.goals-table td.ahead, .goals-list .ahead { color: var(--colorPaletteGreenForeground1, #0e700e); }
.goals-table td.behind, .goals-list .behind { color: var(--colorPaletteDarkOrangeForeground1, #a4262c); }
.goals-list th, .goals-list td { white-space: nowrap; }
.goals-list tr.goals-month td { background: var(--colorNeutralBackground2, #fafafa); font-weight: 600; }
.goals-table tr.selected td, .kpm-table tr.goals-current td { background: var(--colorBrandBackground2, #ebf3fc); }
.goal-input { width: 130px; text-align: right; font: inherit; font-variant-numeric: tabular-nums; padding: 4px 6px; border: 1px solid var(--colorNeutralStroke1, #d1d1d1); border-radius: 4px; background: var(--colorNeutralBackground1, #fff); color: inherit; }
.field-error { color: var(--app-danger); font-size: 12px; margin-top: 2px; }
details.panel > summary { cursor: pointer; list-style: revert; }

/* ---------- Quote requests (company documents, AD-37) ---------- */

.page:is(.trips-page, .qrf-list-page, .qrf-import) { padding-block-start: 12px; }
.page > .workflow-header { gap: 6px 12px; margin-block-end: 10px; }
.workflow-header-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-inline-start: auto; min-width: 0; }
.workflow-header-controls > fluent-button { flex: none; }
.workflow-header-controls .trips-who { flex: 1 1 170px; min-width: min(100%, 140px); }
.qrf-search { flex: 1 1 200px; max-width: 280px; width: auto; }
.qrf-table-region :is(.qrf-list th, .qrf-list td) { padding: 6px 8px; }
.qrf-list-page .qrf-list :is(th, td:first-child:not([colspan])) { background: var(--app-surface); }
.qrf-list-page .qrf-list :is(th:first-child, td:first-child:not([colspan])) {
    position: sticky;
    inset-inline-start: 0;
    z-index: 1;
    min-width: 100px;
    max-width: 132px;
    overflow-wrap: anywhere;
    box-shadow: 1px 0 0 var(--colorNeutralStroke2, #e0e0e0);
}
.qrf-list-page .qrf-list th:first-child { z-index: 2; }
.qrf-list-page .qrf-list tr.clickable:hover td:first-child { background: var(--colorNeutralBackground1Hover, #f5f5f5); }

@media screen and (max-width: 599px) {
    .workflow-header .workflow-header-controls { margin-inline-start: 0; }
    .workflow-header .workflow-header-controls:not(.qrf-import-pick) { flex: 1 1 100%; }
    .workflow-header .qrf-search { flex-basis: 110px; max-width: none; }
}

@media (pointer: coarse) {
    .workflow-header .qrf-search, .workflow-header .qrf-import-pick { min-height: 44px; }
}

/* Importing QRF workbooks (FR-356): Choose workbooks is a label over the file input, so it reads as a primary button and
   the input stays reachable by keyboard; the rows' notes wrap, the account picker gets room. */
.qrf-import-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 4px;
    background: var(--app-brand); color: #fff; font-weight: 600; cursor: pointer; }
.qrf-import-pick .fluent-icon, .qrf-import-pick svg { fill: currentColor; color: #fff; }
.qrf-import-pick:hover { filter: brightness(1.08); }
.qrf-import-pick:focus-within { outline: 2px solid var(--colorStrokeFocus2, #000); outline-offset: 1px; }
.qrf-import-pick.busy { opacity: 0.6; cursor: default; }
.qrf-import-pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: inherit; font-size: 0; }
.qrf-import-table td { vertical-align: top; }
.qrf-import-table .qrf-import-keep { width: 32px; }
.qrf-import-table td.qrf-import-account { min-width: 240px; }
.qrf-import-table td:nth-child(2) { max-width: 240px; }
.qrf-import-notes { min-width: 260px; max-width: 420px; white-space: normal; }
.qrf-import-notes > div + div { margin-top: 4px; }
.qrf-import-done { color: var(--app-success, #107c10); font-weight: 600; }
/* A workbook no account matched (FR-426): its flag, and the accounts it may be as buttons that choose one. */
.qrf-import-flag { margin-bottom: 6px; }
.qrf-import-table td.qrf-import-account > .muted.small { margin-top: 4px; white-space: normal; }
.qrf-import-matches { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-width: 320px; }
.qrf-import-match { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-width: 0; padding: 6px 8px;
    border: 1px solid var(--colorNeutralStroke2, #e0e0e0); border-radius: var(--app-radius, 4px); background: var(--colorNeutralBackground1, #fff);
    color: inherit; font: inherit; text-align: left; white-space: normal; cursor: pointer; }
.qrf-import-match:hover:not(:disabled) { background: var(--colorNeutralBackground1Hover, #f5f5f5); }
.qrf-import-match:focus-visible { outline: 2px solid var(--colorStrokeFocus2, #000); outline-offset: 1px; }
.qrf-import-match.chosen { border-color: var(--app-brand, #0f6cbd); background: var(--colorBrandBackground2, #ebf3fc); }
.qrf-import-match:disabled { opacity: 0.6; cursor: default; }
.qrf-import-match-head { display: flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.qrf-import-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Start from an earlier one (FR-364): above a new quote request's tabs. */
.qrf-start-from { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 4px; padding: 10px 14px;
    border: var(--app-border); border-radius: var(--app-radius); background: var(--app-surface); }
.qrf-start-from-label { font-weight: 600; }
.qrf-start-from fluent-autocomplete, .qrf-start-from .fluent-autocomplete-multiselect { flex: 1 1 320px; max-width: 520px; }
.qrf-list td.num, .qrf-sheet td.num, .qrf-sheet th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The figures that matter, kept in view while the form scrolls. */
.qrf-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr));
    gap: 1px;
    margin: 8px 0;
    border: var(--app-border);
    border-radius: var(--app-radius);
    background: var(--colorNeutralStroke2, #e0e0e0);
    overflow: hidden;
}
.qrf-summary > div { display: flex; flex-direction: column; gap: 2px; padding: 5px 9px; background: var(--app-surface); min-width: 0; }
.qrf-summary strong { font-size: 16px; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.qrf-summary > .qrf-summary-quote { background: var(--colorBrandBackground2, #ebf3fc); }
@media screen and (min-width: 1040px) and (min-height: 760px) {
    .qrf-summary { position: sticky; top: 0; z-index: 3; }
}

.qrf-form { border: 0; margin: 0; padding: 0; min-width: 0; }
.qrf-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 16px; }
.qrf-fields > label, .qrf-fields > div { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; font-size: 12px; color: var(--app-muted); min-width: 0; }
.qrf-fields > .qrf-wide { grid-column: span 3; }
.qrf-fields .native-input { color: var(--app-text); }
.qrf-fields .mt-4 { margin-top: 4px; }
.qrf-label { font-size: 12px; color: var(--app-muted); }
.qrf-notes { height: 110px; padding: 8px 10px; resize: vertical; }
@media (max-width: 900px) {
    .qrf-fields { grid-template-columns: minmax(0, 1fr); }
    .qrf-fields > label, .qrf-fields > div, .qrf-fields > .qrf-wide { grid-column: auto; }
}

/* Sell price: what's typed on the left in cards, what it comes to on the right, kept in view. */
.qrf-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 16px; align-items: start; margin-top: 12px; }
.qrf-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.qrf-side { position: sticky; top: 12px; }
@media (max-width: 1100px) {
    .qrf-layout { grid-template-columns: minmax(0, 1fr); }
    .qrf-side { position: static; }
}
.qrf-main .panel-header, .qrf-side .panel-header { justify-content: space-between; }

/* Fields: labels as Fluent's, three to a row, or two, or the whole row. */
.qrf-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.qrf-grid > label, .qrf-grid > div { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; font-size: 14px; color: var(--app-text); min-width: 0; }
.qrf-line-details fluent-button, .qrf-line-details .qrf-num { flex: none; }
.qrf-grid > .qrf-half { grid-column: span 3; }
.qrf-grid > .qrf-full { grid-column: 1 / -1; }
.qrf-grid .qrf-quiet { font-size: 13px; }
/* The Quote card's other currencies sit under the first, each rate under the first's rate. */
.qrf-grid > .qrf-quote-also { grid-column: 3 / span 2; }
@media (max-width: 640px) {
    .qrf-grid { grid-template-columns: minmax(0, 1fr); }
    .qrf-grid > label, .qrf-grid > div, .qrf-grid > .qrf-half, .qrf-grid > .qrf-quote-also { grid-column: auto; }
}

/* Lines: the name, the figure typed, its details, and what it comes to. */
.qrf-lines { display: flex; flex-direction: column; }
.qrf-line {
    display: grid;
    grid-template-columns: minmax(140px, 190px) 136px minmax(0, 1fr) minmax(96px, auto);
    grid-template-areas: "label value details result";
    gap: 4px 12px;
    align-items: center;
    padding: 8px 14px;
    border-top: var(--app-border);
}
.qrf-line:first-child { border-top: 0; }
.qrf-line-label { grid-area: label; display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
.qrf-line-label small { color: var(--app-muted); font-size: 12px; line-height: 16px; }
.qrf-line-value { grid-area: value; min-width: 0; }
.qrf-line-details { grid-area: details; display: flex; align-items: center; gap: 8px; min-width: 0; }
.qrf-line-result { grid-area: result; display: flex; align-items: center; justify-content: flex-end; gap: 4px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--app-text-2); }
.qrf-line-add { display: block; padding: 4px 8px; }
.qrf-figure { font-variant-numeric: tabular-nums; text-align: right; }
.qrf-line-value.qrf-figure { padding-right: 30px; }
.qrf-unit { display: flex; align-items: center; gap: 6px; }
.qrf-unit-mark { flex: none; width: 14px; }
.qrf-rate-mark { flex: none; white-space: nowrap; font-size: 13px; }
/* The lines follow the card's own width, not the screen's: beside the price on an iPad they're narrower than on a phone
   held sideways. Narrower, the details go under the figure; narrower still, under the name too. */
.qrf-main { container-type: inline-size; }
@container (max-width: 680px) {
    .qrf-line { grid-template-columns: minmax(110px, 1fr) 136px minmax(80px, auto); grid-template-areas: "label value result" "label details details"; }
    .qrf-line-details { flex-wrap: wrap; }
    .qrf-line-details:empty { display: none; }
}
@container (max-width: 440px) {
    .qrf-line { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label label" "value result" "details details"; }
}

/* The price, worked out as the sheet does: each step, then its total. */
.qrf-price { display: flex; flex-direction: column; gap: 0; }
.qrf-price fluent-message-bar { margin-bottom: 8px; }
.qrf-price-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 13px; color: var(--app-text-2); }
.qrf-price-row > span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.qrf-price-row.total { color: var(--app-text); font-weight: 600; border-top: var(--app-border); margin-top: 3px; padding-top: 6px; }
.qrf-price-quote { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding: 12px 14px; border-radius: var(--app-radius); background: var(--colorBrandBackground2, #ebf3fc); }
.qrf-price-quote .qrf-price-pending { font-size: 13px; color: var(--app-text); }
.qrf-price-quote strong { font-size: 24px; line-height: 32px; font-variant-numeric: tabular-nums; color: var(--app-brand); overflow-wrap: anywhere; }
.qrf-price-row.qrf-price-margin { font-size: 15px; color: var(--app-text); padding-top: 10px; }
/* Quote price: type the price to quote under the one worked out, and the margin is set to reach it. */
.qrf-price-aim { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: var(--app-border); }
.qrf-price-aim-label { font-size: 14px; font-weight: 600; color: var(--app-text); }
.qrf-price-aim-row { display: flex; align-items: center; gap: 8px; }
.qrf-price-aim-row .qrf-num { flex: 1 1 auto; min-width: 0; }
.qrf-price-aim-row fluent-button { flex: none; }
.qrf-price-aim small { font-size: 12px; line-height: 16px; }
.qrf-price-aim-done { color: var(--app-success); }
.qrf-price-aim .field-error { margin-top: 0; }

/* Save at the foot of the page, in view while there's something to save. */
.qrf-savebar {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--app-surface);
    border: var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}
.qrf-savebar > fluent-message-bar { flex: 1 1 100%; }
.qrf-savebar-state { font-weight: 600; color: var(--app-warning); white-space: nowrap; }
.qrf-savebar .native-input { flex: 1 1 260px; width: auto; }
@media screen and (max-width: 743px) {
    .qrf-savebar { gap: 6px; padding: 6px 8px; }
    .qrf-savebar-state { flex: 1 1 100%; font-size: 12px; white-space: normal; }
    .qrf-savebar .native-input { flex-basis: 100px; }
}

/* The two sheets: compact rows, typed cells that read as cells, figures in a column. */
.qrf-sheet td { vertical-align: middle; padding: 4px 12px; }
.qrf-sheet .native-input { height: 28px; padding: 0 8px; }
.qrf-sheet td .row { flex-wrap: nowrap; }
.native-input.qrf-num { text-align: right; font-variant-numeric: tabular-nums; }
.native-input.qrf-num.invalid { border-color: var(--app-danger); background: var(--app-danger-bg); }
.qrf-form .native-input:disabled { background: var(--app-canvas); color: var(--app-text); opacity: 1; border-color: transparent; }
.qrf-sheet tr.qrf-section th { position: static; padding: 6px 12px; font-size: 13px; color: var(--app-text); background: var(--colorNeutralBackground3, #f5f5f5); }
.qrf-sheet tr.qrf-total td { font-weight: 600; border-top: 1px solid var(--colorNeutralStroke1, #d1d1d1); }
.qrf-sheet tr.qrf-total.strong td { background: var(--colorBrandBackground2, #ebf3fc); }
.qrf-code { width: 70px; }
.qrf-item { width: 110px; }
/* An item code from before the list that isn't on it (FR-427): marked until one from the list is chosen. */
.native-input.qrf-item-off { border-color: var(--app-warning); color: var(--app-warning); }
.qrf-item-note { margin: 16px 0 0; font-size: 13px; color: var(--app-warning); }
/* Job costing has eleven columns: every figure column has its width, the two text columns share what's left, and the
   table scrolls sideways only when the screen is narrower than it can go. The item code column's width comes out of
   Comment, so the table still fits the 1041px a 1358-wide window gives it. */
.qrf-costing { table-layout: fixed; min-width: 1040px; }
.qrf-costing th, .qrf-costing td { padding-left: 6px; padding-right: 6px; }
.qrf-costing th { white-space: normal; }
.qrf-costing th:nth-child(1) { width: 72px; }
.qrf-costing th:nth-child(2) { width: 136px; }
.qrf-costing th:nth-child(4) { width: 12%; }
.qrf-costing th:nth-child(5) { width: 68px; }
.qrf-costing th:nth-child(6) { width: 64px; }
.qrf-costing th:nth-child(7) { width: 92px; }
.qrf-costing th:nth-child(8) { width: 108px; }
.qrf-costing th:nth-child(9) { width: 92px; }
.qrf-costing th:nth-child(10) { width: 100px; }
.qrf-costing th:nth-child(11) { width: 44px; }
.qrf-costing td:nth-child(11) { padding: 0 2px; }
.qrf-costing .native-input { padding: 0 6px; font-size: 13px; }
.qrf-costing .qrf-code, .qrf-costing .qrf-item { width: 100%; }
.qrf-costing .qrf-tick .small { display: block; }
.qrf-tick { white-space: nowrap; }
.qrf-tick input { width: 18px; height: 18px; vertical-align: middle; }
.qrf-row-actions { white-space: nowrap; text-align: right; }
/* A component's SyteLine part and its past hours, under the component's name (FR-354, FR-355); the box button beside
   the name chooses one, so a line without a part keeps its height. */
.qrf-component { display: flex; align-items: center; gap: 2px; min-width: 0; }
.qrf-component > .native-input { flex: 1 1 auto; min-width: 0; }
.qrf-component > fluent-button { flex: none; }
.qrf-part-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: 3px; line-height: 1.3; }
.qrf-part-chosen { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.qrf-part-past { white-space: nowrap; font-variant-numeric: tabular-nums; }
.qrf-part-action { padding: 0; border: 0; background: none; font: inherit; color: var(--app-brand); cursor: pointer; white-space: nowrap; text-underline-offset: 2px; }
.qrf-part-action:hover { text-decoration: underline; }
.qrf-part-action:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 2px; border-radius: 2px; }
.qrf-print-part { font-size: 9px; color: #333; }

/* The part picker: a search, then one row per part with its past hours on the right. */
.qrf-parts-intro { margin: 0 0 10px; }
.qrf-parts-search { width: 100%; margin-bottom: 10px; }
.qrf-parts-count { margin: 0 0 6px; }
.qrf-parts { display: grid; max-height: min(52vh, 480px); overflow-y: auto; border: var(--app-border); border-radius: var(--app-radius); }
.qrf-part { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-top: var(--app-border); cursor: pointer; min-width: 0; }
.qrf-part:first-child { border-top: 0; }
.qrf-part:hover { background: var(--app-canvas); }
.qrf-part.chosen { background: var(--colorBrandBackground2, #ebf3fc); }
.qrf-part input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--app-brand); }
.qrf-part-text { display: grid; flex: 1 1 auto; min-width: 0; }
.qrf-part-name { overflow-wrap: anywhere; }
.qrf-part-hours { display: grid; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {
    .qrf-part { min-height: 44px; padding: 10px 12px; }
    .qrf-part input { width: 20px; height: 20px; }
    .qrf-part-action { padding: 6px 0; }
}

.qrf-rates { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-top: var(--app-border); font-variant-numeric: tabular-nums; }

.qrf-version { padding: 12px 14px; border-bottom: var(--app-border); }
.qrf-version:last-child { border-bottom: 0; }
.qrf-version.shown { background: var(--colorBrandBackground2, #ebf3fc); }
.qrf-version-note { margin-top: 4px; font-style: italic; }
.qrf-changes { margin: 6px 0 0; padding-left: 20px; font-size: 13px; overflow-wrap: anywhere; }

/* The print page: the two sheets as paper, black on white whatever the theme, at the size they print, so the page on
   screen is the page on paper. Each sheet fits one page of A4 or Letter; the paper is the printer's own. */
.qrf-print { max-width: 780px; margin: 0 auto; padding: 16px 24px 32px; }
.qrf-print-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.qrf-print-sheet { background: #fff; color: #000; border: 1px solid #999; padding: 16px; margin-bottom: 24px; font-size: 11px; line-height: 1.25; }
.qrf-print-sheet header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid #000; padding-bottom: 4px; margin-bottom: 6px; }
.qrf-print-sheet h1 { margin: 0; font-size: 16px; line-height: 1.2; font-style: italic; }
/* The reboot gives tables their own font size, so the sheet's has to be said again. */
.qrf-print-sheet table { width: 100%; border-collapse: collapse; margin-bottom: 6px; font-size: inherit; line-height: inherit; }
.qrf-print-sheet th, .qrf-print-sheet td { border: 1px solid #999; padding: 1px 5px; text-align: left; vertical-align: top; }
.qrf-print-sheet .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qrf-print-head th { width: 18%; background: #eee; font-weight: 600; }
.qrf-print-table thead th { background: #ddd; }
.qrf-print-table tr.section th { background: #eee; }
.qrf-print-table tr.total td { font-weight: 600; }
.qrf-print-table tr.strong td { font-weight: 700; background: #e6f0e6; }
.qrf-print-sheet table.qrf-print-costing { font-size: 10px; }
.qrf-print-costing td:nth-child(1), .qrf-print-costing td:nth-child(2) { white-space: nowrap; }
.qrf-print-notes { border: 1px solid #999; padding: 2px 5px; margin-bottom: 6px; white-space: pre-wrap; }
.qrf-print-sheet footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 8.5px; color: #444; }
@media print {
    /* The skip link is fixed, so it would print on every page. */
    .skip-link { display: none; }
    body:has(.print-document), body:has(.print-document) .app-content { background: #fff; }
    .qrf-print { max-width: none; padding: 0; }
    .qrf-print-sheet { border: 0; padding: 0; margin: 0; break-after: page; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .qrf-print-sheet:last-child { break-after: auto; }
    .qrf-print-table tr { break-inside: avoid; }
}

/* Beacon's Ask from the job costing (FR-353): a question box and questions to start from, each a button that fills it. */
.beacon-ask p { margin: 0; }
.beacon-ask-question { min-height: 120px; resize: vertical; font: inherit; }
.beacon-ask-suggestion {
    display: block; width: 100%; padding: 8px 12px; text-align: left; font: inherit; color: var(--app-text);
    background: var(--app-surface); border: var(--app-border); border-radius: 8px; cursor: pointer;
}
.beacon-ask-suggestion:hover { background: var(--app-hover); border-color: var(--app-brand); }
.beacon-ask-suggestion:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 1px; }
/* The conversation: each question, then Beacon's answer as it gives it (text, tables, what it ran). */
.beacon-turns { display: flex; flex-direction: column; gap: 20px; }
.beacon-turn { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.beacon-question {
    align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: 12px 12px 4px 12px;
    background: var(--app-brand-tint); color: var(--app-text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.beacon-working { display: flex; align-items: center; gap: 8px; color: var(--app-muted); }
.beacon-answer { line-height: 1.5; overflow-wrap: anywhere; min-width: 0; }
.beacon-answer > :first-child { margin-top: 0; }
.beacon-answer > :last-child { margin-bottom: 0; }
.beacon-answer p, .beacon-answer ul, .beacon-answer ol { margin: 0 0 8px; }
.beacon-answer ul, .beacon-answer ol { padding-left: 20px; }
.beacon-answer h1, .beacon-answer h2, .beacon-answer h3, .beacon-answer h4 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.beacon-answer code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; background: var(--app-inset); padding: 1px 4px; border-radius: 4px; }
.beacon-answer table { display: block; overflow-x: auto; max-width: 100%; margin: 0 0 8px; }
.beacon-table { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.beacon-table-title { font-weight: 600; font-size: 13px; }
.beacon-table .table-wrap { max-height: 360px; overflow: auto; border: var(--app-border); border-radius: 8px; }
.beacon-table td, .beacon-answer td { font-variant-numeric: tabular-nums; }
.beacon-steps summary { cursor: pointer; color: var(--app-muted); font-size: 12px; }
.beacon-step { margin-top: 8px; }
.beacon-step pre {
    margin: 4px 0 0; padding: 8px 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; background: var(--app-inset); border-radius: 8px;
}
.beacon-error { color: var(--app-danger); }

/* Competitor intelligence (PRD 4.46): two columns of panels on wide screens, one on a phone. */
.intel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin: 16px 0; }
.page > .panel + .panel, .page > .panel + .intel-grid, .page > .intel-grid + .panel { margin-top: 16px; }
.intel-list { list-style: none; margin: 0; padding: 0; }
.intel-list li { padding: 10px 14px; border-bottom: var(--app-border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.intel-list li:last-child { border-bottom: 0; }
.intel-list li.clickable:hover { background: var(--colorNeutralBackground1Hover, #f5f5f5); cursor: pointer; }
.intel-bar { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 8px; font-size: 13px; color: inherit; }
.intel-bar-track { height: 8px; border-radius: 4px; background: var(--colorNeutralBackground3, #f0f0f0); overflow: hidden; }
.intel-bar-track > span, .intel-spark > span { display: block; height: 8px; border-radius: 4px; background: var(--colorBrandBackground, #0f6cbd); }
.intel-spark { width: 30%; min-width: 80px; }
.intel-notice { padding: 8px 12px; margin: 0 0 12px; border: var(--app-border); border-radius: var(--app-radius); background: var(--colorNeutralBackground2, #fafafa); }
.intel-filters { margin-bottom: 12px; gap: 8px; }
/* The trade views are seven: on a phone the strip scrolls sideways, as the page tabs do, rather than clipping the last ones. */
.segmented.intel-views { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented.intel-views button { flex: none; white-space: nowrap; }
.intel-search { min-width: min(100%, 320px); }
.intel-note { margin: 8px 0 16px; }
.intel-text { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 13px; max-height: 360px; overflow: auto; margin: 6px 0 0; }
.intel-json { white-space: pre-wrap; word-break: break-all; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; max-height: 360px; overflow: auto; margin: 6px 0 0; }
textarea.intel-json { max-height: none; }
.intel-url { word-break: break-all; }
.intel-error { color: var(--app-danger); }
.intel-statement { font-size: 15px; line-height: 22px; }
.intel-excerpt { color: var(--app-text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.intel-cite { margin-left: 6px; }
.intel-number { width: 90px; }
.intel-drawer .table th { position: static; }

/* HubSpot on the record pages (hubspot-leads-and-website-activity): a lead's form submissions (FR-437) and the website
   activity panel and card (FR-441, FR-442). Answers, titles and addresses are the outside world's text, wrapped and never
   markup (AD-10). A form entry opens its answers in place; page views open their page in a new tab. */
div.related-item.form-submission:hover, div.related-item.website-entry:hover { background: transparent; }
.form-page { width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.related-item .form-answers { padding: 4px 0 0; }
.website-page .title, .website-entry .title, .website-form .title { overflow-wrap: anywhere; }
.website-figures { display: grid; gap: 4px; font-size: 13px; overflow-wrap: anywhere; border-bottom: var(--app-border); }
.website-icon { flex: none; color: var(--app-muted); }
details.related-item.website-form { display: block; }
details.related-item.website-form > summary { display: grid; gap: 2px; list-style: none; cursor: pointer; }
details.related-item.website-form > summary::-webkit-details-marker { display: none; }
details.related-item.website-form > summary:focus-visible { outline: 2px solid var(--app-brand); outline-offset: 2px; border-radius: 4px; }
.website-chevron { flex: none; color: var(--app-muted); transition: transform 0.15s ease; }
details.website-form[open] .website-chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .website-chevron { transition: none; } }
.website-foot { display: grid; gap: 8px; }
.website-activity .related-item .meta .truncate, .account-panel .related-item .meta .truncate { max-width: 100%; }
@media (pointer: coarse) {
    details.related-item.website-form > summary, a.website-page { min-height: 44px; align-content: center; }
}
