:root {
    --brand: #2457d6;
    --brand-dark: #1942aa;
    --brand-soft: #eef3ff;
    --ink: #172033;
    --ink-soft: #566078;
    --muted: #7a8499;
    --line: #dfe4ec;
    --line-strong: #cdd4df;
    --surface: #ffffff;
    --surface-soft: #f6f8fb;
    --surface-alt: #eef1f6;
    --success: #137a4f;
    --success-soft: #eaf8f1;
    --danger: #b4232f;
    --danger-soft: #fff0f1;
    --warning: #9a6200;
    --warning-soft: #fff7e3;
    --info: #1758a8;
    --info-soft: #edf5ff;
    --shadow: 0 14px 40px rgba(25, 35, 55, 0.08);
    --shadow-small: 0 5px 18px rgba(25, 35, 55, 0.07);
    --radius: 14px;
    --radius-small: 9px;
    --sidebar-width: 248px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface-soft); scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--surface-soft);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 38px); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 6px; font-size: 19px; line-height: 1.25; letter-spacing: -0.015em; }
h3 { margin-bottom: 6px; }
p { color: var(--ink-soft); }
hr { width: 100%; margin: 18px 0; border: 0; border-top: 1px solid var(--line); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 22px 16px 18px;
    color: #fff;
    background: #111827;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
    display: flex;
    align-items: center;
    min-height: 48px;
    gap: 11px;
    padding: 0 7px 20px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--brand);
    border-radius: 11px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    font-size: 20px;
    font-weight: 800;
}
.brand-logo { width: 42px; height: 42px; flex: 0 0 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; }
.brand-copy strong { max-width: 160px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: #97a1b4; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; padding: 22px 0; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    color: #bdc5d5;
    border-radius: 10px;
    font-weight: 650;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.nav-link.active { color: #fff; background: var(--brand); }
.nav-icon {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 800;
    opacity: 0.82;
}
.sidebar-footer { display: grid; gap: 11px; margin-top: auto; padding: 18px 7px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.user-chip { display: flex; min-width: 0; align-items: center; gap: 10px; }
.user-chip > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.user-chip strong, .user-chip small { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { color: #fff; font-size: 13px; }
.user-chip small { color: #97a1b4; font-size: 11px; }
.avatar { display: inline-flex; width: 34px; height: 34px; flex: 0 0 34px; align-items: center; justify-content: center; color: #fff; background: rgba(255, 255, 255, 0.13); border-radius: 50%; font-weight: 800; }
.link-button { padding: 0; color: #bdc5d5; background: none; border: 0; font-size: 12px; }
.link-button:hover { color: #fff; text-decoration: underline; }
.inline-form { display: inline; }
.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.main-content { width: min(1500px, 100%); margin: 0 auto; padding: 38px 40px 64px; }
.mobile-header { display: none; }
.sidebar-backdrop { display: none; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}
.page-header p { margin-bottom: 0; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.back-link { display: inline-block; margin-bottom: 9px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.title-with-badge { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.title-with-badge h1 { margin: 0; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 6px 15px color-mix(in srgb, var(--brand) 25%, transparent); }
.button.primary:hover { filter: brightness(0.92); }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover { color: var(--brand); border-color: var(--brand); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger-outline { color: var(--danger); background: #fff; border-color: #e4a6ac; }
.button.small { min-height: 33px; padding: 6px 11px; font-size: 12px; }
.button.full { width: 100%; }
.icon-button {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
}
.text-link { font-size: 13px; font-weight: 750; }
.strong-link { color: var(--ink); font-weight: 750; }
.strong-link:hover { color: var(--brand); }

.alert {
    margin-bottom: 18px;
    padding: 12px 15px;
    color: var(--ink);
    background: var(--info-soft);
    border: 1px solid #c6ddfa;
    border-radius: 10px;
    box-shadow: var(--shadow-small);
}
.alert a { font-weight: 750; text-decoration: underline; }
.alert-success { color: #0b5c3a; background: var(--success-soft); border-color: #b7e3cc; }
.alert-error { color: #8b1823; background: var(--danger-soft); border-color: #f0c2c6; }
.alert-warning { color: #744a00; background: var(--warning-soft); border-color: #efd89c; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 21px 22px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; }
.panel-header p { margin: 3px 0 0; font-size: 13px; }
.form-panel { padding: 22px; }
.form-panel > .panel-header { margin: -22px -22px 22px; }
.form-panel > h2:first-child { margin-bottom: 7px; }
.sticky-panel { position: sticky; top: 24px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card { display: flex; min-height: 144px; flex-direction: column; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-small); }
.metric-label { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.metric-value { margin: 8px 0 5px; font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; }
.metric-card a, .metric-note { margin-top: auto; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-card a:hover { color: var(--brand); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.span-2 { grid-column: span 2; }
.dashboard-grid .span-2 { grid-column: auto; }
.status-list { display: grid; padding: 9px 18px 17px; }
.status-list a { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 4px; color: var(--ink); border-bottom: 1px solid var(--line); }
.status-list a:last-child { border-bottom: 0; }
.status-list a:hover { color: var(--brand); text-decoration: none; }
.status-list a span { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 9px; height: 9px; background: var(--muted); border-radius: 50%; }
.status-dot.success { background: var(--success); }
.status-dot.danger { background: var(--danger); }
.status-dot.info { background: var(--info); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 17px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: #fbfcfe; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td { color: var(--ink-soft); font-size: 13px; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
td.strong, .strong { color: var(--ink); font-weight: 750; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.actions-column { width: 1%; text-align: right; white-space: nowrap; }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #fbfcff; }

.badge { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; color: var(--ink-soft); background: var(--surface-alt); border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 800; letter-spacing: 0.035em; text-transform: uppercase; white-space: nowrap; }
.badge.success { color: var(--success); background: var(--success-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.info { color: var(--info); background: var(--info-soft); }

.empty-state { display: flex; min-height: 310px; align-items: center; justify-content: center; flex-direction: column; padding: 40px 20px; text-align: center; }
.empty-state p { max-width: 430px; margin-bottom: 18px; }
.empty-icon { display: inline-flex; width: 48px; height: 48px; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--brand); background: var(--brand-soft); border-radius: 14px; font-size: 19px; font-weight: 850; }
.large-empty { min-height: 440px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 17px; border-bottom: 1px solid var(--line); }
.search-field { display: flex; min-width: min(430px, 100%); flex: 1; gap: 8px; }
.search-field input { flex: 1; }
.filters .search-field { max-width: 520px; }
.filters select { min-width: 160px; }

.form-stack { display: grid; gap: 16px; }
.form-stack.compact-form { gap: 12px; }
.field-grid { display: grid; gap: 17px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid .span-2 { grid-column: span 2; }
.field { display: grid; gap: 6px; margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }
.field label { color: var(--ink); font-size: 12px; font-weight: 750; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea {
    width: 100%;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    outline: 0;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input, select { min-height: 42px; padding: 9px 11px; }
textarea { min-height: 90px; padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
input[readonly] { color: var(--ink-soft); background: var(--surface-soft); }
.input-action-row { display: flex; align-items: stretch; gap: 8px; }
.input-action-row select { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 16px; color: var(--ink-soft); font-size: 12px; }
.checkbox-row input { width: 17px; min-height: auto; height: 17px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 0.72fr); gap: 20px; align-items: start; }
.form-layout > .span-2 { grid-column: auto; }
.form-layout .form-panel { margin-bottom: 20px; }
.muted { color: var(--muted); font-size: 13px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 28px; padding: 19px 21px; background: var(--danger-soft); border: 1px solid #f0c2c6; border-radius: var(--radius); }
.danger-zone h2 { color: var(--danger); margin-bottom: 3px; }
.danger-zone p { margin: 0; font-size: 13px; }

.guest-body { display: flex; align-items: center; justify-content: center; padding: 32px 18px; background: radial-gradient(circle at top, #edf3ff 0, var(--surface-soft) 44%, #f8f9fb 100%); }
.guest-shell { width: min(680px, 100%); }
.guest-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 17px; color: var(--ink); font-weight: 800; }
.guest-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 17px; }
.auth-card { padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-card.compact { width: min(460px, 100%); margin: 0 auto; }
.auth-heading { margin-bottom: 25px; text-align: center; }
.auth-heading h1 { font-size: 30px; }
.auth-heading p { max-width: 500px; margin: 0 auto; }
.auth-card .form-stack { gap: 2px; }

.quote-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 330px); gap: 20px; align-items: start; }
.editor-main { min-width: 0; }
.editor-main > .panel { margin-bottom: 20px; }
.item-header { align-items: center; }
.items-table { min-width: 0; }
.item-grid { display: grid; grid-template-columns: minmax(230px, 1fr) 105px 145px 125px 38px; gap: 10px; align-items: start; }
.item-grid-head { padding: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.item-grid-head span:nth-child(2), .item-grid-head span:nth-child(3), .item-grid-head span:nth-child(4) { text-align: right; }
.item-row { padding: 12px 0; border-top: 1px solid var(--line); }
.item-row:first-of-type { border-top: 1px solid var(--line); }
.item-row .field { margin: 0; }
.item-row textarea { min-height: 58px; resize: vertical; }
.item-row input { min-height: 42px; }
.item-row .js-qty, .item-row .js-price { text-align: right; }
.price-input { position: relative; }
.price-input span { position: absolute; z-index: 1; left: 10px; top: 10px; color: var(--muted); }
.price-input input { padding-left: 28px; }
.line-total { padding: 11px 3px 0; color: var(--ink); font-size: 13px; font-weight: 800; text-align: right; white-space: nowrap; }
.remove-item { width: 34px; height: 34px; margin-top: 4px; color: var(--danger); background: var(--danger-soft); border-color: #f1c7ca; font-size: 20px; }
.compact-grid { gap: 9px; }
.summary-list { display: grid; gap: 10px; margin: 18px 0 20px; }
.summary-list div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.summary-list dt { color: var(--ink-soft); }
.summary-list dd { margin: 0; font-weight: 750; font-variant-numeric: tabular-nums; }
.summary-list .summary-total { margin-top: 5px; padding-top: 13px; border-top: 1px solid var(--line-strong); }
.summary-list .summary-total dt, .summary-list .summary-total dd { color: var(--ink); font-size: 19px; font-weight: 850; }

.quote-view-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 330px); gap: 20px; align-items: start; }
.quote-preview-wrap { min-width: 0; }
.quote-side-stack { display: grid; gap: 16px; }
.copy-field { display: flex; gap: 7px; margin: 14px 0 9px; }
.copy-field input { min-width: 0; font-size: 11px; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.email-composer { scroll-margin-top: 22px; transition: box-shadow 0.18s ease, border-color 0.18s ease; }
.email-composer:target { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent), var(--shadow-small); }
.email-composer textarea { min-height: 175px; font-size: 12px; line-height: 1.55; }
.email-app-fallback { display: block; margin-top: 13px; font-size: 12px; text-align: center; }
.email-last-sent { display: grid; gap: 2px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.email-last-sent strong { color: var(--ink); font-size: 12px; }
.email-last-sent span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.inline-notice { display: grid; gap: 3px; margin: 14px 0 17px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.inline-notice strong { color: var(--ink); }
.inline-notice span { color: var(--ink-soft); }
.inline-notice a { width: fit-content; margin-top: 3px; font-weight: 750; }
.inline-notice.warning { background: var(--warning-soft); border-color: #efd79c; }
.inline-notice.warning strong, .inline-notice.warning a { color: var(--warning); }
.inline-notice.info { background: var(--info-soft); border-color: #c8dcf5; }
.inline-notice.info strong { color: var(--info); }
.smtp-settings { margin-top: 5px; padding-top: 4px; }
.smtp-settings[hidden] { display: none !important; }
.smtp-clear-password { align-self: center; min-height: 42px; margin: 20px 0 17px; padding: 0 2px; }
.security-note { margin: 0; color: var(--muted); font-size: 11px; }

.activity-panel { margin-top: 20px; }
.timeline { display: grid; gap: 0; margin: 0; padding: 5px 23px 20px; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 9px; padding: 16px 0 5px; }
.timeline li:not(:last-child)::before { position: absolute; top: 28px; bottom: -18px; left: 6px; width: 1px; content: ""; background: var(--line); }
.timeline-dot { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 3px; background: var(--brand); border: 3px solid var(--brand-soft); border-radius: 50%; }
.timeline strong { display: block; font-size: 13px; }
.timeline time { color: var(--muted); font-size: 11px; }
.timeline p { margin: 5px 0 0; font-size: 12px; }

.quote-document {
    width: 100%;
    min-height: 900px;
    padding: 46px 50px 34px;
    color: #1c2432;
    background: #fff;
    border: 1px solid #dfe3e9;
    border-radius: 4px;
    box-shadow: 0 12px 32px rgba(26, 35, 50, 0.08);
}
.document-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding-bottom: 30px; border-bottom: 3px solid var(--brand); }
.document-company { max-width: 54%; color: #5a6474; font-size: 11px; line-height: 1.6; }
.document-company-name { margin-bottom: 8px; color: #172033; font-size: 22px; font-weight: 850; letter-spacing: -0.03em; }
.document-logo { display: block; max-width: 190px; max-height: 76px; margin-bottom: 12px; object-fit: contain; object-position: left center; }
.document-title-block { display: flex; align-items: flex-end; flex-direction: column; text-align: right; }
.document-title-block > span { color: var(--brand); font-size: 29px; font-weight: 900; letter-spacing: 0.12em; }
.document-title-block > strong { margin: 2px 0 10px; font-size: 13px; }
.document-address-grid { display: grid; grid-template-columns: 1fr 280px; gap: 42px; padding: 30px 0; }
.document-address-grid > div { color: #5a6474; font-size: 12px; }
.document-address-grid strong { display: block; margin: 5px 0; color: #172033; font-size: 15px; }
.document-address-grid p { margin: 3px 0; color: #5a6474; }
.document-label { display: block; margin-bottom: 6px; color: #788294; font-size: 9px; font-weight: 850; letter-spacing: 0.11em; text-transform: uppercase; }
.document-meta { display: grid; gap: 7px; margin: 0; }
.document-meta div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding-bottom: 6px; border-bottom: 1px solid #e4e7ec; }
.document-meta dt { color: #788294; font-size: 10px; }
.document-meta dd { margin: 0; color: #1c2432; font-size: 11px; font-weight: 750; text-align: right; }
.document-table-wrap { overflow-x: auto; }
.document-table { table-layout: fixed; }
.document-table th, .document-table td { padding: 11px 10px; border-bottom: 1px solid #e4e7ec; font-size: 11px; }
.document-table th { color: #fff; background: var(--brand); }
.document-table th:first-child { width: 52%; text-align: left; }
.document-table td { color: #445064; }
.document-table td:first-child { color: #1c2432; }
.document-totals-section { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 40px; align-items: start; padding: 24px 0; }
.document-notes p { margin: 0; color: #5a6474; font-size: 11px; }
.document-totals { display: grid; gap: 7px; margin: 0; }
.document-totals div { display: flex; justify-content: space-between; gap: 15px; }
.document-totals dt { color: #697486; font-size: 11px; }
.document-totals dd { margin: 0; color: #1c2432; font-size: 11px; font-weight: 750; }
.document-totals .document-grand-total { margin-top: 7px; padding-top: 12px; border-top: 2px solid #1c2432; }
.document-totals .document-grand-total dt, .document-totals .document-grand-total dd { font-size: 17px; font-weight: 900; }
.document-terms { padding: 17px 0 8px; border-top: 1px solid #e4e7ec; }
.document-terms p { margin: 0; color: #697486; font-size: 10px; line-height: 1.65; }
.decision-record { margin-top: 18px; padding: 13px 15px; background: var(--success-soft); border: 1px solid #b7e3cc; border-radius: 8px; }
.decision-record.declined { background: var(--danger-soft); border-color: #f0c2c6; }
.decision-record strong { display: block; color: var(--success); font-size: 12px; }
.decision-record.declined strong { color: var(--danger); }
.decision-record span { color: #697486; font-size: 10px; }
.decision-record p { margin: 5px 0 0; font-size: 11px; }
.document-footer { display: flex; justify-content: space-between; gap: 18px; margin-top: 35px; padding-top: 13px; color: #8a93a3; border-top: 1px solid #e4e7ec; font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }

.settings-main > .panel { margin-bottom: 20px; }
.settings-sidebar { min-width: 0; }
.logo-preview { display: flex; min-height: 120px; align-items: center; justify-content: center; margin: 14px 0; padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.logo-preview img { max-height: 90px; object-fit: contain; }
.colour-field { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; }
.colour-field input { width: 38px; min-height: 28px; height: 28px; padding: 0; border: 0; }
.colour-field span { color: var(--muted); font-size: 12px; }

.print-page { padding: 20px; background: #dfe3e9; }
.print-toolbar { display: flex; justify-content: center; gap: 9px; margin-bottom: 16px; }
.print-canvas { width: min(900px, 100%); margin: 0 auto; }

.public-page { background: #edf0f5; }
.public-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 70px; padding: 13px max(20px, calc((100vw - 1000px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.public-header > div { display: flex; flex-direction: column; }
.public-header strong { color: var(--ink); }
.public-header span { color: var(--muted); font-size: 11px; }
.public-main { width: min(1000px, calc(100% - 32px)); margin: 28px auto 50px; }
.public-document-wrap { width: min(900px, 100%); margin: 0 auto; }
.public-message { display: flex; min-height: 500px; align-items: center; justify-content: center; flex-direction: column; padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.public-message p { max-width: 520px; }
.decision-panel { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1fr); gap: 35px; width: min(900px, 100%); margin: 22px auto 0; padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-small); }
.decision-panel h2 { font-size: 22px; }
.decision-form { min-width: 0; }
.decision-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.state-panel { display: block; text-align: center; }
.state-panel .badge { margin-bottom: 10px; }
.public-footer { padding: 25px; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quote-editor, .quote-view-grid { grid-template-columns: minmax(0, 1fr) 285px; }
    .item-grid { grid-template-columns: minmax(190px, 1fr) 90px 130px 110px 34px; }
    .main-content { padding-right: 26px; padding-left: 26px; }
    .quote-document { padding: 38px 38px 30px; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-102%); transition: transform 0.18s ease; box-shadow: 20px 0 40px rgba(0, 0, 0, 0.22); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(12, 18, 28, 0.48); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-main { margin-left: 0; }
    .mobile-header { position: sticky; top: 0; z-index: 20; display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 18px; background: rgba(255, 255, 255, 0.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
    .mobile-brand { max-width: calc(100% - 70px); overflow: hidden; color: var(--ink); font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
    .main-content { padding: 27px 18px 50px; }
    .dashboard-grid, .form-layout, .quote-editor, .quote-view-grid { grid-template-columns: 1fr; }
    .form-layout > .span-2 { grid-column: auto; }
    .editor-sidebar, .settings-sidebar { order: -1; }
    .sticky-panel { position: static; }
    .quote-summary-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .quote-summary-card h2, .quote-summary-card .summary-list, .quote-summary-card > .field, .quote-summary-card > .button { grid-column: span 2; }
    .quote-summary-card .compact-grid { grid-column: span 2; }
    .quote-document { padding: 32px; }
    .document-address-grid { grid-template-columns: 1fr 240px; gap: 28px; }
    .decision-panel { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    h1 { font-size: 29px; }
    .page-header { align-items: stretch; flex-direction: column; }
    .page-header > .button, .page-header .header-actions { width: 100%; }
    .header-actions { justify-content: stretch; }
    .header-actions .button { flex: 1; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 125px; }
    .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
    .field-grid .span-2 { grid-column: auto; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar > *, .search-field { width: 100%; min-width: 0; }
    .input-action-row { align-items: stretch; flex-direction: column; }
    .danger-zone { align-items: stretch; flex-direction: column; }
    .danger-zone form, .danger-zone .button { width: 100%; }
    .auth-card { padding: 25px 20px; }
    .item-grid-head { display: none; }
    .item-grid { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 17px 39px 17px 0; }
    .item-row .field:first-child { grid-column: span 2; }
    .item-row .line-total { grid-column: span 2; padding-top: 0; }
    .remove-item { position: absolute; top: 15px; right: 0; }
    .quote-document { min-height: auto; padding: 24px 20px; }
    .document-header { flex-direction: column; gap: 22px; }
    .document-company { max-width: 100%; }
    .document-title-block { align-items: flex-start; text-align: left; }
    .document-address-grid { grid-template-columns: 1fr; gap: 20px; }
    .document-totals-section { grid-template-columns: 1fr; gap: 20px; }
    .document-table { min-width: 590px; }
    .quote-document .document-table-wrap { margin-right: -20px; margin-left: -20px; }
    .quote-document .document-table th:first-child, .quote-document .document-table td:first-child { padding-left: 20px; }
    .quote-document .document-table th:last-child, .quote-document .document-table td:last-child { padding-right: 20px; }
    .public-header { align-items: flex-start; padding: 12px 16px; }
    .public-main { width: min(100% - 18px, 1000px); margin-top: 12px; }
    .decision-panel { padding: 22px 18px; }
    .decision-actions { flex-direction: column; }
    .decision-actions .button { width: 100%; }
    .print-page { padding: 5px; }
    .print-toolbar { padding-top: 8px; }
}

@media print {
    @page { size: A4; margin: 10mm; }
    html, body { background: #fff !important; }
    body { font-size: 10pt; }
    .print-toolbar, .public-header, .decision-panel, .public-footer, .alert { display: none !important; }
    .print-page, .public-page { padding: 0; }
    .print-canvas, .public-main, .public-document-wrap { width: 100%; max-width: none; margin: 0; }
    .quote-document { min-height: 0; padding: 0; border: 0; box-shadow: none; }
    .document-table-wrap { overflow: visible; }
    .document-table { min-width: 0; }
    .document-header { break-inside: avoid; }
    .document-totals-section, .document-terms, .decision-record { break-inside: avoid; }
    tr { break-inside: avoid; }
}
.hidden-form { display: none; }

/* SQL installer, staff accounts, permissions, and customer note history */
.user-chip-link { padding: 7px; margin: -7px; border-radius: 10px; }
.user-chip-link:hover, .user-chip-link.active { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.status-list .status-static { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 4px; color: var(--ink); border-bottom: 1px solid var(--line); }
.status-list .status-static:last-child { border-bottom: 0; }
.status-list .status-static > span { display: flex; align-items: center; gap: 9px; }

.customer-detail-grid { display: grid; grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.customer-quotes-panel { margin-top: 20px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; }
.detail-list > div { min-width: 0; padding: 13px 0; border-bottom: 1px solid var(--line); }
.detail-list > div:nth-last-child(-n+2) { border-bottom: 0; }
.detail-list > .full { grid-column: span 2; }
.detail-list dt { margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.detail-list dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.privacy-badge, .role-badge { display: inline-flex; align-items: center; width: fit-content; padding: 5px 9px; color: var(--info); background: var(--info-soft); border: 1px solid #c8dcf5; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.note-composer { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.staff-note-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.staff-note { padding: 15px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.staff-note-head { display: flex; align-items: center; gap: 10px; }
.staff-note-head > div { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.staff-note-head strong { font-size: 13px; }
.staff-note-head time { color: var(--muted); font-size: 11px; }
.staff-note-head form { margin-left: auto; }
.staff-note > p { margin: 11px 0 0 44px; color: var(--ink-soft); white-space: normal; overflow-wrap: anywhere; }
.small-avatar { width: 34px; height: 34px; flex-basis: 34px; color: var(--brand); background: var(--brand-soft); }
.large-avatar { width: 72px; height: 72px; flex-basis: 72px; background: var(--brand); font-size: 28px; }
.danger-text { color: var(--danger); }
.danger-text:hover { color: var(--danger); }
.empty-state.compact { min-height: 190px; padding: 26px 16px; }
.permission-denied { width: min(720px, 100%); margin: 30px auto; }

.permission-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.permission-group { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.permission-group legend { padding: 0 6px; color: var(--ink); font-size: 12px; font-weight: 850; }
.permission-row { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; color: var(--ink-soft); font-size: 12px; }
.permission-row input { width: 17px; min-height: auto; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.permission-row input:disabled + span { opacity: 0.75; }
.checkbox-row > span { display: flex; flex-direction: column; }
.checkbox-row span strong { color: var(--ink); font-size: 13px; }
.checkbox-row span small { color: var(--muted); font-size: 11px; }
.account-active-row { align-items: flex-start; padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.account-security-note { margin-top: 20px; }
.mini-details { display: grid; gap: 8px; margin: 0; }
.mini-details div { display: flex; justify-content: space-between; gap: 15px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mini-details div:last-child { border-bottom: 0; }
.mini-details dt { color: var(--muted); font-size: 11px; }
.mini-details dd { margin: 0; color: var(--ink); font-size: 11px; font-weight: 750; text-align: right; }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.55fr); gap: 20px; align-items: start; }
.account-summary-card { display: flex; align-items: center; flex-direction: column; text-align: center; }
.account-summary-card h2 { margin: 14px 0 3px; }
.account-summary-card > p { margin-bottom: 12px; }
.account-summary-card .mini-details { width: 100%; margin-top: 18px; text-align: left; }

.install-shell { width: min(760px, calc(100% - 28px)); }
.install-card { width: 100%; max-width: none; }
.install-card > p { margin-bottom: 20px; }
.install-form { display: grid; gap: 18px; }
.migration-box { padding: 15px; background: var(--info-soft); border: 1px solid #c8dcf5; border-radius: 10px; }
.migration-box .checkbox-row { align-items: flex-start; margin: 0; }
.install-requirements { display: flex; flex-direction: column; margin-top: 20px; padding-top: 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.install-requirements strong { color: var(--ink); font-size: 12px; }
.inline-notice.success { background: var(--success-soft); border-color: #b7e3cc; }
.inline-notice.success strong { color: var(--success); }

@media (max-width: 1000px) {
    .customer-detail-grid, .profile-grid { grid-template-columns: 1fr; }
    .permission-groups { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .detail-list { grid-template-columns: 1fr; }
    .detail-list > .full { grid-column: auto; }
    .detail-list > div:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
    .detail-list > div:last-child { border-bottom: 0; }
    .staff-note > p { margin-left: 0; }
    .staff-note-head { align-items: flex-start; }
}

.profile-backup-panel { margin-top: 1rem; }
.profile-backup-panel .panel-header { align-items: center; }

/* Invoice module */
.header-actions .inline-form, .table-actions .inline-form { display: inline-flex; }
.dashboard-secondary-grid { margin-top: 20px; }
.invoice-metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.compact-metric { min-height: 118px; }
.compact-metric .metric-value { font-size: 27px; }
.balance-card { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: 0 5px 20px color-mix(in srgb, var(--brand) 10%, transparent); }
.invoice-link-panel { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }
.invoice-link-panel .eyebrow { margin-bottom: 8px; }
.invoice-link-panel h2 { margin-bottom: 8px; }
.compact-details { grid-template-columns: 1fr; margin: 2px 0 16px; }
.compact-details > div, .compact-details > div:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
.compact-details > div:last-child { border-bottom: 0; }

.payment-panel { margin-top: 20px; scroll-margin-top: 22px; }
.payment-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.65fr); gap: 22px; align-items: start; padding: 22px; }
.payment-form { padding: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; }
.payment-form h3 { margin-bottom: 3px; }
.payment-form .field { margin-bottom: 0; }
.payment-panel:target { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent), var(--shadow-small); }

.invoice-document { position: relative; overflow: hidden; }
.invoice-document > * { position: relative; z-index: 1; }
.invoice-document.paid::after, .invoice-document.cancelled::after {
    position: absolute;
    z-index: 0;
    top: 42%;
    left: 50%;
    color: var(--success);
    content: "PAID";
    font-size: clamp(72px, 13vw, 138px);
    font-weight: 950;
    letter-spacing: 0.12em;
    opacity: 0.055;
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(-18deg);
    white-space: nowrap;
}
.invoice-document.cancelled::after { color: var(--danger); content: "CANCELLED"; font-size: clamp(54px, 10vw, 105px); }
.document-totals .document-balance-total { margin-top: 5px; padding-top: 11px; border-top: 2px solid var(--brand); }
.document-totals .document-balance-total dt, .document-totals .document-balance-total dd { color: #172033; font-size: 15px; font-weight: 900; }
.document-payment-instructions { margin-top: 4px; padding: 17px 0; border-top: 1px solid #e4e7ec; }
.document-payment-instructions p { margin: 0; color: #455166; font-size: 10px; line-height: 1.65; white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
    .payment-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .invoice-metric-grid { grid-template-columns: 1fr; }
    .compact-metric { min-height: 105px; }
}

@media (max-width: 680px) {
    .table-actions { flex-wrap: wrap; min-width: 122px; }
    .table-actions .button, .table-actions .inline-form, .table-actions .inline-form .button { width: 100%; }
    .payment-layout { padding: 16px; }
}

@media print {
    .invoice-document.paid::after, .invoice-document.cancelled::after { opacity: 0.075; }
    .document-payment-instructions, .document-balance-total { break-inside: avoid; }
}

/* Materials catalogue and automatic document line insertion */
.muted-text { color: var(--muted); font-size: 11px; font-weight: 700; }
.material-code { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 7px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 750; white-space: nowrap; }
.material-filters .text-link { margin-left: 2px; }
.material-status-field .checkbox-row { margin: 0; }
.material-danger-panel { margin-top: 20px; }
.danger-zone-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px; background: var(--danger-soft); border: 1px solid #f0c2c6; border-radius: 10px; }
.danger-zone-row strong { color: var(--danger); }
.danger-zone-row p { margin: 3px 0 0; font-size: 12px; }

.catalogue-picker { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 18px; padding: 15px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line)); border-radius: 11px; }
.catalogue-picker-main { min-width: 0; flex: 1; }
.catalogue-picker-main > label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
.catalogue-picker-main > small { display: block; margin-top: 7px; color: var(--ink-soft); font-size: 11px; }
.catalogue-picker-row { display: grid; grid-template-columns: minmax(240px, 1fr) 112px; gap: 9px; align-items: end; }
.catalogue-search-box { position: relative; min-width: 0; }
.catalogue-search-box input { padding-right: 34px; background: #fff; }
.catalogue-quantity-field { gap: 4px; margin: 0; }
.catalogue-quantity-field label { color: var(--ink-soft); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.catalogue-quantity-field input { text-align: right; }
.catalogue-results { position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; left: 0; max-height: 360px; overflow-y: auto; padding: 6px; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 18px 45px rgba(25, 35, 55, 0.18); }
.catalogue-results[hidden], .item-material-source[hidden] { display: none !important; }
.catalogue-result { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 10px 11px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; text-align: left; }
.catalogue-result:hover, .catalogue-result:focus-visible { background: var(--brand-soft); outline: 0; }
.catalogue-result + .catalogue-result { border-top: 1px solid var(--line); border-radius: 0; }
.catalogue-result + .catalogue-result:hover, .catalogue-result + .catalogue-result:focus-visible { border-radius: 8px; }
.catalogue-result-details, .catalogue-result-price { display: flex; min-width: 0; flex-direction: column; }
.catalogue-result-name { overflow: hidden; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.catalogue-result-meta { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.catalogue-result-price { align-items: flex-end; color: var(--ink); font-size: 12px; font-weight: 850; white-space: nowrap; }
.catalogue-result-unit { color: var(--muted); font-size: 9px; font-weight: 650; }
.catalogue-results-empty { padding: 14px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.catalogue-picker-empty { align-items: center; }
.catalogue-picker-empty > div { display: flex; min-width: 0; flex-direction: column; }
.catalogue-picker-empty strong { font-size: 12px; }
.catalogue-picker-empty span { color: var(--ink-soft); font-size: 11px; }

.item-description-field { min-width: 0; }
.item-material-source { display: flex; min-width: 0; align-items: center; gap: 7px; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.item-material-source [data-item-material-meta] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-chip { display: inline-flex; flex: 0 0 auto; align-items: center; min-height: 20px; padding: 2px 6px; color: var(--brand); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: 0.04em; text-transform: uppercase; }
.item-material-detach { flex: 0 0 auto; margin-left: auto; padding: 0; color: var(--danger); background: transparent; border: 0; font-size: 10px; font-weight: 750; }
.item-material-detach:hover { text-decoration: underline; }
.document-item-meta { display: block; margin-top: 4px; color: #7a8495; font-size: 8.5px; font-weight: 650; letter-spacing: 0.02em; }

@media (max-width: 680px) {
    .catalogue-picker, .catalogue-picker-empty { align-items: stretch; flex-direction: column; }
    .catalogue-picker > .button { width: 100%; }
    .catalogue-picker-row { grid-template-columns: 1fr; }
    .catalogue-quantity-field { width: 120px; }
    .catalogue-result { gap: 8px; padding: 10px 8px; }
    .item-row .item-description-field { grid-column: span 2; }
    .danger-zone-row { align-items: stretch; flex-direction: column; }
    .danger-zone-row .button { width: 100%; }
}

@media print {
    .document-item-meta { color: #697486; }
}

/* Bundled UK materials catalogue importer */
.catalogue-import-panel { margin-bottom: 20px; }
.catalogue-import-panel .panel-header { align-items: center; }
.catalogue-import-form { display: grid; grid-template-columns: minmax(210px, 280px) minmax(260px, 1fr) auto; gap: 18px; align-items: end; padding: 19px 22px 21px; }
.catalogue-import-form .field, .catalogue-import-form .checkbox-row { margin: 0; }
.catalogue-import-options { display: grid; gap: 6px; align-self: center; }
.catalogue-import-options small { color: var(--muted); font-size: 11px; }
.percentage-input { position: relative; }
.percentage-input input { padding-right: 34px; }
.percentage-input span { position: absolute; top: 50%; right: 12px; color: var(--muted); font-size: 12px; font-weight: 750; transform: translateY(-50%); pointer-events: none; }

@media (max-width: 900px) {
    .catalogue-import-form { grid-template-columns: 1fr 1fr; }
    .catalogue-import-form > .button { grid-column: span 2; width: 100%; }
}

@media (max-width: 680px) {
    .catalogue-import-panel .panel-header { align-items: flex-start; flex-direction: column; }
    .catalogue-import-form { grid-template-columns: 1fr; }
    .catalogue-import-form > .button { grid-column: auto; }
}

/* Staff-only material supplier and source tracking */
.materials-table { min-width: 1180px; }
.material-source-cell { min-width: 190px; }
.material-source-cell strong { display: block; color: var(--ink); font-size: 12px; }
.source-unassigned { color: var(--muted); font-size: 11px; font-style: italic; }
.source-link { display: inline-flex; margin-top: 5px; color: var(--brand); font-size: 10px; font-weight: 750; }
.material-source-section { margin: 22px 0; padding: 19px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; }
.subsection-heading { margin-bottom: 16px; }
.subsection-heading h3 { margin-bottom: 3px; font-size: 17px; }
.subsection-heading p { margin: 0; font-size: 12px; }
.catalogue-source-note { display: flex; gap: 12px; align-items: flex-start; padding: 13px 22px 16px; color: var(--ink-soft); background: #fbfcfe; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.55; }
.catalogue-source-note strong { flex: 0 0 auto; color: var(--ink); }
.catalogue-import-panel .header-actions { flex-wrap: wrap; }

@media (max-width: 680px) {
    .catalogue-source-note { flex-direction: column; gap: 4px; padding: 13px 16px 16px; }
    .material-source-section { padding: 15px; }
}

/* Appointment calendar, availability, and customer confirmations */
.appointment-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.dashboard-appointments-panel { margin-bottom: 20px; }
.calendar-panel { overflow: hidden; margin-bottom: 20px; }
.calendar-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.calendar-month-nav { display: flex; align-items: center; gap: 12px; }
.calendar-month-nav > div { min-width: 150px; text-align: center; }
.calendar-month-nav h2 { margin: 0; font-size: 23px; }
.calendar-month-nav .eyebrow { margin-bottom: 2px; }
.calendar-filters { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 10px; }
.compact-field { margin: 0; }
.compact-field label { font-size: 10px; }
.compact-field select { min-width: 155px; }
.calendar-scroll { overflow-x: auto; }
.appointment-calendar { min-width: 1040px; background: #fff; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays > div { padding: 10px 12px; color: var(--muted); background: #fbfcfe; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 850; letter-spacing: 0.08em; text-align: center; text-transform: uppercase; }
.calendar-weekdays > div:last-child { border-right: 0; }
.calendar-day { min-height: 160px; padding: 9px; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.off-month { background: #fafbfc; }
.calendar-day.off-month > * { opacity: 0.58; }
.calendar-day.today { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand) 58%, transparent); }
.calendar-day-head { display: flex; align-items: center; justify-content: space-between; min-height: 27px; margin-bottom: 5px; }
.calendar-date-number { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; color: var(--ink); border-radius: 50%; font-size: 12px; font-weight: 850; }
.calendar-day.today .calendar-date-number { color: #fff; background: var(--brand); }
.calendar-add { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; color: var(--brand); background: var(--brand-soft); border-radius: 7px; font-size: 17px; font-weight: 750; }
.calendar-add:hover { text-decoration: none; filter: brightness(0.96); }
.calendar-availability, .calendar-events { display: grid; gap: 4px; }
.calendar-availability { margin-bottom: 6px; }
.availability-chip { display: block; overflow: hidden; padding: 3px 6px; color: #275a45; background: #e9f6ef; border: 1px dashed #a7d8bf; border-radius: 5px; font-size: 9px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.calendar-appointment { display: flex; min-width: 0; flex-direction: column; padding: 5px 6px; color: var(--ink); background: var(--surface-soft); border-left: 3px solid var(--muted); border-radius: 5px; }
.calendar-appointment:hover { color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.calendar-appointment strong, .calendar-appointment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-appointment strong { font-size: 10px; }
.calendar-appointment span { color: var(--muted); font-size: 8.5px; }
.calendar-appointment.status-success { border-left-color: var(--success); }
.calendar-appointment.status-info { border-left-color: var(--info); }
.calendar-appointment.status-danger { border-left-color: var(--danger); }
.calendar-more { color: var(--muted); font-size: 9px; font-weight: 700; }
.calendar-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 12px 22px; color: var(--muted); background: #fbfcfe; font-size: 10px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; background: var(--muted); border-radius: 3px; }
.legend-swatch.availability { background: #8fcfaf; border: 1px dashed #438c68; }
.legend-swatch.success { background: var(--success); }
.legend-swatch.info { background: var(--info); }
.legend-swatch.danger { background: var(--danger); }
.upcoming-panel { margin-bottom: 20px; }

.availability-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.7fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.header-filter-form { display: flex; align-items: flex-end; }
.weekday-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.weekday-fieldset legend { margin-bottom: 8px; color: var(--ink); font-size: 12px; font-weight: 750; }
.weekday-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.weekday-option { position: relative; cursor: pointer; }
.weekday-option input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-option span { display: flex; min-height: 39px; align-items: center; justify-content: center; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; font-size: 11px; font-weight: 800; }
.weekday-option input:checked + span { color: #fff; background: var(--brand); border-color: var(--brand); }
.weekday-option input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.numbered-help { display: grid; gap: 16px; margin: 0 0 18px; padding: 0; counter-reset: help-step; list-style: none; }
.numbered-help li { position: relative; display: grid; gap: 3px; padding-left: 38px; counter-increment: help-step; }
.numbered-help li::before { position: absolute; top: 0; left: 0; display: inline-flex; width: 27px; height: 27px; align-items: center; justify-content: center; color: #fff; background: var(--brand); border-radius: 8px; content: counter(help-step); font-size: 11px; font-weight: 850; }
.numbered-help strong { color: var(--ink); font-size: 12px; }
.numbered-help span { color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.availability-list-panel { margin-bottom: 20px; }

.appointment-form-layout, .appointment-view-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.72fr); gap: 20px; align-items: start; }
.form-main-stack, .form-side-stack, .appointment-main-stack, .appointment-side-stack { display: grid; gap: 20px; min-width: 0; }
.page-notice { margin-bottom: 20px; }
.availability-picker { margin-top: 20px; padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; }
.availability-picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.availability-picker-head > div { display: grid; gap: 2px; }
.availability-picker-head strong { color: var(--ink); font-size: 12px; }
.availability-picker-head span { color: var(--muted); font-size: 10px; }
.availability-options { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.availability-options-empty { width: 100%; padding: 11px 12px; color: var(--muted); background: #fff; border: 1px dashed var(--line-strong); border-radius: 8px; font-size: 11px; }
.availability-option-button { display: flex; min-width: 150px; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; text-align: left; }
.availability-option-button:hover, .availability-option-button.selected { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }
.availability-option-time { font-size: 12px; font-weight: 850; }
.availability-option-label { color: var(--muted); font-size: 9px; }
.prose-block { color: var(--ink-soft); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }

.appointment-summary-card { overflow: hidden; }
.appointment-summary-band { display: flex; align-items: center; gap: 20px; padding: 26px; color: #fff; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #111827)); }
.appointment-date-tile { display: flex; width: 82px; min-height: 94px; flex: 0 0 82px; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); background: #fff; border-radius: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.17); }
.appointment-date-tile span { color: var(--brand); font-size: 11px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.appointment-date-tile strong { font-size: 36px; line-height: 1; }
.appointment-date-tile small { color: var(--muted); font-size: 10px; }
.appointment-summary-copy .eyebrow { color: rgba(255,255,255,0.78); }
.appointment-summary-copy h2 { margin-bottom: 5px; color: #fff; font-size: clamp(24px, 3vw, 33px); }
.appointment-summary-copy p { margin: 0; color: rgba(255,255,255,0.82); }
.appointment-details { padding: 5px 22px 12px; }
.customer-response-card.accepted { border-color: #aad9c0; }
.customer-response-card.declined { border-color: #efbcc1; }
.appointment-side-stack .form-panel form + form, .appointment-side-stack .form-panel .button + form { margin-top: 9px; }

.public-company-brand { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; }
.public-company-brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; }
.public-company-brand > span { display: flex; flex-direction: column; }
.public-company-brand small { color: var(--muted); font-size: 11px; }
.appointment-public-main { width: min(820px, calc(100% - 32px)); }
.public-appointment-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.public-appointment-top { padding: 30px 34px 24px; border-bottom: 1px solid var(--line); }
.public-appointment-top .badge { float: right; margin-left: 15px; }
.public-appointment-top h1 { margin: 5px 0 8px; }
.public-appointment-top p { margin: 0; }
.public-schedule-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.public-schedule-date { display: flex; min-height: 250px; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: #fff; background: var(--brand); text-align: center; }
.public-schedule-date span { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.public-schedule-date strong { margin: 6px 0; font-size: 76px; line-height: 0.92; }
.public-schedule-date b { font-size: 14px; }
.public-appointment-details { display: grid; margin: 0; padding: 24px 30px; }
.public-appointment-details > div { display: grid; grid-template-columns: 115px minmax(0, 1fr); gap: 15px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.public-appointment-details > div:last-child { border-bottom: 0; }
.public-appointment-details dt { color: var(--muted); font-size: 11px; font-weight: 750; }
.public-appointment-details dd { margin: 0; color: var(--ink); font-size: 14px; font-weight: 750; overflow-wrap: anywhere; }
.public-appointment-message { padding: 22px 34px 27px; background: var(--surface-soft); border-top: 1px solid var(--line); }
.public-appointment-message strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 12px; }
.public-appointment-message p { margin: 0; color: var(--ink-soft); line-height: 1.65; }
.appointment-decision-panel { margin-top: 20px; }
.public-response-note { max-width: 560px; margin: 16px auto 0; padding: 13px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; text-align: left; }
.public-response-note strong { color: var(--ink); font-size: 11px; }
.public-response-note p { margin: 4px 0 0; }
.public-contact-card { margin-top: 18px; padding: 20px 24px; background: #fff; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.public-contact-card h2 { font-size: 16px; }
.public-contact-card p { margin: 0; }

@media (max-width: 1100px) {
    .appointment-form-layout, .appointment-view-grid { grid-template-columns: 1fr; }
    .form-side-stack .sticky-panel { position: static; }
}

@media (max-width: 900px) {
    .appointment-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calendar-toolbar { align-items: stretch; flex-direction: column; }
    .calendar-filters { justify-content: flex-start; }
    .availability-layout { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .appointment-metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .appointment-metric-grid .metric-card { min-height: 104px; padding: 15px; }
    .appointment-metric-grid .metric-value { font-size: 25px; }
    .calendar-month-nav { flex-wrap: wrap; }
    .calendar-month-nav > div { order: -1; width: 100%; text-align: left; }
    .calendar-filters { display: grid; grid-template-columns: 1fr; }
    .compact-field select { width: 100%; min-width: 0; }
    .weekday-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .availability-picker-head { flex-direction: column; }
    .availability-option-button { width: 100%; }
    .appointment-summary-band { align-items: flex-start; padding: 20px; }
    .appointment-date-tile { width: 67px; min-height: 80px; flex-basis: 67px; }
    .appointment-date-tile strong { font-size: 29px; }
    .appointment-summary-copy h2 { font-size: 23px; }
    .public-appointment-top { padding: 23px 20px 20px; }
    .public-appointment-top .badge { float: none; margin: 0 0 12px; }
    .public-schedule-grid { grid-template-columns: 1fr; }
    .public-schedule-date { min-height: 175px; }
    .public-schedule-date strong { font-size: 60px; }
    .public-appointment-details { padding: 16px 20px; }
    .public-appointment-details > div { grid-template-columns: 1fr; gap: 3px; padding: 11px 0; }
    .public-appointment-message { padding: 19px 20px 22px; }
}

@media print {
    .public-appointment-page .public-header, .public-appointment-page .decision-panel, .public-appointment-page .public-contact-card, .public-appointment-page .public-footer, .public-appointment-page .alert { display: none !important; }
    .public-appointment-page .public-main { width: 100%; max-width: none; margin: 0; }
    .public-appointment-card { box-shadow: none; }
}
