﻿h1:focus {
    outline: none;
}

[hidden] {
    display: none !important;
}

.valid.modified:not([type=checkbox]), .valid.modified:not([type=radio]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ============================================
   ANB Build Estimator - Base CSS
   Shared styles and CSS custom properties
   ============================================ */

/* ----- CSS Reset & Base ----- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 1rem 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-heading);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin: 0 0 1rem 0;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ----- Layout Components ----- */
.app-container {
    --header-height: 5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: color-mix(in srgb, var(--primary-color) 4%, var(--sidebar-bg));
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    z-index: 1000;
    transition: all 0.3s ease;
}

[data-sidebar-minimized] .sidebar {
    width: 70px;
    min-width: 70px;
}

[data-sidebar-minimized] .sidebar .sidebar-brand,
[data-sidebar-minimized] .sidebar .nav-item span,
[data-sidebar-minimized] .sidebar .nav-section-title,
[data-sidebar-minimized] .sidebar .user-info {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
}

[data-sidebar-minimized] .sidebar .nav-item {
    justify-content: center;
    padding: 0.875rem 0.5rem;
}

[data-sidebar-minimized] .sidebar .user-menu {
    justify-content: center;
    padding: 0.5rem;
}

[data-sidebar-minimized] .sidebar .sidebar-footer {
    display: flex;
    justify-content: center;
    padding: 1rem 0.5rem;
}

[data-sidebar-minimized] .sidebar .theme-toggle {
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
    width: fit-content;
    padding: 0.25rem;
    margin: 0 auto;
}

[data-sidebar-minimized] .sidebar .theme-toggle-btn {
    width: 36px;
    height: 36px;
}

[data-sidebar-minimized] .sidebar .theme-toggle-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-hint {
    position: relative;
}

[data-sidebar-minimized] .sidebar .sidebar-hint::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    left: calc(100% + 0.75rem);
    transform: translateY(-50%);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    font-size: 0.8125rem;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1100;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

[data-sidebar-minimized] .sidebar .sidebar-hint:hover::after,
[data-sidebar-minimized] .sidebar .sidebar-hint:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0.25rem 0 0.75rem;
}

.nav-section + .nav-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
    margin: 0 0 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--nav-section-color, var(--primary-color));
}

.nav-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: color-mix(in srgb, var(--nav-section-color, var(--primary-color)) 30%, transparent);
}

.nav-section-title-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

[data-sidebar-minimized] .sidebar .nav-section-title {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background-color: var(--nav-active-bg);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.nav-item.active .nav-item-icon {
    opacity: 1;
}

.nav-submenu {
    background-color: var(--submenu-bg);
}

.nav-submenu .nav-item {
    padding-left: 3.5rem;
    font-size: 0.875rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content {
    flex: 1;
    /* A flex item defaults to min-width: auto, which refuses to shrink below its content's
       min-content width — one wide table or filter rail then stretches the shell past the
       viewport and the whole page scrolls sideways. Pinning it to 0 keeps the shell at
       viewport width so the inner scroll containers (.table-container, .tabs) do the
       scrolling instead. */
    min-width: 0;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* Same reasoning one level down: .page-content is a column-flex item whose block children
   (tables, grids) must not be able to widen it. */
.page-content {
    min-width: 0;
    max-width: 100%;
}

[data-sidebar-minimized] .sidebar ~ .main-content {
    margin-left: 70px;
}

/* Top Header Bar */
.top-header {
    height: var(--header-height);
    background-color: color-mix(in srgb, var(--primary-color) 7%, var(--header-bg));
    border-bottom: 2px solid color-mix(in srgb, var(--primary-color) 55%, var(--border-color));
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1001;
}

.header-left {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    width: calc(260px - 1rem);
}

.header-wordmark {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    white-space: nowrap;
    color: var(--text-heading);
}

.header-wordmark-accent {
    color: var(--primary-color);
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.menu-toggle:hover {
    background-color: var(--nav-hover-bg);
}

.sidebar-toggle {
    position: absolute;
    top: 1.5rem;
    right: -15px;
    width: 30px;
    height: 30px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
    background-color: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.sidebar-toggle i {
    transition: transform 0.3s ease;
}

[data-sidebar-minimized] .sidebar .sidebar-toggle i {
    transform: rotate(180deg);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
}

.header-right {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    gap: 1rem;
}

/* The login CTA is a flex item next to the search box; letting it shrink breaks its
   label onto two lines long before the header actually runs out of room. */
.header-right > .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.search-box {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.search-input {
    /* Matches the height of a .btn: 0.75rem vertical padding + a 0.9375rem
       1.6 line-height, all in rem so both scale together at smaller roots. */
    height: 3rem;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.global-search {
    margin: 0;
}

.icon-btn.global-search-toggle {
    display: none;
    flex-shrink: 0;
}

/* Visibility switches at once rather than after the fade, so the input can take focus in the same tap
   that opened the modal (iOS only raises the keyboard inside the tap). */
.modal-overlay.global-search-modal {
    transition: opacity 0.3s ease;
}

/* In the modal the results sit under the input in the modal body rather than floating over the page */
.global-search-modal .global-search-results {
    position: static;
    min-width: 0;
    max-height: none;
    margin-top: 0.75rem;
    box-shadow: none;
}

/* The form grows with the results below the input, so centre the icon on the 3rem input rather than the form */
.global-search-modal .search-icon {
    top: 1.5rem;
}

/* The native clear button duplicates Escape and sits under the dropdown's edge */
.global-search .search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.global-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1100;
    min-width: 320px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    padding: 0.25rem 0;
    transition: opacity 0.15s ease;
}

.global-search-results.is-loading {
    opacity: 0.6;
}

.global-search-empty {
    margin: 0;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.global-search-group + .global-search-group {
    border-top: 1px solid var(--border-color);
}

.global-search-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 1rem 0.125rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.global-search-count {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.global-search-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}

.global-search-option svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.global-search-option:hover,
.global-search-option.is-active {
    background-color: var(--secondary-color-light);
    color: var(--text-primary);
}

.global-search-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.global-search-title,
.global-search-context {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-title {
    font-size: 0.875rem;
}

.global-search-context {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.global-search-all {
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--primary-color);
}

.search-keywords-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}

.search-keywords-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-color);
}

.search-keywords-item > span:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.search-keywords-add {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-keywords-add .form-input {
    flex: 1 1 14rem;
}

.search-keywords-add .form-select {
    flex: 0 1 14rem;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-results-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.search-results-heading h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.125rem;
}

.search-results-heading svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-results-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-results-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.search-results-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
}

.search-results-list li:last-child .search-results-item {
    border-bottom: 0;
}

.search-results-item:hover .search-results-title {
    color: var(--primary-color);
}

.search-results-context {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.icon-btn:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

.icon-btn .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background-color: var(--danger-color);
    border-radius: 50%;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-menu:hover {
    background-color: var(--nav-hover-bg);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-avatar--xs {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
    background-color: var(--bg-primary);
}

/* ----- Cards ----- */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--card-shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-body {
    color: var(--text-primary);
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Stat Cards */
.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.stat-card-icon.blue { background-color: var(--primary-color-light); color: var(--primary-color); }
.stat-card-icon.green { background-color: var(--success-color-light); color: var(--success-color); }
.stat-card-icon.orange { background-color: var(--warning-color-light); color: var(--warning-color); }
.stat-card-icon.red { background-color: var(--danger-color-light); color: var(--danger-color); }

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}

.stat-change {
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive { color: var(--success-color); }
.stat-change.negative { color: var(--danger-color); }

/* ----- Grid System ----- */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn:hover {
    text-decoration: none;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 1.75rem;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: var(--on-primary);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
    color: white;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: var(--warning-hover);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

.btn-outline-primary {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

.btn-ghost-danger {
    background-color: transparent;
    color: var(--danger-color);
}

.btn-ghost-danger:hover:not(:disabled) {
    background-color: var(--danger-color-light);
    color: var(--danger-hover);
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--danger-color);
    margin-left: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger-color);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
    box-shadow: 0 0 0 3px var(--danger-color-alpha);
}

.form-helper,
.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.autocomplete-suggestions {
    position: absolute;
    z-index: 1000;
    width: 100%;
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.autocomplete-suggestion {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-suggestion:last-child {
    border-bottom: 0;
}

.autocomplete-suggestion:hover {
    background-color: var(--secondary-color-light);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--danger-color);
    margin-top: 0.375rem;
}

.phone-field-row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.phone-field-row .form-input {
    flex: 1 1 auto;
    min-width: 0;
}

.phone-field-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

[data-phone-field] .form-hint:last-child,
[data-phone-field] .form-error:last-child {
    margin-bottom: 0;
}

@media (max-width: 380px) {
    .phone-field-row {
        flex-direction: column;
    }
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* type="search" carries WebKit's searchfield appearance, which draws its own box and clear
   button and disregards the author padding a field reserves for an overlaid icon — the
   magnifying glass then sits outside the control instead of inside it. Desktop engines honour
   the padding, so this only shows up on mobile Safari. Reset it everywhere rather than per
   page: every search field in the app overlays its own icon. */
input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
}

.form-check-input {
    width: 20px;
    height: 20px;
    border: 2px solid var(--input-border);
    border-radius: 4px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.form-check-input[type="radio"] {
    border-radius: 50%;
}

.form-check-label {
    font-size: 0.9375rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Input Group */
.input-group {
    display: flex;
}

.input-group .form-input {
    flex: 1;
}

.input-group-prepend,
.input-group-append {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background-color: var(--input-addon-bg);
    border: 2px solid var(--input-border);
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.input-group-prepend {
    border-right: none;
    border-radius: 8px 0 0 8px;
}

.input-group-append {
    border-left: none;
    border-radius: 0 8px 8px 0;
}

.input-group .form-input:first-child {
    border-radius: 8px 0 0 8px;
}

.input-group .form-input:last-child {
    border-radius: 0 8px 8px 0;
}

/* ----- Tables ----- */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--table-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--table-border);
}

.table th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    background-color: var(--table-row-bg);
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: var(--table-row-hover);
}

.table tbody tr:nth-child(even) {
    background-color: var(--table-row-alt);
}

.table tbody tr:nth-child(even):hover {
    background-color: var(--table-row-hover);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-container--flush {
    border: none;
    border-radius: 0;
}

/* ----- Row actions -----
   A bar of bare icon buttons makes every row guess what a pencil or a receipt does, and three
   of them repeated down the table reads as clutter. Instead one named button carries the action
   the row is actually for, and the rest fold into a labelled overflow menu.

   Naming the action costs contrast, so the button sits in muted type until the row is hovered
   or something inside takes focus — present enough to find, quiet enough to scan past. */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
}

.row-actions__primary {
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
}

tr:hover .row-actions__primary,
.row-actions__primary:hover,
.row-actions__primary:focus-visible {
    border-color: var(--primary-color);
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.row-actions__more {
    padding: 0.375rem;
    color: var(--text-muted);
}

tr:hover .row-actions__more,
.row-actions__more:hover,
.row-actions__more:focus-visible,
.dropdown.active .row-actions__more {
    color: var(--text-primary);
}

/* Without hover there is no second state to reveal, so the action leads in colour from the
   start rather than staying permanently muted. */
@media (hover: none) {
    .row-actions__primary {
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .row-actions__more {
        color: var(--text-secondary);
    }
}

/* ----- Badges & Tags ----- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.material-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.material-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--primary-color);
    border-radius: 999px;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.material-filter-pill:hover {
    background-color: var(--primary-color-alpha);
}

.material-filter-pill:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.badge-primary { background-color: var(--primary-color-light); color: var(--primary-color); }
.badge-success { background-color: var(--success-color-light); color: var(--success-color); }
.badge-warning { background-color: var(--warning-color-light); color: var(--warning-color); }
.badge-danger { background-color: var(--danger-color-light); color: var(--danger-color); }
.badge-secondary { background-color: var(--secondary-color-light); color: var(--text-secondary); }

/* Status badges */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 6px;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-draft { background-color: var(--secondary-color-light); color: var(--text-secondary); }
.status-draft::before { background-color: var(--text-muted); }

.status-pending { background-color: var(--warning-color-light); color: var(--warning-color); }
.status-pending::before { background-color: var(--warning-color); }

.status-sent { background-color: var(--primary-color-light); color: var(--primary-color); }
.status-sent::before { background-color: var(--primary-color); }

.status-approved { background-color: var(--success-color-light); color: var(--success-color); }
.status-approved::before { background-color: var(--success-color); }

.status-rejected { background-color: var(--danger-color-light); color: var(--danger-color); }
.status-rejected::before { background-color: var(--danger-color); }

/* ----- Listing cards ----- */
.listing-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.listing-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "main aside"
        "foot foot";
    column-gap: 1.5rem;
    border: 1px solid var(--card-border, var(--border-color));
    border-radius: 10px;
    background-color: var(--card-bg);
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.listing-card:hover {
    border-color: color-mix(in srgb, var(--primary-color) 45%, var(--border-color));
    box-shadow: var(--card-hover-shadow);
    text-decoration: none;
}

.listing-card.is-urgent {
    box-shadow: inset 3px 0 0 var(--danger-color);
}

.listing-card.is-urgent:hover {
    box-shadow: inset 3px 0 0 var(--danger-color), var(--card-hover-shadow);
}

.listing-card-main {
    grid-area: main;
    min-width: 0;
    padding: 1rem 0 0.875rem 1.25rem;
}

.listing-card-eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.875rem;
    margin-bottom: 0.375rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.listing-card-eyebrow:empty {
    display: none;
}

.listing-card-eyebrow > span {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.listing-card-eyebrow svg {
    width: 13px;
    height: 13px;
}

.listing-card .status {
    padding: 0;
    border-radius: 0;
    background-color: transparent;
    font-size: inherit;
    font-weight: inherit;
}

.listing-card .status::before {
    width: 6px;
    height: 6px;
}

.listing-card-title {
    margin: 0;
    color: var(--text-heading);
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.35;
}

.listing-card-snippet {
    display: -webkit-box;
    margin: 0.375rem 0 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: pre-line;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.listing-card-aside {
    grid-area: aside;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
    padding: 1rem 1.25rem 0.875rem 0;
    text-align: right;
}

.listing-card-aside:empty {
    padding: 0;
}

.listing-card-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.listing-card-figure {
    color: var(--text-heading);
    font-size: 1.125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.listing-card-note {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.listing-card-note.is-urgent {
    color: var(--danger-color);
    font-weight: 600;
}

.listing-card-note svg {
    width: 14px;
    height: 14px;
}

.listing-card-foot {
    grid-area: foot;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 1.25rem;
    padding: 0.625rem 1.25rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.listing-card-foot > span {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.listing-card-foot svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.listing-card-foot-end {
    margin-left: auto;
}

@media (max-width: 576px) {
    .listing-card {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "main"
            "aside"
            "foot";
    }

    .listing-card-main {
        padding-right: 1.25rem;
    }

    .listing-card-aside {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.25rem 0.625rem;
        padding: 0 1.25rem 0.875rem;
        text-align: left;
    }

    .listing-card-note {
        margin-top: 0;
    }

    .listing-card-foot-end {
        margin-left: 0;
    }
}

/* ----- Alerts ----- */
.alert {
    --alert-tone: var(--primary-color);
    --alert-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    border: 1px solid color-mix(in srgb, var(--alert-tone) 22%, var(--border-color));
    border-radius: 10px;
    background-color: color-mix(in srgb, var(--alert-tone) 7%, var(--card-bg));
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.alert:not(:has(.alert-icon, .message-alert-icon))::before {
    content: "";
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 0.1875rem;
    background-color: var(--alert-tone);
    -webkit-mask: var(--alert-glyph) center / contain no-repeat;
    mask: var(--alert-glyph) center / contain no-repeat;
}

.alert-icon,
.alert .message-alert-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 0.1875rem;
    color: var(--alert-tone);
}

.alert .message-alert-icon svg {
    width: 18px;
    height: 18px;
}

.alert strong,
.alert-title {
    color: color-mix(in srgb, var(--alert-tone) 45%, var(--text-heading));
}

.alert a:not(.btn) {
    color: color-mix(in srgb, var(--alert-tone) 70%, var(--text-heading));
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--alert-tone) 40%, transparent);
    text-underline-offset: 2px;
}

.alert a:not(.btn):hover {
    text-decoration-color: currentColor;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    margin: 0 0 0.125rem;
    font-weight: 600;
}

.alert-message {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.alert-close {
    margin: -0.125rem -0.25rem 0 auto;
    padding: 0.25rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.alert-close:hover {
    background-color: color-mix(in srgb, var(--alert-tone) 12%, transparent);
    color: var(--text-heading);
}

.alert-success {
    --alert-tone: var(--success-color);
    --alert-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
}

.alert-warning {
    --alert-tone: var(--warning-color);
    --alert-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

.alert-danger {
    --alert-tone: var(--danger-color);
    --alert-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E");
}

/* ----- Toasts ----- */
.toast-region {
    position: fixed;
    top: 1rem;
    left: 50%;
    z-index: 2500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    width: min(26rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    --toast-accent: var(--primary-color);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 100%;
    pointer-events: auto;
    touch-action: pan-y;
    animation: toast-in 0.42s cubic-bezier(0.21, 1.02, 0.73, 1) backwards;
}

.toast p {
    margin: 0;
}

.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background-color: var(--toast-accent);
    color: #ffffff;
}

.toast-icon svg {
    width: 1rem;
    height: 1rem;
}

.toast-quick {
    --toast-accent: var(--success-color);
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.125rem 0.5rem 0.5rem;
    border-radius: 1.375rem;
    background-color: var(--text-heading);
    color: var(--bg-primary);
    box-shadow: var(--modal-shadow);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
}

.toast-quick .toast-icon {
    width: 1.625rem;
    height: 1.625rem;
}

.toast-card {
    width: 100%;
    padding: 0.875rem 0.75rem 1rem 0.875rem;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--toast-accent) 30%, var(--card-border));
    border-radius: 14px;
    background-color: var(--card-bg);
    box-shadow: var(--modal-shadow), 0 0 0 4px color-mix(in srgb, var(--toast-accent) 10%, transparent);
    color: var(--text-primary);
}

.toast-success { --toast-accent: var(--success-color); }
.toast-warning { --toast-accent: var(--warning-color); }
.toast-error { --toast-accent: var(--danger-color); }

.toast-error {
    animation: toast-in 0.42s cubic-bezier(0.21, 1.02, 0.73, 1) backwards, toast-nudge 0.4s ease-in-out 0.45s;
}

.toast-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    padding-top: 0.1875rem;
}

.toast-title {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.35;
}

.toast-card .toast-message {
    font-size: 0.9375rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.toast-title + .toast-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.toast-action {
    align-self: flex-start;
    margin-top: 0.375rem;
    color: var(--toast-accent);
    font-size: 0.875rem;
    font-weight: 600;
}

.toast-close {
    display: inline-flex;
    flex-shrink: 0;
    padding: 0.25rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.toast-close:hover,
.toast-close:focus-visible {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

.toast-close svg {
    width: 1rem;
    height: 1rem;
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background-color: var(--toast-accent);
    transform-origin: left;
    animation: toast-countdown var(--toast-duration) linear forwards;
}

.toast-paused .toast-progress {
    animation-play-state: paused;
}

.toast-leaving {
    animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-0.75rem) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(-0.5rem) scale(0.96); }
}

@keyframes toast-nudge {
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes toast-countdown {
    to { transform: scaleX(0); }
}

/* Must-read alert */
.toast-alert {
    --toast-accent: var(--primary-color);
    width: min(26rem, calc(100vw - 2rem));
    padding: 1.75rem 1.5rem 1.5rem;
    border: none;
    border-top: 4px solid var(--toast-accent);
    border-radius: 16px;
    background-color: var(--modal-bg);
    box-shadow: var(--modal-shadow);
    color: var(--text-primary);
    text-align: center;
    animation: toast-alert-in 0.3s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast-alert::backdrop {
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    animation: toast-fade 0.3s ease;
}

.toast-alert-success { --toast-accent: var(--success-color); }
.toast-alert-warning { --toast-accent: var(--warning-color); }
.toast-alert-error { --toast-accent: var(--danger-color); }

.toast-alert .toast-icon {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--toast-accent) 15%, transparent);
}

.toast-alert .toast-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.toast-alert-title {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.toast-alert-message {
    margin: 0 0 1.5rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.toast-alert-button {
    width: 100%;
}


@keyframes toast-alert-in {
    from { opacity: 0; transform: translateY(1rem) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast-error,
    .toast-leaving,
    .toast-alert,
    .toast-alert::backdrop {
        animation-duration: 0.01ms;
        animation-delay: 0s;
    }

    .toast-progress {
        display: none;
    }
}

/* ----- Modals ----- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--modal-bg);
    border-radius: 16px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--modal-shadow);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

/* Width tiers, set by Modal.Size. */
.modal-small { max-width: 420px; }
.modal-medium { max-width: 560px; }
.modal-large { max-width: 760px; }
.modal-extralarge { max-width: 1040px; }

.modal-overlay.active .modal {
    transform: none;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-header,
.modal-footer {
    flex-shrink: 0;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ----- Pagination ----- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    max-width: 100%;
}

.pagination-btn {
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--nav-hover-bg);
    border-color: var(--primary-color);
}

.pagination-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}

.pagination-btn.active:hover {
    color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ----- Breadcrumbs ----- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.breadcrumb-item {
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-muted);
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

/* ----- Tabs ----- */
/* The strip and its active panel share one card shell so they read as a single control
   rather than a floating row of labels above an unrelated card. */
.tab-group {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    /* the shell and every box inside it must be allowed to shrink, or a wide table would
       widen the shell instead of scrolling inside its own .table-container */
    min-width: 0;
}

.tabs {
    display: flex;
    flex-wrap: nowrap;
    /* A tab strip that outgrows its container scrolls itself rather than widening the page.
       overflow-y must be hidden explicitly: setting only overflow-x resolves the other axis
       to auto, which would add a stray vertical scrollbar. */
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    /* The rule is an inset shadow rather than a border because the active tab's underline sits
       in the same 2px band; as a border on the scrolling box it would be clipped away. */
    box-shadow: inset 0 -2px 0 var(--border-color);
    margin-bottom: 1.5rem;
    /* the tabs are visibly cut off at the edge, which is the scroll affordance */
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
}

button.tab {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.tabs-action {
    flex: 0 0 auto;
    align-self: center;
    margin-left: 0.25rem;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* A disabled tab stays in the strip so the section is still discoverable, but it reads as
   unavailable and cannot be selected. */
.tab.disabled,
.tab.disabled:hover {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: not-allowed;
}

/* Inside the shell the strip becomes the component's own header band: it loses the outer
   gap, gains a tint to separate it from the panel, and inherits the shell's corners. */
.tab-group > .tabs {
    background-color: var(--table-header-bg);
    padding: 0 0.5rem;
    margin-bottom: 0;
    box-shadow: inset 0 -2px 0 var(--card-border);
    /* the strip rounds itself instead of the shell clipping it, so panel content stays free
       to overflow the shell (dropdowns, popovers) */
    border-radius: 11px 11px 0 0;
}

.tab-panel,
.tab-panel-body {
    min-width: 0;
}

.tab-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-panel-body {
    padding: 1.5rem;
    color: var(--text-primary);
}

/* A panel whose body is its last child should not double the shell's bottom inset with a
   trailing margin from whatever it renders. */
.tab-panel-body > :last-child {
    margin-bottom: 0;
}

/* ----- Empty States ----- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-heading);
}

.empty-state-message {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ----- Loading States ----- */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 50%, var(--skeleton-base) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ----- Tooltips ----- */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    font-size: 0.8125rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    margin-bottom: 0.5rem;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ----- Dropdown ----- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background-color: var(--dropdown-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--dropdown-shadow);
    padding: 0.5rem 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* dropdownManager lifts an open menu into the top layer so table containers cannot clip it.
   The UA popover styles centre the element in the viewport; these hand positioning back to
   the inline coordinates the manager sets. */
.dropdown-menu:popover-open {
    /* Fixed, not absolute: a top-layer element resolves absolute offsets against the document
       origin, so the viewport coordinates the manager measures would be off by the scroll. */
    position: fixed;
    inset: auto;
    margin: 0;
    width: auto;
    height: auto;
    overflow: visible;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    /* menu entries are <button> as often as <a>, so neutralise the button defaults */
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-family: inherit;
}

a.dropdown-item {
    text-decoration: none;
}

.dropdown-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dropdown-item:hover {
    background-color: var(--nav-hover-bg);
}

.dropdown-item--danger {
    color: var(--danger-color);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.split-button {
    display: inline-flex;
}

.split-button__main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.split-button__toggle {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: inset 1px 0 0 color-mix(in srgb, var(--on-primary) 35%, transparent);
}

/* ----- Material Cards ----- */
.material-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.material-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
}

.material-card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background-color: var(--skeleton-base);
}

.material-card-body {
    padding: 1rem;
}

.material-card-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.material-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.material-card-vendor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.material-card-vendor-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    background-color: var(--skeleton-base);
    flex-shrink: 0;
}

.material-card-vendor-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.material-card-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.material-card-unit {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 400;
}

.material-card-media {
    position: relative;
}

.material-card-promo-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
}

.material-card-was {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 0.375rem;
}

.material-card-promo-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----- Estimate Card ----- */
.estimate-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow 0.2s ease;
}

.estimate-card:hover {
    box-shadow: var(--card-hover-shadow);
}

.estimate-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.estimate-card-content {
    flex: 1;
    min-width: 0;
}

.estimate-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.estimate-card-client {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.estimate-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.estimate-card-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-heading);
    text-align: right;
}

/* ----- Category Grid ----- */
.category-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--primary-color);
}

.category-card-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.category-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.category-card-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ----- Theme Toggle ----- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    background-color: var(--toggle-bg);
}

.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn.active {
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.theme-toggle-btn:hover:not(.active) {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
}

/* ----- Settings Shell (sub-navigation + body) ----- */
.settings-shell {
    display: grid;
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.settings-nav .nav-item {
    border-left: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.settings-nav .nav-item.active {
    border-left-color: transparent;
}

.settings-body {
    min-width: 0;
}

@media (max-width: 992px) {
    .settings-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    /* the rail becomes a horizontally scrolling tab strip */
    .settings-nav .card {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .settings-nav .card::-webkit-scrollbar {
        display: none;
    }

    .settings-nav .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* ============================================
   Responsive

   The breakpoint scale for the whole application. Use only these four values,
   always as max-width (the design system is desktop-first):

     1200px  xl  - wide desktop
      992px  lg  - small desktop / landscape tablet
      768px  md  - tablet; the sidebar becomes an off-canvas drawer here
      576px  sm  - phone; tables card-stack and modals become full-screen sheets

   Page-level <style> blocks and scoped .razor.css must reuse these values
   rather than introducing new ones.
   ============================================ */

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .material-active-filters {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        /* the sidebar is overlaid rather than in flow here */
        margin-left: 0;
    }

    [data-sidebar-minimized] .sidebar ~ .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    /* Minimizing is meaningless once the sidebar is an off-canvas drawer, and the button
       hangs 15px past the sidebar's right edge — with the drawer translated off-screen
       that half-circle still pokes into the viewport. */
    .sidebar-toggle {
        display: none;
    }

    /* Everything shares a single row: the menu toggle, the search box and the
       login CTA. The page title is hidden to make room, and the search input
       grows into the leftover space while actions and the CTA keep their
       intrinsic width. */
    .top-header {
        gap: 0.5rem;
    }

    .header-left {
        flex-shrink: 0;
    }

    .page-title {
        display: none;
    }

    .header-brand {
        width: auto;
    }

    .header-wordmark {
        font-size: 1.375rem;
    }

    .header-right {
        flex: 1 1 auto;
        min-width: 0;
        gap: 0.5rem;
    }

    /* Grows into the leftover row space; min-width: 0 lets it shrink past the input's
       default intrinsic width instead of pushing its neighbours out. */
    .search-box {
        flex: 1 1 auto;
        min-width: 0;
    }

    .search-input {
        width: 100%;
    }

    /* Full width under the header, with the page gutter, rather than as wide as the shrunken box */
    .global-search-results {
        position: fixed;
        top: auto;
        left: 1rem;
        right: 1rem;
        min-width: 0;
        margin-top: 0.5rem;
    }

    .user-menu {
        padding: 0.25rem;
    }

    .user-info {
        display: none;
    }

    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    html {
        font-size: 14px;
    }

    .page-content {
        padding: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .header-right {
        gap: 0.25rem;
        justify-content: flex-end;
    }

    /* The wordmark keeps its full width on a phone; the search box gives up its room
       to a magnifying glass button that opens the search in a modal. */
    .top-header .global-search {
        display: none;
    }

    .icon-btn.global-search-toggle {
        display: flex;
    }

    .grid-4 { grid-template-columns: 1fr; }

    .table-container {
        font-size: 0.875rem;
    }

    .table th,
    .table td {
        padding: 0.75rem;
    }

    /* Modals become full-screen sheets: a centred 90%-wide card wastes the little
       space a phone has, and long forms need the whole viewport to scroll in. */
    .modal-overlay {
        align-items: stretch;
        justify-content: stretch;
    }

    .modal,
    .modal-small,
    .modal-medium,
    .modal-large,
    .modal-extralarge {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    /* stacked, full-width footer buttons — side-by-side they get too narrow to hit */
    .modal-footer {
        display: flex;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ----- Utility Classes ----- */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: var(--success-color) !important; }
.bg-warning { background-color: var(--warning-color) !important; }
.bg-danger { background-color: var(--danger-color) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.mr-1 { margin-right: 0.5rem !important; }
.mr-2 { margin-right: 1rem !important; }
.ml-1 { margin-left: 0.5rem !important; }
.ml-2 { margin-left: 1rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.5rem !important; }
.p-2 { padding: 1rem !important; }
.p-3 { padding: 1.5rem !important; }
.p-4 { padding: 2rem !important; }

.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }

.align-center { align-items: center !important; }
.align-start { align-items: start !important; }
.align-end { align-items: end !important; }
.justify-between { justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.justify-end { justify-content: flex-end !important; }

.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }
.gap-3 { gap: 1.5rem !important; }
.gap-4 { gap: 2rem !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

.fs-sm { font-size: 0.875rem !important; }
.fs-md { font-size: 1rem !important; }
.fs-lg { font-size: 1.125rem !important; }

.text-muted-sm { color: var(--text-muted) !important; font-size: 0.875rem !important; }

.rounded { border-radius: 8px !important; }
.rounded-lg { border-radius: 12px !important; }
.rounded-full { border-radius: 9999px !important; }

.d-block { display: block !important; }
.position-relative { position: relative !important; }

.max-h-400px { max-height: 400px !important; }
.overflow-auto { overflow: auto !important; }

.flex-1 { flex: 1 !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-grow-2 { flex-grow: 2 !important; }

.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }

.cursor-pointer { cursor: pointer !important; }

.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }

/* EditEstimatePage specific classes */
.budget-summary-card {
    text-align: center;
    padding: 1.5rem;
    background-color: var(--bg-primary);
    border-radius: 12px;
}

.budget-summary-label {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.budget-summary-value {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.budget-summary-value-success {
    color: var(--success-color);
}

.budget-summary-value-heading {
    color: var(--text-heading);
}

.progress-container {
    margin-top: 1.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.progress-label {
    font-size: 0.875rem;
    font-weight: 600;
}

.progress-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success-color);
}

.progress-bar-container {
    height: 12px;
    background-color: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: calc(var(--utilization) * 1%);
    background-color: var(--progress-color, var(--success-color));
    border-radius: 6px;
}

.additional-cost-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.additional-cost-label {
    font-size: 0.9375rem;
}

.additional-cost-value {
    font-size: 0.9375rem;
    font-weight: 600;
}

.additional-cost-label-success {
    color: var(--success-color);
}

.additional-cost-value-success {
    color: var(--success-color);
}

.total-estimate-row {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem 0 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.total-estimate-label {
    font-size: 1.25rem;
}

.total-estimate-value {
    color: var(--primary-color);
}

.client-info-label {
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.client-info-value {
    margin-bottom: 1rem;
    font-weight: 600;
}

.client-info-value-secondary {
    margin-bottom: 1rem;
}

.client-info-value-no-margin {
    margin-bottom: 0;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.25rem;
}

.attachment-icon-container {
    width: 40px;
    height: 40px;
    background-color: var(--danger-color-light);
    color: var(--danger-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attachment-icon-container-primary {
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.attachment-icon-container-success {
    background-color: var(--success-color-light);
    color: var(--success-color);
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    margin: 0;
    font-weight: 600;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.message-container {
    margin-bottom: 1rem;
}

.message-header {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.message-content-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.message-sender {
    font-size: 0.875rem;
    font-weight: 600;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-bubble {
    background-color: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.message-bubble-primary {
    background-color: var(--primary-color-light);
}

.message-input-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.message-textarea {
    min-height: 80px;
    margin-bottom: 0.5rem;
}

.activity-log-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.activity-log-icon {
    width: 32px;
    height: 32px;
    background-color: var(--success-color-light);
    color: var(--success-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-log-icon-primary {
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.activity-log-icon-secondary {
    background-color: var(--secondary-color-light);
    color: var(--text-secondary);
}

.activity-log-content {
    flex: 1;
}

.activity-log-title {
    font-weight: 600;
}

.activity-log-time {
    margin: 0.125rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.modal-section {
    margin-bottom: 1rem;
}

.modal-section-label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.modal-input-group {
    display: flex;
}

.modal-input-group input {
    flex: 1;
}

.modal-copy-button {
    padding: 0.75rem 1rem;
}

.print-header-section {
    display: flex;
}

.print-company-section {
    flex: 1;
}

.print-logo-section {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
}

.print-company-details-section p {
    margin: 0;
    color: var(--text-primary);
}

.print-estimate-info-section {
    text-align: right;
}

.print-title-section {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
}

.print-subtitle-section p {
    margin: 0;
    color: var(--text-primary);
}

.print-info-section {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.print-info-box {
    flex: 1;
}

.print-info-box h3 {
    margin-bottom: 0.5rem;
    color: var(--text-heading);
}

.print-info-box p {
    margin: 0;
    color: var(--text-primary);
}

.print-info-label {
    font-weight: 600;
}

.print-budget-summary {
    margin-bottom: 1.5rem;
}

.print-budget-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.print-budget-row-total {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.print-notes-section h4 {
    margin-bottom: 0.5rem;
}

.print-notes-section p {
    margin-bottom: 1rem;
}

.print-signature-section {
    margin-top: 2rem;
}

.signature-area {
    display: flex;
    gap: 2rem;
}

.signature-box {
    flex: 1;
}

.signature-line {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
}

.print-items-header {
    display: flex;
}

.print-items-title {
    margin-bottom: 1rem;
    color: #000;
    font-size: 16pt;
}

.print-table-header th {
    width: 40px;
}

.print-table-header-description {
    text-align: left;
}

.print-table-header-category {
    width: 100px;
}

.print-table-header-quantity {
    width: 80px;
}

.print-table-header-unit-price {
    width: 100px;
}

.print-table-header-total {
    width: 120px;
}

.print-table-footer-total {
    border-top: 3px double #000;
    font-size: 13pt;
}

/* Wizard Styles */
.wizard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.wizard-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0 2rem;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border-color);
    z-index: 0;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

.wizard-step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color-light);
    border: 2px solid var(--primary-color-alpha);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.wizard-step-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s ease;
}

.wizard-step.active .wizard-step-number {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}

.wizard-step.active .wizard-step-label {
    color: var(--primary-color);
}

.wizard-step.completed .wizard-step-number {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.wizard-content {
    min-height: 400px;
    padding: 1rem 0;
}

/*.wizard-pane {
    display: none;
}*/

.wizard-pane.active {
    display: block !important;
    animation: fadeIn 0.3s ease;
}

.wizard-navigation {
    display: flex;
    gap: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .wizard-steps {
        padding: 0 1rem;
    }

    .wizard-step-label {
        font-size: 0.75rem;
    }

    .wizard-step-number {
        width: 35px;
        height: 35px;
        font-size: 0.875rem;
    }
}

/* Mobile nav overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

/* Browsers without <dialog> support (Samsung Internet < 21) have no UA rule hiding a
   closed dialog, which otherwise leaves an invisible full-width block swallowing taps. */
#components-reconnect-modal:not([open]) {
    display: none;
}

#components-reconnect-modal.components-reconnect-dialog-fallback[open] {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 3000;
    height: fit-content;
}

#components-reconnect-modal,
.components-startup-error {
    width: min(22rem, calc(100% - 2rem));
    margin: 20vh auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background-color: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--modal-shadow);
}

#components-reconnect-modal {
    opacity: 0;
    animation: components-reconnect-fade-out 0.3s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-slide-up 0.4s ease-out, components-reconnect-fade-in 0.3s ease-out;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

.components-startup-error {
    position: fixed;
    inset: 0;
    z-index: 3000;
    height: fit-content;
}

.components-startup-error[hidden] {
    display: none;
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.components-reconnect-container p {
    margin: 0;
    text-align: center;
}

.components-reconnect-container button {
    border: 0;
    border-radius: 6px;
    padding: 0.625rem 1.5rem;
    background-color: var(--primary-color);
    color: var(--on-primary);
    cursor: pointer;
}

.components-rejoining-animation {
    position: relative;
    width: 80px;
    height: 80px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    opacity: 1;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-reconnect-slide-up {
    from { transform: translateY(30px) scale(0.95); }
    to { transform: translateY(0); }
}

@keyframes components-reconnect-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes components-reconnect-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes components-rejoining-animation {
    0%, 4.9% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    5% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        top: 0;
        left: 0;
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .top-header,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }
}

/* Category tree hover effects */
.category-tree-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.category-tree-item:hover {
    background-color: var(--nav-hover-bg);
}

.category-tree-subitem {
    padding: 0.5rem 0.75rem;
}

.category-tree-subitem:hover {
    background-color: var(--nav-hover-bg);
}
.category-item:hover > div {
    background-color: var(--nav-hover-bg);
}

.category-item.active {
    background-color: var(--nav-active-bg);
    border-left: 3px solid var(--primary-color);
}

.category-item.active .category-tree-item {
    background-color: var(--nav-active-bg);
    color: var(--primary-color);
}

.category-item:hover .subcategories > div {
    background-color: transparent;
}

/* Category tree expand/collapse */
.subcategories[data-expanded="false"] {
    display: none;
}

.subcategories[data-expanded="true"] {
    display: block;
}

.toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}
.toggle-button:hover {
    background-color: var(--nav-hover-bg);
}

.property-item {
    background-color: var(--secondary-color-light);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.25rem;
}

.list-items .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Browse.razor specific classes */
.search-filter-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.search-filter-group {
    flex: 1;
    min-width: 250px;
}

.search-input-container {
    position: relative;
}

.search-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-input-field {
    padding-left: 40px;
}

.filter-group {
    min-width: 180px;
}

.price-range-filter {
    min-width: 150px;
}

.sort-filter {
    min-width: 150px;
}

.search-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.results-info-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-info-text {
    margin: 0;
    color: var(--text-muted);
}

.view-toggle-container {
    display: flex;
    gap: 0.5rem;
}

.view-toggle-button {
    min-width: 40px;
    height: 40px;
}

.grid-view-button {
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.list-view-button {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.materials-grid {
    margin-bottom: 1.5rem;
}

.pagination-container {
    margin-top: 1.5rem;
}
/* Vendor Associations Card Styles */
.vendor-associations-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.accordion-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.accordion-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.accordion-card-body {
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--body-bg);
}

.accordion-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background-color: var(--card-bg);
    transition: background-color 0.2s ease;
}

.accordion-card-header:hover {
    background-color: var(--nav-hover-bg);
}

.vendor-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.vendor-card-actions {
    display: flex;
    gap: 0.25rem;
}



.vendor-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.vendor-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.vendor-detail-item label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.vendor-detail-item span:not(label) {
    font-size: 1rem;
    font-weight: 500;
}

.vendor-price {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.125rem !important;
}

.vendor-properties-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.vendor-properties-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    /*color: var(--text-muted);*/
    margin-bottom: 0.75rem;
}

.vendor-properties-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.vendor-property-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: var(--card-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.vendor-property-label {
    font-size: 0.875rem;
    /*color: var(--text-muted);*/
}

.vendor-property-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.property-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: var(--secondary-color-light);
    color: var(--primary-color);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.accordion-chevron {
    color: var(--text-muted);
}

.accordion-card-body.expanded .accordion-chevron {
    transform: rotate(180deg);
}
.filter-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.filter-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.filter-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.25rem 0;
    margin-bottom: 0.75rem;
    transition: color 0.2s ease;
}

.filter-header:hover {
    color: var(--primary-color);
}

.filter-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
}

.filter-toggle-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.filter-content {
    display: block;
}

.filter-count {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

.form-check {
    align-items: flex-start;
}

.form-check-input {
    margin-top: 0.25rem;
}

/* ----- Utility Classes ----- */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: var(--success-color) !important; }
.bg-warning { background-color: var(--warning-color) !important; }
.bg-danger { background-color: var(--danger-color) !important; }

/* Icon Sizes */
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }
.icon-2xl { width: 32px; height: 32px; }
.icon-3xl { width: 40px; height: 40px; }

/* Flex Layout Utilities */
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

/* Gap Utilities */
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.gap-xl { gap: 1.5rem; }
.gap-2xl { gap: 2rem; }

/* Position Utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Positioning Helpers */
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.top-1 { top: 0.25rem; }
.right-1 { right: 0.25rem; }
.bottom-1 { bottom: 0.25rem; }
.left-1 { left: 0.25rem; }

.top-2 { top: 0.5rem; }
.right-2 { right: 0.5rem; }
.bottom-2 { bottom: 0.5rem; }
.left-2 { left: 0.5rem; }

.top-3 { top: 0.75rem; }
.right-3 { right: 0.75rem; }
.bottom-3 { bottom: 0.75rem; }
.left-3 { left: 0.75rem; }

.top-4 { top: 1rem; }
.right-4 { right: 1rem; }
.bottom-4 { bottom: 1rem; }
.left-4 { left: 1rem; }

/* Transform Utilities */
.translate-x-50 { transform: translateX(-50%); }
.translate-y-50 { transform: translateY(-50%); }
.translate-y-100 { transform: translateY(-100%); }

/* Text Utilities */
.text-strikethrough { text-decoration: line-through; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Width and Height Utilities */
.min-w-0 { min-width: 0; }
.w-4 { width: 1rem; }
.w-6 { width: 1.5rem; }
.w-8 { width: 2rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-16 { width: 4rem; }
.w-20 { width: 5rem; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.w-40 { width: 10rem; }
.w-48 { width: 12rem; }
.w-56 { width: 14rem; }
.w-64 { width: 16rem; }

.h-4 { height: 1rem; }
.h-6 { height: 1.5rem; }
.h-8 { height: 2rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.h-16 { height: 4rem; }
.h-20 { height: 5rem; }
.h-24 { height: 6rem; }
.h-32 { height: 8rem; }
.h-40 { height: 10rem; }
.h-48 { height: 12rem; }
.h-56 { height: 14rem; }
.h-64 { height: 16rem; }

/* Border Utilities */
.border-none { border: none; }
.border-t-none { border-top: none; }
.border-r-none { border-right: none; }
.border-b-none { border-bottom: none; }
.border-l-none { border-left: none; }

/* Overflow Utilities */
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }

/* Cursor Utilities */
.cursor-default { cursor: default; }
.cursor-auto { cursor: auto; }

/* Opacity Utilities */
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Z-index Utilities */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Print-specific Utilities */
.print-only { display: none; }
@media print {
    .print-only { display: block !important; }
    .no-print { display: none !important; }
}

/* ============================================
   Responsive primitives

   Shared building blocks for making desktop-first pages work on phones. Prefer these
   over per-page media queries so behaviour stays consistent across the app.
   ============================================ */

/* ----- Toolbar: wrapping header/action rows ----- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.toolbar__spacer {
    flex: 1 1 auto;
    min-width: 0;
}

.toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* ----- List header: actions + search above a list. Below md the actions move into a FAB. ----- */
.list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.list-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.list-header__search {
    position: relative;
    width: min(100%, 280px);
}

.list-header__tools {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.list-header__tools .list-header__search {
    flex: 0 1 280px;
    min-width: 180px;
}

.list-header__dates {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.list-header__dates .form-input {
    width: 150px;
    min-width: 0;
}

.list-header__dates-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.list-header__dates-separator {
    color: var(--text-muted);
}

.list-header__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.list-header__search .form-input {
    width: 100%;
    padding-left: 40px;
}

/* ----- FAB: speed dial for a page's primary actions on phones ----- */
.fab {
    display: none;
}

@media (max-width: 768px) {
    .fab-duplicate {
        display: none !important;
    }

    .list-header {
        margin-bottom: 0.75rem;
    }

    .list-header__actions {
        display: none;
    }

    .list-header__search {
        width: 100%;
    }

    .list-header__tools {
        width: 100%;
        flex-wrap: wrap;
    }

    .list-header__tools .list-header__search {
        flex-basis: 100%;
    }

    .list-header__dates {
        width: 100%;
        flex-wrap: wrap;
    }

    .list-header__dates-label {
        width: 100%;
    }

    .list-header__dates .form-input {
        flex: 1;
    }

    .list-header__filters {
        justify-content: flex-end;
    }

    :has(> .fab) {
        padding-bottom: 5rem;
    }

    .fab {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.75rem;
        position: fixed;
        right: 1rem;
        bottom: calc(1rem + env(safe-area-inset-bottom));
        z-index: 800;
    }

    .fab__main {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        height: 56px;
        padding: 0 1.25rem 0 1rem;
        border: 0;
        border-radius: 28px;
        background-color: var(--primary-color);
        color: var(--on-primary);
        box-shadow: var(--modal-shadow);
        font: inherit;
        font-weight: 600;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        transition: background-color 0.15s ease;
    }

    .fab__main:hover {
        background-color: var(--primary-hover);
        color: var(--on-primary);
    }

    .fab__main:focus-visible,
    .fab__more:focus-visible {
        outline: none;
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 28%, transparent), var(--modal-shadow);
    }

    .fab__more {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-right: 6px;
        border: 1px solid var(--border-color);
        border-radius: 50%;
        background-color: var(--card-bg);
        color: var(--text-primary);
        box-shadow: var(--modal-shadow);
        cursor: pointer;
    }

    .fab__more-close,
    .fab.open .fab__more-open {
        display: none;
    }

    .fab.open .fab__more-close {
        display: block;
    }

    .fab__menu {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.625rem;
        visibility: hidden;
        opacity: 0;
        transform: translateY(0.5rem);
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    }

    .fab.open .fab__menu {
        visibility: visible;
        opacity: 1;
        transform: none;
    }

    .fab__item {
        display: flex;
        align-items: center;
        gap: 0.625rem;
        padding: 0;
        border: 0;
        background: none;
        color: var(--text-primary);
        font: inherit;
        text-decoration: none;
        cursor: pointer;
    }

    .fab__label {
        padding: 0.375rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background-color: var(--card-bg);
        box-shadow: var(--card-shadow);
        font-size: 0.875rem;
        font-weight: 500;
        white-space: nowrap;
    }

    .fab__icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-right: 6px;
        border: 1px solid var(--border-color);
        border-radius: 50%;
        background-color: var(--card-bg);
        color: var(--primary-color);
        box-shadow: var(--modal-shadow);
    }

    .fab__item:hover .fab__icon,
    .fab__item:focus-visible .fab__icon {
        border-color: var(--primary-color);
    }
}

/* ----- Checkbox / radio rows ----- */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.checkbox-label input {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Radios draw their own ring and dot so they follow the palette. :where keeps the base at zero
   specificity, so a component that hides its radio (display: none) still wins. */
:where(input[type="radio"]) {
    appearance: none;
    display: inline-grid;
    place-content: center;
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    border: 1.5px solid var(--input-border);
    border-radius: 50%;
    background-color: var(--input-bg, var(--card-bg));
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

:where(input[type="radio"])::before {
    content: "";
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background-color: var(--on-primary);
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

:where(input[type="radio"]):hover:not(:disabled) {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 12%, transparent);
}

:where(input[type="radio"]):checked {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

:where(input[type="radio"]):checked::before {
    transform: scale(1);
}

:where(input[type="radio"]):focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 28%, transparent);
}

:where(input[type="radio"]):disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin: 1.25rem 0 0.75rem;
}

.form-section-title:first-child {
    margin-top: 0;
}

/* ----- Split shell: filter rail + body ----- */
.split-shell {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.split-shell__body {
    flex: 1;
    min-width: 0;
}

.filter-sidebar--drawer {
    width: 260px;
    flex-shrink: 0;
}

/* ----- Detail shell: main column + secondary rail ----- */
.detail-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 992px) {
    .detail-shell {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ----- Specification list: name and value rows ----- */
.spec-table th {
    width: 200px;
    background: none;
    white-space: normal;
}

.spec-table tr:last-child th {
    border-bottom: none;
}

@media screen and (max-width: 768px) {
    .spec-table {
        font-size: 0.875rem;
    }

    .spec-table tbody tr,
    .spec-table tbody tr:nth-child(even) {
        background: none;
    }

    .spec-table th,
    .spec-table td {
        padding: 0.625rem 0.875rem;
        vertical-align: top;
        overflow-wrap: anywhere;
    }

    .spec-table th {
        width: 45%;
        font-weight: 500;
        color: var(--text-secondary);
    }

    .spec-table td {
        color: var(--text-heading);
        text-align: right;
    }
}

/* The trigger button and the drawer's own close button only exist below the breakpoint
   where the rail collapses. */
.filter-sidebar__trigger-row,
.filter-sidebar__close {
    display: none;
}

.table-group-header td {
    background-color: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-heading);
}

@media (max-width: 992px) {
    /* The rail becomes an off-canvas drawer, reusing the sidebar's overlay treatment. */
    .split-shell {
        display: block;
    }

    .filter-sidebar--drawer {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1500;
        width: min(320px, 85vw);
        max-height: none;
        height: 100%;
        overflow-y: auto;
        background-color: var(--card-bg);
        border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .filter-sidebar--drawer.open {
        transform: translateX(0);
    }

    .filter-overlay {
        z-index: 1400;
    }

    .filter-sidebar__trigger-row,
    .filter-sidebar__close {
        display: flex;
    }
}

/* ----- Filter panel -----
   Inline above md. Below it the filters move into a full-screen modal behind a trigger
   button so a list's results come before its filters. The closed modal uses display: none
   so tours anchor on the trigger instead. */
.filter-panel,
.filter-panel__dialog,
.filter-panel__body {
    display: contents;
}

.filter-panel-trigger,
.filter-panel__header,
.filter-panel__footer {
    display: none;
}

@media (max-width: 768px) {
    .filter-panel-trigger {
        display: flex;
        margin-bottom: 0.75rem;
    }

    .filter-panel {
        display: none;
    }

    .filter-panel.open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2000;
    }

    .filter-panel__dialog {
        display: flex;
        flex-direction: column;
        height: 100%;
        background-color: var(--modal-bg);
    }

    .filter-panel__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .filter-panel__body {
        display: block;
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }

    .filter-panel__footer {
        display: flex;
        padding: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .filter-panel__footer .btn {
        width: 100%;
    }

    /* the modal is the frame now, so the filter card loses its own */
    .filter-panel__body .card {
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        background: none;
    }

    .filter-panel__body .card-body {
        padding: 0 !important;
    }

    .filter-panel__body .form-select,
    .filter-panel__body .form-input {
        width: 100%;
        max-width: none !important;
    }

    .filter-panel__body .form-group {
        flex: 1 1 100% !important;
    }

    /* the footer's Show results runs the search, so the inline submit would be a second one */
    .filter-panel__inline-only {
        display: none !important;
    }

    body:has(.filter-panel.open) {
        overflow: hidden;
    }
}

/* ----- Card-stack tables -----
   Below md a wide table becomes one card per row that reads top to bottom from the left.
   The first labelled cell, or the cell marked .stack-title, heads the card; the cells under
   it are plain lines without their column label, since a name, an email or a status badge
   says what it is. A cell whose value doesn't (a bare date, count or reference) takes
   .stack-label and gets its label in front of it. Unlabelled cells (bulk-select checkboxes,
   actions) lead or close the card. Rows that are mostly figures use .table-stack--metrics:
   under the title they sit in a two-column grid, each with its label above it. Scoped to
   `screen` so printed output keeps real tables. */
@media screen and (max-width: 768px) {
    .table-stack thead {
        display: none;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
    }

    .table-stack tbody tr {
        border: 1px solid var(--table-border);
        border-radius: 10px;
        margin-bottom: 0.75rem;
        padding: 0.875rem 1rem;
        background-color: var(--table-row-bg);
    }

    /* the nth-child striping reads as noise once rows are cards */
    .table-stack tbody tr:nth-child(even) {
        background-color: var(--table-row-bg);
    }

    .table-stack tbody td {
        /* neutralises the fixed px widths the desktop layout sets on <th>/<td> */
        width: auto !important;
        text-align: left !important;
        border-bottom: none;
        padding: 0;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .table-stack:not(.table-stack--cards) tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.25rem 0.375rem;
    }

    .table-stack:not(.table-stack--cards) tbody td {
        flex: 1 1 100%;
        font-size: 0.875rem;
        color: var(--text-secondary);
    }

    /* cells holding only badges (roles, status) share a line */
    .table-stack:not(.table-stack--cards) tbody td:has(> :is(.badge, .status)):not(:has(> :not(.badge, .status))) {
        flex: 0 0 auto;
    }

    .table-stack:not(.table-stack--cards) tbody tr:not(:has(.stack-title)) > td:nth-child(1 of [data-label]:not([data-label=""])),
    .table-stack:not(.table-stack--cards) tbody td.stack-title {
        order: -1;
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-heading);
    }

    .table-stack:not(.table-stack--cards) tbody td.stack-label::before {
        content: attr(data-label);
        margin-right: 0.375rem;
        font-size: 0.8125rem;
        color: var(--text-muted);
    }

    .table-stack:not(.table-stack--cards) tbody td:not([data-label]),
    .table-stack:not(.table-stack--cards) tbody td[data-label=""] {
        order: 1;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.375rem;
        padding-top: 0.625rem;
        border-top: 1px solid var(--table-border);
    }

    /* a leading unlabelled cell is the bulk-select checkbox: it sits above the title */
    .table-stack:not(.table-stack--cards) tbody td:first-child:not([data-label]),
    .table-stack:not(.table-stack--cards) tbody td:first-child[data-label=""] {
        order: -2;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    /* an actions cell with nothing in it for this row would leave a bare divider */
    .table-stack:not(.table-stack--cards) tbody tr:not(.table-group-header) > td:not([data-label]):not(:has(> :not(:empty), input, button, a, img, svg)),
    .table-stack:not(.table-stack--cards) tbody tr:not(.table-group-header) > td[data-label=""]:not(:has(> :not(:empty), input, button, a, img, svg)) {
        display: none;
    }

    .table-stack.table-stack--metrics tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 1rem;
    }

    .table-stack.table-stack--metrics tbody td {
        font-size: 0.9375rem;
        color: var(--text-primary);
    }

    .table-stack.table-stack--metrics tbody td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.125rem;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .table-stack.table-stack--metrics tbody tr:not(:has(.stack-title)) > td:nth-child(1 of [data-label]:not([data-label=""])),
    .table-stack.table-stack--metrics tbody td.stack-title,
    .table-stack.table-stack--metrics tbody td.stack-wide,
    .table-stack.table-stack--metrics tbody td:not([data-label]),
    .table-stack.table-stack--metrics tbody td[data-label=""] {
        grid-column: 1 / -1;
    }

    .table-stack.table-stack--metrics tbody tr:not(:has(.stack-title)) > td:nth-child(1 of [data-label]:not([data-label=""]))::before,
    .table-stack.table-stack--metrics tbody td.stack-title[data-label]:not([data-label=""])::before {
        content: none;
    }

    .table-stack .table-group-header td {
        border-radius: 8px;
        padding: 0.5rem 0.75rem;
    }

    .table-stack:not(.table-stack--cards) tbody tr.table-group-header > td {
        order: 0;
        margin-top: 0;
        border-top: none;
        padding: 0.5rem 0.75rem;
    }

    .table-stack .table-group-header {
        border: none;
        padding: 0;
        background: none;
    }

    /* the container no longer needs to scroll once rows stack */
    .table-container:has(.table-stack) {
        overflow-x: visible;
        border: none;
    }
}

/* ----- Expense card-stack -----
   Expense and expenditure rows carry more columns than a label-per-cell card can
   hold, so below md `.table-stack--cards` lays them out as a two-column grid with
   no labels at all: name and total lead the card, the unit maths sits under them,
   and the wording inside each cell ("each", "spent", "remaining") says what the
   figure is. Columns worth only a word or two — stage, category, vendor, sku —
   fold into the name cell's meta line and their own cell is dropped. Each table
   then names its own row shape via grid-template-areas. */
.expense-cell-meta {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.expense-cell-qty,
.expense-cell-unit {
    white-space: nowrap;
}

.expense-stack-only {
    display: none;
}

.expense-desktop-only {
    display: inline;
}

.expense-cell-percentage {
    margin-top: 0.125rem;
    font-weight: 600;
}

.expense-cell-percentage--over {
    color: var(--danger-color);
}

@media screen and (max-width: 768px) {
    .table-stack--cards tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        column-gap: 1rem;
        row-gap: 0.5rem;
        padding: 0.75rem;
    }

    .table-stack--expense tbody tr {
        grid-template-areas:
            "name   total"
            "qty    unit"
            "select actions";
    }

    .table-stack--expense-summary tbody tr {
        grid-template-areas:
            "name total"
            "qty  qty";
    }

    .table-stack--expenditure tbody tr {
        grid-template-areas:
            "name total"
            "qty  qty"
            ".    actions";
    }

    .table-stack--cards tbody td {
        display: block;
        min-width: 0;
        padding: 0;
        border-bottom: none;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .table-stack--cards tbody td::before {
        content: none;
    }

    .expense-stack-only {
        display: inline;
    }

    .expense-desktop-only {
        display: none;
    }

    p.expense-stack-only {
        display: block;
    }

    .table-stack tbody td.expense-cell-folded {
        display: none;
    }

    .expense-cell-name { grid-area: name; }
    .expense-cell-total { grid-area: total; }
    .expense-cell-qty { grid-area: qty; }
    .expense-cell-unit { grid-area: unit; }
    .expense-cell-note { grid-area: note; }
    .expense-cell-select { grid-area: select; }
    .expense-cell-actions { grid-area: actions; }

    .table-stack tbody td.expense-cell-total,
    .table-stack tbody td.expense-cell-unit {
        text-align: right !important;
    }

    .expense-cell-total strong {
        font-size: 1.0625rem;
    }

    .table-stack--expense .expense-quantity-needed {
        color: var(--text-heading);
        font-size: 1.0625rem;
        font-weight: 700;
        line-height: 1.25;
    }

    .table-stack--expenditure .expense-cell-name > strong,
    .table-stack--expenditure .expenditure-quantity {
        color: var(--text-heading);
        font-weight: 600;
    }

    .table-stack--expenditure .expense-cell-name > strong {
        font-size: 1.0625rem;
        line-height: 1.25;
    }

    .expense-cell-select,
    .expense-cell-actions {
        align-self: center;
    }

    .expense-cell-actions .table-actions {
        justify-content: flex-end;
    }
}

/* ----- Estimate card-stack -----
   Below md an estimate row becomes a label-free card. Rank and type do the work
   the column headers did: the label and the amount lead the card in heading
   type, the last-modified date and status sit beneath them, and the reference
   closes it out in muted small type. Sent has no value yet, so its cell drops
   rather than showing a bare dash.

   The reference and the action bar span both columns. Four 44px touch targets
   in the right-hand track would size it to ~176px and leave the label about a
   third of the card, so they get a row of their own. The bulk-select checkbox
   is a desktop affordance and drops rather than spend a gutter. */
.estimate-stack-only {
    display: none;
}

/* Title/subtitle cells (label + client, last-modified date + editor) read top-down
   in both the desktop table and the mobile card, so every row aligns to its start. */
.table-stack--estimate tbody td {
    vertical-align: top;
}

.estimate-cell-title {
    display: block;
    font-weight: 600;
    color: var(--text-heading);
    text-decoration: none;
}

.estimate-cell-title:hover {
    text-decoration: underline;
}

.estimate-cell-heading {
    display: block;
}

.estimate-cell-heading .estimate-cell-title {
    display: inline;
}

.estimate-shared-icon {
    display: inline-flex;
    margin-left: 0.375rem;
    vertical-align: -0.125em;
    color: var(--text-muted);
}

.estimate-shared-icon svg {
    width: 1rem;
    height: 1rem;
}

.estimate-cell-subtitle {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-muted);
}

@media screen and (max-width: 768px) {
    .table-stack--estimate tbody tr {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "name     amount"
            "modified status"
            "ref      access";
        column-gap: 0.75rem;
        row-gap: 0.375rem;
        align-items: start;
    }

    .estimate-cell-name { grid-area: name; }
    .estimate-cell-amount { grid-area: amount; }
    .estimate-cell-modified { grid-area: modified; }
    .estimate-cell-status { grid-area: status; }
    .estimate-cell-ref { grid-area: ref; }
    .estimate-cell-access { grid-area: access; }

    .table-stack tbody td.estimate-cell-select {
        display: none;
    }

    .estimate-stack-only {
        display: inline;
    }

    /* The label carries the weight the "Project Name" header used to carry. */
    .estimate-cell-name .estimate-cell-title {
        font-size: 1.0625rem;
        font-weight: 700;
        line-height: 1.25;
    }

    /* Right-aligned lining figures read as money without a header to say so. */
    .table-stack tbody td.estimate-cell-amount {
        text-align: right !important;
        font-size: 1.0625rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        color: var(--text-heading);
        white-space: nowrap;
    }

    .table-stack tbody td.estimate-cell-status,
    .table-stack tbody td.estimate-cell-access {
        text-align: right !important;
    }

    .estimate-cell-access {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .estimate-cell-status .status {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Tracked, muted small type marks the reference as an identifier. */
    .estimate-cell-ref,
    .estimate-cell-ref a,
    .estimate-cell-ref strong {
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        text-decoration: none;
    }

    .estimate-cell-ref .estimate-stack-only {
        font-weight: 400;
        letter-spacing: 0;
    }
}

/* ----- Touch targets ----- */
@media (max-width: 768px) {
    .icon-btn,
    .dropdown-item,
    .table-actions .btn,
    .row-actions .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ----- Blank Centered Layout ----- */
.blank-centered-layout {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    background-color: var(--bg-primary);
    box-sizing: border-box;
}


/* ----- Ad slots -----

   A slot only asks for an ad when its MinViewport or MaxViewport fits the viewport, because a slot
   hidden with display:none would still record an impression nobody saw. .vendor-feature--desktop and
   .vendor-feature--mobile keep the layout right when the window is resized afterwards. The two side
   rails collapse at 992px (AdSizes.RailBreakpoint).
   ============================================ */
.vendor-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.vendor-feature-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.vendor-feature-link {
    display: block;
    max-width: 100%;
}

.vendor-feature img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Inside a card rail the surrounding cards already carry the 1.5rem rhythm. */
.vendor-feature--rail {
    margin-bottom: 1rem;
}

/* Spans the whole row of a .grid-4 feed rather than taking a single 196px cell. */
.vendor-feature--feed {
    grid-column: 1 / -1;
}

.vendor-feature--mobile {
    display: none;
}

@media (max-width: 992px) {
    .vendor-feature--desktop {
        display: none;
    }

    .vendor-feature--mobile {
        display: flex;
    }
}

/* Ad placement map: wireframes of the pages an ad can serve on */
.ad-map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.ad-map-page {
    margin: 0;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
}

.ad-map-page svg {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto;
}

.ad-map-page figcaption {
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.ad-map-block {
    fill: var(--border-color);
}

.ad-map-frame {
    fill: none;
    stroke: var(--border-color);
}

.ad-map-slot {
    cursor: pointer;
}

.ad-map-slot rect {
    fill: var(--card-bg);
    stroke: var(--text-muted);
    stroke-width: 1;
    stroke-dasharray: 3 2;
}

.ad-map-slot text {
    fill: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.ad-map-slot.is-eligible rect {
    fill: var(--primary-color-light);
    stroke: var(--primary-color);
}

.ad-map-slot.is-eligible text {
    fill: var(--primary-color);
}

.ad-map-slot.is-selected rect {
    fill: var(--primary-color);
    stroke: var(--primary-color);
    stroke-dasharray: none;
}

.ad-map-slot.is-selected text {
    fill: #ffffff;
}

.ad-map-slot:hover rect,
.ad-map-slot:focus-visible rect {
    stroke: var(--primary-color);
    stroke-width: 2;
}

.ad-map-slot:focus {
    outline: none;
}

.ad-map-slot.is-disabled {
    cursor: default;
}

.ad-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.ad-map-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ad-map-swatch {
    display: inline-block;
    width: 14px;
    height: 10px;
    border: 1px dashed var(--text-muted);
    border-radius: 2px;
    background-color: var(--card-bg);
}

.ad-map-swatch.is-eligible {
    border-color: var(--primary-color);
    background-color: var(--primary-color-light);
}

.ad-map-swatch.is-selected {
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
}

/* Wizard steps that can be clicked to jump between them */
button.wizard-step {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

button.wizard-step:hover .wizard-step-label {
    color: var(--primary-color);
}

button.wizard-step:focus-visible {
    outline: none;
}

button.wizard-step:focus-visible .wizard-step-number {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Ad campaign editor */
.ad-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.ad-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.ad-save-state {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.ad-save-state.is-dirty {
    color: var(--warning-color);
    font-weight: 600;
}

.ad-status-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.ad-status-headline {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-heading);
}

.ad-status-text {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
}

.ad-status-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.ad-status-warning {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background-color: var(--danger-color-light);
    color: var(--danger-color);
}

.ad-checklist {
    display: grid;
    gap: 0.5rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.ad-checklist li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.ad-checklist li.is-done {
    border-color: transparent;
    background-color: var(--success-color-light);
}

.ad-check-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.ad-checklist li.is-done .ad-check-mark {
    border-color: var(--success-color);
    background-color: var(--success-color);
    color: #ffffff;
}

.ad-checklist-text {
    flex: 1 1 auto;
    min-width: 0;
}

.ad-checklist-text small {
    display: block;
    color: var(--text-muted);
}

.ad-budget {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.ad-budget-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.ad-budget .progress-bar {
    --progress-color: var(--primary-color);
}

.ad-budget-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.ad-budget-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ad-budget-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background-color: var(--bg-primary);
}

.ad-budget-swatch.is-spent {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

.ad-budget-flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.ad-budget-flow .stat-card {
    height: 100%;
    padding: 1rem;
    gap: 0.25rem;
}

.ad-budget-flow small {
    color: var(--text-muted);
}

.ad-budget-flow-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.ad-wizard-card:focus {
    outline: none;
}

.ad-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.ad-step-intro {
    margin-bottom: 1.5rem;
}

.ad-step-intro h3 {
    margin: 0 0 0.25rem;
    font-size: 1.125rem;
    color: var(--text-heading);
}

.ad-step-intro p {
    max-width: 48rem;
    margin: 0;
    color: var(--text-muted);
}

.ad-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.ad-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.ad-section-header > .btn {
    margin-left: auto;
}

.ad-section-title {
    font-weight: 600;
    color: var(--text-heading);
}

.ad-section-meta {
    color: var(--text-muted);
}

.ad-hint {
    color: var(--warning-color);
    font-weight: 500;
}

.ad-choice-group {
    margin-bottom: 1.5rem;
}

.ad-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.25rem 1rem;
}

.ad-selection {
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
}

.ad-selection .material-active-filters {
    margin: 0.5rem 0 0;
}

.ad-scope {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    margin: 0.5rem 0 1rem;
}

.ad-allocate {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.ad-save-first {
    padding: 1.5rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    color: var(--text-secondary);
}

.ad-save-first p {
    margin: 0 0 1rem;
}

@media (max-width: 768px) {
    .ad-budget-flow {
        grid-template-columns: 1fr;
    }

    .ad-budget-flow-arrow {
        justify-self: center;
        transform: rotate(90deg);
    }

    .ad-wizard-card .wizard-steps {
        padding: 0;
    }

    .ad-wizard-card .wizard-step-label {
        display: none;
    }
}

/* ----- Privacy notice ----- */
.privacy-notice {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 2000;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--modal-shadow);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.privacy-notice[hidden] {
    display: none;
}

.privacy-notice p {
    margin: 0;
    flex: 1;
}

@media (max-width: 576px) {
    .privacy-notice {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ----- Vendor portal ----- */
.portal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-toolbar h2 {
    margin: 0;
    font-size: 1.5rem;
}

.portal-toolbar p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.portal-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.portal-controls select {
    min-width: 10rem;
}

.portal-range {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.portal-range button,
.portal-range a {
    text-decoration: none;
    padding: 0.5rem 0.875rem;
    border: none;
    background: var(--card-bg, #fff);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
}

.portal-range button + button,
.portal-range a + a {
    border-left: 1px solid var(--border-color);
}

.portal-range button.active,
.portal-range a.active {
    background: var(--primary-color-light);
    color: var(--primary-color);
    font-weight: 600;
}

.portal-chart {
    position: relative;
    height: 280px;
}

.portal-chart.small {
    height: 200px;
}

.portal-sparkline {
    position: relative;
    width: 120px;
    height: 32px;
}

.portal-note {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin: 0.5rem 0 0;
}

.portal-funnel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.portal-funnel-step {
    display: grid;
    grid-template-columns: 11rem 1fr 5rem;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.portal-bar {
    height: 12px;
    border-radius: 6px;
    background: var(--secondary-color-light);
    overflow: hidden;
}

.portal-bar > span {
    display: block;
    height: 100%;
    background: var(--primary-color);
    border-radius: 6px;
}

.portal-segments {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.portal-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

@media (max-width: 576px) {
    .portal-funnel-step {
        grid-template-columns: 1fr 4rem;
    }

    .portal-funnel-step .portal-bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

.portal-segments .portal-funnel-step {
    grid-template-columns: 1fr auto;
    row-gap: 0.35rem;
}

.portal-segments .portal-funnel-step .portal-bar {
    grid-column: 1 / -1;
    grid-row: 2;
}

.portal-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.portal-grid > *,
.portal-segments > * {
    min-width: 0;
}

.portal-table td:not(:first-child),
.portal-table th:not(:first-child) {
    white-space: nowrap;
}

.listing-item-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.property-row {
    display: grid;
    grid-template-columns: minmax(8rem, 1fr) minmax(0, 2fr);
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.property-row .form-label {
    margin: 0;
}

.listing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

@media (max-width: 576px) {
    .property-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

/* ----- Home dashboard ----- */
.dash-page a,
.dash-page a:hover {
    text-decoration: none;
}

.dash-greeting {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-greeting h1 {
    margin: 0;
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-heading);
}

.dash-greeting p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.dash-greeting-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.dash-vendor-select {
    width: auto;
}

.dash-card-copy {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dash-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-tiles--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dash-tiles .stat-card {
    padding: 1.125rem 1.25rem;
    color: inherit;
}

.dash-tiles a.stat-card:hover {
    border-color: var(--primary-color);
}

.dash-tiles .dash-tile-special {
    border-color: var(--special-color);
    background: var(--special-color);
}

.dash-tile-special .stat-label,
.dash-tile-special .stat-value,
.dash-tile-special .stat-change {
    color: var(--on-special-color);
}

.dash-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dash-pair > .card {
    min-width: 0;
    margin-bottom: 0;
    container-type: inline-size;
}

@container (max-width: 440px) {
    .dash-sparkline {
        display: none;
    }
}

.dash-section-grid {
    margin-bottom: 1.5rem;
}

.dash-section-grid > .card {
    min-width: 0;
    margin-bottom: 0;
}

.dash-list {
    display: flex;
    flex-direction: column;
}

.dash-row {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    color: inherit;
}

.dash-row:first-child {
    padding-top: 0;
}

.dash-row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

a.dash-row:hover .dash-row-title {
    color: var(--primary-color);
}

.dash-row-main {
    flex: 1;
    min-width: 0;
}

.dash-row-title {
    margin: 0;
    overflow: hidden;
    font-weight: 600;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-row-meta {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.dash-row-end {
    flex-shrink: 0;
    text-align: right;
    font-size: 0.875rem;
}

.dash-empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dash-tab-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.dash-specials-note {
    margin: 0 0 1rem;
}

.dash-specials {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 1rem;
}

.dash-special {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 1.125rem;
    border: 1px solid var(--card-border);
    border-top: 4px solid var(--special-color);
    border-radius: 12px;
    background: var(--card-bg, #fff);
    color: inherit;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.dash-special:hover {
    border-color: var(--special-color);
    transform: translateY(-2px);
}

.dash-special-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.dash-special-off {
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--special-color);
    color: var(--on-special-color);
    font-size: 0.875rem;
    font-weight: 700;
}

.dash-special-name {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}

.dash-special-prices {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.dash-special-now {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-heading);
}

.dash-special-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    margin: 0.25rem 0 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.dash-waiting-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 0.75rem;
}

.dash-waiting-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 600;
    transition: border-color 0.2s ease;
}

.dash-waiting-item:hover {
    border-color: var(--primary-color);
}

.dash-waiting-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--secondary-color-light);
    color: var(--text-secondary);
}

.dash-waiting-icon svg {
    width: 1rem;
    height: 1rem;
}

.dash-waiting-text {
    flex: 1;
    min-width: 0;
}

.dash-waiting-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
}

.dash-waiting-item--action {
    border-left-color: var(--warning-color);
}

.dash-waiting-item--action .dash-waiting-icon {
    background: var(--warning-color-light);
    color: var(--warning-hover);
}

.dash-waiting-item--good {
    border-left-color: var(--success-color);
}

.dash-waiting-item--good .dash-waiting-icon {
    background: var(--success-color-light);
    color: var(--success-hover);
}

.dash-waiting-item--quiet {
    color: var(--text-secondary);
    font-weight: 500;
}

.dash-ongoing-count {
    margin-left: 0.375rem;
    vertical-align: middle;
}

.dash-ongoing-unread {
    color: var(--primary-color);
    font-weight: 600;
}

.dash-ongoing-foot {
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

@media (max-width: 768px) {
    .dash-tiles--four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    .dash-sparkline {
        display: none;
    }

    .dash-greeting-actions,
    .dash-greeting-actions .btn,
    .dash-vendor-select {
        width: 100%;
    }
}

/* ----- Messages ----- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nav-count {
    margin-left: auto;
    min-width: 1.375rem;
    padding: 0 0.4375rem;
    border-radius: 999px;
    background-color: var(--primary-color);
    color: var(--on-primary);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

[data-sidebar-minimized] .sidebar .nav-item {
    position: relative;
}

[data-sidebar-minimized] .sidebar .nav-count {
    position: absolute;
    top: 0.625rem;
    right: calc(50% - 16px);
    min-width: 0;
    width: 0.75rem;
    height: 0.75rem;
    padding: 0;
    border: 2px solid var(--sidebar-bg);
    font-size: 0;
    line-height: 0;
}

.dash-section-grid--three {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.message-unread {
    font-weight: 700;
}

.message-snippet {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-alert {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.message-alert-icon svg {
    width: 20px;
    height: 20px;
}

.message-alert-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
}

.message-alert-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
}

.messages-page {
    display: grid;
    grid-template-columns: 12rem minmax(18rem, 24rem) minmax(0, 1fr);
    gap: 1rem;
    height: calc(100dvh - 9rem);
    min-height: 32rem;
}

.messages-folders,
.messages-list,
.messages-thread {
    min-width: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
}

.messages-folders {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.messages-folder-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.messages-folder {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.messages-folder:hover {
    background-color: var(--nav-hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.messages-folder.active {
    background-color: var(--nav-active-bg);
    color: var(--primary-color);
}

.messages-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.messages-search {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.messages-search .form-input {
    flex: 1 1 10rem;
    min-width: 0;
}

.messages-search .form-select {
    flex: 0 1 8rem;
    width: auto;
}

.messages-list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0.25rem;
}

.messages-list-head h2 {
    margin: 0;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.messages-filters,
.messages-search-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.25rem 1rem 0.75rem;
    font-size: 0.8125rem;
}

.messages-search-filters label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.messages-search-filters .form-select {
    width: auto;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.messages-filter {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
}

.messages-filter:hover {
    text-decoration: none;
}

.messages-filter.active {
    border-color: var(--primary-color);
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.messages-empty {
    margin: 0;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.messages-more {
    margin: 0.75rem auto;
}

.thread-row {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}

a.thread-row:hover {
    background-color: var(--table-row-hover);
    text-decoration: none;
}

.thread-row.active {
    background-color: var(--nav-active-bg);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

div.thread-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
}

.thread-row-open {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.thread-row.is-unread .thread-row-people,
.thread-row.is-unread .thread-row-subject {
    font-weight: 700;
}

.thread-row.is-unread .thread-row-people::before {
    content: "";
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    margin-right: 0.375rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    vertical-align: middle;
}

.thread-row-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.thread-row-people {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-row-top time {
    flex-shrink: 0;
    color: var(--text-muted);
}

.thread-row-subject {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
}

.thread-row-count,
.thread-row-folder {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.thread-row-snippet {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.thread-row-snippet mark {
    padding: 0 0.125rem;
    border-radius: 2px;
    background-color: var(--warning-color-light);
    color: inherit;
}

.thread-row-context {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.messages-thread {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-thread-empty {
    margin: auto;
    padding: 2rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.messages-thread-empty svg {
    width: 40px;
    height: 40px;
}

.messages-thread-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.messages-thread-head h2 {
    flex: 1 1 12rem;
    margin: 0;
    font-size: 1.125rem;
    overflow-wrap: anywhere;
}

.messages-thread-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    width: 100%;
}

.messages-back {
    display: none;
}

.messages-thread-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem max(1.25rem, calc((100% - var(--message-column-width)) / 2));
    overflow-y: auto;
}

.message {
    align-self: flex-start;
    max-width: 85%;
    padding: 0.625rem 0.875rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 16px 16px 16px 4px;
    background-color: var(--message-person-0-bg);
}

.message--mine {
    align-self: flex-end;
    border-radius: 16px 16px 4px 16px;
    background-color: var(--message-mine-bg);
}

.message--person-1 {
    background-color: var(--message-person-1-bg);
}

.message--person-2 {
    background-color: var(--message-person-2-bg);
}

.message--new {
    border-color: var(--primary-color);
}

.message--reported {
    border-color: var(--danger-color);
}

.message-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.5rem;
}

.message-head strong {
    color: var(--text-heading);
}

.message-head time {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.message-menu {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
}

.message-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin: 0.25rem 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.message-body {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-receipt {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.message-receipt summary {
    cursor: pointer;
}

.message-receipt ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

.messages-reply {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem max(1.25rem, calc((100% - var(--message-column-width)) / 2)) 1rem;
    border-top: 1px solid var(--border-color);
}

.messages-reply-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.message-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 100%;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    font-size: 0.8125rem;
    font-weight: 500;
}

.message-context-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-context-chip svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.composer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.composer-alert {
    margin: 0;
}

.composer-context {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    font-size: 0.875rem;
}

.composer-context-label {
    color: var(--text-muted);
}

.composer-context-remove,
.recipient-chip button {
    padding: 0 0.125rem;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.composer-ccbcc {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
}

.composer-candidates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.composer-candidates legend {
    padding: 0 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.composer-candidate {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
}

.composer-body {
    min-height: 8rem;
    resize: vertical;
}

.composer--expanded .composer-body {
    min-height: 18rem;
}

.composer-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.composer-priority {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.composer-priority .form-select {
    width: auto;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 0.875rem;
    background-position: right 0.5rem center;
}

.composer-status {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recipient-picker {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem 0.375rem 1rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recipient-picker:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.recipient-picker-label {
    flex-shrink: 0;
    min-width: 2rem;
    color: var(--text-muted);
}

.recipient-picker-field {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.recipient-picker-input {
    flex: 1 1 8rem;
    min-width: 6rem;
    padding: 0.375rem 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    line-height: normal;
}

.recipient-picker-input::placeholder {
    color: var(--text-muted);
}

.recipient-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    padding: 0.125rem 0.25rem 0.125rem 0.625rem;
    border-radius: 999px;
    background-color: var(--secondary-color-light);
    font-size: 0.875rem;
}

.recipient-chip small {
    color: var(--text-muted);
}

.recipient-suggestions {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 30;
    max-height: 16rem;
    margin: 0.25rem 0 0;
    padding: 0.25rem;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--dropdown-bg);
    box-shadow: var(--dropdown-shadow);
    list-style: none;
}

.recipient-suggestion {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 6px;
    cursor: pointer;
}

.recipient-suggestion.active,
.recipient-suggestion:hover {
    background-color: var(--nav-hover-bg);
}

.recipient-suggestion-name {
    font-weight: 600;
}

.recipient-suggestion-detail {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.recipient-suggestion-empty {
    padding: 0.5rem 0.625rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.message-dock {
    position: fixed;
    right: 1.5rem;
    bottom: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    width: min(26rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 5rem);
    border: 1px solid var(--border-color);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background-color: var(--modal-bg);
    box-shadow: var(--modal-shadow);
}

.message-dock-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.message-dock.is-minimized .message-dock-header {
    border-bottom: 0;
}

.message-dock-title {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0;
    overflow: hidden;
    border: 0;
    background: none;
    color: var(--text-heading);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.message-dock-actions {
    display: flex;
    gap: 0.25rem;
}

.message-dock-actions .modal-close {
    display: inline-flex;
    line-height: 0;
}

.message-dock-body {
    padding: 1rem;
    overflow-y: auto;
}

.message-dialog .modal-header {
    gap: 0.75rem;
}

.message-dialog .message-dock-actions {
    margin-left: auto;
}

.message-dock-heading {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1200px) {
    .messages-page {
        grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
        grid-template-rows: auto minmax(32rem, calc(100dvh - 14rem));
        height: auto;
    }

    .messages-folders {
        grid-column: 1 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .messages-folder-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .messages-page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
    }

    .messages-page.has-thread .messages-folders,
    .messages-page.has-thread .messages-list,
    .messages-page:not(.has-thread) .messages-thread {
        display: none;
    }

    .messages-folder-list {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
    }

    .messages-back {
        display: inline-flex;
    }

    .messages-thread {
        min-height: calc(100dvh - 8rem);
    }

    .message-dock {
        right: 0;
        width: 100vw;
        border-radius: 0;
    }
}

/* Location picker */
.location-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.location-picker-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.location-picker-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

.location-picker-search .form-input {
    width: 100%;
}

.location-picker-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--card-hover-shadow);
}

.location-picker-suggestions button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

.location-picker-suggestions button:hover,
.location-picker-suggestions button:focus-visible {
    background: var(--primary-color-light);
}

.location-picker-suggestions small {
    color: var(--text-muted);
}

.location-picker-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.location-picker-actions .btn,
.location-picker-coordinates .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.location-picker-actions i,
.location-picker-actions svg,
.location-picker-details i,
.location-picker-details svg {
    width: 14px;
    height: 14px;
}

.location-picker-message {
    margin: 0;
}

.location-picker-map {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.location-picker-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.location-picker-region,
.location-picker-coordinates {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.location-picker-coordinates code {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.table tbody tr.shopping-group-footer,
.table tbody tr.shopping-group-footer:hover {
    background-color: var(--table-row-bg);
}

.shopping-group-title {
    flex: 1 1 auto;
    min-width: 0;
}

.shopping-group-footer td {
    font-weight: 700;
}

/* Below md each store is one card: its name heads it, the items it sells sit inside as
   receipt lines (name and line total, then quantity × price), and its subtotal closes it.
   The shopping list's own items keep remove in the top right, beside the name. */
@media screen and (max-width: 768px) {
    .shopping-stops tbody {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--table-border);
        border-radius: 10px;
        overflow: hidden;
        background-color: var(--table-row-bg);
    }

    .shopping-stops tbody tr,
    .shopping-stops tbody tr:nth-child(even) {
        margin: 0;
        border: none;
        border-radius: 0;
        background: none;
    }

    .shopping-stops tbody tr.table-group-header {
        padding: 0;
        background-color: var(--table-header-bg);
        border-bottom: 1px solid var(--table-border);
    }

    .shopping-stops tbody tr.table-group-header td {
        padding: 0.75rem 1rem;
        border-radius: 0;
        font-size: 1rem;
        color: var(--text-heading);
    }

    .shopping-stops tbody tr.shopping-line {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "item  item  total"
            "qty   price price";
        column-gap: 0.375rem;
        row-gap: 0.25rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--table-border);
    }

    .shopping-stops tbody tr.shopping-line:has(.shopping-cell-remove) {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "item  item  total remove"
            "qty   price price .";
    }

    .shopping-stops .shopping-cell-item { grid-area: item; }
    .shopping-stops .shopping-cell-total { grid-area: total; }
    .shopping-stops .shopping-cell-quantity { grid-area: qty; }
    .shopping-stops .shopping-cell-price { grid-area: price; }
    .shopping-stops .shopping-cell-remove { grid-area: remove; }

    .shopping-stops .shopping-cell-quantity,
    .shopping-stops .shopping-cell-price {
        font-size: 0.875rem;
        color: var(--text-secondary);
    }

    .shopping-stops .shopping-cell-quantity::after {
        content: " ×";
    }

    .table-stack tbody td.shopping-cell-total {
        text-align: right !important;
        white-space: nowrap;
    }

    .shopping-stops tbody tr.shopping-group-footer {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.75rem 1rem;
    }

    .shopping-stops tbody tr.shopping-group-footer td:nth-child(2) {
        flex-shrink: 0;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    .shopping-stops tbody tr.shopping-group-footer td.shopping-cell-remove {
        display: none;
    }

    .table-stack.table-stack--metrics.shopping-items tbody tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
        grid-template-areas:
            "material material remove"
            "quantity lowest   lowest";
    }

    .table-stack.table-stack--metrics.shopping-items tbody td.shopping-cell-material { grid-area: material; }
    .table-stack.table-stack--metrics.shopping-items tbody td.shopping-cell-quantity { grid-area: quantity; }
    .table-stack.table-stack--metrics.shopping-items tbody td.shopping-cell-lowest { grid-area: lowest; }

    .table-stack.table-stack--metrics.shopping-items tbody td.shopping-cell-remove {
        grid-area: remove;
        align-self: start;
        margin: -0.375rem -0.5rem 0 0;
        padding: 0;
        border-top: none;
    }
}

.shopping-choice-row {
    cursor: pointer;
}

.table tbody tr.shopping-choice-row.is-selected,
.table tbody tr.shopping-choice-row.is-selected:hover {
    background-color: var(--primary-color-light);
}

.shopping-choice {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 0.75rem;
}

.shopping-choice-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    background-color: var(--primary-color-alpha);
    color: var(--primary-color);
}

.shopping-choice-icon svg {
    width: 18px;
    height: 18px;
}

.location-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.location-field-icon,
.location-field > svg:first-child {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.location-field-text {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.location-field-coordinates {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.location-field-text--empty {
    color: var(--text-muted);
}

@media (max-width: 576px) {
    .location-picker-search {
        flex-basis: 100%;
    }
}

/* Store picker */
.receipt-link-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.receipt-link-back {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
}

.receipt-link-item,
.receipt-link-price {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.receipt-link-item {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.receipt-link-price {
    flex-shrink: 0;
    text-align: right;
}

.receipt-link-price strong {
    font-size: 1.125rem;
}

.receipt-link-price span,
.receipt-link-hint {
    font-size: 0.875rem;
}

.receipt-link-vendor {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.receipt-link-hint {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.receipt-link-stores {
    margin-top: 0.25rem;
}

.receipt-link-stores summary {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.9375rem;
}

.receipt-link-stores .store-picker-list {
    max-height: 12rem;
    overflow-y: auto;
}

.receipt-link-material-kind {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 0.75rem;
}

.receipt-link-material-kind .form-check {
    align-items: center;
}

.receipt-link-material-kind .form-check-input {
    margin-top: 0;
    flex-shrink: 0;
}

.receipt-link-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.receipt-link-form .form-group {
    min-width: 0;
    margin-bottom: 0.75rem;
}

.receipt-link-form .form-label {
    margin-bottom: 0.375rem;
}

.receipt-link-form .form-input,
.receipt-link-form .form-select {
    min-width: 0;
    padding: 0.625rem 0.75rem;
}

.receipt-link-vendor .form-group {
    margin-bottom: 0;
}

.receipt-link-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.receipt-review-intro {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.receipt-review-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.receipt-review-section {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.receipt-review-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.receipt-review-heading h4 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
}

.receipt-review-heading .badge {
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.5;
}

.receipt-review-name {
    margin: 0 0 0.25rem;
    color: var(--text-heading);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
}

.receipt-review-secondary {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.receipt-review-note {
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.receipt-review-listing {
    grid-column: 1 / -1;
}

.receipt-review-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin: 0;
}

.receipt-review-facts dt {
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.receipt-review-facts dd {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.receipt-review-properties {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.receipt-review-price {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.receipt-review-price strong {
    color: var(--text-heading);
    font-size: 1.125rem;
}

@media (max-width: 640px) {
    .receipt-review-grid,
    .receipt-review-facts {
        grid-template-columns: minmax(0, 1fr);
    }

    .receipt-link-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .receipt-link-summary {
        flex-wrap: wrap;
    }

    .receipt-link-price {
        flex-basis: 100%;
        text-align: left;
    }
}

.store-picker-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.store-picker-actions {
    display: flex;
    gap: 0.25rem;
}

.store-picker-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.store-picker-list .form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.store-picker-list .form-check-label {
    display: flex;
    flex-direction: column;
}

.store-picker-list small {
    color: var(--text-muted);
}

.pickup-picker {
    display: grid;
    gap: 0.75rem;
}

.pickup-row {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.pickup-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.pickup-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pickup-item {
    padding-left: 1.5rem;
}

.pickup-loads {
    margin: 0;
    padding-left: 1.25rem;
}

/* ----- Rich text: the editor's page and every place its HTML is shown ----- */
.rich-text {
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    tab-size: 0.5in;
    overflow-wrap: anywhere;
    overflow-x: auto;
}

.rich-text sub,
.rich-text sup {
    font-size: 0.75em;
}

.rich-text :is(sub, sup) :is(sub, sup) {
    font-size: 1em;
    vertical-align: baseline;
}

.rich-text :is(ol, ul, blockquote) :is(ol, ul, blockquote) :is(ol, ul, blockquote) :is(ol, ul, blockquote) :is(ol, ul, blockquote) {
    margin-left: 0;
    padding-left: 0;
}

.rich-text > :first-child {
    margin-top: 0;
}

.rich-text > :last-child {
    margin-bottom: 0;
}

.rich-text p {
    margin: 0 0 0.75em;
}

.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4 {
    margin: 1.25em 0 0.5em;
    color: var(--text-heading);
    line-height: 1.3;
}

.rich-text h1 {
    font-size: 1.625rem;
}

.rich-text h2 {
    font-size: 1.25rem;
}

.rich-text h3 {
    font-size: 1.0625rem;
}

.rich-text h4 {
    font-size: 1rem;
    font-style: italic;
}

.rich-text ol,
.rich-text ul {
    margin: 0 0 0.75em;
    padding-left: 2em;
}

.rich-text li {
    margin-bottom: 0.25em;
}

.rich-text li > ol,
.rich-text li > ul {
    margin: 0.25em 0 0;
}

.rich-text blockquote {
    margin: 0 0 0.75em;
    padding-left: 1em;
    border-left: 3px solid var(--border-color);
    color: var(--text-secondary);
}

.rich-text hr {
    margin: 1.25em 0;
    border: 0;
    border-top: 1px solid var(--border-color);
}

/* ----- Document editor ----- */
.doc-editor {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background-color: color-mix(in srgb, var(--bg-primary) 70%, var(--border-color));
}

.doc-editor-ribbon {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    margin: 0;
    padding: 0.375rem 0.5rem;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.doc-editor-group {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding-right: 0.375rem;
    border-right: 1px solid var(--border-color);
}

.doc-editor-group:last-child,
.doc-editor-group:has(+ .doc-editor-end) {
    border-right: 0;
}

.doc-editor-end {
    margin-left: auto;
    padding-right: 0;
}

.doc-editor-ribbon button[data-command] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.doc-editor-ribbon button[data-command] svg {
    width: 17px;
    height: 17px;
}

.doc-editor-ribbon button[data-command]:hover:not(:disabled) {
    background-color: var(--bg-primary);
    color: var(--text-heading);
}

.doc-editor-ribbon button[data-command].active {
    border-color: color-mix(in srgb, var(--primary-color) 35%, transparent);
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.doc-editor-ribbon button[data-command]:focus-visible,
.doc-editor-style:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.doc-editor-ribbon :disabled {
    cursor: default;
    opacity: 0.5;
}

.doc-editor-style {
    height: 32px;
    min-width: 8.5rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.doc-editor-canvas {
    max-height: 70vh;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.doc-editor-page {
    max-width: 880px;
    min-height: 28rem;
    margin: 0 auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 6px 18px rgba(0, 0, 0, 0.06);
    outline: none;
    cursor: text;
}

.doc-editor-page:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 40%, transparent), 0 6px 18px rgba(0, 0, 0, 0.06);
}

.doc-editor-page.is-empty::before {
    content: attr(data-placeholder);
    position: absolute;
    color: var(--text-muted);
    pointer-events: none;
}

.doc-editor.is-disabled .doc-editor-page {
    opacity: 0.6;
    cursor: progress;
}

.doc-editor-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 0.375rem 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.doc-editor-status .is-over {
    color: var(--danger-color);
    font-weight: 600;
}

@media (max-width: 576px) {
    .doc-editor-canvas {
        padding: 0.75rem 0.5rem;
    }

    .doc-editor-page {
        min-height: 20rem;
        padding: 1.25rem 1rem;
    }

    .doc-editor-end {
        width: 100%;
        margin-left: 0;
    }
}

/* ----- Estimate verification ----- */
.estimate-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    vertical-align: middle;
}

.estimate-verified-badge-icon {
    width: 1.125em;
    height: 1.125em;
    flex-shrink: 0;
}

.estimate-verified-badge--compact {
    margin-left: 0.375rem;
    padding: 0.125rem;
}

.estimate-verification-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.estimate-verification-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.estimate-verification-decline {
    margin-top: 1rem;
}

.estimate-verification-asked-title {
    margin: 1.5rem 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.estimate-verification-quote {
    margin: 0.25rem 0 0.5rem;
    font-style: italic;
    color: var(--text-secondary);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.estimate-verification-request {
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--primary-color);
}

.estimate-verification-picked {
    margin-top: 1rem;
}

.estimate-verification-picked-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0 0 0.75rem;
}

.change-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem 1.5rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.change-summary__price {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0;
}

.change-summary__price strong {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-heading);
    font-variant-numeric: tabular-nums;
}

.change-summary__price span,
.change-summary__none {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.change-summary__counts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.change-summary__count {
    --tone: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem 0.25rem 0.5rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone) 12%, transparent);
    color: var(--tone);
    font-size: 0.8125rem;
    font-weight: 600;
}

.change-summary__count--added { --tone: var(--success-color); }
.change-summary__count--removed { --tone: var(--danger-color); }
.change-summary__count--adjusted { --tone: var(--warning-color); }

.change-summary__kept {
    margin: -0.25rem 0 0.75rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.staging-panel {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary-color) 4%, var(--card-bg));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px color-mix(in srgb, var(--primary-color) 18%, var(--border-color));
}

.staging-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.staging-panel__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0 0 0.25rem;
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.staging-panel__title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-heading);
}

.staging-panel__note {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.staging-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.staging-panel .change-summary {
    margin: 1.25rem 0 0;
}

.staging-panel .change-summary__kept {
    margin: 0.5rem 0 0;
}

.staging-panel__fee {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.625rem 0.75rem 0.625rem 1rem;
    border-radius: 10px;
    background: var(--warning-color-light);
    color: var(--warning-color);
}

.staging-panel__fee p {
    flex: 1 1 16rem;
    margin: 0;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.estimate-verification-fee {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.estimate-verification-methods {
    display: flex;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
}

.estimate-staging-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
    background: var(--card-bg, #fff);
}

.estimate-staging-banner p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.estimate-attachments-add {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.estimate-attachments-add .job-check-note {
    flex: 1 1 260px;
    margin: 0;
}

.estimate-attachments-add-button {
    margin-left: auto;
}

.estimate-attachment-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: 0.75rem;
}

.estimate-attachment-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.estimate-attachment-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-muted);
}

.estimate-attachment-thumb i {
    width: 22px;
    height: 22px;
}

.estimate-attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.estimate-attachment-body {
    flex: 1;
    min-width: 0;
}

.estimate-attachment-label {
    margin: 0;
    font-weight: 600;
    color: var(--text-heading);
    overflow-wrap: anywhere;
}

.estimate-attachment-meta {
    margin: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.estimate-attachment-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 0.125rem;
}

.estimate-attachment-errors {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    color: var(--danger-color);
}

.pro-search-results {
    display: flex;
    flex-direction: column;
    margin-top: 0.5rem;
    max-height: 20rem;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg, #fff);
}

.pro-search-result {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.pro-search-result:last-child {
    border-bottom: 0;
}

.pro-search-result:hover,
.pro-search-result:focus-visible {
    background: var(--table-row-hover);
}

.pro-search-result:hover .dash-row-title {
    color: var(--primary-color);
}

@media print {
    .estimate-verified-badge {
        border: 1px solid currentColor;
        background: none;
    }
}

.support-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.support-timeline .message {
    max-width: 90%;
}

.support-note {
    align-self: stretch;
    padding: 0.625rem 0.875rem;
    border: 1px dashed var(--warning-color);
    border-radius: 8px;
    background-color: var(--warning-color-light);
}

.support-event {
    align-self: center;
    max-width: 90%;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.support-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
}

.support-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    background-color: var(--primary-color-light);
}

.support-banner p {
    flex: 1 1 18rem;
    margin: 0;
}

.support-changes {
    margin: 0;
    padding-left: 1.25rem;
}

.support-changes li {
    margin: 0.25rem 0;
}

.support-stars {
    display: inline-flex;
    gap: 0.125rem;
}

.support-star {
    padding: 0.25rem;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.support-star--on {
    color: var(--warning-color);
}

.support-star svg {
    width: 24px;
    height: 24px;
}

.support-star--on svg {
    fill: currentColor;
}

.support-fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}

.support-fields dt {
    color: var(--text-muted);
}

.support-fields dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 640px) {
    .support-fields {
        grid-template-columns: 1fr;
    }

    .support-fields dd {
        margin-bottom: 0.5rem;
    }
}


/* ===== MVC port additions ===== */
/* Map placeholder — stands in for the deferred Google Maps integration.
   Occupies the same box the map did so the vendor page layout is unchanged. */
.map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 320px;
    padding: 2rem;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-muted);
}

.map-placeholder i {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.map-placeholder p {
    margin: 0;
    font-weight: 600;
    color: var(--text-secondary);
}

.map-placeholder span {
    font-size: 0.875rem;
    color: var(--text-muted);
}


/* Moved out of Carousel.razor's scoped <style> block during the MVC port. */
.carousel-indicators .indicator {
    width: 12px;
    height: 12px;
    cursor: pointer;
    border-radius: 50%;
    border: none;
    background-color: var(--border-color);
}

.carousel {
    width: 100%;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    width: 100%;
}

/* One slide wide, so the slides overflow it and app.js can step by translateX(-n * 100%). */
.carousel-track {
    display: flex;
    width: 100%;
    transition: transform 0.3s ease;
}

/* flex-basis rather than min-width: slides must never shrink to share the track. The slide is
   itself a centring box, so images narrower than the frame sit in the middle of it. */
.carousel-slide {
    flex: 0 0 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Fill the frame height and keep the aspect ratio, capped so a wide image letterboxes instead of
   spilling over its neighbours. Without a bound the image renders at its intrinsic size and
   object-fit has nothing to fit against. */
.carousel-slide img {
    display: block;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10;
}

.carousel-nav:hover {
    background: rgba(255, 255, 255, 1);
}

.indicator.active {
    background: var(--primary-color);
}

.thumbnail.active {
    border-color: var(--primary-color);
}

/* Moved out of Carousel.razor's scoped <style> block: the full-screen viewer. */
.carousel-fullscreen-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem;
    box-sizing: border-box;
    outline: none;
}

.carousel-fullscreen-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-fullscreen-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.carousel-fullscreen-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background-color 0.2s ease;
}

.carousel-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.carousel-fullscreen-nav {
    background: rgba(255, 255, 255, 0.85);
    color: #0f172a;
    width: 48px;
    height: 48px;
}

.carousel-fullscreen-nav.prev {
    position: absolute;
    left: -4rem;
    top: 50%;
    transform: translateY(-50%);
}

.carousel-fullscreen-nav.next {
    position: absolute;
    right: -4rem;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 768px) {
    .carousel-fullscreen-nav.prev {
        left: 0.5rem;
    }

    .carousel-fullscreen-nav.next {
        right: 0.5rem;
    }

    .carousel-fullscreen-close {
        top: 0.75rem;
        right: 0.75rem;
    }
}

.carousel-fullscreen-indicators {
    position: absolute;
    bottom: -2rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}
