@import url("/brand-palette.css");

* { box-sizing: border-box; }
:root {
    color-scheme: light;
    --ink: var(--brand-midnight);
    --muted: var(--brand-steel);
    --line: var(--brand-line);
    --blue: var(--brand-electric);
    --blue-hover: var(--brand-blue-hover);
    --blue-soft: var(--brand-blue-soft);
    --canvas: var(--brand-white);
    --workspace-background: radial-gradient(ellipse at 88% 0%, var(--brand-sky-soft), transparent 780px), var(--canvas);
    --sidebar: var(--brand-midnight);
    --sidebar-width: 182px;
    --sidebar-icon-size: 21px;
    --panel-shadow: 0 3px 5px #1a2a4c06, 0 12px 32px #1a2a4c08;
    --surface: var(--brand-white);
    --font-ui: system-ui, sans-serif;
    --text-body: 0.875rem;
    --text-small: 0.75rem;
    --text-caption: 0.6875rem;
    --text-page: clamp(1.5rem, 2.3vw, 1.875rem);
    --text-section: 1rem;
    --weight-medium: 600;
    --weight-heading: 700;
    --danger: #bf2638;
    --danger-hover: #961b2b;
    --danger-surface: #fff0f2;
}
body { min-height: 100vh; margin: 0; background: var(--workspace-background); background-attachment: fixed; background-repeat: no-repeat; color: var(--ink); font: var(--text-body)/1.5 var(--font-ui); }
.sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; width: var(--sidebar-width); overflow-y: auto; padding: 16px 10px 12px; background: linear-gradient(160deg, color-mix(in srgb, var(--brand-midnight) 88%, var(--brand-electric)), var(--sidebar) 62%); color: white; }
.sidebar-nav { display: flex; flex: 1; flex-direction: column; }
#settings-gear { display: grid; place-items: center; align-self: flex-start; margin-top: auto; width: 36px; height: 36px; padding: 0; background: #ffffff0a; border: 1px solid #ffffff20; }
#settings-gear svg { width: var(--sidebar-icon-size); height: var(--sidebar-icon-size); }
#settings-gear:hover, #settings-gear.active { background: #ffffff20; }
.sidebar-modules { display: flex; flex-direction: column; }
.sidebar-module { display: flex; align-items: center; gap: 8px; cursor: grab; touch-action: none; user-select: none; }
.sidebar-modules .sidebar-module.sortable-dragging { background: var(--brand-electric); color: white; }
.sidebar-modules .sortable-placeholder { background: #314777; }
.sidebar-modules .sortable-placeholder.sortable-outside { background: transparent; }
.sidebar-module svg { width: var(--sidebar-icon-size); height: var(--sidebar-icon-size); flex: 0 0 auto; }
.sidebar-module.active { background: var(--brand-electric); box-shadow: 0 4px 14px #060e2d55; }
.brand { --brand-logo-height: 72px; --brand-mark-size: 54px; display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: white; font-size: var(--text-section); font-weight: var(--weight-heading); padding: 4px 6px 12px; margin-bottom: 12px; border-bottom: 1px solid #ffffff20; }
.brand-mark { display: grid; place-items: center; width: var(--brand-mark-size); height: var(--brand-mark-size); border-radius: 12px; background: var(--brand-sky); color: var(--brand-midnight); font-size: 1.4rem; }
.brand-logo { display: block; width: min(100%, 128px); height: var(--brand-logo-height); object-fit: contain; padding: 5px; border-radius: 10px; background: white; }
.brand-logo-default { display: block; width: min(100%, 150px); height: auto; }
.brand-text { min-width: 0; max-width: 100%; line-height: 1.25; overflow-wrap: anywhere; }
nav { display: grid; gap: 6px; }
nav a { color: #c1cde1; padding: 7px 10px; border-radius: 8px; font-weight: var(--weight-medium); }
nav a:hover, nav .active { color: white; background: #263a60; text-decoration: none; }
main {
    --page-inset: clamp(14px, 1.5vw, 28px); --page-start: 20px; --workspace-topbar-height: 56px;
    margin-left: var(--sidebar-width); padding: var(--page-start) var(--page-inset) 20px;
}
.page-heading {
    position: sticky; top: 0; z-index: 12; display: grid; align-items: center;
    grid-template-columns: minmax(0, 1fr) minmax(150px, min(28%, 400px)) minmax(0, 1fr);
    grid-template-areas: "title search actions"; gap: 8px 12px;
    min-height: 56px; margin: calc(-1 * var(--page-start)) calc(-1 * var(--page-inset)) 12px;
    padding: 7px var(--page-inset);
    /* Match the page gradient in viewport coordinates, not coordinates local to the bar. */
    background: var(--workspace-background); background-attachment: fixed; background-repeat: no-repeat;
}
.page-heading > .page-title { grid-area: title; display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title-text { min-width: 0; }
.page-heading .page-title-text:has(> .breadcrumb) { display: flex; align-items: center; gap: 8px; }
.page-heading .breadcrumb { flex: 0 0 auto; }
.page-title-text h1 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.page-heading > .global-search { grid-area: search; align-self: center; }
.page-heading > .page-actions { grid-area: actions; min-width: 0; margin: 0; gap: 6px; }
.page-heading > .page-actions > .button { text-align: center; }
.page-heading > .page-actions .job-values { justify-content: flex-end; }
.breadcrumb { display: inline-flex; color: var(--muted); font-size: var(--text-small); font-weight: var(--weight-medium); }
@media (max-width: 700px) {
    .page-heading {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "title actions" "search search";
        gap: 5px 8px;
    }
    .page-heading > .global-search { width: min(100%, 400px); justify-self: center; }
    .page-heading h1 { font-size: 1.25rem; }
    main { --workspace-topbar-height: 86px; }
}
.breadcrumb:hover { color: var(--blue); }
h1 { margin: 0; font-size: var(--text-page); letter-spacing: -.045em; line-height: 1.15; overflow-wrap: anywhere; }
h1, h2, h3, .settings-section > summary { font-weight: var(--weight-heading); }
h2, .settings-section > summary { font-size: var(--text-section); line-height: 1.3; }
h2 { margin: 0 0 12px; }
h3 { margin: 0; font-size: var(--text-body); overflow-wrap: anywhere; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; box-shadow: var(--panel-shadow); }
.automation-builder > .panel:first-of-type, .panel-accent { background: linear-gradient(110deg, #f1f5ff, white 70%); border-color: #cfddf6; }
.record-anchor#details, .related-records {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
}
.record-anchor#details { background: #ffffff80; }
.related-records { margin-top: 14px; background: #e9effb; border-color: #d7e1f4; }
.record-anchor#details > .panel:last-child, .related-records > .panel:last-of-type { margin-bottom: 0; }
.related-records > h2 { margin-bottom: 12px; }
.related-records > .panel > .diary-toolbar + .table-scroll { margin-top: 8px; }
.directory { padding: 0; overflow: hidden; }
.profile-email-change { margin-block: 0 12px; }
.profile-email-change > summary { color: var(--blue); width: fit-content; }
.profile-email-change > form { margin-block-start: 10px; }
.profile-section + .profile-section { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.filters, .toolbar, .inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters { padding: 11px 12px; background: #fff; }
.filters label:not(.search) { min-width: min(130px, 100%); }
.directory-sort-control {
    position: relative; display: inline-grid; place-items: center; flex: 0 0 36px;
    inline-size: 36px; block-size: 36px; vertical-align: middle; border: 1px solid var(--line);
    border-radius: 8px; color: var(--brand-midnight); background: var(--surface);
}
.directory-sort-control svg { inline-size: 19px; block-size: 19px; pointer-events: none; }
.directory-sort-control select {
    position: absolute; inset: 0; inline-size: 100%; block-size: 100%;
    opacity: 0; cursor: pointer; appearance: auto;
}
.directory-sort-control:hover { background-color: var(--blue-soft); }
.directory-sort-control:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.request-type-filter .directory-sort-control { margin-inline-end: 6px; }

.search { position: relative; flex: 1 1 220px; }
.search input { padding-inline-start: 35px; background: #f8faff; }
.search::before { content: ''; position: absolute; bottom: 12px; left: 11px; width: 10px; height: 10px; border: 1.5px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search::after { content: ''; position: absolute; bottom: 10px; left: 21px; width: 6px; height: 1.5px; background: var(--muted); transform: rotate(45deg); pointer-events: none; }
.toolbar { justify-content: space-between; margin-bottom: 16px; }
.page-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.quote-preview-template { min-width: 0; max-width: min(12rem, 100%); }
.quote-preview-template select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.quote-preview-template:has(.quote-preview-pay) {
    display:grid; grid-template-columns:minmax(0,max-content) minmax(0,max-content);
    align-items:center; gap:5px 12px; max-width:100%;
}
.quote-preview-template:has(.quote-preview-pay) select { width:100%; max-width:12rem; }
.quote-preview-picker { grid-column:1; grid-row:1 / span 2; display:grid; grid-template-rows:subgrid; min-width:0; }
.quote-preview-pay.check { grid-column:2; grid-row:2; margin:0; min-width:0; }
.page-heading:has(.quote-preview-template) > .page-title { display:contents; }
.page-heading:has(.quote-preview-template) .page-title-text { grid-area:title; }
.page-heading .quote-preview-template { grid-area:quote-tools; justify-self:start; }
.page-heading:has(.quote-preview-template) > .page-actions { flex-wrap:nowrap; }
@media (min-width:701px) {
    .page-heading:has(.quote-preview-template) {
        grid-template-areas:"title search actions" "quote-tools quote-tools quote-tools";
        grid-template-rows:minmax(42px,auto) auto;
    }
}
@media (max-width:700px) {
    .page-heading:has(.quote-preview-template) {
        grid-template-areas:"title actions" "search search" "quote-tools quote-tools";
    }
    .page-heading:has(.quote-preview-template) > .page-title { display:contents; }
    .page-heading:has(.quote-preview-template) .page-title-text { grid-area:title; }
    .page-heading .quote-preview-template { grid-area:quote-tools; }
}
body[data-phone-layout] .page-heading:has(.quote-preview-template) {
    grid-template-columns:minmax(0,1fr) minmax(0,auto);
    grid-template-areas:"title actions" "quote-tools quote-tools";
}
body[data-phone-layout] .page-heading:has(.quote-preview-template) > .page-title { display:contents; }
body[data-phone-layout] .page-heading .quote-preview-template { grid-area:quote-tools; }
body[data-phone-layout] .page-heading:has(.quote-preview-template) > .page-actions { max-width:none; }
#quote-send .dialog-actions > p { margin: 0; }
.quote-delivery-form { display:grid; gap:14px; max-width:860px; }
.quote-delivery-form p, .quote-delivery-form ul { margin-block:0; }
.quote-delivery-form h2 { margin-bottom:6px; }
.quote-delivery-form textarea, .quote-delivery-whatsapp { min-width:0; overflow-wrap:anywhere; }
.quote-delivery-whatsapp { white-space:pre-wrap; padding:12px; background:var(--blue-soft); border-radius:8px; }
.quote-delivery-options { margin-block:8px; }
.quote-delivery-options summary { cursor:pointer; color:var(--blue); }
.quote-delivery-options > div { display:grid; gap:6px; padding:8px 0; }
.quote-delivery-actions { justify-content:flex-end; margin-bottom:0; }

main > .settings-tabs:has(+ .page-actions) { margin-bottom: 8px; }
.inline { margin: 12px 0; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { padding: 8px 12px; border-bottom: 1px solid #e8edf6; overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-inline-start: 12px; }
th { background: #eef3fb; white-space: nowrap; border-top: 1px solid var(--line); font-size: var(--text-small); }
th[aria-sort] a { color: var(--blue); }
th a { display: inline-flex; gap: 8px; color: var(--ink); }
tbody tr:hover { background: #f8faff; }
.contact-link { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: var(--weight-heading); }
.directory .contact-link { font-weight: 400; }
.contact-link:hover { color: var(--blue); text-decoration: none; }
tr:nth-child(3n + 2) .avatar { background: #e4f4f0; color: #176951; }
tr:nth-child(3n + 3) .avatar { background: #f1eaff; color: #6335a5; }
.avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; background: #e9efff; color: #2449ae; font-size: var(--text-caption); font-weight: 800; }
.directory td.directory-leading-badge { position: relative; padding-inline-start: 50px; }
.directory td.directory-leading-badge > .avatar { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); }
.page-heading .avatar { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(145deg, #dfe8ff, #eef2ff); border: 1px solid #cfdcfa; font-size: var(--text-section); }
.table-footer { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 5px 12px; font-size: var(--text-small); color: var(--muted); background: #fbfcff; }
.directory:has([data-directory-pagination]) .table-footer { flex-wrap: wrap; }
.directory-paging { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.directory-page-size label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.directory-page-size select { min-height: 28px; padding: 2px 6px; font-size: inherit; width: auto; }
.directory-pagination:not([hidden]) { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.directory-pagination .button { min-height: 28px; padding: 3px 8px; }
.column-picker { width: min(480px, calc(100% - 28px)); max-height: calc(100% - 28px); padding: 22px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); box-shadow: 0 24px 80px #0c17364a; }
.column-picker::backdrop { background: color-mix(in srgb, var(--brand-midnight) 44%, transparent); backdrop-filter: blur(3px); }
.column-group { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.column-group > summary { padding: 10px 12px; }
.column-group > summary::marker { color: var(--blue); }
.column-group[open] > summary { border-bottom: 1px solid var(--line); }
.column-group .grid { padding: 10px 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 12px; }
.empty { text-align: center; padding: 32px; color: var(--muted); }
input, select, textarea, button, .button { font: inherit; font-size: var(--text-body); border: 1px solid #cbd6e9; border-radius: 8px; padding: 6px 9px; background: white; color: inherit; }
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select:not([multiple], [size]) {
    appearance: none;
    min-width: 0;
    padding-inline-end: 32px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 15px center, right 10px center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}
select:not([multiple], [size]):enabled:hover { border-color: #aebfe0; background-color: #f8faff; }
select:disabled { cursor: default; opacity: .65; }

@supports (appearance: base-select) and selector(select::picker(select)) {
    select:not([multiple], [size]), select:not([multiple], [size])::picker(select) {
        appearance: base-select;
    }
    select:not([multiple], [size]) {
        gap: 10px;
        padding-inline-end: 12px;
        background-image: none;
    }
    select:not([multiple], [size]):open { border-color: var(--blue); background-color: #f8faff; }
    select::picker-icon { color: var(--muted); }
    select:open::picker-icon { color: var(--blue); rotate: 180deg; }
    select::picker(select) {
        min-inline-size: max(anchor-size(width), 144px);
        max-inline-size: min(380px, calc(100vw - 24px));
        max-block-size: min(320px, 45dvh);
        margin-block: 6px;
        padding: 5px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        color: var(--ink);
        box-shadow: 0 10px 28px #17213826;
        overscroll-behavior: contain;
    }
    select option {
        gap: 8px;
        min-block-size: 34px;
        padding: 7px 9px;
        border: 0;
        border-radius: 7px;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    select option:checked { background: var(--blue-soft); color: var(--blue); font-weight: var(--weight-medium); }
    select option:enabled:hover, select option:enabled:focus-visible { background: #e0eaff; color: var(--blue-hover); }
    select option:focus-visible { outline-offset: -2px; }
    select option:disabled { color: var(--muted); opacity: .65; }
    select option::checkmark { order: 1; margin-inline-start: auto; color: var(--blue); }
    select optgroup { padding-block: 3px; font-size: var(--text-small); color: var(--muted); }
}
input[type="checkbox"] { accent-color: var(--blue); }
label { display: grid; gap: 5px; font-size: var(--text-small); font-weight: var(--weight-medium); }
label input, label textarea { width: 100%; min-width: 0; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; }
.check input { width: auto; }
input[type="checkbox"][role="switch"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    inline-size: 36px;
    block-size: 20px;
    min-inline-size: 36px;
    margin: 0 6px 0 0;
    padding: 2px 3px;
    border: 1px solid transparent;
    border-radius: 999px;
    background-color: var(--brand-steel);
    background-image: radial-gradient(circle closest-side, #fff 96%, transparent);
    background-size: 14px 14px;
    background-origin: content-box;
    background-position: 0% 50%;
    background-repeat: no-repeat;
    vertical-align: middle;
    cursor: pointer;
    transition: background-position 160ms ease, background-color 160ms ease;
}
input[type="checkbox"][role="switch"]:checked { background-color: var(--blue); background-position: 100% 50%; }
input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
input[type="checkbox"][role="switch"]:disabled { cursor: not-allowed; opacity: .46; }
@media (prefers-reduced-motion: reduce) {
    input[type="checkbox"][role="switch"] { transition: none; }
}
@media (forced-colors: active) {
    input[type="checkbox"][role="switch"] { appearance: auto; background: none; border: 0; padding: 0; }
}

button, .button, summary { cursor: pointer; font-weight: var(--weight-medium); }
.button { display: inline-block; }
button:hover, .button:hover { text-decoration: none; background: #edf2fc; }
button:disabled { cursor: default; opacity: .55; }
input::placeholder { color: #697992; opacity: 1; }
.primary { color: white; background: var(--blue); border-color: var(--blue); box-shadow: 0 3px 6px #234be629; }
.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.danger-button { color: white; background: var(--danger); border-color: var(--danger); }
.danger-button:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.quiet { border-color: transparent; background: transparent; color: var(--blue); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: 12px; margin: 0 0 10px; }
.grid:last-child { margin-bottom: 0; }
.contact-tabs { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; padding: 5px; border: 1px solid var(--line); border-radius: 13px; }
.contact-tabs a { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 7px 13px; border: 1px solid transparent; border-radius: 9px; color: var(--muted); }
.contact-tabs a:hover { background: #e7eeff; color: var(--blue); }
.contact-tabs a[aria-current="location"] { background: var(--blue-soft); border-color: #dce6ff; color: var(--blue); }
.contact-tabs a:focus-visible { outline-offset: -3px; }
.tab-count { min-width: 20px; padding: 0 5px; border-radius: 12px; background: #e7eeff; color: var(--blue); text-align: center; font-size: var(--text-caption); }
dt, .muted, time { color: var(--muted); font-size: var(--text-small); }
dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.note { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notes-heading, .note-header, .note-title-group, .note-actions { display: flex; align-items: center; gap: 8px; }
.notes-heading, .note-header { justify-content: space-between; flex-wrap: wrap; }
.notes-heading h2 { margin: 0; }
.notes-heading { margin-bottom: 12px; }
.note p { margin: 5px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-actions { flex-wrap: wrap; }
.note-metadata { display: inline-flex; flex-wrap: wrap; gap: 3px 7px; color: var(--muted); font-size: var(--text-small); }
.note .edit-note { padding: 4px 8px; font-size: var(--text-small); }
.note-handle { width: 26px; height: 26px; }
.note.sortable-dragging { padding-inline: 10px; }
#note-order-form:not([hidden]), .note-editor-form { display: grid; gap: 12px; }
#note-order-form { margin-top: 14px; }
#note-order-form button { justify-self: start; }
.record-anchor { scroll-margin-top: 64px; }
.contact-tabs { position: sticky; z-index: 3; top: 5px; background: #ffffffee; backdrop-filter: blur(12px); }
:focus-visible { outline: 3px solid #3676db; outline-offset: 2px; }
@media (max-width: 700px) {
    .sidebar { position: static; width: auto; overflow-y: visible; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; }
    .sidebar-nav { flex: 1 1 100%; min-width: 0; flex-direction: row; align-items: center; gap: 8px; }
    .sidebar-modules { flex: 1; flex-direction: row; min-width: 0; overflow-x: auto; }
    .sidebar-module { flex: 0 0 auto; touch-action: pan-y; }
    #settings-gear { margin-top: 0; }
    .brand { --brand-logo-height: 54px; --brand-mark-size: 42px; flex: 1 1 100%; min-width: 0; margin: 0; padding: 0 4px 4px; border: 0; }
    nav { display: flex; }
    main { --page-start: 16px; --page-inset: 12px; margin: 0; padding-bottom: 16px; }
    .panel:not(.directory) { padding: 12px; }
    .filters, .table-footer { padding-inline: 12px; }
}

.section-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr));
    gap: 8px;
}
.section-choices .check {
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.section-choices input { flex: 0 0 auto; margin: 0; }

.settings-tabs { display: flex; gap: 4px; width: fit-content; max-width: 100%; padding: 4px; margin: 0 0 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff9; }
.settings-nav-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; margin-bottom: 16px; }
.settings-nav-row:has(+ .settings-tabs, + .settings-team-row, + .page-actions, + .settings-template-toolbar) { margin-bottom: 8px; }
.settings-nav-row > .settings-tabs { flex: 0 0 auto; margin-bottom: 0; }
.settings-nav-row > .settings-module-tabs { flex: 0 1 auto; min-width: 0; }
.settings-tabs a { flex: 0 0 auto; padding: 6px 13px; border-radius: 8px; color: var(--muted); }
.settings-tabs a:hover { color: var(--blue); background: #e7eeff; }
.settings-tabs a[aria-current="page"] { color: var(--blue); background: var(--blue-soft); }
.settings-tabs a:focus-visible { outline-offset: -3px; }
@media (max-width: 720px) {
    .settings-nav-row { flex-wrap: wrap; }
}
.integration-settings > ul { margin-bottom: 0; }
[data-cleanup-options] [hidden] { display: none; }
.cleanup-value { white-space: pre-wrap; overflow-wrap: anywhere; }

.settings-section > summary::marker { color: var(--blue); }
.module-settings .panel { margin-bottom: 12px; }
.module-settings .panel > :last-child:not(script) { margin-bottom: 0; }
.module-settings form > button[type="submit"] { margin-block: 10px 0; }
.module-settings .choice-field { min-width: 0; }
.module-settings .settings-section {
    margin-top: 8px; border: 1px solid var(--line); border-radius: 10px;
}
.module-settings .settings-section > summary { padding: 10px 12px; cursor: pointer; overflow-wrap: anywhere; }
.module-settings .settings-section[open] > summary {
    background: var(--blue-soft); border-radius: 9px 9px 0 0;
}
.settings-field-form { padding: 12px; }
.settings-add-field .settings-field-form[action="/settings/products"] .grid > .check {
    align-self: end;
    min-block-size: calc(var(--text-body) * 1.5 + 14px);
}

.settings-field-row { position: relative; margin-bottom: 8px; }
.module-settings .settings-add-field > details { border: 0; }
.module-settings .settings-add-field > details > summary.add-field-row {
    display: block; list-style: none; text-align: center; padding: 12px; border-radius: 8px;
    font-size: var(--text-body); font-weight: var(--weight-medium); line-height: inherit;
}
.module-settings .settings-add-field > details > summary.add-field-row:not(:hover) { background: white; }
.module-settings .settings-add-field > details > summary::-webkit-details-marker { display: none; }
.module-settings .settings-add-field > details > form {
    margin-top: 8px; border: 1px solid var(--line); border-radius: 10px;
}
.ticket-visibility-settings [hidden] { display: none; }
.module-settings .settings-field-row > .settings-section { margin-top: 0; }
.settings-field-row[data-field-id] summary { padding-inline-end: 84px; min-height: 42px; }
.settings-field-actions {
    position: absolute; inset-block-start: 5px; inset-inline-end: 8px;
    display: flex; align-items: center; gap: 4px;
}
.settings-field-type { display: grid; align-content: center; gap: 4px; }
.settings-field-type > span { color: var(--muted); font-size: var(--text-small); }
.builder-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.company-form { display: grid; align-items: start; gap: 16px 22px; }
.company-identity { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.company-name, .company-logo, .company-form-actions { grid-column: 1 / -1; }
.company-identity label > select { min-width: 0; width: 100%; }
.company-identity > label:has(> :is([name="company_email"], [name="language"], [name="country"], [name="weather_location"])) {
    align-content: start; min-width: 0;
}
.company-logo { border-top: 1px solid var(--line); padding-top: 12px; }
.company-logo-label { display: block; margin-bottom: 5px; }
#company-logo-upload { margin-top: 6px; }
#company-logo { width: 100%; min-width: 0; }
.company-logo .muted { margin: 5px 0 9px; }
.company-form-actions { display: flex; justify-content: flex-end; }
.general-settings { padding: 14px; }
.general-settings > h2 { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid #e9edf5; }
@media (min-width: 1020px) {
    .company-form { grid-template-columns: minmax(0, 1fr) minmax(310px, 1fr); }
}
@media (max-width: 420px) {
    .company-identity { grid-template-columns: minmax(0, 1fr); }
}
.logo-preview { display: block; width: 90px; height: 60px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; margin: 0 0 8px; }

.working-hours { min-width: 0; margin: 0; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: #f7f9fe; }
[data-staff-schedule] > [data-restore-company-hours] { margin-block-start: .625rem; }
.working-hours legend { padding: 0 5px; font-size: var(--text-small); font-weight: var(--weight-medium); }
.workday { display: grid; grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr)); align-items: center; gap: 8px; padding: 3px 0; }
.workday-header { font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--muted); }
.workday .check { gap: 5px; overflow-wrap: anywhere; }
.workday .check input { flex: 0 0 auto; margin: 0; }
.workday input[type="time"] { width: 100%; min-width: 0; padding: 6px 4px; }
.workday input:disabled { background: #edf2fa; color: var(--muted); }
.legacy-hours { white-space: pre-wrap; overflow-wrap: anywhere; }

.section-save-error { margin-top: 0; color: var(--danger-hover); }
.section-field-scroll { overflow-x: auto; }
.section-field-list {
    --layout-gap: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 170px;
    gap: var(--layout-gap);
    min-width: 460px;
}
.section-field-list > *, .field-layout > [style] {
    grid-row: var(--slot-row);
    grid-column: var(--slot-column) / span var(--slot-width, 1);
    justify-self: var(--slot-align, stretch);
    inline-size: var(--slot-inline-size, auto);
}
.section-field-row { display: grid; align-content: start; gap: 6px; padding: 8px 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; min-width: 0; }
.save-toast { position: fixed; z-index: 5; top: 18px; right: 18px; max-width: calc(100% - 36px); margin: 0; padding: 10px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 4px 16px #16294820; font-weight: var(--weight-medium); }
.job-tba-toast { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.section-field-row label { gap: 2px; }
.section-field-row input, .section-field-row select { padding: 4px 7px; min-width: 0; }
.section-field-row select:not([multiple], [size]) { padding-inline-end: 24px; }
.field-actions { display: flex; justify-content: space-between; }
.field-actions-left { display: flex; align-items: center; gap: 4px; }
.move-contact-field { color: var(--muted); }
.field-move-destinations { display: grid; gap: 6px; max-height: min(48vh, 380px); overflow: auto; }
.field-move-destinations .button { justify-content: flex-start; text-align: left; }
.core-section-settings dt:has(.move-contact-field) { display: flex; align-items: center; gap: 4px; }
.field-actions-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.field-handle { border: 0; padding: 1px 6px; line-height: 1.2; }
.field-handle { cursor: grab; touch-action: none; user-select: none; color: var(--muted); }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; }
.icon-button svg { width: 16px; height: 16px; }
.phone-value { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.phone-value .whatsapp-link { color: #126942; }
.whatsapp-link:hover, .whatsapp-link:focus-visible { background: #e4f5eb; color: #0b5132; }
.whatsapp-link svg { width: 20px; height: 20px; }
.remove-button { color: var(--danger); }
.remove-button:hover, .remove-button:focus-visible, .remove-button[aria-pressed="true"] { color: var(--danger-hover); background: var(--danger-surface); }
.logo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.logo-actions .logo-preview { margin: 0; }
.field-dragging { z-index: 2; opacity: .82; pointer-events: none; }
.field-drop-target { z-index: 1; pointer-events: none; border: 2px dashed var(--blue); border-radius: 9px; background: #e7eeff88; }
.add-field-row { width: 100%; margin-top: 12px; padding: 12px; border-style: dashed; color: var(--blue); }
.field-layout { --layout-gap: 17px; align-items: start; }
.field-layout dd { white-space: pre-wrap; }
@media (min-width: 900px) {
    #contact-editor #contact-section--1 .field-layout > div > label.check:has(> input[type="checkbox"]),
    #contact-editor .contact-email-options {
        margin-block-start: calc(var(--text-small) * 1.5 + 5px);
        min-height: calc(var(--text-body) * 1.5 + 14px);
    }
}
.multiline-input { display: block; height: calc(3em + 20px); line-height: 1.5; overflow-y: auto; resize: none; }
.field-layout .multiline-value { max-height: 3em; line-height: 1.5; overflow-y: auto; }
.multiline-width { gap: 6px; }
.multiline-width[hidden] { display: none; }
.multiline-width input { flex: 0 0 auto; margin: 0; }

@media (min-width: 900px) {
    .field-layout { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(54px, auto); }
}
@media (max-width: 899px) {
    .field-layout > [style] { grid-area: auto; justify-self: stretch; inline-size: auto; }
}

.configure-field { padding: 1px 7px; font-size: var(--text-small); }
#formula-settings > label, #contact-formula-settings > label { margin-bottom: 8px; }
#add-contact-formula-field { display: block; margin: 0 auto 10px; }
.choice-option-row { display: flex; align-items: end; gap: 8px; margin-bottom: 10px; }
.choice-option-row label { flex: 1; }
.choice-option-row .remove-button { margin-bottom: 7px; }
.choice-field { min-width: 0; margin: 0; padding: 5px 8px 8px; border: 1px solid var(--line); border-radius: 8px; }
.choice-field legend, .field-label { font-size: var(--text-small); font-weight: var(--weight-medium); }
.choice-field .check, .field-layout .check { gap: 6px; overflow-wrap: anywhere; }
.choice-field .check input, .field-layout .check input { width: auto; flex: 0 0 auto; }
.computed-field { margin: 4px 0 0; }

.choice-option-row .option-handle { align-self: end; margin-bottom: 7px; width: 26px; height: 26px; }

.contact-sections-panel { padding: clamp(12px, 2vw, 20px); }
.section-list-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-list-heading :is(h2,h3) { margin: 0 0 4px; }
.contact-additional-sections { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.contact-additional-sections > .section-list-heading { margin-bottom: 8px; }
.section-list-heading p { margin: 0; }
.contact-section-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.contact-section-card > summary, .contact-section-core-heading {
    min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 8px 12px;
    list-style: none; border-radius: 9px; color: #1b3253; overflow-wrap: anywhere;
}
.contact-section-card > summary::-webkit-details-marker { display: none; }
.contact-section-card > summary::before {
    content: ""; display: block; flex: 0 0 auto; width: 7px; height: 7px; margin-inline: 2px 4px;
    border: solid var(--blue); border-width: 0 2px 2px 0; transform: rotate(-45deg);
}
.contact-section-card[open] > summary::before { transform: rotate(45deg); }
.contact-section-card > summary:hover { background: #f4f8ff; }
.contact-section-card[open] > summary, .contact-section-core-heading { background: var(--blue-soft); border-radius: 9px 9px 0 0; }
.contact-section-count {
    flex: 0 0 auto; padding: 2px 8px; border-radius: 999px; background: #edf2fb; color: #425774;
    font-size: var(--text-small); font-weight: var(--weight-medium);
}
.contact-section-card[open] .contact-section-count, .contact-section-core-heading .contact-section-count { background: var(--surface); }
/* Ticket field editors share the collapsible Contacts cards without changing field behavior. */
.ticket-fields-settings > .section-list-heading { margin-bottom: 8px; }
.ticket-fields-settings .contact-section-card > summary { padding-inline-end: 84px; cursor: pointer; }
.ticket-fields-settings .contact-section-card > summary .section-summary-title { min-width: 0; }
.ticket-fields-settings .contact-section-count { flex: 0 1 auto; min-width: 0; }
.contact-sections-panel .section-builder { padding: 12px; }
.contact-section-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.contact-section-toolbar .section-name-field { flex: 1 1 230px; min-width: 0; max-width: 420px; }
.contact-section-always-show { min-height: 36px; white-space: nowrap; }
.contact-section-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
.contact-sections-panel .section-field-list { grid-auto-rows: 154px; }
.contact-sections-panel .section-field-list:empty { display: none; }
.contact-card-preview { margin: 12px; border: 1px solid #cbd9fb; border-radius: 12px; }
.core-field-hint { margin: 0 0 10px; font-size: var(--text-small); }
.core-field-title {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
    padding: 2px 4px; border: 1px solid transparent; border-radius: 6px; background: transparent;
    color: var(--blue); font-size: inherit; font-weight: inherit; text-align: start; overflow-wrap: anywhere;
}
.core-field-title:is(:hover,:focus-visible) { background: var(--blue-soft); border-color: var(--line); }
#rename-core-field [data-rename-error][hidden] { display: none; }
.contact-card-sample-values {
    --layout-gap: 12px;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 3px var(--layout-gap); margin: 0;
}
.contact-card-sample-values > div { min-width: 0; padding-inline-start: 12px; border-inline-start: 1px solid #d4e0f4; }
.contact-card-sample-values dt { font-size: var(--text-small); color: var(--muted); margin-bottom: 2px; line-height: 1.25; }
.contact-card-preview .contact-card-sample-values dd { margin: 0; overflow-wrap: anywhere; }
.contact-card-sample-values > [style] {
    grid-row: var(--slot-row);
    grid-column: var(--slot-column) / span var(--slot-width);
    justify-self: var(--slot-align, stretch);
    inline-size: var(--slot-inline-size, auto);
}
.contact-card-preview span:is(.job-map-link, .whatsapp-link) { cursor: default; }
.contact-card-preview .job-map-link { padding: 3px 7px; font-size: var(--text-small); }
.sample-address-one-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
    .contact-card-sample-values { grid-template-columns: repeat(auto-fit, minmax(min(165px, 100%), 1fr)); }
    .contact-card-sample-values > [style] { grid-area: auto; justify-self: stretch; inline-size: auto; }
}
#new-section { margin-top: 8px; }
.section-item { position: relative; margin-top: 8px; }
.section-item > details > summary { padding-inline-end: 73px; }
.section-list-actions { position: absolute; top: 9px; inset-inline-end: 10px; display: flex; align-items: center; gap: 4px; }
.section-list-actions .section-handle { width: 26px; height: 26px; }
.contact-sections-empty { margin: 10px 0 0; }
#editable-section-list:not(:empty) + .contact-sections-empty { display: none; }
#section-order-form:not([hidden]) { display: flex; justify-content: flex-end; margin-top: 10px; }
.sortable-dragging {
    position: fixed;
    z-index: 10;
    top: var(--drag-top);
    left: var(--drag-left);
    width: var(--drag-width);
    pointer-events: none;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 8px 24px #16294830;
    opacity: .85;
}
.sortable-placeholder { border: 2px dashed var(--blue); border-radius: 9px; background: #e7eeff88; }
.sortable-placeholder.sortable-outside { border-color: transparent; background: transparent; }

.bulk-controls:has(> :not(dialog):not([hidden])) {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 8px 0;
}
.bulk-controls .check, .bulk-selection { display: flex; align-items: center; gap: 8px; }
.bulk-selection[hidden] { display: none; }
[data-bulk-count] { padding: 4px 8px; }
.bulk-selection { flex-wrap: wrap; }
.bulk-selection [data-bulk-delete] { color: #a12430; }
.bulk-edit-form { display: grid; gap: 12px; }
.bulk-edit-form .check { gap: 6px; }
.bulk-stage-message { margin: 0; }
.bulk-field-sections { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.bulk-field-sections legend { margin-bottom: 6px; font-weight: 600; }
.bulk-edit-form [hidden] { display: none; }
.bulk-edit-form [data-bulk-value] > span { display: block; }
.bulk-select-column, .directory .bulk-select-cell { width: 40px; }
.directory .bulk-select-cell { padding: 4px; text-align: center; }
[data-bulk-all], [data-bulk-record] { width: 14px; height: 14px; margin: 0; vertical-align: middle; cursor: pointer; }
[data-bulk-all]:disabled { cursor: default; }
.directory table { table-layout: fixed; width: 100%; }
.directory th[data-column] { position: relative; padding-inline-end: 22px; }
.directory .column-title { vertical-align: middle; white-space: nowrap; }
.directory span.column-title { display: inline-block; }
.column-grip { margin-inline-end: 5px; padding-inline: 2px; vertical-align: middle; }
.column-resize { position: absolute; inset: 4px 0 4px auto; width: 12px; padding: 0; border: 0; border-radius: 3px; background: transparent; cursor: col-resize; touch-action: none; }
.directory th:last-child .column-resize { display: none; }
.column-resize::after { content: ""; position: absolute; inset: 5px 4px 5px auto; width: 1px; background: #9baed0; }
.column-resize:hover::after, .column-resize:focus-visible::after { width: 2px; background: var(--blue); }
.column-drag-preview {
    position: fixed; top: 0; left: 0; z-index: 30; pointer-events: none;
    background: var(--surface); box-shadow: 0 8px 24px #16294830;
    outline: 1px solid #9bb1f0; opacity: .94;
}
.column-drag-preview th { background: #e5edff; }
.directory .column-drag-placeholder { background: #e7eeff; color: transparent; }
.column-drag-placeholder > * { visibility: hidden; }
.clear-filters[hidden] { display: none; }

.history-list { margin: 0 0 14px; padding: 0 0 0 20px; list-style: none; border-left: 2px solid #dce6fc; }
.history-event { position: relative; padding: 0 0 14px; }
.history-event + .history-event { padding-top: 14px; border-top: 1px solid var(--line); }
.history-event::before { content: ""; position: absolute; left: -26px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--surface); }
.history-event + .history-event::before { top: 19px; }
.history-event-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
.history-metadata { display: grid; justify-items: end; gap: 2px; margin-inline-start: auto; text-align: end; }
.history-metadata span { font-size: var(--text-small); color: var(--muted); }
.history-change { margin: 9px 0 0; padding: 9px 12px; background: #f6f8fd; border: 1px solid #e6edf9; border-radius: 9px; }
.history-change h4 { margin: 0 0 5px; font-size: var(--text-small); overflow-wrap: anywhere; }
.history-change dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.history-change dd { white-space: pre-wrap; }

.company-form-actions:has(> button[hidden]) { display: none; }

/* Jobs and engineer diary */
.jobs-header-totals .job-values { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 4px 0 0; font-variant-numeric: tabular-nums; }
.jobs-header-totals .job-values > div { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.jobs-header-totals .job-values dd { margin: 0; font-weight: 700; }
.jobs-list-schedule > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 7px; }
.jobs-list-address { white-space: pre-line; }
.jobs-list-schedule > .muted { display: block; margin-top: 4px; }
.jobs-list-money { font-variant-numeric: tabular-nums; }
.diary-toolbar, .diary-team > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.diary-toolbar h2, .diary-team h2 { margin: 0; }
.diary-job p { margin: 4px 0; }
.job-title { font-weight: 700; overflow-wrap: anywhere; }
.job-inline-contact, .job-values { margin-top: 14px; }
.job-item { display: grid; grid-template-columns: 2fr minmax(90px, .65fr) 1.4fr auto; gap: 10px; align-items: end; margin-bottom: 9px; }
.job-record-actions, .job-contact-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.job-values dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.job-values dt { font-size: .84rem; color: var(--brand-steel); }
.diary-note-editor label { margin-bottom: 8px; }
.diary-note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.job-error { color: #a01b32; }
.diary-date-controls, .diary-date-controls form, .diary-row-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.diary-date-controls input { margin: 0; width: auto; }
.diary-days { position: relative; display: flex; gap: 5px; padding: 8px 0 4px; margin-top: 10px; overflow-x: auto; }
.diary-days a { flex: 1 0 39px; display: grid; justify-items: center; gap: 4px; padding: 6px 3px; border-radius: 8px; background: #f0f4fb; color: #273b61; }
.diary-days a span { font-size: .75rem; }
.diary-note { border-top: 1px solid #dbe4f3; padding: 9px 0; margin-top: 9px; }
.diary-note-dialog { width: min(540px, calc(100% - 28px)); padding: 0; }
.diary-note-dialog header { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; background: var(--brand-midnight); color: white; }
.diary-note-dialog header h2 { margin: 0; }
.diary-note-dialog header button { background: transparent; color: white; border-color: #ffffff66; padding: 2px 8px; }
.diary-note-dialog header button:hover { background: #ffffff25; }
.diary-note-dialog-body { display: grid; gap: 9px; padding: 14px; }
.diary-note-dialog .diary-supplier { border: 0; padding: 0; min-width: 0; margin: 0; }
.diary-note-dialog .diary-supplier[hidden] { display: none; }
.diary-supplier { margin-top: 9px; }
.diary-grid { display: grid; grid-template-columns: .8fr 1.15fr 1.65fr .75fr 1fr 1fr; gap: 10px; }
.diary-grid > * { min-width: 0; overflow-wrap: anywhere; }
.diary-column-headings { padding: 8px 12px; color: var(--brand-steel); font-size: .8rem; font-weight: 700; }
.diary-team { border: 1px solid #d7e1f4; border-radius: 12px; margin-bottom: 14px; background: white; }
.diary-team > header { background: #e9effb; padding: 8px 12px; border-radius: 11px 11px 0 0; }
.diary-job { padding: 9px 12px; border-top: 1px solid #e2e9f5; }
.diary-job .job-contact-actions { gap: 5px; margin-top: 6px; }
.diary-job .job-contact-actions .button { min-height: 0; padding: 4px 6px; font-size: .78rem; }
.diary-row-actions { margin-top: 8px; justify-content: flex-end; align-items: start; }
.job-status { background: var(--stage-bg, #e9effb); color: var(--stage-ink, #234085); border-radius: 6px; display: inline-block; padding: 3px 6px; font-size: .8rem; }
@media (max-width: 760px) {
    .diary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .diary-column-headings { display: none; }
    .job-item { grid-template-columns: 1fr 1fr; }
}
.job-receipt iframe { display: block; width: 100%; min-height: 72vh; border: 1px solid var(--line); border-radius: 8px; background: white; }
.quote-preview-document iframe[data-sized] { box-sizing:content-box; width:calc(100% - 2px); min-height:0; }

/* Compact diary sheet */
.diary-calendar { margin-bottom: 12px; }
.diary-banner { padding: 12px 14px; background: var(--brand-midnight); color: white; border-radius: 10px 10px 3px 3px; }
.diary-banner .diary-selected-date { color: inherit; font-size: clamp(1.1rem, 2vw, 1.5rem); }
.diary-banner .button { background: #ffffff13; border-color: #ffffff46; color: white; }
.diary-banner .button:hover { background: #ffffff29; }
.diary-banner .diary-date-controls { display: grid; grid-template-columns: 30px 11rem auto 30px; margin-inline-start: auto; }
.diary-banner .button { text-align: center; }
.diary-month { padding: 6px 9px; border: 1px solid #ffffff46; border-radius: 8px; background: #ffffff13; font-weight: 700; }
@media (max-width: 400px) {
    .diary-banner .diary-date-controls { width: 100%; grid-template-columns: 28px minmax(0, 1fr) auto 28px; }
}
.diary-days { gap: 4px; padding: 5px; margin-top: 4px; background: #e4eaf4; border-radius: 7px; }
.diary-days a { flex: 1 0 28px; padding: 4px 2px; background: white; border: 1px solid #d0daeb; border-radius: 5px; font-size: var(--text-caption); }
.diary-days [aria-current="date"] { color: white; background: var(--brand-midnight); border-color: var(--brand-midnight); }
.diary-days [data-non-working] { color: #a41e37; background: #fcecf0; border-color: #efccd3; }
.diary-days [data-today] { border-color: #3478db; box-shadow: inset 0 0 0 1px #3478db; }
.diary-days [data-non-working][aria-current="date"] { border-color: #a41e37; }
.diary-days .diary-weekday { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.diary-notes { border: 1px solid #eee1bb; border-radius: 9px; background: white; margin-bottom: 10px; }
.diary-notes > header { padding: 7px 11px; background: #fff6dc; border-radius: 8px 8px 0 0; align-items: start; }
.diary-note-actions { display: flex; align-items: start; gap: 8px; }
.diary-note-button {
    display: inline-block; list-style: none; font-size: var(--text-small); line-height: 1.35;
    padding: 4px 8px; border: 1px solid #cbd6e9; border-radius: 6px;
    background: white; color: var(--brand-midnight); font-weight: 700;
}
.diary-note-button::-webkit-details-marker { display: none; }
.diary-note-button:hover, .diary-note-button:focus-visible { background: #e9eff9; }
.diary-note-add { padding: 5px 9px; border-color: var(--ink); background: #fff6dc; color: var(--ink); }
.diary-note-add:hover, .diary-note-add:focus-visible { background: #f7eac3; }
.diary-note-delete { background: #fff2f3; color: #bf2638; border-color: #f2a4ae; }
.diary-note-delete:hover, .diary-note-delete:focus-visible { background: #fadce1; color: #a41e32; }
.diary-notes .diary-note { display: flex; align-items: start; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 7px 11px; margin: 0; border-color: #f0e9d8; }
.diary-note p { margin: 0; color: var(--muted); font-size: var(--text-small); }
.diary-engineer-filter { max-width: min(100%, 24rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diary-engineer-options { display: grid; gap: 8px; max-height: 45vh; overflow: auto; padding: 4px 2px; }
.diary-grid { grid-template-columns: minmax(80px, .8fr) minmax(100px, 1.15fr) minmax(170px, 3.5fr) minmax(120px, 1.35fr) minmax(110px, 1fr); gap: 0; }
.diary-grid > * { padding: 6px 9px; }
.diary-grid > * + * { border-inline-start: 1px solid var(--brand-line); }
.diary-column-headings { padding: 0; background: #c3cad4; border-radius: 6px 6px 0 0; color: #242f41; }
.diary-column-headings > * + * { border-inline-start-color: #aab4c2; }
@media (min-width: 881px) {
    body:not([data-phone-layout]) .diary-column-headings + .diary-team,
    body:not([data-phone-layout]) .diary-column-headings + .diary-team > header {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
}
.diary-team > header { background: #dce8fa; color: #24466f; border-bottom: 1px solid #c0d4ef; padding: 5px 9px; }
.diary-team > header .button { background: #ffffff70; color: inherit; border-color: currentColor; padding: 3px 8px; }
.diary-team > header .button:hover { background: #ffffffc7; }
.diary-team > header[data-booked-out] { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); background: #f5e2df; color: #773d39; border-bottom-color: #e8c8c4; }
.diary-division-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.diary-booked-out-badge { justify-self: center; padding: 3px 8px; border-radius: 4px; background: #f0ceca; color: #773d39; font-size: var(--text-body); font-weight: var(--weight-medium); }
@media (max-width: 640px) {
    .diary-team > header[data-booked-out] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .diary-booked-out-badge { grid-column: 1 / -1; grid-row: 2; }
}

.diary-empty { margin: 0; padding: 10px; }
.diary-job { padding: 0; }
.diary-row-actions { margin-top: 0; padding: 4px 8px; background: #f7f9fd; }
.diary-row-actions .button, .diary-row-actions button { padding: 3px 7px; font-size: var(--text-small); }
.diary-work-items { padding: 0; margin: 5px 0 0; list-style: none; }
.diary-work-items li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; padding: 3px 0; border-top: 1px solid #edf1f6; }
.diary-work-items small { flex-basis: 100%; color: var(--muted); }
.diary-staff { color: #954641; font-weight: 700; }
.diary-time-booking { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.diary-booking { margin: 0; }
.diary-booking button { padding: 2px 6px; background: #f1f5f9; color: var(--brand-steel); font-size: var(--text-small); }
.diary-booking button[data-tbc="true"] { background: #fff0b8; border-color: #e2ba53; color: #6e4500; }
.diary-address { display: flex; align-items: start; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; margin-bottom: 6px; }
.diary-address p { margin: 0; white-space: pre-line; }
.diary-address .button { min-height: 0; padding: 3px 6px; font-size: var(--text-small); }
.diary-amounts { margin: 4px 0 0; }
.diary-amounts > div { display: flex; justify-content: space-between; gap: 8px; padding-top: 3px; }
.diary-amounts > div:first-child { padding: 5px 7px; border-radius: 5px; background: #edf2fa; font-size: 1.05rem; }
.diary-amounts dd { margin: 0; color: #954641; font-weight: 700; }
.diary-amounts > div:first-child dt { color: #954641; font-size: inherit; font-weight: 700; }
.diary-amounts > div:last-child { border-top: 1px solid var(--line); margin-top: 3px; font-weight: 700; }
.job-note-box { display: grid; align-content: start; gap: 4px; }
.job-note-box textarea { display: block; width: 100%; min-height: 0; padding: 5px 6px; resize: vertical; }
.job-note-box textarea::placeholder { font-style: italic; }
.job-note-box small { color: var(--danger); }
.diary-job-stage .job-status { display: block; padding: 6px 8px; text-align: center; font-weight: 750; }
.diary-payment-method { margin: 6px 0 0; text-align: center; font-size: var(--text-small); }
.diary-status-actions { display: grid; gap: 5px; }
.diary-status-actions:not(:empty) { margin-top: 12px; }
.diary-status-actions > button { padding: 4px 6px; font-size: var(--text-small); }
[data-stage="tba"] { --stage-bg: #dce4ff; --stage-ink: #243d76; --stage-accent: #7889bd; }
[data-stage="scheduled"] { --stage-bg: #e4e5e7; --stage-ink: #353b45; --stage-accent: #777d86; }
[data-stage="pending"] { --stage-bg: #f4d5fa; --stage-ink: #69247d; --stage-accent: #ae42c4; }
[data-stage="debt"] { --stage-bg: #ffd9db; --stage-ink: #8f212a; --stage-accent: #d7464c; }
[data-stage="completed"] { --stage-bg: #d5f1dc; --stage-ink: #205c34; --stage-accent: #42995b; }
[data-stage="cancelled"] { --stage-bg: #d2eaff; --stage-ink: #174c78; --stage-accent: #358ed4; }
@media (max-width: 880px) {
    .diary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .diary-column-headings { display: none; }
    .diary-job .diary-grid > * { border: 0; }
    .diary-work { grid-column: 1 / -1; }
}

.diary-confirmation { width: min(400px, calc(100% - 28px)); }
.diary-confirmation p { margin: 0; }
.diary-confirmation .diary-delete-warning { margin-top: 5px; color: var(--danger); }

.diary-confirmation.overtime-confirmation { width: min(680px, calc(100% - 16px)); max-width: none; box-sizing: border-box; }
.overtime-confirmation .diary-note-dialog-body { grid-template-columns: minmax(0, 1fr); overflow-wrap: anywhere; }
.overtime-crew { display: grid; gap: .55rem; margin-bottom: .85rem; }
.overtime-crew p { margin: 0 0 .25rem; }
.overtime-crew .inline-check { justify-content: flex-start; }
.overtime-actions { flex-wrap: wrap; }
.overtime-actions > button { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 620px) {
    .overtime-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
    .overtime-actions > button { width: 100%; min-height: 44px; }
}

.job-overview { padding: clamp(14px, 2vw, 24px); }
.job-overview,
#contact-editor:not([action$="?id=0"]) #contact-section--1 {
    background: linear-gradient(115deg, #edf3ff, white 75%);
    border-color: #cbd9fb;
}
.contact-overview-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 14px; }
.contact-overview-heading > h2 { margin: 0; }
.contact-option-badge {
    padding: 3px 7px; border: 1px solid; border-radius: 7px;
    font-size: var(--text-small); font-weight: var(--weight-medium);
}
.contact-billing-status { color: #244580; background: #edf3ff; border-color: #cbd8fb; }
.contact-billing-status[data-billing-enabled="1"] { background: #e0eaff; }
.contact-email-optout-status { color: #684208; background: #fff5dd; border-color: #ebd8a2; }
.contact-email-optout-status[data-email-optout-enabled="1"] { background: #ffebbd; }
.contact-option-pair { display: grid; justify-items: start; gap: 3px; white-space: normal; }
.contact-overview > .field-layout { --layout-gap: 16px; row-gap: 3px; grid-auto-rows: auto; }
.contact-overview > .field-layout > div {
    min-width: 0; padding: 3px 12px; border-inline-start: 1px solid #d4e0f4;
}
.contact-overview dt { font-weight: 700; overflow-wrap: anywhere; }
.contact-overview > .field-layout dt { line-height: 1.25; }
.contact-overview > .field-layout dd { margin-block-start: 2px; }
.contact-overview dd { font-size: 1rem; font-weight: 600; }
.contact-overview .contact-overview-name dd { font-size: clamp(1.25rem, 2vw, 1.75rem); }
.job-overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, .8fr); gap: 20px; }
.job-overview-grid > div + div { border-inline-start: 1px solid #d4e0f4; padding-inline-start: 20px; }
.job-overview-label { display: block; color: var(--muted); font-size: var(--text-small); font-weight: 700; margin-bottom: 5px; }
.job-customer { font-size: clamp(1.25rem, 2vw, 1.75rem); margin-bottom: 8px; overflow-wrap: anywhere; }
.job-overview-phone { font-size: 1.125rem; font-weight: 650; gap: 8px; }
.job-location-address { font-size: 1.125rem; font-weight: 650; margin: 0 0 8px; white-space: pre-line; overflow-wrap: anywhere; }
.job-map-link { display: inline-flex; align-items: center; gap: 5px; }
.job-map-link svg { width: 16px; height: 16px; flex: 0 0 auto; }
.job-appointment { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.job-appointment time, .job-appointment span { font-size: 1.15rem; font-weight: 650; color: var(--ink); }
.job-appointment time.job-appointment-time { font-size: 1.55rem; color: var(--brand-midnight); }
@media (max-width: 900px) {
    .job-overview-grid { grid-template-columns: 1fr; gap: 12px; }
    .job-overview-grid > div + div { padding-inline-start: 0; border-inline-start: 0; border-top: 1px solid #d4e0f4; padding-top: 10px; }
}

.job-finances { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 325px); gap: 16px; align-items: start; }
.job-work-table, .job-payment-summary { border: 1px solid var(--line); border-radius: 10px; }
.job-work-table th { border-top: 0; background: #f4f7fc; }
.job-work-table tr:last-child td { border-bottom: 0; }
.job-work-table th:nth-child(2), .job-work-table td:nth-child(2) { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.job-work-empty { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.job-payment-summary { overflow: hidden; background: #f9fbff; }
.job-payment-summary .job-values { display: block; margin: 0; }
.job-payment-summary .job-values > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 12px; }
.job-payment-summary .job-values > div + div { border-top: 1px solid var(--line); }
.job-payment-summary .job-values dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 650; }
.job-payment-summary .job-values > div:last-child { background: var(--blue-soft); padding-block: 10px; }
.job-payment-summary .job-values > div:last-child dt { font-weight: 700; color: var(--ink); }
.job-payment-summary .job-values > div:last-child dd { font-size: 1.3rem; color: #204696; }
.job-payment-summary .job-record-actions:not(:empty) { padding: 10px 12px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
    .job-finances { grid-template-columns: minmax(0, 1fr); }
    .job-payment-summary { width: min(100%, 325px); justify-self: end; }
}


.job-overview-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; border-top: 1px solid #d4e0f4; padding-top: 10px; margin-top: 16px; }
.job-overview-footer .job-values { flex: 1 1 280px; margin: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
.job-overview-footer .job-record-actions { margin-inline-start: auto; gap: 8px; }
.customer-debt-notice, .invoice-number-notice { padding: 8px 12px; border: 1px solid #edc797; border-radius: 8px; background: #fff1d9; color: #713809; font-weight: 700; }

.job-contact-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 24px; align-items: start; margin-bottom: 8px; }
.job-selected-customer { padding: 4px clamp(16px, 3vw, 48px); text-align: center; overflow-wrap: anywhere; }
#job-contact-selected { margin: 0; color: var(--brand-midnight); font-size: clamp(1.2rem, 2vw, 1.6rem); font-weight: 700; }
#job-contact-address { margin: 2px 0 0; color: var(--muted); white-space: pre-line; }
#job-contact-status { margin: 5px 0; color: var(--muted); }
#job-contact-address:empty, #job-contact-status:empty { display: none; }
.job-selected-customer [data-clear-contact] { margin-top: 6px; }
@media (max-width: 700px) {
    .job-contact-layout { grid-template-columns: minmax(0, 1fr); }
    .job-selected-customer { padding-inline: 12px; }
}
#job-contact-results { list-style: none; margin: 5px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 8px; max-height: 16rem; overflow-y: auto; }
#job-contact-results button { width: 100%; border: 0; text-align: start; overflow-wrap: anywhere; }
#job-contact-results button:focus-visible { outline-offset: -2px; }

.job-details-columns { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(16px, 2vw, 30px); }
.job-booking-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; gap: 10px 14px; padding-inline-start: clamp(16px, 2vw, 30px); border-inline-start: 1px solid var(--line); }
.job-title-editor input { font-size: 1.125rem; font-weight: 700; padding-block: 8px; }
.job-schedule-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.4fr); gap: 10px; margin-top: 10px; }
.job-schedule-editor select, .job-booking-confirmation select { width: 100%; }
.job-booking-extras { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.job-additional-dates { flex: 1 1 12.5rem; min-width: 0; }
.job-duration-editor { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.job-duration-editor input {
    inline-size: calc(3ch + 14px); min-inline-size: 0; padding-inline: 5px;
    text-align: center; appearance: textfield;
}
.job-duration-editor input::-webkit-inner-spin-button,
.job-duration-editor input::-webkit-outer-spin-button { appearance: none; margin: 0; }
#job-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); column-gap: 12px; }
.job-date-row { display: flex; align-items: end; gap: 8px; margin-bottom: 6px; }
.job-date-row label { min-width: 0; width: min(13rem, 100%); }
.job-additional-dates button { padding: 4px 8px; font-size: var(--text-small); }
.job-additional-dates small { margin-inline-start: 6px; }
.job-engineers { border: 0; padding: 0; margin: 0; min-width: 0; }
.job-engineers legend { padding: 0; margin-bottom: 5px; color: var(--muted); font-size: var(--text-small); font-weight: 650; }
.job-engineer-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.job-engineer-choices .check { display: inline-flex; gap: 6px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 16px; background: white; cursor: pointer; }
.job-engineer-choices .check:has(:checked) { border-color: #b8cbf5; background: var(--blue-soft); color: #204696; }
.job-engineer-choices input { margin: 0; flex: 0 0 auto; }
.job-settings-form { display: grid; gap: 12px; margin-bottom: 12px; }
.job-settings-card, .job-settings-card-body, .job-settings-options > * { min-width: 0; }
.job-settings-card h2 { margin: 0; }
.job-settings-card-body { padding: 12px; }
.job-settings-card-body > .muted { margin: 0 0 10px; }
.job-settings-options {
    display: grid; gap: 10px 12px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 185px), 1fr));
    align-items: start;
}
.job-setting-list { padding: 8px; }
.job-setting-rows { display: grid; gap: 5px; }
.job-setting-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; }
.job-setting-row input { min-width: 0; width: 100%; padding: 5px 8px; }
.job-setting-add { width: 100%; padding: 5px 8px; border-style: dashed; color: var(--blue); }
.job-setting-rows:not(:empty) + template + .job-setting-add { margin-top: 6px; }
.job-settings-card-body .check { gap: 6px; overflow-wrap: anywhere; }
.job-settings-card-body .check:has(:disabled) { cursor: default; }
.job-settings-rule {
    display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.job-settings-rule label { min-width: 0; }
.job-settings-rule p { margin: 0 0 5px; }
.job-settings-actions { display: flex; justify-content: flex-end; }
.job-settings-actions:not(:has(button:not([hidden]))) { display: none; }
@media (max-width: 1000px) {
    .job-details-columns { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .job-booking-editor { padding-inline-start: 0; padding-top: 12px; border-inline-start: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 540px) {
    .job-schedule-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .job-schedule-editor > label:last-child { grid-column: 1 / -1; }
    .job-booking-editor { grid-template-columns: minmax(0, 1fr); }
}

.temporal-field { position: relative; display: block; min-width: 0; }
.temporal-field > input { width: 100%; padding-inline-end: 34px; }
.temporal-field > input::-webkit-calendar-picker-indicator { display: none; }
.workday .temporal-field > input { padding-inline-end: 26px; }
.temporal-trigger { position: absolute; inset: 3px 3px 3px auto; display: grid; place-items: center; width: 26px; padding: 0; border: 0; background: transparent; color: var(--blue); }
.workday .temporal-trigger { width: 22px; }
.temporal-trigger::before { content: ""; box-sizing: border-box; width: 14px; height: 13px; border: 1.5px solid currentColor; border-radius: 3px; background: linear-gradient(currentColor, currentColor) 0 3px / 100% 1px no-repeat; }
.temporal-trigger[data-kind="time"]::before { height: 14px; border-radius: 50%; background: linear-gradient(currentColor, currentColor) 50% 2px / 1px 5px no-repeat, linear-gradient(currentColor, currentColor) 65% 55% / 4px 1px no-repeat; }
.temporal-dialog { width: min(355px, calc(100% - 28px)); padding: 0; }
.temporal-dialog > header { display: flex; align-items: center; justify-content: space-between; padding: 10px 13px; background: var(--brand-midnight); color: white; }
.temporal-dialog > header h2 { margin: 0; }
.temporal-close { padding: 2px 8px; color: white; background: transparent; border-color: #ffffff66; }
.temporal-close:hover { background: #ffffff25; }
.temporal-dialog > div { padding: 12px; }
.temporal-month-header { display: grid; grid-template-columns: 34px 1fr 34px; gap: 5px; align-items: center; text-align: center; margin-bottom: 8px; }
.temporal-month-header strong { text-transform: capitalize; }
.temporal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.temporal-days span { color: var(--muted); font-size: var(--text-caption); }
.temporal-days button { padding: 6px 0; border-color: transparent; }
.temporal-days button[data-today] { border-color: #7298ed; }
.temporal-days button[aria-pressed="true"] { color: white; background: var(--blue); border-color: var(--blue); }
.temporal-time { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.temporal-calendar + .temporal-time { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }

.temporal-quarters { display: flex; gap: 6px; grid-column: 1 / -1; }
.temporal-quarters button { flex: 1; padding: 4px 6px; }
.conflict-alternatives { display:grid; gap:8px; margin-top:12px; }
.conflict-alternatives select { width:100%; }
#booking-warning .dialog-actions, #leave-booking-conflict .dialog-actions { flex-wrap:wrap; }
.booking-reasons { margin: 0; padding-inline-start: 20px; }
.booking-reasons li + li { margin-top: 6px; }

.job-line-items-editor { min-width: 0; }
.job-line-items-editor .job-item { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f9fbff; }
.job-line-items-editor .job-item input[name="item_price"] { text-align: end; font-variant-numeric: tabular-nums; }
.job-line-items-editor #add-job-item { color: var(--blue); border-style: dashed; }
.job-payment-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 10px 12px; }
.job-payment-inputs > label:last-child { grid-column: 1 / -1; }
.job-payment-summary .job-editor-totals { border-top: 1px solid var(--line); }
@media (max-width: 950px) {
    .job-finances-editor { grid-template-columns: minmax(0, 1fr); }
    .job-finances-editor .job-payment-summary { width: min(100%, 325px); justify-self: end; }
}

/* Fictional local role preview. */
.role-preview-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; margin-bottom: 12px; border: 1px solid #cbd9fb; border-radius: 9px; background: #edf3ff; color: #204696; }
.role-preview-bar small { display: inline-block; margin-inline-start: 10px; color: var(--muted); }
.role-intro p, .role-card p { margin-block: 4px 10px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.role-grid .role-card { margin: 0; }
.role-card header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; }
.role-card h2 { margin: 0; }
.role-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 5px 10px; margin-block: 10px; }
.role-add { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.role-add label { min-width: min(100%, 225px); }
.role-note { display: grid; gap: 8px; justify-items: start; }
.role-note label { width: min(100%, 640px); }
.role-person { margin: -6px 0 12px; color: var(--muted); }
.user-directory th, .user-directory td { text-align: start; }
.user-directory td a { font-weight: var(--weight-medium); }
.user-directory td.user-directory-action { width: 1%; text-align: end; }
.staff-contact-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-block: 8px 12px; }

.task-list { min-width: 680px; }
.task-list th:nth-child(3), .task-list td:nth-child(3) { white-space: nowrap; }
.task-form .panel { padding: clamp(14px, 2vw, 24px); }
.task-editor-grid { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(0, 1fr)); gap: 12px 18px; align-items: end; }
@media (max-width: 980px) {
    .task-editor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .task-editor-subject { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    .task-editor-grid { grid-template-columns: minmax(0, 1fr); }
}
.task-directory { --task-action-width: 54px; }
.task-action-column, .task-list .task-list-action { width: var(--task-action-width); }
.task-list .task-list-action { padding: 4px 8px 4px 12px; }
.task-directory [data-task-completion-error]:not([hidden]) { margin: 0 12px 8px; }
.task-list th:has(+ .task-list-action) .column-resize { display: none; }
.task-complete-button {
    display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
    border: 1px solid #abd7bd; border-radius: 8px; background: #edf8f1; color: #216446;
}
.task-complete-button:hover, .task-complete-button:focus-visible { background: #d7f0e1; }
.task-complete-button svg { width: 16px; height: 16px; }
.task-reopen-button { border-color: #b6c9f5; background: #eef3ff; color: #2850ad; }
.task-reopen-button:hover, .task-reopen-button:focus-visible { background: #dfeaff; }
.task-overview dd { margin-inline-start: 0; }


fieldset.job-inline-contact { border: 0; padding: 0; min-width: 0; }

/* Tickets uses the shared plain contact and gradient detail panels. */
.ticket-wide { grid-column: 1 / -1; }
.ticket-field-value { white-space: pre-line; overflow-wrap: anywhere; }
.ticket-record-fields dl { gap: 10px; }
.ticket-record-fields dl > div {
    min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
}
.ticket-record-fields dt { font-weight: var(--weight-heading); overflow-wrap: anywhere; }
.ticket-workflow-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; }
.ticket-workflow-controls .check { min-height: 36px; }
.ticket-workflow-controls [hidden] { display: none; }
.ticket-config-step {
    display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 12px;
    border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
}
.ticket-config-step > label { flex: 1 1 180px; }
.ticket-config-step .icon-button, .ticket-step-number { align-self: center; }
.ticket-config-step [data-workflow-handle] { cursor: grab; touch-action: none; }
.ticket-step-number { display: none; }
.ticket-steps-ordered .ticket-step-number {
    position: relative; display: grid; place-items: center; width: 26px; height: 26px;
    border-radius: 50%; background: #e7eeff; color: #2344a0; font-size: 12px; font-weight: 700;
}
.ticket-steps-ordered .ticket-config-step:has(+ .ticket-config-step) .ticket-step-number::after {
    content: "↓"; position: absolute; top: calc(100% + 2px); color: #526b9b;
    font-size: 10px; line-height: 1; pointer-events: none;
}
.ticket-config-add { margin-bottom: 10px; }
form:has(> .ticket-signoff-actions) > label { display: block; width: 100%; }
form:has(> .ticket-signoff-actions) input[name="completion_note"] {
    display: block; width: 100%; max-width: 100%;
}
.ticket-signoff-actions { justify-content: center; margin: 12px 0 0; }
.page-actions button[name="action"][value="reopen"] { background: #fff0c9; color: #704700; border-color: #c58d36; font-weight: 700; }
.page-actions button[name="action"][value="reopen"]:hover { background: #ffe4a5; }

.product-values dd { white-space: pre-wrap; }
.product-description { margin: 12px 0; }
.product-gross-price { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: var(--surface); font-size: var(--text-body); font-weight: 700; }

.company-layout-settings { margin-top: 12px; }
.company-layout-settings > button { margin-top: 8px; }
.task-list + [data-layout-reset], .directory > [data-layout-reset] { margin: 8px 12px; }

.field-api-section { margin-bottom: 12px; }
.field-api-section h2 { margin-bottom: 8px; }
.field-api-section table { table-layout: fixed; }
.field-api-section th:first-child { width: 33.3333%; }
.field-api-section code { user-select: all; }
.field-api-section small { margin-inline-start: 6px; color: var(--muted); }

.sidebar-utilities { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.sidebar-utilities #settings-gear { margin-top: 0; flex: 0 0 auto; }
.sidebar-utility { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: #ffffff0a; border: 1px solid #ffffff20; }
.sidebar-utility svg { width: var(--sidebar-icon-size); height: var(--sidebar-icon-size); }
.sidebar-utility[aria-current="page"] { background: var(--brand-electric); }
.sidebar .sidebar-toggle {
  flex: 0 0 auto; margin-inline-start: auto; color: #c1cde1;
}
.sidebar .sidebar-toggle:hover { color: white; background: #263a60; }
.sidebar .sidebar-toggle[hidden], .sidebar-icon-label[hidden] { display: none; }
.sidebar-icon-label {
  position: fixed; z-index: 30; transform: translateY(-50%); pointer-events: none;
  background: var(--sidebar); color: white; padding: 4px 8px; border-radius: 6px;
  box-shadow: var(--panel-shadow); font-size: var(--text-small);
}
@media (min-width: 701px) {
  body[data-sidebar-collapsed] { --sidebar-width: 56px; }
  body[data-sidebar-collapsed] .sidebar { padding-block-start: 42px; }
  body[data-sidebar-collapsed] .sidebar .brand,
  body[data-sidebar-collapsed] .sidebar-module-label { display: none; }
  body[data-sidebar-collapsed] .sidebar .sidebar-toggle { margin-inline-start: 0; }
  body[data-sidebar-collapsed] .sidebar-toggle-arrow { transform: rotate(180deg); transform-origin: 14.5px 12px; }
  body[data-sidebar-collapsed] .sidebar-module { justify-content: center; padding-inline: 4px; }
  body[data-sidebar-collapsed] .sidebar-utilities { flex-direction: column; align-items: center; }
}
.template-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.template-source { display: grid; align-content: start; gap: 12px; }
.template-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.template-source textarea { display: block; min-height: 320px; font-family: monospace; }
.template-source [role="status"]:empty { display: none; }
.template-sumup-option { display: grid; gap: 4px; justify-items: start; }
.template-sumup-option label { display: inline-flex; gap: 7px; align-items: center; }
.template-sumup-option input[type="checkbox"]:not([role="switch"]) { width: auto; margin: 0; }
.template-details { grid-column: 1 / -1; margin-bottom: 0; }
.template-details [data-custom-sender][hidden] { display: none; }
.template-title-fields { grid-template-columns:repeat(3,minmax(0,1fr)); align-items:start; }
.template-title-fields > *, .template-sender-fields select { min-width:0; }
.template-sender-fields { display:grid; gap:8px; }
.template-description-field { grid-column:1 / -1; }
@media (max-width:640px) {
    .template-title-fields { grid-template-columns:minmax(0,1fr); }
}
.template-preview h2 { margin-bottom: 8px; }
.template-preview iframe { display: block; width: 100%; height: 620px; border: 1px solid var(--line); border-radius: 8px; background: white; }
@media (max-width: 950px) {
    .template-editor { grid-template-columns: minmax(0, 1fr); }
    .sidebar-utilities { flex-wrap: nowrap; }
}
.template-row-action { width: 54px; text-align: end; }
.template-handoff { width: min(780px, calc(100% - 28px)); }
.template-handoff textarea { display: block; width: 100%; margin: 10px 0; resize: vertical; font-family: monospace; }
.template-handoff [role="status"]:empty { display: none; }
.template-field-picker { position: relative; flex: 1 1 220px; min-width: 0; }
.template-field-picker input { width: 100%; }
.template-field-menu {
    position: absolute; inset: calc(100% + 4px) 0 auto; z-index: 5; max-height: min(320px, 45vh);
    overflow: auto; padding: 5px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); box-shadow: 0 8px 24px #16294830;
}
.template-field-group { margin: 0 -5px 4px; padding: 6px 13px; background: var(--blue-soft); color: #284779; font-size: var(--text-small); font-weight: 700; }
.template-field-menu [role="group"] + [role="group"] { margin-top: 5px; }
.template-field-option { padding: 5px 8px; border-radius: 5px; cursor: pointer; overflow-wrap: anywhere; }
.template-field-option:is(:hover, .template-field-active, [aria-selected="true"]) { background: #e7eeff; }
.template-field-menu p { margin: 4px 8px; }

.quote-editor { display: grid; gap: 12px; }
.quote-description { display: block; margin-top: 12px; }
.quote-line { container-type: inline-size; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.quote-line + .quote-line { margin-top: 8px; }
[data-quote-lines]:not(:empty) + .quote-line-actions { margin-top: 10px; }
.quote-line-fields { display: grid; grid-template-columns: minmax(180px, 3fr) repeat(3, minmax(76px, 1fr)) auto; align-items: start; gap: 8px; }
.quote-line-fields .remove-button { margin-top: 20px; }
.quote-line-item { display: grid; gap: 5px; min-width: 0; }
.quote-item-description { margin-top: 3px; color: var(--muted); font-size: var(--text-small); font-weight: 400; }
.quote-line-item textarea { width: 100%; min-width: 0; }
.quote-multiline { white-space: pre-wrap; overflow-wrap: anywhere; }
.quote-record-items { margin-top: 12px; }
.quote-record-items :is(th,td):not(:first-child), .quote-record-items .job-payment-summary dd {
    white-space:nowrap; overflow-wrap:normal; word-break:normal; font-variant-numeric:tabular-nums;
}
.quote-record-items td:first-child { overflow-wrap:anywhere; }
.quote-record-items h2 { margin-bottom: 8px; }
.customer-overview-email { margin-top: 6px; overflow-wrap: anywhere; }
@media (min-width: 901px) {
    .job-overview-grid.overview-two-columns { grid-template-columns: 1fr 1fr; }
}
@container (max-width: 490px) {
    .quote-line-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
}
select[data-sales-stage], select[data-ticket-stage], select[data-stage-colour-select] { background-color: var(--stage-bg); color: var(--stage-ink); font-weight: 600; }
[data-sales-stage-form] { margin-top: 3px; }
.sales-record-status-division { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; }
.sales-record-status-division .sales-record-division { align-self: center; }
.sales-record-division .job-overview-label { margin: 0; }
[data-sales-stage-form] select { max-width: 220px; }
[data-list-stage-form] { display: inline-block; max-width: 100%; margin: 0 0 2px; vertical-align: middle; }
[data-list-stage-form] select { max-width: 100%; font-size: var(--text-small); padding-block: 3px; }
.sales-stage-panel > p { margin: 6px 0 12px; }
.sales-stage-list { display: grid; gap: 8px; }
.sales-stage-option {
    display: grid; grid-template-columns: minmax(140px, 1.3fr) minmax(162px, .95fr) minmax(156px, .85fr) minmax(90px, .7fr) 32px;
    align-items: end; gap: 8px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
}
.sales-stage-new { margin: 12px 0; background: #f5f8fe; }
.remove-sales-stage { align-self: end; justify-self: end; margin-bottom: 4px; }
.sales-stage-preview { align-self: center; display: flex; align-items: center; min-height: 36px; overflow-wrap: anywhere; }
.sales-stage-preview [hidden] { display: none; }
.sales-stage-palette { min-width: 0; border: 0; padding: 0; margin: 0; }
.sales-stage-palette legend { padding: 0; margin-bottom: 4px; }
.sales-stage-palette > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; }
.sales-stage-swatch { position: relative; display: grid; place-items: center; width: 22px; height: 22px; cursor: pointer; }
.sales-stage-swatch input { position: absolute; width: 22px; height: 22px; margin: 0; opacity: 0; cursor: pointer; }
.sales-stage-swatch span { width: 17px; height: 17px; border-radius: 50%; background: var(--stage-accent); pointer-events: none; }
.sales-stage-swatch input:checked + span { outline: 2px solid var(--stage-ink); outline-offset: 2px; }
.sales-stage-swatch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 3px; }
.sales-stage-panel > [data-layout-reset] { margin-top: 10px; }
@media (max-width: 880px) {
    .sales-stage-option { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sales-stage-custom > div { gap: 6px 8px; }
.sales-stage-custom [data-stage-custom] { flex: 0 0 auto; margin: 0; }
.sales-stage-custom input[type="color"] { width: 36px; height: 30px; padding: 2px; cursor: pointer; }
.sales-stage-custom [data-stage-hex] { width: 88px; padding: 4px 6px; font-family: monospace; }

.fixed-stage-name { align-self: center; min-height: 36px; display: flex; align-items: center; font-weight: 600; }
.fixed-stage-option { grid-template-columns: minmax(140px, 1.3fr) minmax(162px, .95fr) minmax(156px, .85fr) minmax(90px, .7fr); }
.sales-stage-panel .sales-stage-list + button { margin-top: 10px; }
.diary-team > header[data-stage] { background: var(--stage-bg); color: var(--stage-ink); border-bottom-color: var(--stage-accent, currentColor); }
.diary-team > header[data-stage] .diary-booked-out-badge { background: var(--stage-bg); color: var(--stage-ink); outline: 1px solid currentColor; }
.diary-booking button[data-stage] { background: var(--stage-bg); color: var(--stage-ink); border-color: var(--stage-accent, currentColor); }
@media (max-width: 880px) {
    .fixed-stage-option { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.workspace-access { max-width: 36rem; margin: 7vh auto; padding: 1rem; }
.workspace-access form, .workspace-access label { display: grid; gap: .5rem; }
.workspace-access form { gap: 1rem; }
.workspace-background { min-height: 100vh; margin: 0; background: linear-gradient(150deg, var(--brand-sky-soft), var(--brand-white) 65%); }
.workspace-access { display: grid; min-height: 100vh; place-items: center; margin: 0 auto; }
.workspace-card { width: 100%; border-top: 5px solid #2773ce; padding: clamp(1.25rem, 4vw, 2.5rem); }
.workspace-card h1 { margin: .55rem 0; }
.workspace-brand { color: #1b5f9f; font-size: 1.2rem; margin-top: 0; }
.workspace-card form { margin: 1.25rem 0; }
.workspace-notice { background: #edf6ff; border-radius: .5rem; padding: .75rem; }
.workspace-access .workspace-remember { display: flex; align-items: center; gap: .6rem; width: fit-content; cursor: pointer; }
.workspace-remember input[type="checkbox"] { width: 1rem; height: 1rem; min-height: 0; padding: 0; margin: 0; accent-color: var(--blue); }
.workspace-remember input:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.workspace-remember-note { color: var(--muted); font-size: .84rem; margin: -.62rem 0 0 1.6rem; }

.workspace-account-links { display: flex; flex-wrap: wrap; gap: .55rem; margin-bottom: 0; }
.workspace-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin: .75rem 0; }

.password-rules { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; font-size: .9rem; }
.password-rules li { display: flex; gap: .6rem; align-items: baseline; color: #982a2a; }
.password-rules li[data-met="true"] { color: #146237; }
.password-rule-symbol { display: inline-block; width: 1rem; font-weight: bold; text-align: center; }
.password-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.ticket-filter-button, .manage-columns { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; }
.ticket-filter-button svg, .manage-columns svg { width: 19px; height: 19px; }
.ticket-filter-button.is-active { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.ticket-filter-dialog { width: min(680px, calc(100% - 28px)); }
.ticket-filter-dialog[open] { display: flex; flex-direction: column; }
.ticket-filter-dialog > :not(.ticket-filter-body) { flex: none; }
.ticket-filter-body { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; padding: 3px; margin: -3px; }
.ticket-filter-dialog > .ticket-filter-switch { align-self: flex-start; }
@media (max-height: 520px) {
    .ticket-filter-dialog { padding: 12px; }
    .ticket-filter-dialog > h2 { margin-block: 0 8px; }
    .ticket-filter-dialog > .ticket-filter-switch { margin-bottom: 10px; }
}
.list-column-picker { width: min(600px, calc(100% - 28px)); }
.list-column-picker > p { margin: -4px 0 14px; }
.list-column-groups { display: grid; gap: 8px; }
.list-column-picker .column-group { margin: 0; border-radius: 10px; background: var(--surface); }
.list-column-picker .column-group > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-radius: 10px; background: var(--canvas); font-weight: var(--weight-medium);
    list-style: none;
}
.list-column-picker .column-group > summary::-webkit-details-marker { display: none; }
.list-column-picker .column-group > summary::after {
    content: ""; width: 7px; height: 7px; margin: 0 4px 3px; border: solid currentColor;
    border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.list-column-picker .column-group[open] > summary { border-radius: 10px 10px 0 0; }
.list-column-picker .column-group[open] > summary::after { transform: rotate(225deg); margin-block: 3px 0; }
.list-column-picker .column-group .grid { gap: 8px; }
.list-column-picker label.check {
    min-width: 0; min-height: 36px; padding: 6px 9px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface); overflow-wrap: anywhere;
}
.list-column-picker label.check:has(:checked) { background: var(--blue-soft); border-color: #cbd8fb; }
.list-column-picker label.check:has(:disabled) { cursor: default; }
.list-column-picker .dialog-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

[data-clear-ticket-list] { min-height: 36px; }
.ticket-filter-switch {
    display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px;
    border-radius: 10px; background: var(--canvas);
}
.ticket-filter-switch button { border-color: transparent; background: transparent; }
.ticket-filter-switch button[aria-pressed="true"] {
    background: var(--surface); color: var(--blue); box-shadow: 0 1px 4px #17213816;
}
.ticket-filter-dialog [hidden] { display: none; }
.ticket-saved-filter-picker > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none;
}
.ticket-saved-filter-picker > summary::-webkit-details-marker { display: none; }
.ticket-saved-filter-picker > summary::after {
    content: ""; width: 7px; height: 7px; margin: 0 3px 3px;
    border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.ticket-saved-filter-picker[open] > summary::after { transform: rotate(225deg); margin-block: 3px 0; }
.ticket-saved-filter-picker > div {
    display: grid; gap: 3px; padding: 5px; margin-top: 6px;
    border: 1px solid var(--line); border-radius: 8px;
}
.ticket-saved-filter-picker p { margin: 6px; }
.ticket-saved-filter-entry { display: flex; align-items: center; gap: 8px; padding-inline-end: 4px; }
.ticket-saved-filter-entry > [data-apply-saved-filter] {
    flex: 1; min-width: 0; text-align: start; overflow-wrap: anywhere;
}
.ticket-filter-row {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 8px; align-items: end; padding: 0 0 12px;
}
.ticket-filter-row + .ticket-filter-row { padding-top: 10px; border-top: 1px solid var(--line); }
.ticket-filter-join { grid-column: 1 / -1; }
.ticket-filter-join select { width: auto; color: var(--blue); background-color: var(--blue-soft); }
.ticket-filter-row .remove-ticket-condition { grid-column: -2; margin-bottom: 5px; }
.ticket-filter-condition-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-filter-footer {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.ticket-filter-footer-save { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-filter-footer .dialog-actions { margin-inline-start: auto; padding: 0; }
@media (max-width: 560px) {
    .ticket-filter-row { grid-template-columns: minmax(0, 1fr) auto; }
    .ticket-filter-row label { grid-column: 1; }
}

.automation-fields { min-width: 0; }
.automation-fields[hidden], [data-automation-address][hidden] { display: none; }
.automation-fields > p { margin: 0 0 12px; }
.automation-fields > label { max-width: 360px; }
.automation-fields > .muted { margin: 10px 0 0; }

/* Workflow rule builder */
.automation-builder { display: grid; gap: 12px; }
.automation-builder > .panel { margin: 0; display: grid; gap: 12px; }
.automation-builder > .panel:nth-of-type(n+3) { position: relative; margin-top: 20px; }
.automation-builder > .panel:nth-of-type(n+3)::before {
  content: ""; position: absolute; top: -25px; left: calc(50% - 9px);
  width: 18px; height: 18px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235374a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3.5v12m-4-4 4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.automation-builder .panel h2, .automation-builder .panel p { margin: 0; }
.automation-builder [hidden] { display: none !important; }
.automation-builder [data-duration], .automation-builder [data-builder-email] { display: grid; gap: 10px; }
.automation-builder [data-duration] > label,
.automation-builder [data-builder-stage] > label { max-width: 360px; }
.automation-builder [data-builder-add] { justify-self: start; }
.automation-builder [data-builder-conditions] { display: grid; gap: 8px; }
.automation-builder [data-builder-conditions]:empty { display: none; }
.automation-condition {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) auto;
  align-items: end; gap: 10px; border-radius: 8px; padding: 10px; background: var(--canvas, #f6f8fb);
}
.automation-condition select, .automation-condition input { width: 100%; min-width: 0; }
.automation-condition .automation-remove { grid-column: 4; min-width: 36px; font-size: 1.25rem; }

.automation-builder [data-condition-controls] { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 10px; }
.automation-builder [data-criteria-pattern] { max-width: 360px; }
.automation-condition[data-condition-number]::before {
  content: attr(data-condition-number); grid-row: 1; grid-column: 1 / -1;
  color: var(--muted); font-weight: 600; font-size: .8em;
}

.automation-builder .automation-trigger-width { width: min(100%, 360px); }
.automation-builder .automation-date-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.automation-builder [data-date-trigger] { display: grid; gap: 8px; }
.automation-builder .automation-date-pair :is(select, input) { min-width: 0; }

.automation-builder [data-builder-conditions] { gap: 38px; }
.automation-condition { position: relative; }
.automation-condition [data-criteria-join] {
  position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  min-width: 52px; min-height: 26px; padding: 2px 8px; border-radius: 20px;
}

/* Desktop automation flow, staggered to keep Conditions and Action roomy. */
@media (min-width: 1040px) {
  .automation-builder {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 34px 0;
    align-items: start;
  }
  .automation-builder > .panel:nth-of-type(1) { grid-column: 1 / -1; grid-row: 1; }
  .automation-builder > .panel:nth-of-type(2) {
    grid-column: 1 / 5; grid-row: 2;
    width: calc(100% + 12px); gap: 10px;
  }
  .automation-builder > .panel:nth-of-type(3) {
    grid-column: 3 / -1; grid-row: 3; margin-top: 8px;
  }
  .automation-builder > .panel:nth-of-type(4) {
    grid-column: 1 / 11; grid-row: 4; margin-top: 22px;
  }
  .automation-builder > .panel:nth-of-type(3)::before,
  .automation-builder > .panel:nth-of-type(4)::before {
    background-size: 100% 100%;
  }
  .automation-builder > .panel:nth-of-type(3)::before {
    left: calc(20% + 18px); top: -96px;
    width: clamp(145px, 23%, 230px); height: 91px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 210 91' preserveAspectRatio='none' fill='none' stroke='%235374a6' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath vector-effect='non-scaling-stroke' d='M6 24 H145 Q188 24 188 61 V82'/%3E%3C/svg%3E");
  }
  .automation-builder > .panel:nth-of-type(4)::before {
    left: auto; right: calc(18px - 20%); top: -52px;
    width: calc(20% - 26px); height: 130px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 130' preserveAspectRatio='none' fill='none' stroke='%235374a6' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath vector-effect='non-scaling-stroke' d='M142 6 V73 Q142 106 109 106 H7'/%3E%3C/svg%3E");
  }
}
@media (min-width: 1040px) {
  /* One pixel-sized chevron for both arrows, independent of the stretched shafts. */
  .automation-builder > .panel:nth-of-type(3)::after,
  .automation-builder > .panel:nth-of-type(4)::after {
    content: ""; position: absolute; width: 36px; height: 24px; pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 24' fill='none' stroke='%235374a6' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4 L18 20 L32 4'/%3E%3C/svg%3E") center / 36px 24px no-repeat;
  }
  .automation-builder > .panel:nth-of-type(3)::after {
    left: calc(20% + 18px + clamp(129.81px, 20.59%, 205.90px));
    top: -14px; transform: translate(-50%, -20px);
  }
  .automation-builder > .panel:nth-of-type(4)::after {
    left: calc(100.933333% + 14.786667px);
    top: 54px; transform: translate(-50%, -50%) rotate(90deg);
  }
}
@media (min-width: 1040px) and (prefers-reduced-motion: no-preference) {
  .automation-builder > .panel:nth-of-type(3)::before { animation: automation-curve-in 320ms ease-out both; }
  .automation-builder > .panel:nth-of-type(4)::before { animation: automation-curve-back 320ms 100ms ease-out both; }
  @keyframes automation-curve-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
  @keyframes automation-curve-back { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
}

/* Trigger controls use the full inside width of their own card. */
.automation-builder > .panel:nth-of-type(2) .automation-trigger-width { width: 100%; max-width: none; }

.automation-builder > .panel:nth-of-type(3) .automation-trigger-width { width: 100%; max-width: none; }
.automation-trigger-hints { display: grid; }
.automation-trigger-hints > p { grid-area: 1 / 1; visibility: hidden; }
.automation-trigger-hints[data-trigger-hints="time_in_stage"] [data-trigger-stage-hint],
.automation-trigger-hints[data-trigger-hints="record_action"] [data-trigger-record-hint],
.automation-trigger-hints[data-trigger-hints="date_field"] [data-trigger-date-hint] { visibility: visible; }

.automation-builder .automation-date-pair:has([data-stage-selector]:not([hidden])) {
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(59px, .55fr);
  align-items: end;
  gap: 7px;
}
.automation-builder .automation-date-pair:has([data-stage-selector]:not([hidden])) select {
  padding-inline-start: 7px;
  padding-inline-end: 24px;
  height: 35px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.automation-list-delete-column { width: 52px; }
.directory .automation-list-delete { padding-inline: 6px 10px; text-align: right; white-space: nowrap; }
.directory .automation-list-delete .remove-button { vertical-align: middle; }

.template-settings-directory { width: 100%; max-width: none; }
.template-settings-directory > [role="status"] { margin: 12px 14px; }
.template-settings-directory .template-description-column { width: 50%; }
.template-settings-directory .template-restore-column { width: 180px; }

.template-handoff-trigger { white-space: nowrap; min-height: 35px; }
.template-default-choice { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.template-default-choice select { flex: 1 1 170px; min-width: 0; }

/* Keep template view tabs immediately above the content, below the workspace header. */
.settings-template-toolbar { margin-bottom: 12px; }
.settings-template-toolbar > .settings-subtabs { min-width: 0; margin-block: 0; }

.related-sales-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.recurring-invoice-schedules {
  margin: 10px 0;
  padding: 8px 0;
  border-block: 1px solid var(--line);
}
.recurring-invoice-schedules h3 { margin: 0 0 6px; }
.recurring-invoice-schedules :is(th, td) { padding-block: 4px; }
.recurring-row-actions { display: flex; align-items: center; gap: 4px; }
.recurring-edit:hover, .recurring-edit:focus-visible { background: var(--line); }
.recurring-invoice-enabled { margin-top: 12px; }
.quote-editor [data-recurring-monthly][hidden],
.quote-editor [data-recurring-interval][hidden] { display: none; }

.recurring-customer-card {
  padding: 6px;
  background: #f5f8ff;
}
.recurring-customer-card .job-error { margin: 8px 12px 0; }
.recurring-customer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
}
.recurring-customer-link:hover { background: var(--blue-soft); text-decoration: none; }
.recurring-customer-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.recurring-customer-link .avatar {
  width: 38px;
  height: 38px;
  border: 1px solid #cfdcfa;
  border-radius: 10px;
  background: linear-gradient(145deg, #dfe8ff, #eef2ff);
  font-size: var(--text-section);
}
.recurring-customer-identity { min-width: 0; flex: 1 1 auto; }
.recurring-customer-identity h2 {
  margin: 0 0 2px;
  font-size: var(--text-caption);
  color: var(--muted);
}
.recurring-customer-name {
  color: var(--ink);
  font-size: var(--text-section);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.recurring-customer-visit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-caption);
  font-weight: 650;
}
.recurring-customer-visit svg { flex: 0 0 16px; width: 16px; height: 16px; }

.ticket-editor-status { display: grid; justify-items: start; align-content: start; gap: 4px; }

.recurring-inline-fields:not([hidden]) { display: contents; }
.recurring-inline-help { grid-column: 1 / -1; }
.recurring-inline-help .recurring-invoice-enabled { margin-top: 0; }
.recurring-inline-help p:last-child { margin-bottom: 0; }
.quote-editor [data-invoice-stage][hidden], .recurring-inline-fields[hidden] { display: none; }
[data-make-recurring][aria-expanded="true"] { background: var(--blue-soft); color: var(--blue); }

.sales-history-summary { margin: 0 0 14px; }
.sales-history-summary > div { padding: 8px 10px; border-radius: 8px; background: var(--canvas); }
.sales-history-summary dt { font-size: var(--text-small); color: var(--muted); }
.sales-history-summary dd { margin: 3px 0 0; }

tr[data-record-row] { cursor: pointer; }
tr[data-record-row] a:not(.button):not(.icon-button):hover {
  color: var(--blue);
  text-decoration: none;
}

.customer-name-link { color: var(--ink); }
.customer-name-link:hover, .customer-name-link:focus-visible,
.recurring-customer-link:hover .recurring-customer-name,
.recurring-customer-link:focus-visible .recurring-customer-name {
  color: var(--blue);
  text-decoration: none;
}

.quote-validity-deposit {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.quote-validity-deposit > section + section {
    border-inline-start: 1px solid var(--line);
    padding-inline-start: 20px;
}
@media (max-width: 700px) {
    .quote-validity-deposit { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .quote-validity-deposit > section + section {
        border-inline-start: 0;
        padding-inline-start: 0;
        border-block-start: 1px solid var(--line);
        padding-block-start: 14px;
    }
}
.quote-validity-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.quote-validity-form input { width: 7rem; }
.sales-number-preview {
  display: flex;
  align-items: baseline;
  gap: 8px 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--blue-soft);
}
.sales-number-preview output {
  font-weight: var(--weight-heading);
  overflow-wrap: anywhere;
}

.contact-billing-document-settings {
    margin-block: 12px; padding: 12px;
    border: 1px solid var(--line); border-radius: 12px;
}
.contact-billing-document-settings h3,
.contact-billing-document-settings p { margin: 0 0 6px; }
.contact-billing-document-controls, .contact-billing-document-options {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.contact-billing-document-controls { justify-content: space-between; }
.contact-billing-document-options .check { gap: 6px; cursor: pointer; }
.contact-email-options { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
#contact-editor .billing-opt-in { gap: 6px; }
#contact-editor .billing-opt-in input { margin: 0; }
.contact-billing-fallback { margin-top: 6px; }
.contact-billing-panel fieldset { border: 0; padding: 0; }
.contact-billing-panel[hidden],
#contact-editor:not(:has([name="billing_enabled"]:checked)) [data-contact-billing-panel] { display: none; }
@media (min-width: 850px) {
    .contact-billing-panel > .grid { grid-template-columns: minmax(0, 1fr) minmax(0, .7fr) minmax(0, 1.6fr); align-items: start; }
}
@media (max-width: 849px) {
    .contact-billing-panel .billing-address-input { grid-column: 1 / -1; }
}

.contact-duplicate-card { padding-block: 10px; }
.contact-duplicate-card > .toolbar { align-items: center; margin: 0; }
.contact-duplicate-results-heading { align-items: center; margin-bottom: 12px; }
#duplicate-match-results thead th:last-child { width: 1%; }
.contact-duplicate-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; }
.contact-duplicate-row-actions > :is(a, button) { white-space: nowrap; }
:is(.contact-duplicate-card, .contact-duplicate-results-heading) h2 { margin: 0 0 4px; }
:is(.contact-duplicate-card, .contact-duplicate-results-heading) p { margin: 0; }
.contact-duplicate-review-heading { align-items: flex-start; margin-bottom: 10px; }
.contact-duplicate-review-heading h2, .contact-duplicate-review-heading p { margin: 0 0 4px; }
.transfer-export-actions { justify-content: flex-start; }
.transfer-export-actions > select { min-inline-size: min(150px, 100%); }
.data-transfer-preview { overflow-x: auto; margin-bottom: 10px; }
.data-transfer-preview table { width: 100%; }
[data-transfer-issues]:focus, [data-transfer-mapping-step]:focus,
[data-transfer-confirm]:focus { outline: none; }
.transfer-step > summary { font-size: var(--text-section); line-height: 1.3; }
.transfer-step[open] > summary { margin-bottom: 10px; }
.transfer-import-order { font-size: .9rem; margin-block: 10px 14px; }
.transfer-import-order p, .transfer-import-order ol { margin-block: 0 5px; }
.transfer-import-order ol { padding-inline-start: 1.4em; }
[data-transfer-confirm] > :is(h3, p[role="status"]) {
  max-inline-size: 46rem;
  margin-inline: auto;
  text-align: start;
  overflow-wrap: anywhere;
}
.transfer-step[hidden], [data-transfer-reuse-help][hidden] { display: none; }
.transfer-draft-list { list-style: none; margin: 0; padding: 0; }
.transfer-draft-list > li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-block: 7px; }
.transfer-draft-list > li + li { border-top: 1px solid var(--line); }
.transfer-draft-list .toolbar { margin: 0; }
.transfer-draft-list small { color: var(--muted); }
.transfer-draft-sticky {
  position: sticky; inset-block-end: max(12px, env(safe-area-inset-bottom)); z-index: 3;
  display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end;
  width: max-content; max-width: 100%; margin: 0 12px 10px auto;
  padding: 4px; border-radius: 10px; background: var(--surface); box-shadow: var(--panel-shadow);
}
.transfer-issue-complete, [data-transfer-issue-filter]:has(option.transfer-issue-complete:checked) { color: #17653a; font-weight: var(--weight-medium); }
/* Keep bulk actions together at the standard toolbar gap, like the draft actions. */
[data-transfer-issue-controls] { justify-content: flex-end; }
[data-transfer-issue-controls] > label { margin-inline-end: auto; }
[data-transfer-clear-shown][hidden] { display: none; }
@media (max-width: 680px) {
  .transfer-draft-sticky { inset-block-end: max(8px, env(safe-area-inset-bottom)); margin-inline-end: 4px; }
}
/* Issue rows grow with the page; the shared table wrapper still handles horizontal overflow. */
.transfer-issue-results thead { position: sticky; top: 0; z-index: 1; }
.transfer-issue-results td small { display: block; }
.transfer-duplicate-layout table { table-layout: fixed; min-width: 760px; }
.transfer-issue-number { width: 3.25rem; }
.transfer-duplicate-layout th:first-child, .transfer-duplicate-layout td:first-child {
  padding-inline: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.transfer-issue-record { width: 24%; }
.transfer-issue-result { width: 27%; }
.transfer-issue-action { width: 23%; }
.transfer-duplicate-layout td { vertical-align: top; overflow-wrap: anywhere; }
.transfer-issue-results tr[data-transfer-issue-group]:has(details[open]) { background: #f8faff; }
.transfer-duplicate-matches { margin-top: 4px; }
.transfer-new-match-note { margin-top: 4px; }
.transfer-duplicate-layout tr:not(:has([data-transfer-duplicate-values][open])) .transfer-duplicate-matches dl { display: none; }
.transfer-duplicate-matches > [data-transfer-merge-match] + [data-transfer-merge-match] { margin-top: 10px; }
.transfer-merge-value { display: flex; align-items: baseline; gap: 5px; }
.transfer-merge-value > input { flex: none; width: auto; margin: 0; }
.transfer-merge-value > input[hidden], [data-transfer-merge-field][hidden], [data-transfer-merge-match][hidden],
[data-transfer-optout-review][hidden], .transfer-issue-results [data-transfer-resolution-help][hidden] { display: none; }
[data-transfer-duplicate-action] > select { width: 100%; min-width: 0; }
.transfer-issue-results [data-transfer-resolution-help]:not([hidden]) { margin-top: 4px; }
:is([data-transfer-email-action], [data-transfer-value-action]) { display: flex; align-items: center; gap: 6px; }
:is([data-transfer-email-action], [data-transfer-value-action]) > input { flex: 1 1 0; min-width: 0; width: 0; }
:is([data-transfer-email-action], [data-transfer-value-action]) > .check { flex: none; align-items: center; margin: 0; line-height: 1.1; }
[data-transfer-email-action] > .check span { text-align: center; white-space: nowrap; }
.data-transfer-preview details { margin-top: 4px; }
.data-transfer-preview dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; margin: 6px 0 0; }
.data-transfer-preview dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
[data-transfer-upload] > button { margin-block-start: 10px; }
[data-transfer-mapping] .toolbar { margin-block: 10px; }
.transfer-mapping-toolbar:not([hidden]) {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px;
    margin-block: 10px;
}
.transfer-mapping-filters {
    display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px;
    border: 1px solid var(--line); border-radius: 12px;
}
.transfer-mapping-filters button { border: 0; background: transparent; padding: 6px 10px; }
.transfer-mapping-filters button[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }
.transfer-mapping-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.transfer-mapping-table { table-layout: fixed; min-width: 555px; }
.transfer-mapping-table thead th:nth-child(2) { width: 30%; }
.transfer-mapping-table thead th:nth-child(3) { width: 20%; }
.transfer-mapping-table tbody th { background: var(--surface); white-space: normal; font-size: var(--text-body); }
.transfer-mapping-table tbody tr:nth-child(even) :is(th,td) { background: #f9fbff; }
.transfer-mapping-table tbody tr[data-transfer-mapping-error] > :is(th, td) {
    background: #fff1f1; border-bottom-color: #eab9ba;
}
.transfer-mapping-table tr[data-transfer-mapping-error] > th { box-shadow: inset 4px 0 #bd2634; }
.transfer-mapping-table [aria-invalid="true"] { border-color: #bd2634; }
.transfer-mapping-message:not([hidden]) { display: block; margin-top: 6px; color: #8d1725; line-height: 1.35; }
.transfer-mapping-table select { width: 100%; max-width: 26rem; min-width: 0; }

[data-cleanup-phone][hidden] { display: none; }
/* Let the three columns share the width equally, regardless of their content. */
.cleanup-comparison { border: 1px solid var(--line); border-radius: 8px; }
.cleanup-comparison table { table-layout: fixed; }
.cleanup-comparison :is(th, td) { vertical-align: top; white-space: normal; }
.cleanup-comparison tr > :not(:first-child) { border-inline-start: 1px solid var(--line); }
.cleanup-comparison tbody th { background: var(--surface); font-size: var(--text-body); }
.cleanup-comparison tbody th a { display: inline; }
.cleanup-comparison tbody .cleanup-value { white-space: pre-wrap; }
.cleanup-comparison .cleanup-before { background: #f7f9fc; }
.cleanup-comparison .cleanup-after { background: var(--blue-soft); }
.cleanup-comparison tbody tr:last-child > * { border-bottom: 0; }
.cleanup-preview-actions, .cleanup-preview-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cleanup-preview-actions > button { margin-inline-start: auto; }

.transfer-field-preview { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: middle; }
.transfer-mapping-table select[hidden] { display: none; }
.transfer-field-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    text-align: start; width: 100%; max-width: 26rem; min-height: 34px;
}
.transfer-field-trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-field-trigger::after {
    content: ""; flex: 0 0 6px; height: 6px; margin-inline: 4px;
    border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.transfer-field-picker[hidden] { display: none; }
.transfer-field-picker {
    position: fixed; z-index: 25; padding: 6px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); box-shadow: 0 8px 22px #182b4c26; box-sizing: border-box;
}
.transfer-field-picker input { width: 100%; }
.transfer-picker-rename:not([hidden]) { display: flex; gap: 6px; align-items: center; margin-block: 6px; }
.transfer-picker-rename input { min-width: 0; }
.transfer-picker-rename button { flex: none; white-space: nowrap; }
.transfer-source-picker { display: block; position: relative; min-width: 0; }
.transfer-source-picker > input { width: 100%; padding-inline-end: 28px; }
.transfer-source-picker::after {
    content: ""; pointer-events: none; position: absolute; inset-inline-end: 13px; inset-block-start: 12px;
    width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.transfer-source-picker > .transfer-field-choices:not([hidden]) {
    display: block; position: absolute; z-index: 25; inset-inline: 0; inset-block-start: 100%;
    max-height: 12rem; padding: 4px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); box-shadow: 0 8px 22px #182b4c26;
}
.transfer-source-picker [role="option"] { display: block; }
.transfer-field-choices { overflow-y: auto; margin-top: 4px; position: relative; }
.transfer-field-choices [role="option"] {
    padding: 6px 8px; cursor: pointer; border-radius: 5px; overflow-wrap: anywhere;
}
.transfer-field-choices [role="option"]:is([data-active],:hover) { background: var(--blue-soft); }
.transfer-field-choices [role="option"][aria-selected="true"] { font-weight: var(--weight-medium); }

.mass-delete-preview-header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 16px; margin-bottom: 12px; }
.mass-delete-preview-header p:last-child { margin-bottom: 0; }
.mass-delete-review { margin-inline-start: auto; }
.mass-delete-confirm { width: min(425px, calc(100% - 28px)); }
.mass-delete-confirm .dialog-actions { flex-wrap: wrap; gap: 8px; }
.mass-delete-confirm .dialog-actions .check { flex-basis: 100%; }

[data-numbering-ack], label.check:has([name="invoice_delete_ack"]) { gap: 6px; }
[data-numbering-ack][hidden] { display: none; }

.mass-delete-confirm [hidden] { display: none; }
.mass-delete-confirm ul { margin: 8px 0 12px; padding-inline-start: 22px; }

.mass-delete-confirm:has([data-mass-delete-kept]:not([hidden])) { width: min(720px, calc(100% - 28px)); }
.mass-delete-kept-groups { display: grid; gap: 8px; max-height: min(55vh, 440px); overflow: auto; padding: 2px 4px 2px 2px; }
.mass-delete-reason { border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.mass-delete-reason summary { cursor: pointer; padding: 9px 0; font-weight: var(--weight-medium); }
.mass-delete-reason > p { margin: 0 0 8px; }
.mass-delete-confirm .mass-delete-kept-list { list-style: none; padding: 0; margin: 0 0 8px; }
.mass-delete-kept-list li { display: grid; gap: 2px; padding: 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.mass-delete-linked { font-size: .9em; }

.mass-delete-kept-record { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }

/* Global search fills the centre cell of the shared workspace header. */
.global-search { position: relative; width: 100%; min-width: 0; margin: 0; }
.global-search-control {
    display: flex; align-items: center; min-height: 37px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); overflow: hidden;
}
.global-search-control:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #416adc2b; }
.global-search-control button {
    display: grid; place-items: center; flex: 0 0 40px; padding: 6px; border: 0; border-radius: 0;
    color: var(--muted); background: transparent;
}
.global-search-control button svg { width: 21px; height: 21px; }
.global-search-control input { flex: 1 1 auto; min-width: 0; width: auto; margin: 0; border: 0; padding: 7px 10px 7px 0; line-height: 1.3; background: transparent; }
.global-search-control input:focus { outline: none; box-shadow: none; }
.global-search-matches {
    position: absolute; inset: calc(100% + 6px) 0 auto;
    border-radius: 13px; border: 1px solid var(--line); overflow: hidden;
    background: var(--surface); box-shadow: 0 12px 32px #16294830;
}
.global-search-preview-groups {
    display: grid; gap: 8px; max-height: min(52vh, 420px); overflow: auto;
    padding: 8px; background: #f4f7fd; overscroll-behavior: contain;
}
.global-search-group {
    min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    scroll-margin-top: calc(var(--workspace-topbar-height) + 12px);
}
.global-search-group-heading {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0;
    padding: 9px 12px; border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--line);
    background: #ecf2fd; color: #27446f;
}
.global-search-matches .global-search-group-heading { font-size: var(--text-small); padding: 6px 9px; }
.global-search-count {
    display: inline-grid; place-items: center; min-width: 22px; padding: 2px 6px;
    border-radius: 999px; color: #244777; background: #dbe7fa;
    font-size: var(--text-small); font-weight: 700; font-variant-numeric: tabular-nums;
}
.global-search-group ul { padding: 0; margin: 0; list-style: none; }
.global-search-group li + li { border-top: 1px solid #edf1f8; }
.global-search-group li a {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 13px; color: var(--ink); font-weight: var(--weight-medium); overflow-wrap: anywhere;
}
.global-search-matches li a { padding: 6px 9px; }
.global-search-group li:last-child > a { border-radius: 0 0 9px 9px; }
.global-search-group li a::after {
    content: ""; flex: none; width: 6px; height: 6px; margin-inline-end: 3px;
    border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); opacity: .55;
}
.global-search-group li a:is(:hover, :focus-visible) {
    color: var(--blue); background: #f2f6ff; text-decoration: none; outline-offset: -2px;
}
.global-search-preview-footer { padding: 8px; border-top: 1px solid var(--line); }
.global-search-all { width: 100%; color: var(--blue); }
.global-search-preview-empty { margin: 0; padding: 12px; color: var(--muted); }
.global-search-announcement { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.global-search-results { display: grid; gap: 13px; }
.global-search-result-text { display: grid; min-width: 0; gap: 2px; }
.global-search-result-title { font-weight: 700; }
.global-search-matched-fields { display: flex; flex-wrap: wrap; gap: 3px 14px; }
.global-search-match { min-width: 0; color: var(--muted); font-size: var(--text-small); font-weight: 400; overflow-wrap: anywhere; }
.global-search-match strong { font-weight: 650; }
.global-search-match mark { padding: 0 1px; border-radius: 3px; color: #204074; background: #e3edff; font-weight: 700; }
.global-search-summary, .global-search-empty {
    padding: clamp(13px, 2vw, 22px); border: 1px solid #cfddf6; border-radius: 12px;
    background: linear-gradient(108deg, #eaf2ff, var(--surface) 88%);
}
.global-search-summary p {
    margin: 0 0 4px; color: #2e5084; font-size: var(--text-small); font-weight: 700;
}
.global-search-summary h2 { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); overflow-wrap: anywhere; }
.global-search-empty h2 { margin: 0; }
.global-search-empty p { margin: 5px 0 0; color: var(--muted); }
.global-search-jumps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.global-search-jumps a {
    display: inline-flex; align-items: center; gap: 7px; padding: 3px 4px 3px 9px;
    border: 1px solid #d5e2f8; border-radius: 999px; color: #244777; background: var(--surface);
}
.global-search-jumps a:is(:hover, :focus-visible) { color: var(--blue); background: #f2f6ff; }
.global-search-group-note { padding: 8px 13px; margin: 0; color: var(--muted); border-top: 1px solid var(--line); }
main:has(> [data-workspace-topbar]) .contact-tabs { top: var(--workspace-topbar-height); }
main:has(> [data-workspace-topbar]) .record-anchor { scroll-margin-top: calc(var(--workspace-topbar-height) + 62px); }

/* View tabs share the title cell instead of pushing the module content down. */
.page-heading .page-title:has(> .module-tabs) { gap: 7px; }
.page-heading .page-title:has(> .module-tabs) h1 {
    display: block; white-space: nowrap; text-overflow: ellipsis;
    font-size: clamp(1rem, 1.65vw, var(--text-page));
}
.page-heading .module-tabs {
    flex: 0 1 auto; min-width: 0; max-width: 72%; margin: 0; padding: 2px; gap: 1px;
    border-radius: 8px; scrollbar-width: thin; align-items: center;
}
/* Size each Jobs title slot against the same translated headings, not the current title. */
.page-heading .page-title-text[data-diary-title] { display: grid; flex: none; }
.page-heading .page-title-text[data-diary-title] h1,
.page-heading .page-title-text[data-diary-title]::before,
.page-heading .page-title-text[data-diary-title]::after {
    grid-area: 1 / 1; white-space: nowrap; font-size: clamp(1rem, 1.65vw, var(--text-page));
    font-weight: var(--weight-heading); letter-spacing: -.045em; line-height: 1.15;
}
.page-heading .page-title-text[data-diary-title]::before { content: attr(data-diary-title); visibility: hidden; }
.page-heading .page-title-text[data-diary-title]::after { content: attr(data-unscheduled-title); visibility: hidden; }
.page-heading [data-jobs-view-tabs] { max-width: none; }
.page-heading .module-tabs a {
    display: inline-flex; align-items: center; min-height: 30px; padding: 4px 8px;
    font-size: 0.8125rem; line-height: 1.15; white-space: nowrap; border-radius: 5px;
}
@media (min-width: 701px) {
    .page-heading:has([data-jobs-view-tabs]) {
        grid-template-columns: minmax(max-content, 1fr) minmax(125px, min(23%, 400px)) minmax(0, 1fr);
    }
}
@media (max-width: 700px) {
    .page-heading:has([data-jobs-view-tabs]) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "title title" "search actions";
    }
    .page-heading:has([data-jobs-view-tabs]):not(:has(> .page-actions)) {
        grid-template-areas: "title title" "search search";
    }
}

@media (max-width: 700px) {
    .page-heading .page-title-text:has(> .breadcrumb) { display: grid; gap: 0; }
}
@media (min-width: 701px) {
    .global-search-matches {
        inset-inline: 50% auto; transform: translateX(-50%);
        width: max(100%, 300px);
    }
}
@media (max-width: 700px) {
    .page-heading:has([data-jobs-view-tabs]):has(> .page-actions) .global-search-matches {
        inset-inline-end: auto; width: min(340px, calc(100vw - 24px));
    }
}

/* Keep the full results compact; the narrower live dropdown keeps its stacked detail. */
.global-search-results .global-search-result-text { display: flex; align-items: baseline; gap: 10px; }
.global-search-results .global-search-result-title {
    flex: 0 1 auto; min-width: 0; max-width: 50%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.global-search-results .global-search-matched-fields {
    flex: 1 1 0; min-width: 0; display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted);
}
.global-search-results .global-search-match + .global-search-match::before {
    content: "·"; margin-inline: 8px; color: var(--muted);
}

.global-search-announcement.global-search-live-error {
    position: static; width: auto; height: auto; clip-path: none;
    padding: 9px 12px; margin: 0 0 10px; border: 1px solid var(--danger);
    border-radius: 8px; background: var(--danger-surface); color: var(--danger-hover);
}

.global-search-history-tag {
    flex: 0 0 auto; white-space: nowrap; padding: 2px 7px; border-radius: 999px;
    color: #4c3409; background: #ffedb9; font-size: var(--text-small); font-weight: 700;
}
.global-search-result-text:has(.global-search-history-tag) .global-search-result-title { max-width: 35%; }
.history-event[id^="history-event-"] { scroll-margin-top: calc(var(--workspace-topbar-height, 56px) + 12px); }
.history-event[id^="history-event-"]:target { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (max-width: 540px) {
    .global-search-results .global-search-result-text:has(.global-search-history-tag) {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px;
    }
    .global-search-result-text:has(.global-search-history-tag) .global-search-result-title { max-width: none; }
    .global-search-result-text:has(.global-search-history-tag) .global-search-matched-fields {
        grid-column: 1 / -1; grid-row: 2;
    }
    .global-search-history-meta { grid-column: 2; grid-row: 1; }
}


.global-search-history-meta { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.global-search-history-date { color: var(--muted); font-size: var(--text-caption); font-weight: 400; font-variant-numeric: tabular-nums; }
.temporal-display { display: none; }
.temporal-field[data-date-present] > input:not(:focus) { color: transparent; -webkit-text-fill-color: transparent; }
.temporal-field[data-date-present] > input:not(:focus) ~ .temporal-display {
    position: absolute; inset: 0 34px 0 9px; display: flex; align-items: center;
    width: auto; overflow: hidden; white-space: nowrap; pointer-events: none;
    color: var(--ink); font: inherit;
}
.temporal-field[data-date-present] > input:disabled ~ .temporal-display { color: var(--muted); }


.editor-detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.editor-detail-heading > button { margin-bottom: 10px; }
.editor-secondary-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }


.ticket-filter-row {
    --filter-option-hover: #e0eaff;
    --filter-picker-shadow: 0 10px 28px #17213826;
}
.record-filter-field-picker, [data-condition-multi-picker] { display: block; min-width: 0; }
.ticket-filter-row :is(select[data-condition-field], select[data-condition-operator],
    [data-condition-single] > select, .record-filter-field-trigger) {
    width: 100%; min-width: 0; min-height: 34px;
    font: inherit; font-size: var(--text-body); font-weight: var(--weight-medium);
    color: var(--ink);
}
.record-filter-field-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    text-align: start; overflow-wrap: anywhere;
    padding-inline: 9px 32px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 15px center, right 10px center;
    background-size: 5px 5px; background-repeat: no-repeat;
}
.record-filter-field-trigger:hover { border-color: #aebfe0; background-color: #f8faff; }
.record-filter-field-trigger[aria-expanded="true"] { border-color: var(--blue); background-color: #f8faff; }
.record-filter-field-menu {
    /* A fixed overlay does not contribute overflow to the modal or its scrollable body. */
    position: fixed; inset: auto; z-index: 8; display: flex; flex-direction: column; padding: 5px;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--filter-picker-shadow);
}
.record-filter-field-menu > input { flex: none; width: 100%; }
.record-filter-field-options {
    display: grid; grid-template-columns: minmax(0, 1fr);
    min-height: 0; max-height: min(320px, 45dvh); overflow-y: auto; overscroll-behavior-y: contain;
}
.record-filter-field-menu > input + .record-filter-field-options { margin-top: 4px; }
.record-filter-field-options button {
    display: grid; grid-template-columns: minmax(0, 1fr) 12px; align-items: center; gap: 8px;
    width: 100%; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 7px;
    text-align: start; color: var(--ink); background: transparent;
    font: inherit; font-size: var(--text-body); font-weight: normal; overflow-wrap: anywhere;
}
.record-filter-field-options button[aria-pressed="true"] {
    background: var(--blue-soft); color: var(--blue); font-weight: var(--weight-medium);
}
.record-filter-field-options button:hover, .record-filter-field-options button:focus-visible {
    background: var(--filter-option-hover); color: var(--blue-hover);
}
.record-filter-field-options button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.record-filter-field-options button[aria-pressed="true"]::after {
    content: "✓"; grid-column: 2; justify-self: end; color: var(--blue); line-height: 1;
}
@supports (appearance: base-select) and selector(select::picker(select)) {
    .record-filter-field-trigger { padding-inline-end: 12px; background-image: none; }
    .record-filter-field-trigger::after {
        content: ""; flex: none; width: 8px; height: 7px; color: var(--muted);
        background: currentColor; clip-path: polygon(0 0, 100% 0, 50% 100%);
    }
    .record-filter-field-trigger[aria-expanded="true"]::after { color: var(--blue); rotate: 180deg; }
    .ticket-filter-row select option { font-weight: normal; }
    .ticket-filter-row select option:checked { font-weight: var(--weight-medium); }
}
.record-filter-field-empty { display: block; padding: 5px 7px; color: var(--muted); }

.record-filter-field-cell, .record-filter-value-cell { min-width: 0; }
[data-condition-multi] {
    display: grid; gap: 5px; font-size: var(--text-small); font-weight: var(--weight-medium);
}
[data-condition-multi-picker] .record-filter-field-trigger > span {
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 560px) {
    .ticket-filter-row :is(.record-filter-field-cell, .record-filter-value-cell) { grid-column: 1; }
}

.settings-team-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.settings-team-row > .settings-tabs { margin: 0; }
.settings-team-row > .request-type-filter,
.settings-team-row > [data-holiday-year] { margin-inline-start: auto; }
.team-holiday-list p { margin: .65rem 0 0; }
.team-holiday-list td:not(:first-child) { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
    .team-holiday-list td:first-child { grid-column: 1 / -1; }
}
.request-type-filter { min-width: 0; max-width: 100%; }
.request-type-filter select { max-width: 100%; }
.request-list td small { display: block; color: var(--muted); margin-top: 3px; }
.request-list td small.job-error { color: var(--danger); }
.request-list .holiday-controls { gap: .4rem; }
.request-list .request-payout-controls { justify-content: flex-end; margin-bottom: 10px; }
@media (max-width: 700px) {
    .request-list table, .request-list tbody { display: block; }
    .request-list thead { display: none; }
    .request-list tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; padding: 9px; border-bottom: 1px solid var(--line); }
    .request-list td { display: block; min-width: 0; border: 0; padding: 0; overflow-wrap: anywhere; }
    .request-list td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--text-caption); }
    .request-list td:last-child, .request-list td.empty { grid-column: 1 / -1; }
    .request-list td:empty { display: none; }
}
.profile-leave-links { display: flex; flex-wrap: wrap; gap: .75rem; }
.holiday-heading, .holiday-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.holiday-heading { justify-content: space-between; align-items: center; }
.holiday-policy-dates { border-top: 1px solid var(--line); padding-top: .75rem; }
.holiday-policy-dates h3 { margin: 0; }
.holiday-policy-dates > p { margin: .35rem 0 .65rem; }
.holiday-policy-dates > ul { margin-bottom: 0; }
.holiday-controls label { min-width: max-content; }
.holiday-controls input[type="number"] { max-width: 7rem; }
.holiday-controls .check { align-self: center; }
.holiday-controls > .check:has(> input[name="carry"]) {
    align-self: flex-end;
    min-block-size: calc(var(--text-body) * 1.5 + 14px);
}
.holiday-balance { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .75rem; }
.holiday-balance div { background: var(--blue-soft); border-radius: .55rem; padding: .6rem .8rem; }
.holiday-balance dt { color: var(--muted); font-size: .85rem; }
.holiday-balance dd { margin: .2rem 0 0; font-size: 1.15rem; font-weight: 600; }
.holiday-request { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.holiday-request p { margin: .25rem 0 0; }
.holiday-state, .holiday-conflict { font-size: .85rem; color: var(--muted); }
.holiday-closures { padding: 0; list-style: none; }
.holiday-closures li { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.holiday-closures li form { margin-left: auto; }
.holiday-blocked { color: var(--muted); }

.holiday-calendar-dialog { width: min(460px, calc(100% - 24px)); }
.holiday-calendar-dialog p { margin: 0; }
.holiday-calendar-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.holiday-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .25rem; text-align: center; }
.holiday-calendar-grid[data-calendar-days] { user-select: none; touch-action: none; }
.holiday-calendar-grid button { width: 100%; min-width: 0; padding: .4rem 0; }
.holiday-calendar-grid button[aria-pressed="true"] { color: white; background: var(--blue); border-color: var(--blue); }
.holiday-calendar-grid button[data-ineligible], .holiday-calendar-grid button:disabled { color: var(--muted); background: #f0f3f8; }
.holiday-calendar-grid button[data-ineligible][data-in-range] { background: var(--blue-soft); color: var(--muted); border-color: var(--line); }
.holiday-calendar-grid button[aria-current="date"] { font-weight: 700; text-decoration: underline; }
.holiday-calendar-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.holiday-date-types button { width: 100%; }
.holiday-date-types button[aria-pressed="true"] { color: white; background: var(--blue); border-color: var(--blue); }
.holiday-date-types small { display: block; margin-top: 3px; }
.holiday-date-types [data-calendar-mode]::before { content: ""; display: inline-block; width: .65em; height: .65em; border-radius: 50%; margin-inline-end: .45em; background: var(--blue); }
.holiday-date-types [data-calendar-mode="fixed"]::before { background: #0f766e; }
.holiday-date-types [data-calendar-mode][aria-pressed="true"]::before { outline: 1px solid white; }
.holiday-calendar-grid button[data-holiday-kind="floating"] { color: white; background: var(--blue); border-color: var(--blue); }
.holiday-calendar-grid button[data-holiday-kind="fixed"] { color: white; background: #0f766e; border-color: #0f766e; }
.holiday-calendar-grid button[data-holiday-kind="both"] { color: white; background: linear-gradient(135deg,#0f766e 0 50%,var(--blue) 50%); border-color: #0f766e; }
.holiday-controls [data-calendar-native][hidden] { display: none; }

/* Public account pages share the marketing site's pale blue and wordmark. */
.workspace-site-header{width:min(70rem,100%);margin:0 auto;padding:1rem clamp(1rem,4vw,2.7rem);display:flex;align-items:center;justify-content:space-between;gap:.8rem}
.workspace-wordmark{display:inline-flex;align-items:center;gap:.55rem;color:var(--brand-midnight);font-size:1.19rem;letter-spacing:-.04em;font-weight:770;white-space:nowrap}
.workspace-wordmark{position:relative}
.workspace-wordmark::before{content:"";display:block;width:clamp(135px,24vw,180px);aspect-ratio:530/144;background:url("/bluecollar-wordmark.svg") center/contain no-repeat}
.workspace-wordmark img{display:none}
.workspace-wordmark span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.workspace-home{font-size:.875rem;font-weight:650;color:#365591;white-space:nowrap}
.workspace-site-header + .workspace-access{min-height:0;padding:clamp(1rem,4vh,3rem) 1rem 2.5rem}
.workspace-site-header + .workspace-access--split{width:min(61rem,100%);max-width:none;grid-template-columns:minmax(0,1.04fr) minmax(0,.96fr);gap:clamp(1rem,4vw,3rem);align-items:center}
.workspace-site-header + .workspace-access .workspace-card{border:1px solid #d6e0f0;border-radius:14px;background:#fff;box-shadow:0 12px 32px #152b5310}
.workspace-card .workspace-account-links{gap:.65rem 1rem;font-size:.875rem}
.workspace-card .workspace-account-links a,.workspace-story a{color:#2548a2;font-weight:650}
.workspace-card .workspace-account-links a:hover,.workspace-story a:hover,.workspace-home:hover{text-decoration:underline;text-underline-offset:3px}
.workspace-story{display:grid;align-content:center;gap:.9rem;width:100%;padding:clamp(1rem,2.6vw,2rem);color:var(--brand-midnight)}
.workspace-story h2{margin:0;font-size:clamp(1.9rem,3.8vw,3rem);line-height:1.08;letter-spacing:-.04em}
.workspace-story p{margin:0;color:var(--brand-steel)}
.workspace-story .workspace-kicker{font-size:.86rem;font-weight:750;color:#365591}
@media(max-width:700px){.workspace-site-header + .workspace-access--split{max-width:36rem;grid-template-columns:1fr;gap:1rem}.workspace-story{padding:.75rem .4rem}.workspace-story h2{font-size:1.45rem}}
.workspace-access label[hidden]{display:none}

.phone-requests-link { display: none; }

/* Phone browser layout. Desktop pointer/hover layouts keep their existing rules. */
[data-phone-select-label] { display: none; }
@media (max-width: 1024px) and (hover: none) and (pointer: coarse) {
    body[data-phone-layout] {
        --phone-nav-height: 57px; --phone-search-height: 58px;
        --phone-inset-start: max(12px, env(safe-area-inset-left));
        --phone-inset-end: max(12px, env(safe-area-inset-right));
        background-attachment: scroll;
    }
    body[data-phone-layout] .sidebar {
        position: fixed; inset: auto 0 0; z-index: 20; width: auto; overflow: visible;
        display: block; min-height: calc(52px + env(safe-area-inset-bottom));
        padding: 3px env(safe-area-inset-right) calc(3px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
        border-top: 1px solid #334466;
    }
    body[data-phone-layout] .sidebar .brand, body[data-phone-layout] .sidebar-module-label { display: none; }
    body[data-phone-layout] .sidebar-nav {
        display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
        align-items: stretch; gap: 0; min-width: 0;
    }
    body[data-phone-layout] .sidebar-modules, body[data-phone-layout] .sidebar .sidebar-utilities { display: contents; }
    body[data-phone-layout] .sidebar-module, body[data-phone-layout] #settings-gear {
        display: grid; place-items: center; padding: 3px; margin: 0; border-radius: 8px;
        min-width: 0; min-height: 44px; cursor: pointer; touch-action: manipulation;
    }
    body[data-phone-layout] .sidebar-module svg, body[data-phone-layout] #settings-gear svg {
        width: min(22px, 74%); height: auto; aspect-ratio: 1;
    }
    body[data-phone-layout] #settings-gear { width: auto; height: auto; border: 0; }
    .phone-search-bar {
        position: sticky; inset-block-start: 0; z-index: 19;
        padding: calc(6px + env(safe-area-inset-top)) var(--phone-inset-end) 6px var(--phone-inset-start);
        background: #eff3fe; border-bottom: 1px solid #dbe5f6;
    }
    body[data-phone-profile-page] main > :is(.settings-nav-row, .settings-tabs, .settings-template-toolbar),
    body[data-phone-requests-page] main > .settings-nav-row,
    body[data-phone-requests-page] .settings-team-row > .settings-team-tabs { display: none; }
    body[data-phone-profile-page] .phone-requests-link { display: inline-flex; }
    body[data-phone-layout] main {
        --page-start: 14px; --page-inset: 12px; margin: 0; min-width: 0;
        padding: var(--page-start) var(--phone-inset-end) calc(16px + var(--phone-nav-height)) var(--phone-inset-start);
    }
    body[data-phone-layout] .page-heading {
        position: relative; top: 0; min-height: 0; gap: 5px 8px;
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        grid-template-areas: "title actions";
        margin: calc(-1 * var(--page-start)) calc(-1 * var(--phone-inset-end)) 9px calc(-1 * var(--phone-inset-start));
        padding: 4px var(--phone-inset-end) 7px var(--phone-inset-start);
        background: #eff3fe; border-bottom: 1px solid #dbe5f6;
    }
    body[data-phone-layout] .page-heading:has(.module-tabs) {
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        grid-template-areas: "title actions" "tabs tabs";
    }
    body[data-phone-layout] .page-heading:has(.module-tabs) > .page-title {
        display: contents;
    }
    body[data-phone-layout] .page-heading > .page-title > .page-title-text { grid-area: title; min-width: 0; display: block; }
    body[data-phone-layout] .page-heading:has(.module-tabs) .page-title > .avatar { display: none; }
    body[data-phone-layout] .page-heading .page-title-text[data-diary-title]::before,
    body[data-phone-layout] .page-heading .page-title-text[data-diary-title]::after { display: none; }
    body[data-phone-layout] .page-heading h1,
    body[data-phone-layout] .page-heading .page-title-text[data-diary-title] h1 {
        font-size: 1.2rem; white-space: normal; line-height: 1.2; overflow-wrap: anywhere;
    }
    body[data-phone-layout] .page-heading .module-tabs {
        grid-area: tabs; width: max-content; max-width: 100%; padding: 2px; margin: 0;
    }
    body[data-phone-layout] .page-heading .module-tabs a { min-height: 40px; }
    body[data-phone-layout] .page-heading > .page-actions { max-width: min(58vw, 26rem); gap: 4px; }
    body[data-phone-layout] .page-heading:has(> .page-actions > :nth-child(4)) {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "title" "actions";
    }
    body[data-phone-layout] .page-heading:has(> .page-actions > :nth-child(4)) > .page-actions { max-width: none; justify-content: start; }
    body[data-phone-layout] .page-heading .jobs-header-totals { line-height: 1.2; min-width: 0; }
    body[data-phone-layout] .global-search-control input[type="search"] { padding-inline-start: 0; }
    body[data-phone-layout] .global-search-matches { width: 100%; inset-inline: 0; transform: none; }
    body[data-phone-layout] main .contact-tabs { top: var(--phone-search-height); }
    body[data-phone-layout] main .record-anchor { scroll-margin-top: calc(var(--phone-search-height) + 60px); }
    body[data-phone-layout] .panel, body[data-phone-layout] .record-actions { min-width: 0; }
    body[data-phone-layout] .filters { padding: 9px; gap: 7px; }
    body[data-phone-layout] .filters .search { flex-basis: 100%; }
    body[data-phone-layout] .filters .directory-sort-control + .search { flex: 1 1 calc(100% - 44px); min-width: 0; }
    body[data-phone-layout] .filters > label:not(.search) { flex: 1 1 8rem; min-width: 0; }
    body[data-phone-layout] .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
    body[data-phone-layout] input:not([type="checkbox"], [type="radio"], [type="hidden"]),
    body[data-phone-layout] select, body[data-phone-layout] textarea { font-size: 16px; max-width: 100%; }
    body[data-phone-layout] button, body[data-phone-layout] .button,
    body[data-phone-layout] .global-search-control { min-height: 44px; }
    body[data-phone-layout] .button { display: inline-flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
    body[data-phone-layout] .dialog-actions, body[data-phone-layout] .diary-toolbar { flex-wrap: wrap; }
    body[data-phone-layout] .column-picker { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px); padding: 14px; }
    body[data-phone-layout] .diary-days { scroll-snap-type: x proximity; }
    body[data-phone-layout] .diary-days a { min-height: 44px; flex: 1 0 40px; scroll-snap-align: start; }
    body[data-phone-layout] .diary-banner .diary-date-controls {
        width: 100%; grid-template-columns: 44px minmax(0, 1fr) auto 44px; gap: 5px;
    }
    body[data-phone-layout] .diary-month { min-width: 0; overflow-wrap: anywhere; }
    body[data-phone-layout] .diary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body[data-phone-layout] .diary-column-headings { display: none; }
    body[data-phone-layout] .diary-job .diary-grid > * { border: 0; }
    body[data-phone-layout] .diary-work { grid-column: 1 / -1; }
    body[data-phone-layout] .diary-job-stage .diary-status-actions { margin-top: 6px; }

    body[data-phone-layout] .directory .table-scroll { min-width: 0; max-width: 100%; }
    body[data-phone-layout] .directory table[data-phone-table] {
        display: block; width: 100% !important; min-width: 0; max-width: 100%; table-layout: auto;
    }
    body[data-phone-layout] [data-phone-table] colgroup { display: none; }
    body[data-phone-layout] [data-phone-table] thead { display: block; background: #f0f4fc; }
    body[data-phone-layout] [data-phone-table] thead > tr {
        display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 44px;
        padding: 2px 8px; white-space: normal;
    }
    body[data-phone-layout] [data-phone-table] thead th {
        width: auto; min-width: 0; max-width: 100%; flex: 0 1 auto;
        padding: 0; border: 0; background: none; white-space: normal;
    }
    body[data-phone-layout] [data-phone-table] thead th:not(.bulk-select-cell):not(:has(a.column-title)),
    body[data-phone-layout] [data-phone-table] .column-grip,
    body[data-phone-layout] [data-phone-table] .column-resize { display: none; }
    body[data-phone-layout] [data-phone-table] .column-title {
        display: inline-flex; align-items: center; min-height: 42px; padding: 0 6px; gap: 4px;
        white-space: normal; overflow-wrap: anywhere;
    }
    body[data-phone-layout] [data-phone-table] [data-phone-select-label] {
        display: inline; margin-inline-start: 5px; font-size: .75rem; color: var(--muted);
    }
    body[data-phone-layout] [data-phone-table] tbody { display: grid; gap: 8px; padding: 8px; background: #f4f7fc; }
    body[data-phone-layout] [data-phone-table] tbody tr {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start; gap: 6px 12px; padding: 9px 10px;
        border: 1px solid #dae3f2; border-radius: 9px; background: white;
    }
    body[data-phone-layout] [data-phone-table] tbody td { width: auto; min-width: 0; padding: 2px 0; border: 0; white-space: normal; }
    body[data-phone-layout] [data-phone-table] td[data-phone-empty]:not([data-phone-primary]) { display: none; }
    body[data-phone-layout] [data-phone-table] td[data-mobile-label]:not([data-phone-primary])::before {
        content: attr(data-mobile-label); display: block; color: var(--muted); font-size: .72rem;
    }
    body[data-phone-layout] [data-phone-table] td[data-phone-primary] {
        grid-column: 1 / -1; grid-row: 1; padding-inline-end: 32px; min-height: 28px; font-weight: 650;
    }
    body[data-phone-layout] [data-phone-table] td.bulk-select-cell {
        grid-column: 2; grid-row: 1; justify-self: end; z-index: 1; margin: 0;
    }
    body[data-phone-layout] [data-phone-table] td.directory-leading-badge { padding-inline-start: 34px; }
    body[data-phone-layout] [data-phone-table] td.directory-leading-badge > .avatar { inset-inline-start: 0; }
    body[data-phone-layout] [data-phone-table] td.empty { grid-column: 1 / -1; padding: 14px; }
    body[data-phone-layout] .table-footer { flex-wrap: wrap; gap: 8px; padding: 6px 9px; }
}

/* Home dashboard */
.crm-home-dashboard { display: grid; gap: 16px; container-type: inline-size; }
.home-hero, .home-card, .home-stat { margin: 0; min-width: 0; }
.home-hero { padding: clamp(18px, 3vw, 32px); background: linear-gradient(118deg, var(--blue-soft), var(--surface) 88%); }
.home-hero h2 { margin: 4px 0; font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.035em; overflow-wrap: anywhere; }
.home-hero p, .home-card > p { margin: 0; color: var(--muted); }
.home-hero p:first-child { font-size: var(--text-small); }
.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.home-stat { display: grid; align-content: start; gap: 3px; padding: 14px 16px; color: var(--ink); text-decoration: none; }
.home-stat:hover { border-color: var(--blue); }
.home-stat span, .home-stat small { color: var(--muted); font-size: var(--text-small); }
.home-stat strong { font-size: clamp(1.4rem, 3vw, 2rem); color: var(--blue); letter-spacing: -.03em; overflow-wrap: anywhere; }
.home-agenda { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(275px, 100%), 1fr)); gap: 16px; }
.home-card { padding: 16px; }
.home-card header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.home-card h2 { margin: 0; font-size: 1rem; }
.home-card a { color: var(--blue); text-decoration: none; overflow-wrap: anywhere; }
.home-card a:hover { color: var(--blue-hover); text-decoration: underline; }
.home-list, .home-team-grid { list-style: none; margin: 0; padding: 0; }
.home-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.home-list .home-list-time { flex: 0 1 auto; min-width: 0; text-align: end; overflow-wrap: anywhere; color: var(--muted); font-variant-numeric: tabular-nums; }
.home-list .home-list-time:empty { display: none; }
.home-team-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(min(218px, 100%), 1fr);
  gap: 10px; margin-top: 12px; overflow-x: auto; }
.home-team-grid li { padding: 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; overflow-wrap: anywhere; }
.home-team-person { display:flex; flex-wrap:nowrap; align-items:baseline; gap:8px; }
.home-team-person > strong, .home-team-person > .home-badge { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.home-team-person > .home-badge { flex:0 0 auto; max-width:76%; }
.home-team-links { display:grid; gap:7px; margin-top:8px; font-size:var(--text-small); }
.home-team-booking { display:grid; gap:2px; min-width:0; }
.home-team-booking a { font-weight:var(--weight-medium); }
.home-team-customer { font-weight: var(--weight-medium); }
.home-team-address { color:var(--muted); white-space:pre-line; }
.home-team-figures { display:flex; flex-wrap:wrap; gap:4px 12px; margin:5px 0 0;
  padding-top:6px; border-top:1px solid var(--line); font-variant-numeric:tabular-nums; }
.home-team-figures > div { min-width:0; }
.home-team-figures dt { color:var(--muted); font-size:.72rem; }
.home-team-figures dd { margin:0; font-weight:650; white-space:nowrap; }
.home-team-links:empty { display: none; }
.home-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--text-small); font-weight: 650; color: var(--muted); background: var(--canvas); }
.home-badge[data-status="booked"] { color: var(--blue); background: var(--blue-soft); }
.home-badge[data-status="tentative"] { color: #854000; background: #fff3da; }
.home-badge[data-status="free"] { color: #1b6546; background: #e5f5ec; }

/* Home briefing, workflow and personal notes */
.home-hero { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:16px; }
.home-weather { min-width:0; max-width:100%; padding:11px 14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
.home-weather h3 { margin:0 0 7px; font-size:.875rem; overflow-wrap:anywhere; }
.home-weather > a { display:inline-block; margin-top:5px; font-size:var(--text-caption); }
.home-weather-stats { display:flex; flex-wrap:wrap; gap:7px 16px; margin:0; }
.home-weather-stats dt { color:var(--muted); font-size:var(--text-small); }
.home-weather-stats dd { margin:0; font-weight:700; font-variant-numeric:tabular-nums; }
/* Management's daily snapshot uses the existing Home theme. */
.home-hero-management { display:grid; grid-template-columns:max-content minmax(0,1fr) minmax(12rem,15rem); gap:clamp(12px,2vw,24px); }
.home-hero-management.home-hero-with-weather { grid-template-columns:max-content minmax(0,1fr) minmax(12rem,15rem) max-content; }
.home-hero-management .home-greeting, .home-hero-personal .home-greeting { min-width:0; max-width:18rem; }
.home-hero-personal { display:grid; grid-template-columns:max-content minmax(0,1fr); gap:clamp(12px,2vw,24px); }
.home-hero-personal.home-hero-with-weather { grid-template-columns:max-content minmax(0,1fr) max-content; }
@container (max-width: 800px) {
    .home-hero-personal { grid-template-columns:minmax(0,1fr); }
    .home-hero-personal.home-hero-with-weather { grid-template-columns:minmax(0,1fr) max-content; }
    .home-hero-personal .home-hero-counters { grid-column:1 / -1; grid-row:2; }
}
@container (max-width: 520px) {
    .home-hero-personal.home-hero-with-weather { grid-template-columns:minmax(0,1fr); }
}
.home-hero-counters { display:flex; flex-wrap:wrap; justify-content:center; align-items:flex-start; min-width:0; gap:10px clamp(13px,1.3vw,20px); padding:8px 10px; }
.home-inline-counter { display:grid; flex:0 0 auto; width:max-content; max-width:100%; min-width:0; gap:3px; padding:0 2px; color:var(--ink); text-align:center; text-decoration:none; overflow-wrap:anywhere; }
.home-inline-counter span, .home-inline-counter small { color:var(--muted); font-size:var(--text-small); line-height:1.2; }
.home-inline-counter span { white-space:nowrap; }
.home-inline-counter strong { grid-row:1; font-size:clamp(1.4rem, 3vw, 2rem); line-height:1.15; color:var(--blue); letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
@container (max-width: 1030px) {
    .home-hero-management { grid-template-columns:minmax(0,1fr) minmax(12rem,15rem); }
    .home-hero-management.home-hero-with-weather { grid-template-columns:minmax(0,1fr) minmax(12rem,15rem) max-content; }
    .home-hero-management .home-hero-counters { grid-column:1 / -1; grid-row:2; }
}
@container (max-width: 660px) {
    .home-hero-management, .home-hero-management.home-hero-with-weather { grid-template-columns:minmax(0,1fr); }
}
#home-money { scroll-margin-top: 85px; }
.home-money-period { display:inline-flex; flex-wrap:wrap; gap:3px; margin-inline-start:auto; background:var(--canvas); border:1px solid var(--line); border-radius:9px; padding:3px; }
.home-money-period a { display:inline-flex; align-items:center; min-height:30px; padding:4px 11px; border-radius:6px; color:var(--muted); font-size:var(--text-small); }
.home-money-period a:hover { color:var(--blue); background:var(--blue-soft); text-decoration:none; }
.home-money .home-money-error:not([hidden]) { margin:0 0 8px; color:var(--muted); font-size:var(--text-small); }
.home-money-period a[aria-current] { color:var(--blue); background:var(--surface); box-shadow:0 1px 3px #16224b24; font-weight:700; }
.home-money-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(224px,100%),1fr)); gap:12px; }
.home-money-card { min-width:0; border:1px solid var(--line); border-radius:12px; padding:13px 15px; }
.home-money-card h3 { margin:0 0 4px; font-size:.95rem; }
.home-money-card p, .home-money-card dt, .home-money-card small, .home-money .home-money-footnote { color:var(--muted); font-size:var(--text-small); }
.home-money-card p { margin:0; }
.home-money-card dl { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding-top:10px; border-top:1px solid var(--line); margin:10px 0 0; }
.home-money-card dd { margin:1px 0 0; font-size:clamp(1rem, 2.4vw, 1.55rem); font-weight:700; font-variant-numeric:tabular-nums; letter-spacing:-.03em; overflow-wrap:anywhere; }
.home-money-card dl > :last-child dd { color:var(--blue); }
.home-money-card small { display:block; margin-top:8px; }
.home-money .home-money-footnote { margin-top:10px; }
.home-requests { min-width:0; padding:0 12px; border-inline-start:1px solid var(--line); }
.home-requests h3 { margin:0 0 6px; font-size:.875rem; }
.home-requests a { color:var(--blue); text-decoration:none; overflow-wrap:anywhere; }
.home-requests a:hover { color:var(--blue-hover); text-decoration:underline; }
.home-requests h3 a, .home-request-group > a { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.home-requests h3 strong { background:var(--blue-soft); border-radius:999px; padding:0 7px; }
.home-request-preview { position:relative; }
.home-request-groups { display:grid; gap:6px; }
.home-request-preview[data-fits] > .home-request-groups { max-height:9.5rem; overflow:clip; }
.home-request-preview:not([data-fits]) .home-request-list { display:none; }
.home-request-group > a { font-size:var(--text-small); }
.home-request-list { display:grid; gap:3px; margin:3px 0 0; padding:0; list-style:none; }
.home-request-list li { display:flex; align-items:baseline; justify-content:space-between; gap:4px 8px; flex-wrap:wrap; font-size:var(--text-caption); overflow-wrap:anywhere; }
.home-request-list small { color:var(--muted); font-size:inherit; }
@container (max-width: 660px) {
    .home-requests { padding:8px 0 0; border-inline-start:0; border-top:1px solid var(--line); }
}
.home-sticky-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(255px,100%),1fr)); gap:12px; margin-top:12px; }
.home-sticky { padding:12px; background:#fff5cc; border:1px solid #e8d9a2; color:#43371b; border-radius:10px; min-width:0; }
.home-sticky[data-tone="blue"] { background:#edf2ff; border-color:#cdd9f5; color:#25395f; }
.home-sticky[data-tone="green"] { background:#e9f8ed; border-color:#bcdfc9; color:#204434; }
.home-sticky[data-tone="pink"] { background:#fff0f5; border-color:#eed0dd; color:#583142; }
.home-sticky p { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.home-card details summary { cursor:pointer; font-weight:650; color:var(--blue); }
#home-notes > header { align-items:center; }
.home-sticky { position:relative; display:flex; flex-direction:column; gap:10px; }
.home-note-actions { display:flex; align-items:center; justify-content:flex-end; gap:6px; margin-top:auto; }
.home-note-actions .button { min-height:32px; padding:4px 10px; }
.home-note-actions .icon-button { width:32px; height:32px; }
.home-sticky .home-note-handle { position:absolute; inset-block-start:6px; inset-inline-end:6px; width:32px; height:32px; cursor:grab; color:inherit; font-size:1.15rem; touch-action:none; user-select:none; }
.home-sticky .home-note-handle:active { cursor:grabbing; }
.home-sticky .home-note-handle + p { padding-inline-end:30px; min-height:26px; }
.home-sticky.is-dragging { opacity:.65; }
.home-sticky.is-drop-target { outline:2px solid var(--blue); outline-offset:2px; }
.home-note-form textarea { width:100%; resize:vertical; }
.home-note-form .dialog-actions { flex-wrap:wrap; }
#home-notes .home-note-feedback { margin:0; color:var(--muted); font-size:var(--text-small); }
#home-notes .home-note-feedback.is-error { color:var(--danger); }
#home-notes .home-note-feedback:empty { min-height:0; }
@media (pointer:coarse) {
    .home-note-actions .button { min-height:44px; }
    .home-note-actions .icon-button, .home-sticky .home-note-handle { width:44px; height:44px; }
    .home-sticky .home-note-handle + p { padding-inline-end:42px; min-height:38px; }
}
@media (prefers-reduced-motion:no-preference) {
    .home-stat { transition:border-color .15s, box-shadow .15s; }
    .home-stat:hover { box-shadow:0 4px 14px color-mix(in srgb, var(--brand-electric) 13%, transparent); }
}

/* Keep secondary text readable where the brand tint sits under it. */
.home-hero, .panel-accent { --muted: var(--brand-muted-on-tint); }

/* Contact agreements and template fields */
.agreement-toolbar { justify-content: space-between; align-items: center; gap: .75rem; }
.agreement-toolbar h3 { margin: 0; }
.agreement-form { display: grid; gap: .8rem; }
.agreement-field-row:not([hidden]) { display: grid; grid-template-columns: repeat(auto-fit,minmax(9rem,1fr)); gap: .6rem; align-items: end; padding: .65rem; border: 1px solid var(--brand-line,#cbd5e1); border-radius: .5rem; }
.agreement-display .preserve, .agreement-form .preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.agreement-dialog { box-sizing: border-box; width: min(94vw,48rem); height: min(88dvh,52rem); border: 1px solid var(--brand-line,#cbd5e1); border-radius: .8rem; padding: .65rem; }
.agreement-dialog:not([open]) { display: none; }
.agreement-dialog[open] { display: grid; grid-template-rows: auto minmax(0,1fr); gap: .5rem; }
.agreement-dialog > button { justify-self: end; }
.agreement-dialog::backdrop { background: rgb(15 23 42 / .5); }
.agreement-dialog iframe { width: 100%; height: 100%; border: 0; }

.brand-logo-default { display: block; width: min(100%, 150px); height: auto; }

/* Shared BlueCollar controls inside the agreement popup and the signing link. */
body.agreement-standalone { min-height: 100dvh; padding: clamp(10px, 3vw, 22px); }
.agreement-standalone > .agreement-editor { width: min(100%, 48rem); margin: 0 auto; }
.agreement-dialog iframe { background: var(--canvas); border-radius: 9px; }
.agreement-editor { display: grid; gap: 14px; min-width: 0; }
.agreement-heading { background: var(--brand-blue-soft); color: var(--ink); padding: 14px 16px; border-radius: 10px; }
.agreement-heading h1 { margin: 0; font-size: clamp(1.1rem, 3.5vw, 1.5rem); overflow-wrap: anywhere; }
.agreement-heading p { margin: 3px 0 0; overflow-wrap: anywhere; }
.agreement-eyebrow { color: var(--blue-hover); font-size: var(--text-small); font-weight: var(--weight-heading); margin-bottom: 4px; }
.agreement-picker { max-width: 24rem; width: 100%; }
.agreement-editor h2 { margin: 0 0 8px; }
.agreement-editor textarea { min-height: 90px; }
.agreement-terms-card, .agreement-signature-card { border: 1px solid var(--line); background: var(--surface); padding: clamp(10px, 2.5vw, 16px); border-radius: 10px; min-width: 0; }
.agreement-terms-card p { margin: 0; }
.agreement-signature-card { display: grid; gap: 9px; }
.agreement-signature-card h2 { margin: 0; }
.agreement-signature-card canvas { display: block; width: 100%; max-height: 10rem; object-fit: fill; border: 1px dashed var(--brand-steel); border-radius: 8px; background: #fff; touch-action: none; }
.agreement-signature-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.agreement-signature-tools .quiet { padding-inline: 5px; }
.agreement-signature-card .check { gap: 7px; }
.agreement-signature-card [role="alert"] { margin: 0; color: var(--danger); }
.agreement-signature-card [role="alert"]:empty { display: none; }
.agreement-editor-actions { justify-content: flex-end; gap: 8px; }
.agreement-action-note { margin: 0; }
.agreement-editor dl > div { display: grid; gap: 8px; grid-template-columns: minmax(5rem, 1fr) minmax(0, 2fr); }
.agreement-editor dd { margin: 0; }
.agreement-editor dt { font-weight: var(--weight-medium); }
.agreement-editor .agreement-quote-table { overflow-x: auto; }
.agreement-editor .preserve { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Section-first agreement template field picker */
.agreement-picker-section { display: grid; gap: .55rem; }
.agreement-picker-section > h2, .agreement-picker-section > p { margin: 0; }
.agreement-contact-section { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.agreement-contact-section > .check { font-size: var(--text-body); padding: 9px 12px; gap: 8px; cursor: pointer; }
.agreement-section-fields:not([hidden]) { display: grid; gap: 1px; border-top: 1px solid var(--line); padding: 6px 12px 8px 26px; }
.agreement-mapped-field { padding: .3rem .1rem; }
.agreement-mapped-field > .check { gap: 8px; cursor: pointer; }
.agreement-mapped-options:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 8px; padding: 5px 0 0 21px; align-items: end; max-width: 32rem; }
.agreement-mapped-options .check { margin-bottom: 5px; gap: 5px; }
.agreement-picker-section .agreement-field-row:not([hidden]) { grid-template-columns: minmax(0, 1fr) auto auto; }
@media (max-width: 460px) {
    .agreement-mapped-options:not([hidden]) { grid-template-columns: 1fr; }
}
/* Only the agreement being filled in, not the template editor. */
.agreement-form-sections { display: grid; gap: .55rem; min-width: 0; }
.agreement-form-section { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); min-width: 0; }
.agreement-form-section > summary { padding: .6rem .8rem; color: var(--blue-hover); font-weight: var(--weight-heading); }
.agreement-form-section[open] > summary { border-bottom: 1px solid var(--line); background: var(--brand-blue-soft); border-radius: 9px 9px 0 0; }
.agreement-form-section[open] > .agreement-field-stack { animation: agreement-drop .15s ease-out; }
@keyframes agreement-drop { from { opacity: .45; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .agreement-form-section[open] > .agreement-field-stack { animation: none; } }
.agreement-field-stack { display: grid; gap: .6rem; padding: .75rem; min-width: 0; }
.agreement-input-row { display: grid; grid-template-columns: minmax(5.5rem, 27%) minmax(0,1fr); align-items: center; gap: .55rem; min-width: 0; }
.agreement-input-row > span { overflow-wrap: anywhere; min-width: 0; }
.agreement-input-row > input, .agreement-input-row > select, .agreement-input-row > textarea { width: 100%; min-width: 0; }
.agreement-editor .agreement-input-row textarea { min-height: 3.2rem; }
.agreement-next-row { display: flex; justify-content: flex-end; }
.agreement-section-tick { margin-inline-start: .4rem; color: var(--blue-hover); font-weight: 750; }
.agreement-section-tick[hidden] { display: none; }

.temporal-field[hidden] { display: none; }

/* Checkbox-backed picklists use the same colours, sizes and checkmark as select::picker(select). */
.multi-choice-field { display: grid; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.multi-choice-field > legend { padding: 0; margin-bottom: 5px; }
details[data-multi-picklist] { position: relative; min-width: 0; }
details[data-multi-picklist][open] { z-index: 8; }
details[data-multi-picklist] > summary {
    display: flex; align-items: center; gap: 10px;
    min-width: 0; min-height: 0; padding: 6px 12px 6px 9px;
    list-style: none; border: 1px solid #cbd6e9; border-radius: 8px;
    background: white; color: var(--ink); cursor: pointer;
    font: inherit; font-size: var(--text-body); font-weight: normal;
}
details[data-multi-picklist] > summary::-webkit-details-marker { display: none; }
details[data-multi-picklist] > summary::after {
    content: ""; flex: none; margin-inline-start: auto; width: 8px; height: 7px;
    background: var(--muted); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
details[data-multi-picklist] > summary > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details[data-multi-picklist] > summary:hover { border-color: #aebfe0; background-color: #f8faff; }
details[data-multi-picklist][open] > summary { border-color: var(--blue); background-color: #f8faff; }
details[data-multi-picklist][open] > summary::after { background: var(--blue); rotate: 180deg; }
details[data-multi-picklist] > summary[aria-invalid="true"] { border-color: var(--danger); }
details[data-multi-picklist] > [data-multi-options] {
    position: fixed; inset: auto; z-index: 9;
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 0;
    max-height: min(320px, 45dvh, var(--option-space, 320px)); padding: 5px; margin: 0;
    overflow: auto; overscroll-behavior: contain;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
    color: var(--ink); box-shadow: 0 10px 28px #17213826;
}
details[data-multi-picklist] > [data-multi-options] > .check {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 12px;
    min-height: 34px; padding: 7px 9px; margin: 0; gap: 8px; border: 0; border-radius: 7px;
    font-size: var(--text-body); font-weight: normal; color: var(--ink); background: transparent;
    cursor: pointer; overflow-wrap: anywhere;
}
details[data-multi-picklist] > [data-multi-options] > .check > input[type="checkbox"] {
    position: absolute; width: 1px; min-width: 0; height: 1px; padding: 0; margin: 0; opacity: 0;
}
details[data-multi-picklist] > [data-multi-options] > .check:has(:checked) {
    background: var(--blue-soft); color: var(--blue); font-weight: var(--weight-medium);
}
details[data-multi-picklist] > [data-multi-options] > .check:has(:checked)::after {
    content: "✓"; grid-column: 2; justify-self: end; color: var(--blue); line-height: 1;
}
details[data-multi-picklist] > [data-multi-options] > .check:not(:has(:disabled)):is(:hover, :focus-within) {
    background: #e0eaff; color: var(--blue-hover);
}
details[data-multi-picklist] > [data-multi-options] > .check:has(:focus-visible) {
    outline: 2px solid currentColor; outline-offset: -2px;
}
details[data-multi-picklist] > [data-multi-options] > .check:has(:disabled) { color: var(--muted); opacity: .65; cursor: default; }
details[data-multi-picklist] > [data-multi-options] > [data-agreement-multi-done] { margin: 4px; }

.agreement-attachments-table :is(th,td):nth-child(2) { width: 28%; white-space: nowrap; }
.agreement-attachments-table :is(th,td):last-child { width: 1%; }
.agreement-attachments-table td:first-child { overflow-wrap: anywhere; }
.agreement-attachment-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; white-space: nowrap; }
.agreement-attachment-actions .button { min-height: 28px; padding: 3px 8px; }
.agreement-compare-values { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,14rem),1fr)); gap: 8px; }
.agreement-compare-values div { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.agreement-compare-values dt { font-weight: var(--weight-medium); }
.agreement-compare-values dd { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.agreement-contact-review label { width: min(100%, 22rem); }
.agreement-contact-review > .toolbar { margin-top: 12px; }
@media (max-width: 600px) {
    .agreement-attachments-table { table-layout: fixed; }
    .agreement-attachments-table :is(th,td) { padding-inline: 5px; }
    .agreement-attachments-table th:first-child { white-space: normal; }
    .agreement-attachments-table :is(th,td):nth-child(2) { width: 82px; }
    .agreement-attachments-table :is(th,td):last-child { width: 123px; }
    .agreement-attachment-actions { gap: 3px; flex-wrap: wrap; }
    .agreement-attachment-actions .button { padding-inline: 4px; }
}

/* Company reports are private management views, separate from the Home money cards. */
.report-period {display:flex; align-items:end; flex-wrap:wrap; gap:10px;}
.report-period label {flex:1 1 10rem; max-width:16rem; margin:0;}
.report-period :is(input,select) {width:100%; min-width:0;}
.report-period :is(button,a) {white-space:nowrap;}
.report-period:has(select) .report-custom {display:none;}
.report-period:has(select option[value="custom"]:checked) .report-custom {display:block;}

.quote-subcontractor {margin-top:8px;}
.quote-item-description-row {display:flex; align-items:center; gap:8px; margin-top:3px; min-width:0;}
.quote-item-description-row .quote-item-description {flex:1; margin:0;}
.quote-subcontract-toggle {flex:0 1 auto; margin:0; gap:5px; font-size:var(--text-small); line-height:1.2;}
.quote-subcontract-toggle input {flex:none; margin:0;}
.quote-subcontractor fieldset {min-width:0; border:1px solid var(--line); border-radius:8px; padding:8px;}
.quote-subcontractor legend {padding:0 6px; font-size:.8rem; color:var(--muted);}
.quote-subcontractor-fields {display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr)); gap:8px; align-items:end;}
.quote-subcontractor-fields label {margin:0; min-width:0;}
.quote-subcontractor-fields :is(input,select) {width:100%; min-width:0;}
.quote-subcontractor-totals {display:flex; flex-wrap:wrap; gap:6px 16px; margin:9px 0 0; color:var(--brand-steel);}
.quote-subcontractor-totals :is(dt,dd) {display:inline; margin:0; font-size:var(--text-small); font-weight:400;}
.quote-subcontractor-totals dd {margin-inline-start:4px; font-variant-numeric:tabular-nums;}
.quote-subcontractor :is([hidden],fieldset[hidden]) {display:none!important;}

#company-report {scroll-margin-top:90px;}

[data-condition-range]:not([hidden]) {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: 6px;
}
[data-condition-range] label { min-width: 0; }
[data-condition-range] small { grid-column: 1 / -1; margin: 0; }

.quote-catalogue-actions {display:flex; align-items:center; flex-wrap:wrap; gap:6px 10px; margin-top:5px;}
.quote-catalogue-actions small:empty {display:none;}
.quote-new-supplier:not([hidden]) {display:flex; align-items:end; flex-wrap:wrap; gap:6px 8px;}
.quote-new-supplier label {margin:0;}
@container (max-width: 490px) {
    .quote-line-item:has(.quote-subcontract-toggle) {grid-column:1 / -1;}
}

.quote-catalogue-dialog {width:min(440px,calc(100vw - 32px));}
.quote-catalogue-dialog form > label {margin-bottom:8px;}
.quote-catalogue-dialog textarea {width:100%;}
.quote-search-add {display:block; width:100%; text-align:left; color:var(--blue);}
.quote-supplier-picker {min-width:0;}
.quote-supplier-picker small:empty {display:none;}

.product-option-row {display:flex; align-items:center; flex-wrap:wrap; gap:8px 20px; margin-top:8px;}
.product-option-row .check {margin:0; gap:6px; white-space:nowrap;}
