:root {
    --brand-primary: #D6181F;
    --brand-primary-dark: #A91218;
    --brand-primary-light: #ED1C24;
    --brand-accent: #FF5A5F;
    --brand-gray: #8C8C8C;
    --brand-gray-light: #CFCFCF;
    --brand-ink: #1F1F1F;
    --brand-ink-soft: #2C2C2C;
    --brand-gradient: linear-gradient(135deg, #B01218 0%, #D6181F 100%);

    /* Secondary accents give sections and metrics their own identity
       while the brand red stays the primary action color. */
    --accent-red: #D6181F;
    --accent-red-bg: #FDECEC;
    --accent-teal: #0E8C80;
    --accent-teal-bg: #E2F5F2;
    --accent-charcoal: #2C2C2C;
    --accent-charcoal-bg: #EDEDED;
    --accent-amber: #B86E00;
    --accent-amber-bg: #FFF3DC;
    --accent-rose: #CF2C58;
    --accent-rose-bg: #FDEAF0;
    --accent-steel: #5C5C5C;
    --accent-steel-bg: #F0F0F0;

    --bg-app: #F4F4F4;
    --surface: #FFFFFF;
    --surface-alt: #F8F8F8;
    --surface-sunken: #EFEFEF;
    --border: #E5E5E5;
    --border-strong: #CFCFCF;

    --text-primary: #1F1F1F;
    --text-secondary: #525252;
    --text-muted: #6E6E6E;

    --danger: #9F1239;
    --danger-bg: #FCE7EE;
    --success: #13885D;
    --success-bg: #E5F6EE;
    --warning: #A86400;
    --warning-bg: #FFF4E0;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-display: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --fs-2xs: 0.6875rem;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.9375rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.75rem;
    --fs-3xl: 2.25rem;

    --shadow-xs: 0 1px 2px rgba(23, 23, 23, 0.05);
    --shadow-sm: 0 1px 2px rgba(23, 23, 23, 0.04), 0 1px 3px rgba(23, 23, 23, 0.06);
    --shadow-md: 0 6px 16px -4px rgba(23, 23, 23, 0.10), 0 2px 4px -2px rgba(23, 23, 23, 0.05);
    --shadow-lg: 0 20px 40px -12px rgba(23, 23, 23, 0.22), 0 4px 10px -4px rgba(23, 23, 23, 0.06);
    --ring: 0 0 0 3px rgba(214, 24, 31, 0.22);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --bs-body-font-family: var(--font-sans);
    --bs-body-color: var(--text-primary);
    --bs-body-color-rgb: 31, 31, 31;
    --bs-heading-color: var(--text-primary);
    --bs-secondary-color: #5C5C5C;
    --bs-primary: #D6181F;
    --bs-primary-rgb: 214, 24, 31;
    --bs-link-color: #D6181F;
    --bs-link-color-rgb: 214, 24, 31;
    --bs-link-hover-color: #A91218;
    --bs-link-hover-color-rgb: 169, 18, 24;
    --bs-border-color: var(--border);
    --bs-border-radius: 0.5rem;
    --bs-border-radius-sm: 0.375rem;
    --bs-border-radius-lg: 0.75rem;
    --bs-focus-ring-color: rgba(214, 24, 31, 0.25);
}

html, body {
    font-family: var(--font-sans);
    font-feature-settings: "cv11", "ss01";
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
}

/* Force Havit toast container to overlay rather than render inline.
   Without this, the empty container's default margin pushes body height
   and creates a small vertical scroll, and toasts can render off-screen. */
.hx-toast-container {
    position: fixed !important;
    bottom: 0;
    right: 0;
    pointer-events: none;
    z-index: 1090;
}

.hx-toast-container > * {
    pointer-events: auto;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
}

a:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display);
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

h1, h2, h3, .h1, .h2, .h3 {
    font-weight: 700;
}

h4, h5, h6, .h4, .h5, .h6 {
    font-weight: 650;
}

::selection {
    background: rgba(237, 28, 36, 0.2);
}

code, kbd, pre, samp {
    font-family: var(--font-mono);
}

.timeline-markdown h1,
.timeline-markdown h2,
.timeline-markdown h3,
.timeline-markdown h4,
.timeline-markdown h5,
.timeline-markdown h6 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.25;
    margin: 0.65rem 0 0.35rem;
}

.timeline-markdown h1 {
    font-size: 1rem;
}

.timeline-markdown h2 {
    font-size: 0.95rem;
}

.timeline-markdown h3 {
    font-size: 0.9rem;
}

.timeline-markdown h4,
.timeline-markdown h5,
.timeline-markdown h6 {
    font-size: 0.84rem;
}

.timeline-markdown :first-child {
    margin-top: 0;
}

h1:focus,
:focus-visible {
    outline: none;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-check-input:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--brand-primary-light);
    outline-offset: 2px;
}

/* ---------- Auth (login layout) form elements ---------- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.auth-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.auth-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 0.875rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.auth-input::placeholder {
    color: #A1A1A1;
}

.auth-input:focus {
    border-color: var(--brand-primary-light);
    box-shadow: var(--ring);
    outline: none;
}

.auth-input.invalid,
.auth-input[aria-invalid="true"] {
    border-color: var(--danger);
}

.auth-error {
    color: var(--danger);
    font-size: 0.8125rem;
}

.auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.auth-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-primary);
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 0 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    text-decoration: none;
}

.auth-btn:active {
    transform: translateY(1px);
}

.auth-btn-primary {
    background: var(--brand-primary) linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 100%);
    color: #fff;
    box-shadow: 0 1px 2px rgba(169, 18, 24, 0.3), 0 6px 16px -6px rgba(214, 24, 31, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.auth-btn-primary:hover {
    background-color: var(--brand-primary-dark);
    color: #fff;
    text-decoration: none;
}

.auth-btn-secondary {
    background: var(--surface);
    color: var(--brand-primary);
    border-color: var(--border-strong);
}

.auth-btn-secondary:hover {
    background: var(--surface-alt);
    border-color: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    text-decoration: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-link-subtle {
    font-size: 0.8125rem;
    color: var(--brand-primary);
    font-weight: 500;
}

.auth-meta {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.auth-status {
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.alert-danger,
.auth-status-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(214, 62, 90, 0.22);
}

.alert-success,
.auth-status-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(31, 157, 109, 0.22);
}

/* ---------- Portal page chrome ---------- */

/* Card-style header used on list pages via the PageHeader component */
.page-header-card,
.page-header {
    background:
        radial-gradient(70% 160% at 100% 0%, rgba(237, 28, 36, 0.10) 0%, transparent 60%),
        radial-gradient(45% 140% at 82% 120%, rgba(217, 71, 76, 0.07) 0%, transparent 70%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.page-header-text {
    min-width: 0;
    flex: 1 1 16rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow-wrap: anywhere;
}

.page-header-heading {
    min-width: 0;
}

.page-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-lg);
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 8px 18px -6px rgba(214, 24, 31, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.page-header-icon svg {
    width: 22px;
    height: 22px;
}

.page-header-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.page-header-subtitle {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    margin: 0.25rem 0 0;
    line-height: 1.45;
}

.page-header-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    max-width: 100%;
}

/* Filter / search bar */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.875rem;
    box-shadow: var(--shadow-sm);
}

/* When filter bar has labeled search + dropdowns, top-align so label rows and inputs line up */
.filter-bar--aligned {
    align-items: flex-start;
}

/* Bookkeeping recorded transactions: uniform control height (no stacked labels on date pickers). */
.filter-bar--transactions {
    align-items: center;
}

.filter-bar--transactions .filter-bar-date {
    flex: 0 0 auto;
    min-width: min(11rem, 100%);
}

.filter-bar--transactions .filter-bar-checkbox {
    min-height: 38px;
    margin-bottom: 0;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.filter-bar-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.filter-bar-search {
    position: relative;
    flex: 1;
    min-width: min(100%, 16rem);
}

.filter-bar .filter-bar-select .form-label,
.filter-bar .filter-bar-select label.form-label {
    margin-bottom: 0.5rem;
    min-height: 1.25rem;
    line-height: 1.25;
}

.filter-bar .filter-bar-select {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.filter-bar-clear {
    display: flex;
    align-items: center;
}

.filter-bar .filter-bar-clear .clear-filters {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}

/* Match search field height to Bootstrap / Havit selects in this bar */
.filter-bar .filter-bar-select .form-select,
.filter-bar .filter-bar-select select {
    min-height: 38px;
}

.filter-bar-dropdowns {
    flex-shrink: 0;
}

.filter-bar-select {
    min-width: 12rem;
    max-width: 18rem;
}

.filter-bar .search-input {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 38px;
}

.filter-bar .search-icon {
    position: absolute;
    left: 0.75rem;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.filter-bar .search-field {
    width: 100%;
    height: 38px;
    padding: 0 0.875rem 0 2.25rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface-alt);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.filter-bar .search-field:hover {
    border-color: #C0C0C0;
}

.filter-bar .search-field:focus {
    background: var(--surface);
}

.filter-bar .search-field::placeholder {
    color: #A1A1A1;
}

.filter-bar .search-field:focus {
    border-color: var(--brand-primary-light);
    box-shadow: var(--ring);
    outline: none;
}

.filter-bar .clear-filters {
    color: var(--brand-primary);
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.filter-bar .clear-filters:hover {
    text-decoration: underline;
}

/* Table cell polish */
.cell-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.cell-with-icon svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.cell-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
}

.cell-link:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}


/* ---------- Account settings (Manage) layout ---------- */
.manage-grid {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 768px) {
    .manage-grid {
        grid-template-columns: 1fr;
    }
}

.manage-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.manage-nav-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.manage-nav-list li {
    padding: 0;
}

.manage-nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    line-height: 1.2;
}

.manage-nav-list .nav-link:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.manage-nav-list .nav-link.active {
    background: var(--accent-red-bg);
    color: var(--brand-primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.manage-nav-list .nav-link svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.manage-nav-list .nav-link.active svg {
    color: var(--brand-primary);
}

.manage-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Recovery code styling */
.recovery-code-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .recovery-code-grid {
        grid-template-columns: 1fr;
    }
}

.recovery-code {
    display: block;
    padding: 0.5rem 0.75rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.04em;
}

/* QR code container for authenticator setup */
.qr-code-host {
    display: inline-block;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.shared-key {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9375rem;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

/* Static-key/value list used on Profile page header */
.read-only-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.read-only-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.read-only-field-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.field-help {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0.375rem 0 0;
}

.setup-list {
    padding-left: 1.25rem;
    margin: 0;
}

.setup-list > li {
    margin-bottom: 1.5rem;
}

.setup-list > li:last-child {
    margin-bottom: 0;
}

/* Passkey list */
.passkey-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.passkey-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
}

.passkey-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.passkey-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.passkey-name {
    font-weight: 500;
    color: var(--text-primary);
}

.passkey-actions {
    display: flex;
    gap: 0.375rem;
    margin: 0;
}

.page-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 750;
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-secondary);
    margin: 0;
    font-size: var(--fs-sm);
    line-height: 1.45;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    --kpi-accent: var(--brand-primary);
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.25rem 1.125rem 1.375rem;
    box-shadow: var(--shadow-sm);
}

.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--kpi-accent);
}

.kpi-grid > .kpi-card:nth-child(4n + 2) { --kpi-accent: var(--accent-teal); }
.kpi-grid > .kpi-card:nth-child(4n + 3) { --kpi-accent: var(--accent-charcoal); }
.kpi-grid > .kpi-card:nth-child(4n + 4) { --kpi-accent: var(--accent-amber); }

a.kpi-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

a.kpi-link:hover {
    border-color: var(--brand-primary-light);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: inherit;
}

a.kpi-link:active {
    transform: translateY(1px);
}

.kpi-label {
    font-size: var(--fs-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 750;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 0.375rem 0 0.25rem;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
}

.kpi-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.kpi-muted {
    color: var(--text-muted);
}

.panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

@media (max-width: 900px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-alt) 100%);
}

.panel-title,
.panel-header > h2,
.panel-header > div > h2 {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin: 0;
    color: var(--text-primary);
}

.panel-header p {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin: 0.2rem 0 0;
}

.panel > .table,
.panel > .table-responsive > .table,
.panel .hx-grid .table {
    margin-bottom: 0;
}

.panel-body {
    padding: 1.25rem;
}

.panel-empty {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.panel-empty p {
    margin: 0;
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.checklist li {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.check.pending {
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.activity-feed {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:first-child {
    padding-top: 0;
}

.activity-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    flex-shrink: 0;
}

.activity-body {
    min-width: 0;
    flex: 1;
}

.activity-title {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.activity-title:hover {
    color: var(--brand-primary);
    text-decoration: underline;
}

.activity-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.activity-action {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 0.25rem;
}

/* ---------- Identity scaffolded form polish (non-auth-layout pages) ---------- */
.form-floating > .form-control:focus,
.form-floating > .form-control-plaintext:focus {
    border-color: var(--brand-primary-light);
    box-shadow: var(--ring);
}

/* ---------- Bootstrap component theme ---------- */
.btn {
    --bs-btn-font-family: var(--font-sans);
    --bs-btn-font-weight: 600;
    --bs-btn-font-size: 0.9rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-border-radius: var(--radius-md);
    --bs-btn-focus-box-shadow: var(--ring);
    letter-spacing: -0.005em;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-sm {
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-padding-x: 0.75rem;
    --bs-btn-padding-y: 0.3125rem;
    --bs-btn-border-radius: 7px;
}

.btn-lg {
    --bs-btn-font-size: 1rem;
    --bs-btn-padding-x: 1.375rem;
    --bs-btn-padding-y: 0.6875rem;
    --bs-btn-border-radius: 10px;
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-primary-dark);
    --bs-btn-hover-border-color: var(--brand-primary-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #2E2E2E;
    --bs-btn-active-border-color: #2E2E2E;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 100%);
    box-shadow: 0 1px 2px rgba(169, 18, 24, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px -2px rgba(214, 24, 31, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: rgba(214, 24, 31, 0.38);
    --bs-btn-hover-color: var(--brand-primary-dark);
    --bs-btn-hover-bg: var(--accent-red-bg);
    --bs-btn-hover-border-color: var(--brand-primary);
    --bs-btn-active-color: var(--brand-primary-dark);
    --bs-btn-active-bg: #E7E7E7;
    --bs-btn-active-border-color: var(--brand-primary);
    --bs-btn-disabled-color: var(--brand-primary);
    --bs-btn-disabled-bg: var(--surface);
    --bs-btn-disabled-border-color: rgba(214, 24, 31, 0.3);
    box-shadow: var(--shadow-xs);
}

.btn-outline-secondary,
.btn-light {
    --bs-btn-color: var(--text-primary);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text-primary);
    --bs-btn-hover-bg: var(--surface-alt);
    --bs-btn-hover-border-color: #B8B8B8;
    --bs-btn-active-color: var(--text-primary);
    --bs-btn-active-bg: var(--surface-sunken);
    --bs-btn-active-border-color: #B8B8B8;
    --bs-btn-disabled-color: var(--text-muted);
    --bs-btn-disabled-bg: var(--surface);
    --bs-btn-disabled-border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-outline-danger {
    --bs-btn-color: var(--danger);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: rgba(210, 54, 90, 0.4);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #B32A4B;
    --bs-btn-active-border-color: #B32A4B;
}

.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #B32A4B;
    --bs-btn-hover-border-color: #B32A4B;
    --bs-btn-active-bg: #9C2441;
    --bs-btn-active-border-color: #9C2441;
}

.btn-outline-warning {
    --bs-btn-color: var(--warning);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: rgba(214, 138, 0, 0.45);
    --bs-btn-hover-color: #5C3700;
    --bs-btn-hover-bg: var(--warning-bg);
    --bs-btn-hover-border-color: #D68A00;
    --bs-btn-active-color: #5C3700;
    --bs-btn-active-bg: #FFE8BC;
    --bs-btn-active-border-color: #D68A00;
}

.btn-link,
a.btn-link {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-hover-color: var(--brand-primary-dark);
    --bs-btn-active-color: var(--brand-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-close:focus {
    box-shadow: var(--ring);
}

/* Form controls */
.form-control,
.form-select {
    border-color: var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fs-base);
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-control:hover:not(:disabled):not(:focus),
.form-select:hover:not(:disabled):not(:focus) {
    border-color: #C0C0C0;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary-light);
    box-shadow: var(--ring);
}

.form-control::placeholder {
    color: #A1A1A1;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--surface-sunken);
}

.form-control-sm,
.form-select-sm {
    border-radius: 7px;
    font-size: var(--fs-sm);
}

.form-control-lg,
.form-select-lg {
    font-size: var(--fs-md);
}

.form-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-floating > label,
.form-floating > .form-label {
    font-size: var(--fs-base);
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 0;
}

.form-text {
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.form-check-input {
    border-color: var(--border-strong);
}

.form-check-label {
    font-size: var(--fs-base);
}

.form-check-input:focus {
    border-color: var(--brand-primary-light);
    box-shadow: var(--ring);
}

.form-switch .form-check-input:focus {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%232A8AE6'/%3e%3c/svg%3e");
}

/* Tables */
.table {
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border);
    --bs-table-hover-bg: rgba(214, 24, 31, 0.035);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-striped-bg: rgba(31, 31, 31, 0.018);
    font-size: 0.9rem;
}

.table > thead > tr > th,
.table > thead th {
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom-color: var(--border);
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.875rem;
}

.table-sm > :not(caption) > * > * {
    padding: 0.4rem 0.6rem;
}

.table > tbody > tr > td {
    vertical-align: middle;
}

.panel .table > tbody > tr:last-child > *,
.panel .table > tfoot > tr:last-child > * {
    border-bottom-width: 0;
}

.table-hover > tbody > tr {
    transition: background-color 0.12s ease;
}

/* Badges */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 999px;
    padding: 0.36em 0.7em;
}

.badge.text-bg-light,
.badge.bg-light {
    background-color: var(--surface-sunken) !important;
    color: #404040 !important;
    box-shadow: inset 0 0 0 1px var(--border);
}

.badge.text-bg-primary,
.badge.bg-primary {
    background-color: var(--accent-red-bg) !important;
    color: var(--brand-primary-dark) !important;
    box-shadow: inset 0 0 0 1px rgba(214, 24, 31, 0.2);
}

.badge.text-bg-success,
.badge.bg-success {
    background-color: var(--success-bg) !important;
    color: #0D6E4A !important;
    box-shadow: inset 0 0 0 1px rgba(19, 136, 93, 0.22);
}

.badge.text-bg-danger,
.badge.bg-danger {
    background-color: var(--danger-bg) !important;
    color: #B02248 !important;
    box-shadow: inset 0 0 0 1px rgba(210, 54, 90, 0.22);
}

.badge.text-bg-warning,
.badge.bg-warning {
    background-color: var(--warning-bg) !important;
    color: #8A5200 !important;
    box-shadow: inset 0 0 0 1px rgba(214, 138, 0, 0.28);
}

.badge.text-bg-info,
.badge.bg-info {
    background-color: var(--accent-steel-bg) !important;
    color: #3F3F3F !important;
    box-shadow: inset 0 0 0 1px rgba(74, 74, 74, 0.22);
}

.badge.text-bg-secondary,
.badge.bg-secondary {
    background-color: #EFEFEF !important;
    color: #535353 !important;
    box-shadow: inset 0 0 0 1px rgba(83, 83, 83, 0.18);
}

.badge.text-bg-dark,
.badge.bg-dark {
    background-color: var(--brand-ink) !important;
    color: #fff !important;
}

/* Alerts */
.alert {
    --bs-alert-border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-warning {
    --bs-alert-color: #6E4400;
    --bs-alert-bg: var(--warning-bg);
    --bs-alert-border-color: #F4D49A;
    --bs-alert-link-color: #5C3700;
}

.alert-info {
    --bs-alert-color: #3A3A3A;
    --bs-alert-bg: var(--accent-steel-bg);
    --bs-alert-border-color: #D4D4D4;
    --bs-alert-link-color: #353535;
}

.alert-secondary,
.alert-light {
    --bs-alert-color: var(--text-secondary);
    --bs-alert-bg: var(--surface-alt);
    --bs-alert-border-color: var(--border);
}

/* Tabs, pagination, progress */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--border);
    --bs-nav-tabs-border-radius: 0;
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-border-color: transparent;
    --bs-nav-tabs-link-hover-border-color: transparent;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
}

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.625rem 0.875rem;
    background: transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--brand-primary);
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: var(--brand-primary-dark);
    border-bottom-color: var(--brand-primary);
    background: transparent;
}

.pagination {
    --bs-pagination-color: var(--text-secondary);
    --bs-pagination-hover-color: var(--brand-primary);
    --bs-pagination-hover-bg: var(--accent-red-bg);
    --bs-pagination-focus-color: var(--brand-primary);
    --bs-pagination-focus-box-shadow: var(--ring);
    --bs-pagination-active-bg: var(--brand-primary);
    --bs-pagination-active-border-color: var(--brand-primary);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-border-radius: var(--radius-md);
    font-size: var(--fs-sm);
}

.progress {
    --bs-progress-bar-bg: var(--brand-primary);
    --bs-progress-bg: var(--surface-sunken);
    --bs-progress-border-radius: 999px;
}

.dropdown-menu {
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-border-radius: var(--radius-lg);
    --bs-dropdown-link-active-bg: var(--brand-primary);
    --bs-dropdown-link-hover-bg: var(--surface-alt);
    --bs-dropdown-font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    padding: 0.375rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
}

/* Modals and offcanvas */
.modal-content {
    border: 0;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.modal-header,
.offcanvas-header {
    border-bottom: 1px solid var(--border);
    padding: 1.125rem 1.5rem;
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
    padding: 0.875rem 1.5rem;
}

.modal-title,
.offcanvas-title {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.015em;
}

.modal-backdrop {
    --bs-backdrop-bg: #1F1F1F;
    --bs-backdrop-opacity: 0.45;
}

.offcanvas {
    --bs-offcanvas-border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

.card {
    --bs-card-border-color: var(--border);
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-cap-bg: var(--surface-alt);
    box-shadow: var(--shadow-sm);
}

hr {
    border-color: var(--border);
    opacity: 1;
}

.darker-border-checkbox.form-check-input {
    border-color: var(--border-strong);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
}

/* Small status component used by auth pages */
::deep .alert {
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.blazor-error-boundary {
    background: var(--danger);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Bootstrap form-floating keeps the placeholder transparent until the input
   is focused or filled — the label sits in its place. Only restyle the
   placeholder for the focused/filled state so we don't collide with the label. */
.form-floating > .form-control:focus::placeholder,
.form-floating > .form-control:not(:placeholder-shown)::placeholder,
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control-plaintext:not(:placeholder-shown)::placeholder {
    color: var(--text-muted);
}

/* ---- Billing / Stripe ---- */
.stripe-mode-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #FFF6E0;
    color: #6B4F00;
    border-bottom: 1px solid #F2D27A;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.stripe-mode-banner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: #862A2D;
    color: #FFFFFF;
    border-bottom: 1px solid #303030;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.impersonation-banner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.impersonation-exit-form {
    margin: 0;
}

.impersonation-exit-btn {
    margin-left: 0.5rem;
}

.billing-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.billing-tab {
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.billing-tab:hover {
    color: var(--text-primary);
}

.billing-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: var(--fs-2xs);
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(31, 31, 31, 0.06);
}

.status-badge::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.status-badge-paid, .status-badge-active, .status-badge-succeeded {
    background: var(--success-bg);
    color: #0D6E4A;
}

.status-badge-open, .status-badge-trialing {
    background: var(--accent-red-bg);
    color: var(--brand-primary);
}

.status-badge-draft, .status-badge-incomplete {
    background: #F0F0F0;
    color: var(--text-secondary);
}

.status-badge-uncollectible, .status-badge-past_due, .status-badge-failed, .status-badge-canceled, .status-badge-void {
    background: var(--danger-bg);
    color: #B02248;
}

.status-badge-warning, .status-badge-awaiting {
    background: var(--warning-bg);
    color: #8A5200;
}

.amount-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.linked-customer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.linked-customer-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.invoice-line-row {
    display: grid;
    grid-template-columns: 2fr 1fr 80px 120px auto;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.5rem;
}

.no-stripe-config {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

.ticket-comment {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
}

.ticket-comment.internal {
    background: #fff8e1;
    border-color: #f5c542;
}

.ticket-comment-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.ticket-comment-body {
    white-space: pre-wrap;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.ticket-info {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.375rem;
    margin: 0;
    font-size: 0.9375rem;
}

.ticket-info dt {
    color: var(--text-muted);
    font-weight: 500;
}

.ticket-info dd {
    margin: 0;
    color: var(--text-primary);
}

.ticket-description {
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* ===== Submit ticket form ===== */

.ticket-form {
    max-width: 56rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.form-section-head {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    align-items: flex-start;
}

/* Validation messages: Havit renders them as absolute, single-line, truncated
   "feedback-floating" — force them to flow inline and wrap so long messages
   stay readable. */
.form-section .invalid-tooltip,
.form-section .invalid-feedback,
.form-section .feedback-floating {
    position: static !important;
    display: block;
    margin-top: 0.25rem;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

    .form-section .invalid-feedback.text-truncate,
    .form-section .feedback-floating.text-truncate,
    .form-section .invalid-feedback > span,
    .form-section .feedback-floating > span {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }

.form-section-icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(214, 24, 31, 0.08);
    color: var(--brand-primary);
    font-size: 1.05rem;
}

.form-section-heading {
    min-width: 0;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.form-section-hint {
    margin: 0.125rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.4;
}

.form-section-body {
    padding: 1.25rem;
}

/* Segmented (radio-as-buttons) control */

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.segmented-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    min-height: 2.75rem;
    user-select: none;
}

    .segmented-option:hover {
        border-color: var(--brand-primary-light);
        background: var(--surface-alt);
    }

    .segmented-option i.bi {
        font-size: 1.05rem;
        color: var(--text-muted);
        transition: color 0.15s ease;
    }

    .segmented-option.is-active {
        border-color: var(--brand-primary);
        background: rgba(214, 24, 31, 0.08);
        color: var(--brand-primary-dark);
        box-shadow: 0 0 0 2px rgba(214, 24, 31, 0.15);
    }

        .segmented-option.is-active i.bi {
            color: var(--brand-primary);
        }

.segmented-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

    .segmented-input:focus-visible + i.bi,
    .segmented-option:has(.segmented-input:focus-visible) {
        outline: 2px solid var(--brand-primary-light);
        outline-offset: 2px;
    }

/* Wizard inside a section */

.ticket-wizard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ticket-wizard-progress {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ticket-wizard-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.ticket-wizard-step {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.ticket-wizard-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.ticket-wizard-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.ticket-wizard-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-light));
    transition: width 0.25s ease;
}

.ticket-wizard-body {
    margin-top: 0.25rem;
}

.ticket-wizard-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--border);
    padding-top: 0.75rem;
}

/* Drop zone */

.ticket-dropzone {
    display: block;
    position: relative;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    background: var(--surface-alt);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

    .ticket-dropzone:hover {
        border-color: var(--brand-primary-light);
        background: rgba(214, 24, 31, 0.04);
    }

.ticket-dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ticket-dropzone-content {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    pointer-events: none;
}

.ticket-dropzone-icon {
    font-size: 1.5rem;
    color: var(--brand-primary);
}

/* File chips */

.ticket-file-list {
    list-style: none;
    margin: 0.875rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ticket-file {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

    .ticket-file > i.bi {
        color: var(--brand-primary);
    }

.ticket-file-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticket-file-size {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.ticket-file-remove {
    line-height: 1;
}

/* Footer actions */

.ticket-form-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    margin-top: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 1;
}

@media (max-width: 575px) {
    .segmented {
        grid-template-columns: 1fr;
    }

    .form-section-head {
        gap: 0.625rem;
    }

    .ticket-wizard-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .ticket-wizard-label {
        text-align: left;
    }
}

/* ===== Ticket view ===== */

.ticket-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ticket-hero {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.ticket-hero-main {
    min-width: 0;
    flex: 1 1 24rem;
}

.ticket-hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.ticket-hero-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--brand-primary);
    font-weight: 600;
}

.ticket-hero-dot {
    color: var(--text-muted);
}

.ticket-hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.625rem;
    line-height: 1.25;
}

.ticket-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.ticket-hero-actions {
    flex-shrink: 0;
}

/* Status / meta pills */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    border: 1px solid transparent;
    line-height: 1;
}

    .status-pill > i.bi {
        font-size: 0.875rem;
    }

    .status-pill.is-info {
        background: rgba(237, 29, 36, 0.1);
        color: #C41016;
        border-color: rgba(237, 29, 36, 0.25);
    }

    .status-pill.is-primary {
        background: rgba(214, 24, 31, 0.12);
        color: var(--brand-primary-dark);
        border-color: rgba(214, 24, 31, 0.3);
    }

    .status-pill.is-warning {
        background: rgba(245, 158, 11, 0.12);
        color: #b45309;
        border-color: rgba(245, 158, 11, 0.35);
    }

    .status-pill.is-secondary {
        background: rgba(115, 115, 115, 0.12);
        color: #4F4F4F;
        border-color: rgba(115, 115, 115, 0.3);
    }

    .status-pill.is-success {
        background: var(--success-bg);
        color: var(--success);
        border-color: rgba(31, 157, 109, 0.3);
    }

    .status-pill.is-dark {
        background: rgba(35, 35, 35, 0.08);
        color: var(--text-primary);
        border-color: rgba(35, 35, 35, 0.2);
    }

    .status-pill.is-light {
        background: var(--surface-alt);
        color: var(--text-secondary);
        border-color: var(--border);
    }

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.625rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    line-height: 1;
}

    .meta-pill > i.bi {
        font-size: 0.875rem;
        color: var(--brand-primary);
    }

/* Composer (reply box) */

.ticket-composer {
    margin-bottom: 1rem;
}

.ticket-composer-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ticket-closed-banner {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

    .ticket-closed-banner > i.bi {
        color: var(--text-muted);
        font-size: 1.05rem;
    }

/* Conversation thread */

.ticket-thread {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.thread-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

    .thread-item.is-mine {
        flex-direction: row-reverse;
    }

.thread-avatar {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.thread-item.is-theirs .thread-avatar {
    background: var(--brand-gray);
}

.thread-bubble {
    min-width: 0;
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.thread-item.is-mine .thread-bubble {
    background: rgba(214, 24, 31, 0.06);
    border-color: rgba(214, 24, 31, 0.2);
}

.thread-item.is-internal .thread-bubble {
    background: #fff8e1;
    border-color: #f5c542;
}

.thread-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
}

.thread-author {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.thread-time {
    color: var(--text-muted);
    margin-left: auto;
    cursor: help;
}

.thread-body {
    white-space: pre-wrap;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* Empty state */

.ticket-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
}

    .ticket-empty > i.bi {
        font-size: 1rem;
    }

/* Compact dropzone variant for the sidebar */

.ticket-dropzone-compact {
    padding: 0.875rem;
}

    .ticket-dropzone-compact .ticket-dropzone-icon {
        font-size: 1.25rem;
    }

@media (max-width: 575px) {
    .ticket-hero {
        padding: 1rem 1.125rem;
    }

    .ticket-hero-title {
        font-size: 1.25rem;
    }

    .thread-bubble {
        max-width: 100%;
    }

    .thread-item.is-mine {
        flex-direction: row;
    }
}

/* Admin tickets: status filter strip (segmented with counts) */

.ticket-status-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    padding: 1px;
    margin-bottom: 1rem;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.ticket-status-segment {
    flex: 1 1 auto;
    min-width: 5.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border: none;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.ticket-status-segment:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.ticket-status-segment.is-active {
    background: var(--surface-alt);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 0 var(--brand-primary);
}

.ticket-status-segment:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    z-index: 1;
}

.ticket-status-label {
    text-align: center;
    white-space: nowrap;
}

.ticket-status-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

/* Proposal respond page: prominent "View the full proposal" CTA card.
   This page only handles comments + signing — the full proposal (line items,
   totals, attachments) lives on the public proposal page, so we surface it
   as a clickable banner that's hard to miss. */
.proposal-respond-cta {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #F1F1F1 0%, #F7F7F7 100%);
    border: 1px solid #D6D6D6;
    border-left: 4px solid var(--brand-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.proposal-respond-cta:hover,
.proposal-respond-cta:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
    border-color: var(--brand-primary-light);
    border-left-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

.proposal-respond-cta:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.proposal-respond-cta:active {
    transform: translateY(1px);
}

.proposal-respond-cta-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid #D6D6D6;
    color: var(--brand-primary);
    box-shadow: 0 1px 2px rgba(214, 24, 31, 0.08);
}

.proposal-respond-cta-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1 1 auto;
}

.proposal-respond-cta-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}

.proposal-respond-cta-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.proposal-respond-cta-action {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(214, 24, 31, 0.25);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.proposal-respond-cta:hover .proposal-respond-cta-action,
.proposal-respond-cta:focus-visible .proposal-respond-cta-action {
    background: var(--brand-primary-dark);
    box-shadow: 0 4px 12px rgba(214, 24, 31, 0.35);
}

@media (max-width: 575px) {
    .proposal-respond-cta {
        flex-wrap: wrap;
        padding: 0.875rem 1rem;
    }

    .proposal-respond-cta-text {
        flex: 1 1 calc(100% - 64px);
    }

    .proposal-respond-cta-action {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* Dashboard "action needed" block — used for proposals awaiting client signature.
   Warm amber accent so it reads as "do this now" without looking like an error. */
.action-needed-block {
    background: linear-gradient(135deg, #FFF6E5 0%, #FFFBEF 100%);
    border: 1px solid #F5CF7A;
    border-left: 4px solid #D88A00;
    border-radius: var(--radius-md);
    padding: 1.125rem 1.25rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.action-needed-header {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: 0.875rem;
}

.action-needed-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: #D88A00;
    color: #FFFBEF;
    font-size: 1.05rem;
    box-shadow: 0 2px 6px rgba(216, 138, 0, 0.25);
}

.action-needed-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #5A3F00;
    margin: 0 0 0.125rem;
    line-height: 1.25;
}

.action-needed-sub {
    font-size: 0.875rem;
    color: #7A5A1F;
    margin: 0;
    line-height: 1.4;
}

.action-needed-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-needed-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 0.875rem 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid #F0D89A;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.action-needed-card:hover,
.action-needed-card:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
    border-color: #D88A00;
    box-shadow: 0 4px 12px rgba(216, 138, 0, 0.15);
}

.action-needed-card:focus-visible {
    outline: 2px solid #D88A00;
    outline-offset: 2px;
}

.action-needed-card:active {
    transform: translateY(1px);
}

.action-needed-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1 1 auto;
}

.action-needed-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-needed-card-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.action-needed-card-cta {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 2px 4px rgba(214, 24, 31, 0.2);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.action-needed-card:hover .action-needed-card-cta,
.action-needed-card:focus-visible .action-needed-card-cta {
    background: var(--brand-primary-dark);
    box-shadow: 0 3px 8px rgba(214, 24, 31, 0.3);
}

@media (max-width: 575px) {
    .action-needed-card {
        flex-wrap: wrap;
    }

    .action-needed-card-cta {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* Proposal respond — conversation thread (chat bubbles).
   Visually mirrors the ticket thread but lives independently so the two
   pages can evolve without coupling. Client messages appear right-aligned
   ("is-mine"), team messages left-aligned ("is-theirs is-team"). */
.proposal-thread-scroll {
    max-height: 420px;
    padding: 0.75rem 0.25rem 0.25rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.proposal-thread {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.proposal-thread-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

.proposal-thread-item.is-mine {
    flex-direction: row-reverse;
}

.proposal-thread-avatar {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--brand-gray);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 2px rgba(30, 30, 30, 0.08);
}

.proposal-thread-item.is-mine .proposal-thread-avatar {
    background: var(--brand-primary);
}

.proposal-thread-item.is-team .proposal-thread-avatar {
    background: var(--brand-primary);
}

.proposal-thread-item.is-mine.is-team .proposal-thread-avatar {
    background: var(--brand-primary-dark);
}

.proposal-thread-bubble {
    min-width: 0;
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.proposal-thread-item.is-mine .proposal-thread-bubble {
    background: rgba(214, 24, 31, 0.07);
    border-color: rgba(214, 24, 31, 0.22);
}

.proposal-thread-item.is-team:not(.is-mine) .proposal-thread-bubble {
    background: rgba(237, 28, 36, 0.06);
    border-color: rgba(237, 28, 36, 0.25);
}

.proposal-thread-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
}

.proposal-thread-item.is-mine .proposal-thread-meta {
    justify-content: flex-end;
}

.proposal-thread-author {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
}

.proposal-thread-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    background: rgba(214, 24, 31, 0.12);
    color: var(--brand-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.proposal-thread-time {
    color: var(--text-muted);
    margin-left: auto;
    font-size: 0.75rem;
    cursor: help;
}

.proposal-thread-item.is-mine .proposal-thread-time {
    margin-left: 0;
    margin-right: auto;
}

.proposal-thread-body {
    white-space: pre-wrap;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Empty state */
.proposal-thread-empty {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem;
    color: var(--text-secondary);
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    margin: 0.25rem;
}

.proposal-thread-empty > i.bi {
    font-size: 1.5rem;
    color: var(--brand-gray);
    line-height: 1;
    margin-top: 0.1rem;
}

.proposal-thread-empty-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.proposal-thread-empty-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Composer (textarea + counter + send) */
.proposal-composer-input {
    resize: vertical;
}

.proposal-composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.proposal-composer-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.proposal-composer-count.is-warn {
    color: #B36B00;
    font-weight: 500;
}

.proposal-composer-send {
    display: inline-flex;
    align-items: center;
}

@media (max-width: 575px) {
    .proposal-thread-bubble {
        max-width: 100%;
    }

    .proposal-thread-item.is-mine {
        flex-direction: row;
    }

    .proposal-thread-item.is-mine .proposal-thread-meta {
        justify-content: flex-start;
    }

    .proposal-thread-item.is-mine .proposal-thread-time {
        margin-left: auto;
        margin-right: 0;
    }
}

.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: #862A2D;
    color: #FFFFFF;
    border-bottom: 1px solid #303030;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.impersonation-banner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.impersonation-exit-form {
    margin: 0;
}

.impersonation-exit-btn {
    margin-left: 0.5rem;
}

.grid-row-clickable {
    cursor: pointer;
}

.page-header, .panel-header, .passkey-row, .impersonation-banner { flex-wrap: wrap; }
.panel, .panel-grid > *, .kpi-card { min-width: 0; }
.page-title, .page-subtitle, .panel-title, .kpi-value, .passkey-name, .shared-key, .alert { overflow-wrap: anywhere; }
.qr-code-host { max-width: 100%; }
.qr-code-host img, .qr-code-host canvas { max-width: 100%; height: auto; }

@media (max-width: 900px) {
    .portal-nav-open body { overflow: hidden; }
}

@media (max-width: 360px) {
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
    .page-header-card, .page-header { padding: 1rem 1.125rem; }
    .page-header-text { gap: 0.75rem; }
    .page-header-icon { width: 2.5rem; height: 2.5rem; border-radius: 10px; }
    .page-header-icon svg { width: 20px; height: 20px; }
    .page-header-title, .page-title { font-size: var(--fs-lg); }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
    .kpi-card { padding: 0.875rem 0.875rem 0.875rem 1.125rem; }
    .kpi-value { font-size: var(--fs-xl); }
    .panel-header { padding: 0.875rem 1rem; }
    .panel-body { padding: 1rem; }
    .page-header-actions { flex: 1 1 100%; }
    .filter-bar-dropdowns { flex: 1 1 100%; min-width: 0; }
    .filter-bar-select { flex: 1 1 100%; min-width: 0; max-width: 100%; }
    .passkey-actions { flex-wrap: wrap; }
    .impersonation-banner { justify-content: flex-start; }
    .manage-nav-list .nav-link, .portal-sidebar .nav-link { min-height: 44px; }
    /* A 16px input font prevents iOS focus zoom from obscuring form actions. */
    .portal input:not([type=checkbox]):not([type=radio]), .portal select, .portal textarea,
    .auth-shell input, .auth-shell select, .auth-shell textarea,
    .modal input, .modal select, .modal textarea, .offcanvas input, .offcanvas textarea,
    .agent-dialog input, .agent-dialog select, .agent-dialog textarea { font-size: 1rem; }
}
.agent-selection-banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2147483647; width: max-content; max-width: calc(100vw - 24px); padding: 12px 16px; background: #D6181F; color: white; border-radius: 8px; box-shadow: 0 4px 20px #0004; }
.agent-selection-highlight { position: fixed; z-index: 2147483646; pointer-events: none; border: 2px solid #D6181F; background: #1656b522; }
