/* ==========================================================================
   components.css — reusable component library. Minimal, flat, hairline.
   One component per section under a clear header. BEM throughout.
   ========================================================================== */

/* ==========================================================================
   Button
   ========================================================================== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast);
}
.button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.button--primary { background: var(--primary); color: var(--text-on-accent); }
.button--primary:hover { background: var(--primary-hover); color: var(--text-on-accent); }

.button--secondary {
    background: var(--bg-surface);
    border-color: var(--border-color-strong);
    color: var(--text-strong);
}
.button--secondary:hover { background: var(--bg-surface-alt); border-color: var(--text-faint); }

.button--ghost { background: transparent; color: var(--text-default); }
.button--ghost:hover { background: var(--bg-hover); color: var(--text-strong); }

.button--danger { background: var(--color-danger-500); color: var(--color-neutral-0); }
.button--danger:hover { background: var(--color-danger-700); }

.button--small { height: 30px; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.button--block { width: 100%; }
.button__icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Interaction states — consistent across all buttons */
.button:active { transform: translateY(0.5px); }
.button:disabled, .button[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.button[data-loading="true"] { color: transparent; pointer-events: none; position: relative; }
.button[data-loading="true"]::after {
    content: ""; position: absolute; width: 14px; height: 14px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    color: var(--text-on-accent); animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Card
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
}
.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color-subtle);
}
.card__title { font-size: var(--text-md); font-weight: var(--font-semibold); }
.card__body { padding: var(--space-5); }

/* ==========================================================================
   Page header
   ========================================================================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}
.page-header__heading { display: flex; flex-direction: column; gap: var(--space-1); }
.page-header__title { font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); }
.page-header__subtitle { color: var(--text-muted); font-size: var(--text-md); }
.page-header__actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-3); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--text-strong); }
.breadcrumbs__sep { color: var(--text-faint); }

/* ==========================================================================
   Status badge
   ========================================================================== */
.status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 2px var(--space-2) 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    line-height: 1.5;
}
.status__dot { width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; flex-shrink: 0; }
.status--success { background: var(--color-success-50); color: var(--color-success-700); }
.status--warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.status--danger  { background: var(--color-danger-50);  color: var(--color-danger-700);  }
.status--info    { background: var(--color-info-50);    color: var(--color-info-700);     }
.status--neutral { background: var(--bg-sunken);        color: var(--text-muted);         }

/* ==========================================================================
   Field
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-strong); }
.field__label-optional { color: var(--text-faint); font-weight: var(--font-normal); }
.field__input {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--text-strong);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
textarea.field__input { height: auto; padding: var(--space-3); }
.field__input::placeholder { color: var(--text-faint); }
.field__input:focus { outline: none; border-color: var(--ring); box-shadow: var(--shadow-focus); }
.field__input:disabled { background: var(--bg-sunken); color: var(--text-muted); cursor: not-allowed; }
.field__hint { font-size: var(--text-xs); color: var(--text-muted); }
.field__error { font-size: var(--text-xs); color: var(--color-danger-700); display: inline-flex; align-items: center; gap: var(--space-1); }
.field--error .field__input { border-color: var(--color-danger-500); }
.field--error .field__input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-500) 30%, transparent); }
.field__required { color: var(--color-danger-500); margin-left: 2px; }
.field-group { display: grid; gap: var(--space-5); }

/* Input group — prefix/suffix (e.g. £ … pcm) */
.input-group { display: flex; align-items: stretch; }
.input-group__addon {
    display: inline-flex; align-items: center;
    padding: 0 var(--space-3);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color-strong);
    color: var(--text-muted);
    font-size: var(--text-base);
}
/* display:inline-flex above overrides the hidden attribute — restore it so a
   toggled adornment (e.g. the % / £ management-fee symbol) actually hides. */
.input-group__addon[hidden] { display: none; }
.input-group__addon--prefix { border-right: none; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group__addon--suffix { border-left: none; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-group .field__input { border-radius: 0; }
.input-group__addon--prefix + .field__input { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-group:has(.input-group__addon--suffix) .field__input:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }

/* Native select, styled */
.select-native { position: relative; display: block; }
.select-native select {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-8) 0 var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--text-strong);
    appearance: none;
    cursor: pointer;
}
.select-native select:focus { outline: none; border-color: var(--ring); box-shadow: var(--shadow-focus); }
.select-native__chevron { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }

/* Switch / toggle */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    position: relative;
    width: 38px; height: 22px;
    background: var(--color-neutral-300);
    border-radius: var(--radius-pill);
    transition: background var(--transition-base);
    flex-shrink: 0;
}
.switch__thumb {
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: var(--bg-surface);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base);
}
.switch__input:checked + .switch__track { background: var(--primary); }
.switch__input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch__input:focus-visible + .switch__track { box-shadow: var(--shadow-focus); }
.switch__text { display: flex; flex-direction: column; gap: var(--space-1); }
.switch__label { font-size: var(--text-base); color: var(--text-strong); }

/* Choice rows (checkbox / radio) */
.choice { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; padding: var(--space-1) 0; }
.choice__control { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--primary); flex-shrink: 0; }
.choice__text { display: flex; flex-direction: column; }
.choice__label { color: var(--text-strong); font-size: var(--text-base); }
.choice__hint { color: var(--text-muted); font-size: var(--text-xs); }
.choice-list { display: flex; flex-direction: column; gap: var(--space-2); }

/* Choice cards (selectable boxed options) */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); }
.choice-card {
    display: flex; align-items: flex-start; gap: var(--space-2);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.choice-card:hover { border-color: var(--text-faint); }
.choice-card--selected,
.choice-card:has(input:checked) { border-color: var(--primary); background: var(--bg-surface-alt); box-shadow: inset 0 0 0 1px var(--primary); }
.choice-card__title { color: var(--text-strong); font-weight: var(--font-medium); font-size: var(--text-base); }
.choice-card__hint { color: var(--text-muted); font-size: var(--text-xs); }

/* Tag editor (data-taginput) — a free-form chip list with an inline add field. */
.taglist {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-surface); cursor: text;
}
.taglist:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.tag {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2);
    background: var(--bg-sunken); border-radius: var(--radius-sm);
    font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-strong);
}
.tag__remove {
    display: grid; place-items: center; width: 18px; height: 18px;
    border: none; background: none; cursor: pointer;
    color: var(--text-muted); font-size: var(--text-base); line-height: 1; border-radius: var(--radius-sm);
}
.tag__remove:hover { color: var(--color-danger-700); background: var(--bg-hover); }
.tag__input {
    flex: 1; min-width: 100px;
    border: none; background: none; outline: none;
    font: inherit; color: var(--text-default); padding: var(--space-1);
}

/* Record picker — searchable single/multi select (progressive enhancement).
   The native control shows when JS is off; .is-enhanced hides it once wired. */
.picker { position: relative; }
.picker.is-enhanced .picker__native { display: none; }
.picker__field { position: relative; }
.picker__input { padding-inline-end: var(--space-8); }   /* room for the clear button */
.picker__clear {
    position: absolute; inset-block: 0; inset-inline-end: var(--space-2);
    margin-block: auto; height: 22px; width: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: none; cursor: pointer;
    color: var(--text-faint); font-size: var(--text-lg); line-height: 1;
    border-radius: var(--radius-pill);
}
.picker__clear[hidden] { display: none; }
.picker__clear:hover { color: var(--text-strong); background: var(--bg-surface-alt); }
.picker__menu {
    position: absolute; inset-inline: 0; top: calc(100% + var(--space-1));
    z-index: var(--z-dropdown);
    background: var(--bg-surface);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 18rem; overflow-y: auto;
    padding: var(--space-1);
}
.picker__menu[hidden] { display: none; }
.picker__option {
    display: block; width: 100%; text-align: start;
    border: 0; background: none; cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
}
.picker__option:hover,
.picker__option--active { background: var(--bg-surface-alt); }
.picker__option-title { display: block; color: var(--text-strong); font-size: var(--text-base); }
.picker__option-sub { display: block; color: var(--text-muted); font-size: var(--text-xs); margin-block-start: 1px; }
.picker__empty { padding: var(--space-3); color: var(--text-muted); font-size: var(--text-sm); }
.picker__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block-start: var(--space-3); }
.picker__chip {
    display: inline-flex; align-items: center; gap: var(--space-2);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-pill);
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
    font-size: var(--text-sm);
}
.picker__chip--lead { border-color: var(--primary); background: var(--accent-soft, var(--bg-surface-alt)); }
.picker__chip-name { color: var(--text-strong); font-weight: var(--font-medium); }
.picker__chip-lead {
    border: 0; background: none; cursor: pointer;
    color: var(--text-muted); font-size: var(--text-xs);
    padding: 2px var(--space-2); border-radius: var(--radius-pill);
}
.picker__chip-lead:hover { color: var(--text-strong); }
.picker__chip--lead .picker__chip-lead { color: var(--primary); }
.picker__chip-remove {
    border: 0; background: none; cursor: pointer;
    color: var(--text-faint); font-size: var(--text-lg); line-height: 1;
    padding: 0 var(--space-1); border-radius: var(--radius-sm);
}
.picker__chip-remove:hover { color: var(--danger, var(--text-strong)); }

/* Compliance summary chips above the checklist */
.compliance-summary { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-block-end: var(--space-4); }

/* File dropzone (visual only) */
.dropzone {
    border: 1.5px dashed var(--border-color-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-surface-alt);
    display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover { border-color: var(--text-faint); background: var(--bg-sunken); }
.dropzone:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-color: var(--ring); }
.dropzone--over { border-color: var(--accent); background: var(--bg-sunken); }
.dropzone__icon { color: var(--text-faint); }
.dropzone__title { color: var(--text-strong); font-weight: var(--font-medium); }
.dropzone strong { color: var(--accent); }

/* Compliance checklist (required items, present/missing obvious) */
.checklist { display: flex; flex-direction: column; }
.checklist__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border-color-subtle); }
.checklist__item:first-child { border-top: none; }
.checklist__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); flex-shrink: 0; background: var(--bg-sunken); color: var(--text-muted); }
.checklist__item--ok .checklist__icon { background: var(--color-success-50); color: var(--color-success-700); }
.checklist__item--due .checklist__icon { background: var(--color-warning-50); color: var(--color-warning-700); }
.checklist__item--overdue .checklist__icon { background: var(--color-danger-50); color: var(--color-danger-700); }
.checklist__item--missing .checklist__icon { background: var(--bg-sunken); color: var(--text-faint); border: 1px dashed var(--border-color-strong); }
.checklist__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.checklist__name { color: var(--text-strong); font-weight: var(--font-medium); }
.checklist__detail { color: var(--text-muted); font-size: var(--text-sm); }

/* Attached file list */
.filelist { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.filerow {
    display: flex; align-items: center; gap: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
}
.filerow__icon {
    display: grid; place-items: center;
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-sunken); color: var(--text-muted);
    font-size: 10px; font-weight: var(--font-bold); letter-spacing: 0.02em;
}
.filerow__icon--pdf { background: var(--color-danger-50); color: var(--color-danger-700); }
.filerow__icon--img { background: var(--color-info-50); color: var(--color-info-700); }
.filerow__icon--doc { background: var(--color-info-50); color: var(--color-info-700); }
.filerow__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.filerow__name { color: var(--text-strong); font-weight: var(--font-medium); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filerow__meta { color: var(--text-muted); font-size: var(--text-xs); }
.filerow__actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }
.fileprogress { height: 4px; border-radius: var(--radius-pill); background: var(--bg-sunken); overflow: hidden; margin-top: 4px; }
.fileprogress__bar { height: 100%; background: var(--primary); border-radius: var(--radius-pill); }

/* ==========================================================================
   Form layout
   ========================================================================== */
.form { max-width: 880px; display: flex; flex-direction: column; gap: var(--space-section); padding-bottom: var(--space-16); }
.form__group { /* uses .card */ }
.form__group-desc { color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }

/* Collapsible "More detail" group (native <details>) */
.form__group--collapsible > .card__header { cursor: pointer; list-style: none; user-select: none; }
.form__group--collapsible > .card__header::-webkit-details-marker { display: none; }
.form__group--collapsible:not([open]) > .card__header { border-bottom: none; }
.form__group-chevron { width: 18px; height: 18px; color: var(--text-faint); transition: transform var(--transition-fast); flex-shrink: 0; }
.form__group--collapsible[open] .form__group-chevron { transform: rotate(180deg); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.form-field--full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Sticky save bar — full-bleed within the content column, lifts clear of the
   window/taskbar edge via safe-area padding. */
.form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-top: var(--space-4);
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    margin-top: var(--space-4);
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
}
.form-actions__hint { color: var(--text-muted); font-size: var(--text-sm); margin-right: auto; display: inline-flex; align-items: center; gap: var(--space-2); }
.form-actions__hint-dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--color-warning-500); }

/* Unsaved-changes banner */
.banner {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-5);
}
.banner--warning { background: var(--color-warning-50); color: var(--color-warning-700); border: 1px solid color-mix(in srgb, var(--color-warning-500) 30%, transparent); }
.banner--info { background: var(--color-info-50); color: var(--color-info-700); border: 1px solid color-mix(in srgb, var(--color-info-500) 30%, transparent); }

/* Select (visual only) */
.select {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.select__control {
    height: 36px;
    padding: 0 var(--space-8) 0 var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--text-default);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    white-space: nowrap;
}
.select__control:hover { border-color: var(--text-faint); }
.select__chevron { position: absolute; right: var(--space-2); color: var(--text-faint); pointer-events: none; }

/* ==========================================================================
   Toolbar / filter bar
   ========================================================================== */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.toolbar__search {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 360px;
}
.toolbar__search .field__input { padding-left: var(--space-8); }
.toolbar__search-icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.toolbar__filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.toolbar__spacer { flex: 1; }

/* ==========================================================================
   Data table
   ========================================================================== */
.table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
/* A table placed inside a card uses the card's frame — drop the wrapper's own
   border/radius/shadow so they don't double up (e.g. the rent-payments cards). */
.card__body > .table-wrap { border: none; border-radius: 0; box-shadow: none; background: transparent; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table__head {
    text-align: left;
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-surface-alt);
}
.table__head .table__cell { font-weight: var(--font-semibold); padding-block: var(--space-3); }
.table__cell { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-color-subtle); vertical-align: middle; }
.table__row:last-child .table__cell { border-bottom: none; }
.table__body .table__row { transition: background var(--transition-fast); cursor: pointer; }
.table__body .table__row:hover { background: var(--bg-surface-alt); }
.table__cell--strong { color: var(--text-strong); font-weight: var(--font-medium); }
.table__cell--muted { color: var(--text-muted); }
.table__cell--actions { text-align: right; width: 1%; white-space: nowrap; }
.table__checkbox { width: 1%; }

/* Row flags (arrears / attention) — subtle tint + coloured left edge */
.table__row--danger { box-shadow: inset 3px 0 0 0 var(--color-danger-500); background: color-mix(in srgb, var(--color-danger-50) 55%, transparent); }
.table__row--danger:hover { background: var(--color-danger-50); }
.table__row--warning { box-shadow: inset 3px 0 0 0 var(--color-warning-500); }

/* Sparkline */
.spark { display: block; color: var(--text-faint); }
.spark--success { color: var(--color-success-500); }
.spark--warning { color: var(--color-warning-500); }
.spark--danger  { color: var(--color-danger-500); }
.spark--info    { color: var(--color-info-500); }

/* Cell with avatar/title+sub */
.cell-lead { display: flex; align-items: center; gap: var(--space-3); }
.cell-lead__avatar {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: var(--bg-sunken); color: var(--text-muted);
    display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--font-semibold);
    flex-shrink: 0;
}
.cell-lead__title { color: var(--text-strong); font-weight: var(--font-medium); }
.cell-lead__sub { color: var(--text-muted); font-size: var(--text-xs); }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-4);
}
.pagination__info { font-size: var(--text-sm); color: var(--text-muted); }
.pagination__controls { display: flex; align-items: center; gap: var(--space-1); }
.pagination__page {
    display: grid; place-items: center;
    min-width: 32px; height: 32px; padding: 0 var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-default);
    font-size: var(--text-sm);
    cursor: pointer;
}
.pagination__page:hover { background: var(--bg-hover); }
.pagination__page--active { background: var(--primary); color: var(--text-on-accent); border-color: var(--primary); }
.pagination__page--disabled { color: var(--text-faint); cursor: not-allowed; }

/* ==========================================================================
   Segmented control / tabs
   ========================================================================== */
.segmented {
    display: inline-flex;
    padding: 3px;
    background: var(--bg-sunken);
    border-radius: var(--radius-md);
    gap: 2px;
}
.segmented__item {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: transparent;
}
.segmented__item--active { background: var(--bg-surface); color: var(--text-strong); box-shadow: var(--shadow-xs); }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-color); margin-bottom: var(--space-6); }
.tabs__tab {
    padding: var(--space-3) var(--space-3);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    border: none; background: none; cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs__tab:hover { color: var(--text-strong); }
.tabs__tab--active { color: var(--text-strong); border-bottom-color: var(--primary); }

/* ==========================================================================
   Dashboard widget / stat
   ========================================================================== */
.widget {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    box-shadow: var(--shadow-xs);
}
.widget__head { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); }
.widget__icon { color: var(--text-faint); }
.widget__icon svg { width: 16px; height: 16px; }
.widget__title { font-size: var(--text-sm); font-weight: var(--font-medium); }
.widget__value { font-size: var(--text-3xl); font-weight: var(--font-semibold); color: var(--text-strong); line-height: 1.1; letter-spacing: var(--tracking-tight); }
.widget__meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
/* Status-breakdown pills under a widget's value (e.g. maintenance by status). */
.widget__badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.widget__trend--up   { color: var(--color-success-700); font-weight: var(--font-medium); }
.widget__trend--down { color: var(--color-danger-700);  font-weight: var(--font-medium); }

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.grid--wide { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
    padding: var(--space-16) var(--space-6);
}
.empty-state__icon {
    display: grid; place-items: center;
    width: 48px; height: 48px;
    border-radius: var(--radius-lg);
    background: var(--bg-sunken);
    color: var(--text-faint);
}
.empty-state__title { font-size: var(--text-lg); }
.empty-state__text { color: var(--text-muted); max-width: 42ch; }
.empty-state__actions { margin-top: var(--space-2); display: flex; gap: var(--space-2); }

/* ==========================================================================
   Auth screen (login) — minimal light
   ========================================================================== */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-6); background: var(--bg-body); }
.auth__card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}
.auth__brand { display: flex; align-items: center; gap: var(--space-3); }
.auth__brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--primary); color: var(--text-on-accent); font-weight: var(--font-bold); }
.auth__brand-name { font-size: var(--text-md); font-weight: var(--font-semibold); color: var(--text-strong); }
.auth__heading { display: flex; flex-direction: column; gap: var(--space-1); }
.auth__title { font-size: var(--text-xl); }
.auth__subtitle { color: var(--text-muted); }
.auth__form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); }
.auth__footer { text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.demo-note { border: 1px dashed var(--border-color-strong); background: var(--bg-surface-alt); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-xs); color: var(--text-muted); display: flex; flex-direction: column; gap: var(--space-1); }
.demo-note__label { font-weight: var(--font-semibold); color: var(--text-default); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.demo-note code { color: var(--text-strong); }

/* Ref link in tables — subtle, not a loud blue link */
.ref-link code { color: var(--text-default); }
.ref-link:hover code { color: var(--accent); text-decoration: underline; }

/* ==========================================================================
   Document preview (client statement, invoices)
   ========================================================================== */
.document {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: clamp(var(--space-5), 4vw, var(--space-10));
    max-width: 840px;
}
.document__head { display: flex; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; padding-bottom: var(--space-5); border-bottom: 1px solid var(--border-color); }
.document__agency { font-size: var(--text-lg); font-weight: var(--font-semibold); color: var(--text-strong); }
.document__muted { color: var(--text-muted); font-size: var(--text-sm); }
.document__meta { text-align: right; }
.document__doctype { font-size: var(--text-xl); letter-spacing: var(--tracking-tight); margin-bottom: var(--space-1); }
.document__parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-6); padding-block: var(--space-6); }
.document__label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--font-semibold); }
.document__party-name { font-weight: var(--font-semibold); color: var(--text-strong); margin-top: var(--space-1); }
.document__table { border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; margin-top: var(--space-2); }
.document__num { text-align: right; }
.document__out { color: var(--color-danger-700); }
/* Expense breakdown: a total row groups with its indented sub-lines (the line
   under the group sits below the last child, not between total and breakdown). */
.document__row--group .table__cell { border-bottom: none; }
.document__subrow .table__cell { border-bottom: none; padding-block: var(--space-1); }
.document__subrow td:first-child { padding-inline-start: var(--space-8); }
.document__sub { color: var(--text-muted); font-size: var(--text-sm); }
.document__subrow--last .table__cell { border-bottom: 1px solid var(--border-color); }
.document__total-row .table__cell { border-top: 1px solid var(--border-color); border-bottom: none; font-size: var(--text-lg); color: var(--text-strong); }
.document__foot { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: var(--space-1); }

/* ==========================================================================
   Record detail (the "view" screen)
   ========================================================================== */
.record__header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}
.record__avatar {
    width: 48px; height: 48px;
    border-radius: var(--radius-lg);
    background: var(--bg-sunken);
    color: var(--text-default);
    display: grid; place-items: center;
    font-size: var(--text-md); font-weight: var(--font-semibold);
    flex-shrink: 0;
}
.record__ident { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.record__eyebrow { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--font-medium); }
.record__titlerow { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.record__title { font-size: var(--text-xl); letter-spacing: var(--tracking-tight); line-height: 1.2; }
.record__subtitle { color: var(--text-muted); font-size: var(--text-sm); }
.record__ref { color: var(--text-default); font-weight: var(--font-medium); font-family: var(--font-mono); font-size: var(--text-xs); }
.record__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.record__layout { display: grid; grid-template-columns: 1fr; gap: var(--space-section); }
@media (min-width: 900px) { .record__layout { grid-template-columns: minmax(0, 1fr) 300px; } }

/* Field display (definition list) */
.fields { display: grid; gap: var(--space-4); }
.fields__row { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-4); align-items: baseline; }
.fields__label { color: var(--text-muted); font-size: var(--text-sm); }
.fields__value { color: var(--text-strong); font-weight: var(--font-medium); }
@media (max-width: 480px) { .fields__row { grid-template-columns: 1fr; gap: var(--space-1); } }

/* Summary card (linked record) */
.summary-card {
    display: flex; align-items: center; gap: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.summary-card:hover { border-color: var(--border-color-strong); box-shadow: var(--shadow-sm); }
.summary-card__avatar { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--bg-sunken); color: var(--text-default); display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--font-semibold); flex-shrink: 0; }
.summary-card__body { display: flex; flex-direction: column; min-width: 0; }
.summary-card__label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.summary-card__name { color: var(--text-strong); font-weight: var(--font-medium); }
.summary-card__sub { color: var(--text-muted); font-size: var(--text-sm); }
.summary-card__chevron { width: 16px; height: 16px; color: var(--text-faint); margin-left: auto; flex-shrink: 0; }

/* Activity timeline */
.timeline { display: flex; flex-direction: column; }
.timeline__item { display: flex; gap: var(--space-3); padding-bottom: var(--space-4); position: relative; }
.timeline__item:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 16px; bottom: 0; width: 1px; background: var(--border-color); }
.timeline__dot { width: 11px; height: 11px; border-radius: var(--radius-pill); border: 2px solid var(--primary); background: var(--bg-surface); margin-top: 3px; flex-shrink: 0; z-index: 1; }
.timeline__body { display: flex; flex-direction: column; gap: 1px; }
.timeline__body strong { color: var(--text-strong); font-weight: var(--font-medium); }
.timeline__time { font-size: var(--text-xs); color: var(--text-faint); }

/* ==========================================================================
   Summary strip (RAG counts above a list, e.g. compliance)
   ========================================================================== */
.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.summary-stat {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-xs);
}
.summary-stat__dot { width: 8px; height: 8px; border-radius: var(--radius-pill); }
.summary-stat__dot--success { background: var(--color-success-500); }
.summary-stat__dot--warning { background: var(--color-warning-500); }
.summary-stat__dot--danger { background: var(--color-danger-500); }
.summary-stat__dot--info { background: var(--color-info-500); }
.summary-stat__dot--neutral { background: var(--text-faint); }
.summary-stat__value { font-size: var(--text-xl); font-weight: var(--font-semibold); color: var(--text-strong); }
.summary-stat__label { font-size: var(--text-sm); color: var(--text-muted); }

/* ==========================================================================
   Area chart (pure SVG, shadcn-charts style)
   ========================================================================== */
.area-chart { display: flex; flex-direction: column; gap: var(--space-2); }
.area-chart__axis {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-faint);
    padding-inline: var(--space-1);
}

/* Stat row that often sits above a chart */
.stat-row { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-bottom: var(--space-5); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.stat__value { font-size: var(--text-2xl); font-weight: var(--font-semibold); color: var(--text-strong); letter-spacing: var(--tracking-tight); }
.stat__delta { font-size: var(--text-xs); }
.stat__delta--up { color: var(--color-success-700); }
.stat__delta--down { color: var(--color-danger-700); }

/* ==========================================================================
   Property gallery cards (grid view)
   ========================================================================== */
.gallery { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.property-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.property-card:hover { border-color: var(--border-color-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.property-card__media {
    aspect-ratio: 16 / 10;
    background:
        linear-gradient(135deg, var(--color-neutral-100), var(--color-neutral-200));
    display: grid; place-items: center;
    color: var(--text-faint);
    position: relative;
}
.property-card__media svg { width: 30px; height: 30px; }
.property-card__status { position: absolute; top: var(--space-3); left: var(--space-3); }
.property-card__fav { position: absolute; top: var(--space-3); right: var(--space-3); background: color-mix(in srgb, var(--bg-surface) 85%, transparent); }
.property-card__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.property-card__price { font-size: var(--text-lg); font-weight: var(--font-semibold); color: var(--text-strong); }
.property-card__price span { font-size: var(--text-xs); font-weight: var(--font-normal); color: var(--text-muted); }
.property-card__title { font-weight: var(--font-medium); color: var(--text-strong); }
.property-card__sub { color: var(--text-muted); font-size: var(--text-sm); }
.property-card__features { display: flex; gap: var(--space-4); margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border-color-subtle); font-size: var(--text-sm); color: var(--text-muted); }
.property-card__feature { display: inline-flex; align-items: center; gap: var(--space-1); }

/* ==========================================================================
   Calendar (month grid)
   ========================================================================== */
.calendar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
/* minmax(0, 1fr) forces 7 equal columns — a plain 1fr lets long event chips
   stretch their own column, which made the week's columns uneven. */
.calendar__weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-color-subtle);
}
.calendar__weekday { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: var(--font-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar__day {
    min-height: 104px;
    padding: var(--space-2);
    border-right: 1px solid var(--border-color-subtle);
    border-bottom: 1px solid var(--border-color-subtle);
    display: flex; flex-direction: column; gap: var(--space-1);
}
.calendar__day:nth-child(7n) { border-right: none; }
.calendar__day--muted { background: var(--bg-surface-alt); }
.calendar__day--muted .calendar__date { color: var(--text-faint); }
.calendar__date { font-size: var(--text-sm); color: var(--text-default); font-weight: var(--font-medium); align-self: flex-start; padding: 2px 6px; border-radius: var(--radius-sm); }
.calendar__date--today { background: var(--primary); color: var(--text-on-accent); }
.calendar__event {
    font-size: var(--text-xs);
    line-height: 1.35;
    padding: 3px var(--space-2);
    border-radius: var(--radius-sm);
    border-left: 3px solid currentColor;
    background: var(--bg-sunken);
    color: var(--text-default);
    /* Wrap long titles onto a new line rather than overflow/truncate. */
    white-space: normal;
    overflow-wrap: anywhere;
}
.calendar__event--success { color: var(--color-success-700); background: var(--color-success-50); }
.calendar__event--info { color: var(--color-info-700); background: var(--color-info-50); }
.calendar__event--warning { color: var(--color-warning-700); background: var(--color-warning-50); }
.calendar__event--danger { color: var(--color-danger-700); background: var(--color-danger-50); }
.calendar__event--accent { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--bg-surface)); }
.calendar__event--neutral { color: var(--text-muted); background: var(--bg-sunken); }
/* The chips are links to their record — keep the chip look, drop the underline. */
a.calendar__event { text-decoration: none; cursor: pointer; }
a.calendar__event:hover { filter: brightness(0.96); }
/* Cancelled / completed items still show but read as done (muted, struck through).
   The cancelled rule must come AFTER the link reset above to win (equal specificity). */
.calendar__event--done { color: var(--text-muted); background: var(--bg-sunken); border-left-color: var(--border-color); }
a.calendar__event--cancelled { text-decoration: line-through; }
.calendar__more { font-size: var(--text-xs); color: var(--text-muted); padding-inline: var(--space-2); }

@media (max-width: 768px) {
    .calendar__day { min-height: 72px; }
    .calendar__event { display: none; }
    .calendar__day::after { content: attr(data-count); }
}

/* ==========================================================================
   Board (kanban) — onboarding pipeline
   ========================================================================== */
.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 1fr);
    gap: var(--space-4);
    overflow-x: auto;
    padding-bottom: var(--space-3);
}
.board__column {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-height: 120px;
}
.board__column-head { display: flex; align-items: center; justify-content: space-between; padding-inline: var(--space-1); }
.board__column-title { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--text-strong); }
.board__column-count { font-size: var(--text-xs); color: var(--text-muted); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-pill); padding: 0 var(--space-2); }
.board__cards { display: flex; flex-direction: column; gap: var(--space-2); }
.board__card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.board__card:hover { border-color: var(--border-color-strong); box-shadow: var(--shadow-sm); }
.board__card-name { color: var(--text-strong); font-weight: var(--font-medium); font-size: var(--text-base); }
.board__card-property { color: var(--text-default); font-size: var(--text-sm); }
.board__card-meta { color: var(--text-faint); font-size: var(--text-xs); margin-top: var(--space-1); }
.board__add {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px dashed var(--border-color-strong);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    cursor: pointer;
}
.board__add:hover { color: var(--text-strong); border-color: var(--text-faint); }
/* Live onboarding cards: a clickable name, a "move to" select and per-card actions. */
.board__card { cursor: default; }
.board__card-name { display: block; cursor: pointer; }
.board__card-name:hover { color: var(--accent); }
.board__empty { color: var(--text-faint); text-align: center; font-size: var(--text-sm); padding: var(--space-2) 0; }
.board__card-actions { margin-block-start: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.select-native--sm select { height: 30px; font-size: var(--text-xs); padding-block: 0; }

/* ==========================================================================
   Overlay: modal/dialog + slide-over (share .overlay backdrop + transitions)
   ========================================================================== */
.overlay {
    position: fixed; inset: 0; z-index: var(--z-dialog);
    display: flex;
    background: oklch(0.145 0 0 / 0.45);
    opacity: 0;
    transition: opacity var(--transition-base);
}
/* The hidden attribute must win, or the overlay sits invisibly over the page
   (author display:flex would otherwise override the UA [hidden] rule). */
.overlay[hidden] { display: none; }
.overlay.is-open { opacity: 1; }

/* Dialog (centred) */
.overlay--dialog { align-items: center; justify-content: center; padding: var(--space-6); }
.dialog {
    width: 100%; max-width: 440px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transform: scale(0.96) translateY(6px);
    transition: transform var(--transition-base);
    overflow: hidden;
}
.overlay.is-open .dialog { transform: none; }
.dialog__header { padding: var(--space-5) var(--space-5) 0; display: flex; align-items: flex-start; gap: var(--space-3); }
.dialog__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-md); flex-shrink: 0; background: var(--color-danger-50); color: var(--color-danger-700); }
.dialog__title { font-size: var(--text-lg); }
.dialog__body { padding: var(--space-3) var(--space-5) var(--space-5); color: var(--text-muted); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-color-subtle); background: var(--bg-surface-alt); }

/* Slide-over (right drawer) */
.overlay--slideover { justify-content: flex-end; }
.slideover {
    width: min(440px, 100%); height: 100%;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}
.overlay.is-open .slideover { transform: none; }
.slideover__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-color); }
.slideover__title { font-size: var(--text-md); font-weight: var(--font-semibold); }
.slideover__body { flex: 1; overflow-y: auto; padding: var(--space-5); }
.slideover__footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-color); }

/* ==========================================================================
   Range slider
   ========================================================================== */
.range { width: 100%; appearance: none; height: 6px; border-radius: var(--radius-pill); background: var(--bg-sunken); cursor: pointer; }
.range:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.range::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg-surface); box-shadow: var(--shadow-sm); cursor: pointer; }
.range::-moz-range-thumb { width: 18px; height: 18px; border: 2px solid var(--bg-surface); border-radius: 50%; background: var(--primary); cursor: pointer; }

/* ==========================================================================
   Tooltip — a single body-level element positioned by JS (initTooltips), so it
   is never clipped by an overflow ancestor (e.g. a horizontally-scrolling table).
   Trigger with [data-tooltip="…"]; .has-tooltip is kept only as a no-op marker.
   ========================================================================== */
.tooltip-pop {
    position: fixed; top: 0; left: 0; z-index: var(--z-notification);
    background: var(--color-neutral-900); color: var(--color-neutral-50);
    font-size: var(--text-xs); line-height: 1.3; white-space: nowrap;
    padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    opacity: 0; pointer-events: none; transition: opacity var(--transition-fast);
}
.tooltip-pop.is-visible { opacity: 1; }

/* "Required" marker beside a compliance requirement name */
.req-tag {
    display: inline-block; margin-inline-start: var(--space-2);
    font-size: var(--text-xs); font-weight: var(--font-medium);
    color: var(--text-muted); background: var(--bg-surface-alt);
    border: 1px solid var(--border-color-strong); border-radius: var(--radius-pill);
    padding: 0 var(--space-2); vertical-align: middle;
}

/* ==========================================================================
   Toast / notification
   ========================================================================== */
.toast {
    display: flex; align-items: flex-start; gap: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--text-faint);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3) var(--space-4);
    max-width: 380px;
}
.toast--success { border-left-color: var(--color-success-500); }
.toast--danger { border-left-color: var(--color-danger-500); }
.toast--info { border-left-color: var(--color-info-500); }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast--success .toast__icon { color: var(--color-success-700); }
.toast--danger .toast__icon { color: var(--color-danger-700); }
.toast__title { color: var(--text-strong); font-weight: var(--font-medium); }
.toast__text { color: var(--text-muted); font-size: var(--text-sm); }

/* Flash message — fixed top-right toast (auto-dismissed by app.js) */
.flash { position: fixed; top: calc(var(--topbar-height) + var(--space-4)); right: var(--space-gutter); z-index: var(--z-notification); animation: flash-in var(--transition-base); }
.flash .toast { box-shadow: var(--shadow-lg); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Shared keyboard-focus + hover affordances for custom interactive elements
   ========================================================================== */
.sidebar__item:focus-visible,
.menu__item:focus-visible,
.tabs__tab:focus-visible,
.segmented__item:focus-visible,
.summary-card:focus-visible,
.choice-card:focus-visible,
.property-card:focus-visible,
.board__card:focus-visible,
.pagination__page:focus-visible,
.account:focus-visible,
.ref-link:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}
.table__body .table__row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.icon-button:active, .pagination__page:active, .segmented__item:active { transform: translateY(0.5px); }

/* Inline row action buttons (tables) */
.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; }
.icon-button--active { background: var(--accent-soft); color: var(--accent); }
.icon-button--active:hover { background: var(--accent-soft); color: var(--accent-hover); }

/* ==========================================================================
   Date picker (shadcn-style) — trigger field + calendar popover
   ========================================================================== */
.datefield { display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border-color-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-strong); cursor: pointer; font-size: var(--text-base); }
.datefield:hover { border-color: var(--text-faint); }
.datefield__icon { color: var(--text-muted); }
.minical { width: min(248px, calc(100vw - var(--space-8))); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-3); }
.minical__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.minical__month { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--text-strong); }
.minical__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.minical__dow { text-align: center; font-size: 10px; color: var(--text-faint); font-weight: var(--font-semibold); padding-bottom: var(--space-1); text-transform: uppercase; }
.minical__day { aspect-ratio: 1; display: grid; place-items: center; border: none; background: none; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text-default); cursor: pointer; }
.minical__day:hover { background: var(--bg-hover); }
.minical__day--muted { color: var(--text-faint); }
.minical__day--today { box-shadow: inset 0 0 0 1px var(--border-color-strong); }
.minical__day--selected { background: var(--primary); color: var(--text-on-accent); }

/* ==========================================================================
   Inspections — mobile-first room-by-room builder
   ========================================================================== */
.inspect-progress { margin-bottom: var(--space-5); }
.inspect { display: flex; flex-direction: column; gap: var(--space-4); max-width: 720px; }

.inspect-room { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); overflow: hidden; }
.inspect-room__head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); cursor: pointer; list-style: none; }
.inspect-room__head::-webkit-details-marker { display: none; }
.inspect-room__title { font-weight: var(--font-semibold); color: var(--text-strong); font-size: var(--text-md); }
.inspect-room__chevron { width: 18px; height: 18px; color: var(--text-faint); margin-left: auto; transition: transform var(--transition-fast); }
.inspect-room[open] .inspect-room__chevron { transform: rotate(180deg); }
.inspect-room__body { padding: 0 var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }

.inspect-item { padding-top: var(--space-4); border-top: 1px solid var(--border-color-subtle); display: flex; flex-direction: column; gap: var(--space-2); }
.inspect-item__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.inspect-item__label { font-weight: var(--font-medium); color: var(--text-strong); }
.inspect-item__cond { flex-wrap: wrap; }
.inspect-item__note { color: var(--text-default); font-size: var(--text-sm); background: var(--bg-surface-alt); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.inspect-item__addnote { align-self: flex-start; background: none; border: none; color: var(--accent); font-size: var(--text-sm); cursor: pointer; padding: 0; }

.inspect-photos { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.inspect-photo { width: 56px; height: 56px; border-radius: var(--radius-md); background: var(--bg-sunken); display: grid; place-items: center; color: var(--text-faint); flex-shrink: 0; }
.inspect-photo--add { border: 1.5px dashed var(--border-color-strong); background: transparent; cursor: pointer; color: var(--text-muted); }
.inspect-photo--add:hover { border-color: var(--text-faint); color: var(--text-strong); }

/* On phones the condition control goes full width under the label for easy tapping */
@media (max-width: 560px) {
    .inspect-item__cond { width: 100%; }
    .inspect-item__cond .segmented__item { flex: 1; text-align: center; }
}

/* ==========================================================================
   Conversation thread (support tickets)
   ========================================================================== */
.thread { display: flex; flex-direction: column; gap: var(--space-5); }
.thread__msg { display: flex; gap: var(--space-3); }
.thread__avatar { width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--bg-sunken); color: var(--text-muted); display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--font-semibold); flex-shrink: 0; }
.thread__bubble { background: var(--bg-surface-alt); border: 1px solid var(--border-color-subtle); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); flex: 1; }
.thread__meta { font-size: var(--text-sm); margin-bottom: var(--space-1); }
.thread__meta strong { color: var(--text-strong); }
.thread__msg--out .thread__avatar { background: var(--accent); color: var(--text-on-accent); }
.thread__msg--out .thread__bubble { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }

/* ==========================================================================
   Module matrix (orgs x modules)
   ========================================================================== */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); background: var(--bg-surface); }
.matrix { min-width: max-content; }
.matrix__org {
    position: sticky; left: 0; z-index: 1;
    background: var(--bg-surface);
    min-width: 200px;
    /* <th> defaults to centred; keep the role label + description left-aligned so
       they sit under the "Role" header next to the avatar, not floating centre. */
    text-align: start;
    box-shadow: 1px 0 0 var(--border-color-subtle);
}
.matrix__head .matrix__org, .matrix thead .matrix__org { background: var(--bg-surface-alt); }
/* Rotated group headers: anchor every label to the same bottom baseline and
   centre it over its column — unanchored, labels of different lengths float at
   ragged heights. The "Role" header cell shares the baseline so the whole
   header row lines up. */
.matrix thead .table__cell { vertical-align: bottom; }
.matrix__mod { white-space: nowrap; text-align: center; }
.matrix__mod span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--text-xs); }
.matrix__cell { text-align: center; }
/* Role matrix: each cell holds a small access-level select. */
.matrix__cell--level { padding-inline: var(--space-2); }
.matrix__cell--level .select-native { min-width: 110px; }
.matrix__cell--level .select-native select { font-size: var(--text-xs); padding-block: var(--space-1); }
.matrix__toggle { display: inline-grid; place-items: center; cursor: pointer; }
.matrix__toggle input { position: absolute; opacity: 0; }
.matrix__box {
    width: 22px; height: 22px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color-strong);
    display: grid; place-items: center; color: transparent;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.matrix__box svg { width: 14px; height: 14px; }
.matrix__toggle input:checked + .matrix__box { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.matrix__toggle input:focus-visible + .matrix__box { box-shadow: var(--shadow-focus); }

/* Editable feature list (plan bullets) */
.feature-edit { display: flex; flex-direction: column; gap: var(--space-2); }
.feature-edit__row { display: flex; align-items: center; gap: var(--space-2); }
.feature-edit__row .reorder__handle { cursor: grab; }
.feature-edit__row .field__input { flex: 1; }

/* Module enable grid — label then its toggle, sitting right beside it */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: var(--space-3) var(--space-6); }
.module-grid__item { padding-block: var(--space-1); justify-content: flex-start; }
.module-grid__item .switch__label { min-width: 104px; }

/* ==========================================================================
   Plan cards
   ========================================================================== */
.plan-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.plan-card--highlight { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.plan-card__head { display: flex; flex-direction: column; gap: var(--space-1); }
.plan-card__name { font-weight: var(--font-semibold); color: var(--text-strong); font-size: var(--text-md); }
.plan-card__price { font-size: var(--text-2xl); font-weight: var(--font-bold); color: var(--text-strong); letter-spacing: var(--tracking-tight); }
.plan-card__price span { font-size: var(--text-sm); font-weight: var(--font-normal); color: var(--text-muted); }
.plan-card__limits { display: flex; flex-direction: column; gap: var(--space-1); padding-block: var(--space-3); border-block: 1px solid var(--border-color-subtle); }
.plan-card__limit { display: flex; justify-content: space-between; font-size: var(--text-sm); }
.plan-card__features { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-default); }
.plan-card__features li { display: flex; align-items: center; gap: var(--space-2); }
.plan-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--space-2); }

/* ==========================================================================
   Reorderable list (drag to reorder nav items, etc.)
   ========================================================================== */
.reorder { display: flex; flex-direction: column; gap: var(--space-1); }
.reorder__item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    cursor: grab;
}
.reorder__item:hover { border-color: var(--border-color-strong); background: var(--bg-surface-alt); }
.reorder__handle { color: var(--text-faint); display: grid; place-items: center; }
.reorder__handle svg { width: 18px; height: 18px; }
.reorder__icon { width: 17px; height: 17px; color: var(--text-muted); }
.reorder__label { color: var(--text-strong); font-weight: var(--font-medium); flex: 1; }

/* ==========================================================================
   Settings (vertical tabbed layout)
   ========================================================================== */
.settings { display: grid; grid-template-columns: 1fr; gap: var(--space-6); }
@media (min-width: 820px) { .settings { grid-template-columns: 200px minmax(0, 1fr); align-items: start; } }
.settings__nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-height) + var(--space-4)); }
.settings__nav-item {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border: none; background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-base); font-weight: var(--font-medium);
    cursor: pointer;
}
.settings__nav-item:hover { background: var(--bg-hover); color: var(--text-strong); }
.settings__nav-item[aria-selected="true"] { background: var(--bg-sunken); color: var(--text-strong); }
.settings__nav-item:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
@media (max-width: 819px) {
    .settings__nav { flex-direction: row; flex-wrap: wrap; position: static; }
}

/* ==========================================================================
   Helpers
   ========================================================================== */
.stack { display: flex; flex-direction: column; gap: var(--space-section); }
.muted { color: var(--text-muted); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.row--tight { gap: var(--space-2); }
.sg-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--font-semibold); margin-bottom: var(--space-2); }
.placeholder-panel {
    border: 1px dashed var(--border-color-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-12) var(--space-8);
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-surface-alt);
}

/* Needs-attention list (actionable items on the dashboard) */
.attention { display: flex; flex-direction: column; }
.attention__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-color-subtle); }
.attention__item:first-child { border-top: none; }
.attention__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-md); flex-shrink: 0; }
.attention__icon svg { width: 17px; height: 17px; }
.attention__icon--danger { background: var(--color-danger-50); color: var(--color-danger-700); }
.attention__icon--warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.attention__icon--info { background: var(--color-info-50); color: var(--color-info-700); }
.attention__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attention__title { color: var(--text-strong); font-weight: var(--font-medium); }
.attention__detail { color: var(--text-muted); font-size: var(--text-sm); }

/* Definition-style rows (label left, value right) */
.dl { display: flex; flex-direction: column; gap: var(--space-3); }
.dl__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* Vertical feed (viewings, activity) */
.feed { display: flex; flex-direction: column; gap: var(--space-4); }
.feed__item { display: flex; flex-direction: column; gap: 2px; }
.feed__time { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--text-xs); }
.feed__title { color: var(--text-strong); font-weight: var(--font-medium); }

/* Impersonation bar — fixed-height sticky strip while a platform admin acts as an
   org user. The layout reserves exactly this height (--imp-bar-h on the body) so
   the rest of the app sits unchanged below it. A clean near-black strip on the
   house primary (matches the primary buttons), so it reads as a deliberate mode
   rather than an alert — and flips with the theme like everything else. */
.is-impersonating { --imp-bar-h: 2.75rem; }
.impersonation-bar {
    position: sticky; top: 0; z-index: var(--z-notification);
    height: var(--imp-bar-h);
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-4);
    padding-inline: var(--space-5);
    background: var(--primary);
    color: var(--text-on-accent);
    font-size: var(--text-sm);
}
.impersonation-bar__text { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; }
.impersonation-bar__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: color-mix(in srgb, var(--text-on-accent) 78%, transparent); }
.impersonation-bar__label strong { color: var(--text-on-accent); font-weight: var(--font-semibold); }
.impersonation-bar__chip {
    display: grid; place-items: center; flex-shrink: 0;
    width: 24px; height: 24px; border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--text-on-accent) 16%, transparent);
    color: var(--text-on-accent);
}
.impersonation-bar__chip svg { width: 14px; height: 14px; }
.impersonation-bar__stop {
    flex-shrink: 0; cursor: pointer;
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--text-on-accent) 14%, transparent);
    color: var(--text-on-accent);
    border: 1px solid color-mix(in srgb, var(--text-on-accent) 22%, transparent);
    font-size: var(--text-sm); font-weight: var(--font-medium);
    transition: background var(--transition-fast);
}
.impersonation-bar__stop:hover { background: color-mix(in srgb, var(--text-on-accent) 26%, transparent); }
.impersonation-bar__stop:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--text-on-accent) 50%, transparent); }
.impersonation-bar__stop:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* ==========================================================================
   Announcement banner (platform → org users) — calm, dismissible, in-content
   ========================================================================== */
.announce-bar {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin-block-end: var(--space-5);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    color: var(--text-default);
}
.announce-bar__chip {
    display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0;
    border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent);
}
.announce-bar__body { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); flex: 1; min-width: 0; font-size: var(--text-sm); }
.announce-bar__body strong { color: var(--text-strong); }
.announce-bar__text { color: var(--text-muted); }
.announce-bar__dismiss {
    display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0;
    border-radius: var(--radius-md); color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.announce-bar__dismiss:hover { background: var(--bg-hover); color: var(--text-strong); }
.announce-bar__dismiss:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* Activity / audit timeline (org Activity tab) — one line per event, kept calm */
.activity { display: flex; flex-direction: column; }
.activity__item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border-color-subtle); }
.activity__item:first-child { border-top: none; }
.activity__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md); flex-shrink: 0; background: var(--bg-sunken); color: var(--text-muted); margin-block-start: 1px; }
.activity__icon svg { width: 15px; height: 15px; }
.activity__icon--success { background: var(--color-success-50); color: var(--color-success-700); }
.activity__icon--danger  { background: var(--color-danger-50);  color: var(--color-danger-700); }
.activity__icon--warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.activity__icon--info    { background: var(--color-info-50);    color: var(--color-info-700); }
.activity__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.activity__desc { color: var(--text-strong); }
.activity__meta { color: var(--text-muted); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.activity__actor { color: var(--text-muted); font-weight: var(--font-medium); }
.activity__via { color: var(--text-faint); }

/* Deposit cap hint — suggested figure derived from rent (data-cap) */
.field__cap { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.field__cap strong { color: var(--text-strong); font-weight: var(--font-semibold); }
.field__cap-apply {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--accent); font: inherit; font-size: var(--text-xs); font-weight: var(--font-medium);
    text-decoration: underline; text-underline-offset: 2px;
}
.field__cap-apply:hover { color: var(--accent-hover); }

/* ==========================================================================
   Date picker — themed calendar popover (shadcn-inspired). Replaces the
   unstyleable native date input. Trigger looks like a field input.
   ========================================================================== */
.datepicker { position: relative; }
.datepicker__trigger {
    display: flex; align-items: center; gap: var(--space-2);
    width: 100%; text-align: left; cursor: pointer;
    font-weight: var(--font-normal); color: var(--text-default);
}
.datepicker__icon { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }
.datepicker__text { flex: 1; }
.datepicker__text--placeholder { color: var(--text-faint); }

.datepicker__panel {
    position: absolute; z-index: var(--z-dropdown);
    top: calc(100% + var(--space-1)); left: 0;
    /* Never wider than the viewport — a fixed 7×36px grid overflowed phones. */
    width: min(max-content, calc(100vw - var(--space-8)));
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
}

.datepicker__head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.datepicker__title { flex: 1; text-align: center; font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-strong); border: none; background: none; cursor: pointer; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); }
.datepicker__title:hover { background: var(--bg-hover); }
.datepicker__nav {
    display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0;
    border: none; background: none; cursor: pointer;
    border-radius: var(--radius-md); color: var(--text-muted);
}
.datepicker__nav:hover { background: var(--bg-hover); color: var(--text-strong); }
.datepicker__nav svg { width: 16px; height: 16px; }

.datepicker__weekdays { display: grid; grid-template-columns: repeat(7, 36px); margin-bottom: var(--space-1); }
.datepicker__weekdays span { text-align: center; font-size: var(--text-xs); color: var(--text-muted); }

.datepicker__grid { display: grid; grid-template-columns: repeat(7, 36px); grid-auto-rows: 36px; }
@media (max-width: 420px) {
    .datepicker__weekdays, .datepicker__grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .datepicker__grid { grid-auto-rows: 34px; }
    .datepicker__grid--years { width: 100%; }
}
/* Year view — fast year skipping (3 × 4 = 12 years per page) */
.datepicker__grid--years { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 44px; gap: var(--space-1); width: 252px; }
.datepicker__year {
    display: grid; place-items: center;
    border: none; background: none; cursor: pointer;
    border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--text-default);
    transition: background var(--transition-fast);
}
.datepicker__year:hover { background: var(--bg-hover); color: var(--text-strong); }
.datepicker__day {
    display: grid; place-items: center; width: 36px; height: 36px;
    border: none; background: none; cursor: pointer;
    border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--text-default);
    transition: background var(--transition-fast);
}
.datepicker__day:hover { background: var(--bg-hover); color: var(--text-strong); }
.datepicker__day--muted { color: var(--text-faint); }
.datepicker__day--today { background: var(--bg-sunken); color: var(--text-strong); font-weight: var(--font-medium); }
.datepicker__day--selected,
.datepicker__day--selected:hover { background: var(--primary); color: var(--text-on-accent); font-weight: var(--font-medium); }

.datepicker__foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: var(--space-2); padding-top: var(--space-2);
    border-top: 1px solid var(--border-color-subtle);
}
.datepicker__action {
    background: none; border: none; padding: var(--space-1) var(--space-2); cursor: pointer;
    color: var(--accent); font-size: var(--text-sm); font-weight: var(--font-medium); border-radius: var(--radius-sm);
}
.datepicker__action:hover { background: var(--bg-hover); }

/* Repeater rows (dynamic children list on the tenant form) */
.repeater-item { border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: var(--space-4); background: var(--bg-surface); }
.repeater-item__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.repeater-item__title { font-weight: var(--font-semibold); color: var(--text-strong); }

/* Print — drop the app chrome so a printed page (e.g. a statement document) is
   clean: no sidebar/topbar, no nav crumbs, no action buttons, no history card. */
@media print {
    .sidebar, .topbar, .impersonation-bar, .flash,
    .breadcrumbs, .page-header__actions, .tabs, .record-history { display: none !important; }
    .shell, .shell__main, .shell__content { display: block !important; padding: 0 !important; margin: 0 !important; }
    .document { box-shadow: none !important; border: none !important; max-width: none !important; margin: 0 !important; }
}
